Merge remote-tracking branch 'contiki-gb/master'
diff --git a/contiki-apple2/Makefile b/contiki-apple2/Makefile
new file mode 100644
index 0000000..18d56b4
--- /dev/null
+++ b/contiki-apple2/Makefile
@@ -0,0 +1,67 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.6 2005/04/18 21:49:36 oliverschmidt Exp $
+#
+
+CONTIKI=../contiki
+CONTIKICC65=../contiki-cc65
+
+usage:
+	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+	@echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+	@echo 'is one of the following:'
+	@echo all
+	@echo apple2
+	@echo apple2enh
+	@echo programs
+	@echo programsenh
+	@echo '(Also check the Makefile for more targets to try...)'
+
+all: clean apple2enh programsenh
+
+apple2:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.apple2 SYS=apple2
+
+apple2enh:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.apple2 SYS=apple2enh
+
+programs:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs SYS=apple2
+
+programsenh:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs SYS=apple2enh
+
+CCDEPFLAGS=
+
+include $(CONTIKICC65)/Makefile.cc65
+
diff --git a/contiki-apple2/Makefile.apple2 b/contiki-apple2/Makefile.apple2
new file mode 100644
index 0000000..293f4d2
--- /dev/null
+++ b/contiki-apple2/Makefile.apple2
@@ -0,0 +1,65 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.apple2,v 1.20 2006/05/30 20:51:01 oliverschmidt Exp $
+#
+
+all: contiki
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+AFLAGS:=-t $(SYS) -I lib -I $(CC65_INC)/../asminc
+
+CFLAGS:=$(CFLAGSCC65) --code-name CONTIKI \
+        -DWITH_ASCII -DWITH_UIP -DWITH_LOADER_ARCH -DWITH_ETHERNET
+
+ifeq ($(SYS),apple2)
+
+CTK=ctk.o ctk-conio.o
+
+else # apple2
+
+CTK=ctk.o ctk-mousetext.o ctk-mouse.o
+
+uip.s uip_arch.s uiplib.s tcpip.s: %.s: %.c
+	$(CC) $(CFLAGS) $(OPT) -DUIP_CODE -o $(notdir $@) $<
+
+endif # apple2
+
+contiki:crt0.o main.o ek.o ek-service.o timer.o program-handler.o arg.o \
+	loader-arch.o clock-arch.o bank.o kfs.o import.o $(CTK) $(UIP) \
+	www-dsc.o \
+	email-dsc.o \
+	ftp-dsc.o \
+	directory-dsc.o
+	$(LD) -C $(SYS).cfg -Ln contiki-labels -m contiki.map $^ $(SYS).lib
diff --git a/contiki-apple2/Makefile.programs b/contiki-apple2/Makefile.programs
new file mode 100644
index 0000000..b3df70e
--- /dev/null
+++ b/contiki-apple2/Makefile.programs
@@ -0,0 +1,94 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.20 2006/05/30 20:51:01 oliverschmidt Exp $
+#
+
+all: loader-arch-module.o loader-arch-module-dsc.o contiki-labels.o \
+     about.prg about.dsc \
+     calc.prg calc.dsc \
+     config.prg \
+     configedit.prg configedit.dsc \
+     dhcp.prg dhcp.dsc \
+     directory.prg directory.dsc \
+     email.prg email.dsc \
+     ftp.prg ftp.dsc \
+     irc.prg irc.dsc \
+     memstat.prg memstat.dsc \
+     processes.prg processes.dsc \
+     shell.prg shell.dsc \
+     telnet.prg telnet.dsc \
+     welcome.prg \
+     wget.prg wget.dsc \
+     www.prg www.dsc \
+     lancegs.drv lancegs.dsc \
+     uther.drv uther.dsc \
+     plasma.sav plasma.dsc \
+     ssfire.sav ssfire.dsc
+
+ifeq ($(SYS),apple2enh)
+
+all: webserver.prg webserver.dsc \
+     bounce.sav bounce.dsc
+
+endif # apple2enh
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+AFLAGS:=-t $(SYS)
+
+CFLAGS:=$(CFLAGSCC65) \
+        -DWITH_ASCII -DWITH_UIP -DWITH_LOADER_ARCH -DWITH_ETHERNET
+
+configedit.prg: configedit.o ctk-textentry-checkbox.o
+
+dhcp.prg: $(DHCP) lc-asm.o
+
+directory.prg: $(DIRECTORY) cfs.o
+
+email.prg: $(EMAIL) lc-asm.o
+
+ftp.prg: $(FTP) cfs.o
+
+irc.prg: $(IRC) lc-asm.o
+
+shell.prg: $(SHELL_) cfs.o
+
+telnet.prg: $(TELNET)
+
+webserver.prg: $(WEBSERVER) lc-asm.o
+
+wget.prg: $(WGET)
+
+www.prg: $(WWW)
+
+lancegs.drv: lancegs-drv.o lan91c96.o uip_arp.o
+
+uther.drv: uther-drv.o cs8900a.o uther-drv-asm.o uip_arp.o
diff --git a/contiki-apple2/apple2.cfg b/contiki-apple2/apple2.cfg
new file mode 100644
index 0000000..2e8c07d
--- /dev/null
+++ b/contiki-apple2/apple2.cfg
@@ -0,0 +1,36 @@
+MEMORY {
+    ZP:     start = $0080, size = $001A, file = "", define = yes;
+    BUFFER: start = $0800, size = $0400, file = "";
+    HEADER: start = $0000, size = $0004, file = "contiki";
+    RAM:    start = $0C00, size = $8A00, file = "contiki";
+    PIC:    start = $0000, size = $FFFF, file = "contiki";
+    TMP:    start = $0000, size = $FFFF, file = "contiki";
+    LC:     start = $D400, size = $0C00, file = "contiki";
+}
+SEGMENTS {
+    ZEROPAGE: load = ZP,             type = zp;
+    UIPBUF:   load = BUFFER,         type = bss;
+    EXEHDR:   load = HEADER,         type = ro;
+    STARTUP:  load = RAM,            type = ro,  define = yes;
+    CONTIKI:  load = RAM,            type = ro;
+    RODATA:   load = RAM,            type = ro;
+    DATA:     load = RAM,            type = rw;
+    BSS:      load = RAM,            type = bss, define = yes;
+    BOOT:     load = PIC,            type = ro,  define = yes;
+    INIT:     load = TMP, run = RAM, type = ro,  define = yes;
+    CODE:     load = LC,             type = ro,  define = yes;
+}
+FEATURES {
+    CONDES: segment = INIT,
+	    type  = constructor,
+	    label = __CONSTRUCTOR_TABLE__,
+	    count = __CONSTRUCTOR_COUNT__;
+    CONDES: segment = RODATA,
+	    type  = destructor,
+	    label = __DESTRUCTOR_TABLE__,
+	    count = __DESTRUCTOR_COUNT__;
+}
+SYMBOLS {
+    __STACKSIZE__ = $0100;
+    __UIP_SIZE__  = $0000;
+}
diff --git a/contiki-apple2/apple2enh.cfg b/contiki-apple2/apple2enh.cfg
new file mode 100644
index 0000000..68fdc20
--- /dev/null
+++ b/contiki-apple2/apple2enh.cfg
@@ -0,0 +1,41 @@
+MEMORY {
+    ZP:     start = $0080, size = $001A, file = "", define = yes;
+    BUFFER: start = $0800, size = $0400, file = "";
+    HEADER: start = $0000, size = $0004, file = "contiki";
+    RAM:    start = $0C00, size = $8A00, file = "contiki";
+    PIC:    start = $0000, size = $FFFF, file = "contiki";
+    TMP:    start = $0000, size = $FFFF, file = "contiki";
+    LC:     start = $D000, size = $1000, file = "contiki";
+    AUX:    start = $2000, size = $2000, file = "contiki";
+}
+SEGMENTS {
+    ZEROPAGE: load = ZP,             type = zp;
+    UIPBUF:   load = BUFFER,         type = bss;
+    EXEHDR:   load = HEADER,         type = ro;
+    STARTUP:  load = RAM,            type = ro,  define = yes;
+    CONTIKI:  load = RAM,            type = ro;
+    RODATA:   load = RAM,            type = ro;
+    DATA:     load = RAM,            type = rw;
+    BSS:      load = RAM,            type = bss, define = yes;
+    BOOT:     load = PIC,            type = ro,  define = yes;
+    INIT:     load = TMP, run = RAM, type = ro,  define = yes;
+    CODE:     load = LC,             type = ro,  define = yes;
+    UIP:      load = AUX,            type = ro,  define = yes;
+}
+FEATURES {
+    CONDES: segment = INIT,
+	    type  = constructor,
+	    label = __CONSTRUCTOR_TABLE__,
+	    count = __CONSTRUCTOR_COUNT__;
+    CONDES: segment = RODATA,
+	    type  = destructor,
+	    label = __DESTRUCTOR_TABLE__,
+	    count = __DESTRUCTOR_COUNT__;
+    CONDES: segment = RODATA,
+	    type  = interruptor,
+	    label = __INTERRUPTOR_TABLE__,
+	    count = __INTERRUPTOR_COUNT__;
+}
+SYMBOLS {
+    __STACKSIZE__ = $0100;
+}
diff --git a/contiki-apple2/apps/bounce-dsc.c b/contiki-apple2/apps/bounce-dsc.c
new file mode 100644
index 0000000..abc2251
--- /dev/null
+++ b/contiki-apple2/apps/bounce-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: bounce-dsc.c,v 1.1 2006/05/30 20:50:26 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon bounce_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+    "Screensaver with a bouncing box",
+    "bounce.sav",
+    bounce_init,
+    &bounce_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char bounceicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char bounceicon_textmap[9] = {
+  '-', '|', '-',
+  '|', '|', '|',
+  '|', '-', '|'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon bounce_icon =
+  {CTK_ICON("Bounce", bounceicon_bitmap, bounceicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/bounce.c b/contiki-apple2/apps/bounce.c
new file mode 100644
index 0000000..b56d1d1
--- /dev/null
+++ b/contiki-apple2/apps/bounce.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: bounce.c,v 1.1 2006/05/30 20:50:26 oliverschmidt Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+EK_EVENTHANDLER(bounce_eventhandler, ev, data);
+EK_POLLHANDLER(bounce_pollhandler);
+EK_PROCESS(p, "Bounce screensaver", EK_PRIO_LOWEST,
+	   bounce_eventhandler, bounce_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static char pos[4] = {3, 17, 7, 13};
+static char vec[4] = {-1, 1, -1, 1};
+static char max[4];
+static char rev[2];
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(bounce_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+    max[0] = max[1] = ctk_draw_width();
+    max[2] = max[3] = ctk_draw_height();
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(bounce_pollhandler)
+{
+  static unsigned char i;
+
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+    for(i = 0; i < 4; ++i) {
+      pos[i] += vec[i];
+      if(pos[i] <= 0 || pos[i] >= max[i]) {
+        vec[i] = -vec[i];
+      }
+    }
+    if(pos[0] == pos[1] || pos[2] == pos[3]) {
+      return;
+    }
+    for(i = 0; i < 2; ++i) {
+      rev[i] = pos[i * 2] > pos[i * 2 + 1];
+    }
+    _textframexy(pos[0 + rev[0]],
+		 pos[2 + rev[1]],
+		 pos[1 - rev[0]] - pos[0 + rev[0]],
+		 pos[3 - rev[1]] - pos[2 + rev[1]], _TEXTFRAME_TALL);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/config.c b/contiki-apple2/apps/config.c
new file mode 100644
index 0000000..409da35
--- /dev/null
+++ b/contiki-apple2/apps/config.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: config.c,v 1.13 2006/06/28 23:10:44 oliverschmidt Exp $
+ *
+ */
+
+
+#include <string.h>
+#include <unistd.h>
+
+#include "uiplib.h"
+#include "resolv.h"
+#include "uip_arp.h"
+
+#include "program-handler.h"
+#include "kfs.h"
+
+#include "config.h"
+
+
+static config_t config = {0,
+#ifdef __APPLE2__
+			  "SSFire.sav", 5,
+#else /* __APPLE2__ */
+			  "Bounce.sav", 5,
+#endif /* __APPLE2__ */
+			  "Uther.drv", 0,
+			  "",
+			  {0xA8C0, 0x8000}, {0xFFFF, 0x00FF},
+			  {0xA8C0, 0x0100}, {0xA8C0, 0x0100},
+			  0xA2};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+config_load(void)
+{
+  int fd;
+
+  fd = kfs_open("contiki.cfg");
+  if(fd == -1) {
+    return;
+  }
+  kfs_read(fd, &config, sizeof(config));
+  kfs_close(fd);
+}
+/*-----------------------------------------------------------------------------------*/
+static void 
+config_apply(void)
+{
+#ifdef __APPLE2ENH__
+
+  ctk_draw_setbackground(config.bkgnd);
+
+#endif /* __APPLE2ENH__ */
+
+  program_handler_setscreensaver(config.screensaver);
+
+  CTK_SCREENSAVER_SET_TIMEOUT(config.timeout * 60);
+
+  config_setlanslot(config.slot);
+
+  if(*config.driver) {
+    program_handler_load(config.driver, NULL);
+  }
+
+  if(*config.prefix == '/') {
+    config_setprefixok(chdir(config.prefix) == 0);
+  }
+
+#ifdef WITH_UIP
+
+  uip_sethostaddr(config.ipaddr);
+
+#ifdef WITH_ETHERNET
+
+  uip_setnetmask(config.netmask);
+  uip_setdraddr(config.gateway);
+  uip_ethaddr.addr[5] = config.maclsb;
+
+#endif /* WITH_ETHERNET */
+
+  resolv_conf(config.dnsserver);
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+  arg_free(arg);
+  config_load();
+  config_apply();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/config.h b/contiki-apple2/apps/config.h
new file mode 100644
index 0000000..ea7e1b3
--- /dev/null
+++ b/contiki-apple2/apps/config.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: config.h,v 1.8 2006/06/28 23:10:44 oliverschmidt Exp $
+ *
+ */
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+typedef struct {
+  unsigned char bkgnd;
+  char screensaver[16];
+  unsigned char timeout;
+  char driver[16];
+  unsigned char slot;
+  char prefix[65];
+  u16_t ipaddr[2];
+  u16_t netmask[2];
+  u16_t gateway[2];
+  u16_t dnsserver[2];
+  unsigned char maclsb;
+} config_t;
+
+extern unsigned char lanslot;
+extern unsigned char prefixok;
+
+#define config_getlanslot()	lanslot
+#define config_setlanslot(slot)	lanslot = (slot)
+
+#define config_getprefixok()	prefixok
+#define config_setprefixok(ok)  prefixok = (ok)
+
+#endif /* __CONFIG_H__ */
diff --git a/contiki-apple2/apps/configedit-dsc.c b/contiki-apple2/apps/configedit-dsc.c
new file mode 100644
index 0000000..cfe7564
--- /dev/null
+++ b/contiki-apple2/apps/configedit-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.3 2005/05/06 22:33:51 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+    "Edit Contiki configuration",
+    "configedit.prg",
+    configedit_init,
+    &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+  '-', '-', '-',
+  'C', 'F', 'G',
+  'E', 'D', 'T'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon configedit_icon =
+  {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/configedit-dsc.h b/contiki-apple2/apps/configedit-dsc.h
new file mode 100644
index 0000000..0b33f4a
--- /dev/null
+++ b/contiki-apple2/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2004/12/26 14:13:34 oliverschmidt Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-apple2/apps/configedit.c b/contiki-apple2/apps/configedit.c
new file mode 100644
index 0000000..e3aa78b
--- /dev/null
+++ b/contiki-apple2/apps/configedit.c
@@ -0,0 +1,508 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.12 2006/06/28 23:10:45 oliverschmidt Exp $
+ *
+ */
+
+
+#include <string.h>
+
+#include "uiplib.h"
+#include "resolv.h"
+#include "uip_arp.h"
+#include "ctk.h"
+
+#include "program-handler.h"
+#include "packet-service.h"
+#include "kfs.h"
+#include "cfs.h"
+
+#include "ctk-textentry-checkbox.h"
+
+#include "config.h"
+
+
+static config_t config;
+static struct ctk_window window;
+
+#ifdef __APPLE2ENH__
+
+static struct ctk_label backgroundlabel =
+  {CTK_LABEL(0, 1, 11, 1, "Background")};
+static char bkgnd[2];
+static struct ctk_textentry backgroundtextentry =
+  {CTK_TEXTENTRY_INPUT(12, 1, 1, 1, bkgnd, 1, ctk_textentry_checkbox_input)};
+static struct ctk_label backgrounddescr =
+  {CTK_LABEL(16, 1, 12, 1, "('x' or ' ')")};
+
+#endif /* __APPLE2ENH__ */
+
+static struct ctk_label screensaverlabel =
+  {CTK_LABEL(0, 3, 11, 1, "Screensaver")};
+static char screensaver[16];
+static struct ctk_textentry screensavertextentry =
+  {CTK_TEXTENTRY(12, 3, 15, 1, screensaver, 15)};
+
+static struct ctk_label timeoutlabel =
+  {CTK_LABEL(0, 4, 11, 1, "Timeout")};
+static char timeout[2];
+static struct ctk_textentry timeouttextentry =
+  {CTK_TEXTENTRY(12, 4, 1, 1, timeout, 1)};
+static struct ctk_label timeoutdescr =
+  {CTK_LABEL(16, 4, 12, 1, "(in Minutes)")};
+
+static struct ctk_label driverlabel =
+  {CTK_LABEL(0, 6, 11, 1, "LAN driver")};
+static char driver[16];
+static struct ctk_textentry drivertextentry =
+  {CTK_TEXTENTRY(12, 6, 15, 1, driver, 15)};
+
+static struct ctk_label slotlabel =
+  {CTK_LABEL(0, 7, 11, 1, "LAN slot")};
+static char slot[2];
+static struct ctk_textentry slottextentry =
+  {CTK_TEXTENTRY(12, 7, 1, 1, slot, 1)};
+static struct ctk_label slotdescr =
+  {CTK_LABEL(16, 7, 12, 1, "('1' to '7')")};
+
+static struct ctk_label prefixlabel =
+  {CTK_LABEL(0, 9, 11, 1, "DOS Prefix")};
+static char prefix[65];
+static struct ctk_textentry prefixtextentry =
+  {CTK_TEXTENTRY(12, 9, 15, 1, prefix, 65)};
+
+static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 11, 10, 1, "IP address")};
+static char ipaddr[16];
+static struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(12, 11, 15, 1, ipaddr, 15)};
+
+#ifdef WITH_ETHERNET
+
+static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 12, 11, 1, "Netmask")};
+static char netmask[16];
+static struct ctk_textentry netmasktextentry =
+  {CTK_TEXTENTRY(12, 12, 15, 1, netmask, 15)};
+
+static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 13, 11, 1, "Gateway")};
+static char gateway[16];
+static struct ctk_textentry gatewaytextentry =
+  {CTK_TEXTENTRY(12, 13, 15, 1, gateway, 15)};
+
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 14, 11, 1, "DNS server")};
+static char dnsserver[16];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(12, 14, 15, 1, dnsserver, 15)};
+
+static struct ctk_label maclsblabel =
+  {CTK_LABEL(0, 16, 11, 1, "MAC address")};
+static char maclsb[4];
+static struct ctk_textentry maclsbtextentry =
+  {CTK_TEXTENTRY(12, 16, 3, 1, maclsb, 3)};
+static struct ctk_label maclsbdescr =
+  {CTK_LABEL(18, 16, 10, 1, "(LSB only)")};
+
+#else /* WITH_ETHERNET */
+
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 12, 11, 1, "DNS server")};
+static char dnsserver[16];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(12, 12, 15, 1, dnsserver, 15)};
+
+#endif /* WITH_ETHERNET */
+
+static struct ctk_button okbutton =
+  {CTK_BUTTON(0, 18, 12, "Save & close")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(22, 18, 6, "Cancel")};
+
+
+static struct ctk_window errordialog;
+
+static struct ctk_label errormsg =
+  {CTK_LABEL(0, 1, 19, 1, "Error saving config")};
+static struct ctk_button errorokbutton =
+  {CTK_BUTTON(7, 3, 2, "Ok")};
+
+
+EK_EVENTHANDLER(config_eventhandler, ev, data);
+EK_PROCESS(p, "Configuration", EK_PRIO_NORMAL,
+	   config_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+static ek_id_t driverid = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+  arg_free(arg);
+    
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+makebyte(u8_t byte, char *str)
+{
+  if(byte >= 100) {
+    *str++ = (byte / 100 ) % 10 + '0';
+  }
+  if(byte >= 10) {
+    *str++ = (byte / 10) % 10 + '0';
+  }
+  *str++ = (byte % 10) + '0';
+
+  return str;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makeaddr(u16_t *addr, char *str)
+{
+  str = makebyte(HTONS(addr[0]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[0]) & 0xff, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) & 0xff, str);
+  *str++ = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static int
+makedriver(const char *name, char *str)
+{
+  char *pattern = PACKET_SERVICE_NAME ": ";
+
+  while(*pattern) {
+    if(*name++ != *pattern++) {
+      return 0;
+    }
+  }
+
+  while(*name) {
+    *str++ = *name++;
+  }
+  strcpy(str, ".drv");
+
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makestrings(void)
+{
+  u16_t addr[2], *addrptr;
+  struct ek_proc *p;
+
+#ifdef __APPLE2ENH__
+
+  if(ctk_draw_getbackground()) {
+    *bkgnd = 'x';
+  }
+
+#endif /* __APPLE2ENH__ */
+
+  strncpy(screensaver, program_handler_getscreensaver(), sizeof(screensaver));
+
+  *timeout = (CTK_SCREENSAVER_TIMEOUT() / 60) % 10 + '0';
+
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    if(makedriver(p->name, driver)) {
+      driverid = p->id;
+      break;
+    }
+  }
+
+  if(config_getlanslot() != 0) {
+    *slot = config_getlanslot() + '0';
+  }
+
+  if(config_getprefixok()) {
+    getcwd(prefix, sizeof(prefix));
+  }
+
+#ifdef WITH_UIP
+
+  uip_gethostaddr(addr);
+  makeaddr(addr, ipaddr);
+  
+#ifdef WITH_ETHERNET
+
+  uip_getnetmask(addr);
+  makeaddr(addr, netmask);
+  
+  uip_getdraddr(addr);
+  makeaddr(addr, gateway);
+
+  makebyte(uip_ethaddr.addr[5], maclsb);
+
+#endif /* WITH_ETHERNET */
+
+  addrptr = resolv_getserver();
+  if(addrptr != NULL) {
+    makeaddr(addrptr, dnsserver);
+  }
+  
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+nullterminate(char *cptr)
+{
+  /* Find the first space character in the ipaddr and put a zero there
+     to end the string. */
+  for(; *cptr != ' ' && *cptr != 0; ++cptr);
+  *cptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makeconfig(void)
+{
+  u16_t addr[2];
+  char *cptr;
+  u8_t tmp;
+
+#ifdef __APPLE2ENH__
+
+  config.bkgnd = (*bkgnd == 'x');
+
+#endif /* __APPLE2ENH__ */
+
+  nullterminate(screensaver);
+  strcpy(config.screensaver, screensaver);
+
+  if(*timeout >= '1' && *timeout <= '9') {
+    config.timeout = *timeout - '0';
+  }
+
+  nullterminate(driver);
+  strcpy(config.driver, driver);
+
+  if(*slot >= '1' && *slot <= '7') {
+    config.slot = *slot - '0';
+  } else {
+    config.slot = 0;
+  }
+
+  nullterminate(prefix);
+  strcpy(config.prefix, prefix);
+
+#ifdef WITH_UIP
+
+  nullterminate(ipaddr);
+  if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) {
+    config.ipaddr[0] = addr[0];
+    config.ipaddr[1] = addr[1];
+  }
+  
+#ifdef WITH_ETHERNET
+
+  nullterminate(netmask);
+  if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) {
+    config.netmask[0] = addr[0];
+    config.netmask[1] = addr[1];
+  }
+
+  nullterminate(gateway);
+  if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) {
+    config.gateway[0] = addr[0];
+    config.gateway[1] = addr[1];
+  }
+
+  tmp = 0;
+  for(cptr = maclsb; *cptr >= '0' && *cptr <= '9'; ++cptr) {
+    tmp = (tmp * 10) + (*cptr - '0');
+  }
+  if(tmp != 0) {
+    config.maclsb = tmp;
+  }
+
+#endif /* WITH_ETHERNET */
+  
+  nullterminate(dnsserver);
+  if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) {
+    config.dnsserver[0] = addr[0];
+    config.dnsserver[1] = addr[1];
+  }
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+config_apply(void)
+{
+#ifdef __APPLE2ENH__
+
+  ctk_draw_setbackground(config.bkgnd);
+
+#endif /* __APPLE2ENH__ */
+
+  program_handler_setscreensaver(config.screensaver);
+
+  CTK_SCREENSAVER_SET_TIMEOUT(config.timeout * 60);
+
+  if(driverid != EK_ID_NONE) {
+    ek_post(driverid, EK_EVENT_REQUEST_EXIT, NULL);
+  }
+
+  config_setlanslot(config.slot);
+
+  if(*config.driver) {
+    program_handler_load(config.driver, NULL);
+  }
+
+  if(*config.prefix == '/') {
+    config_setprefixok(chdir(config.prefix) == 0);
+  }
+
+#ifdef WITH_UIP
+
+  uip_sethostaddr(config.ipaddr);
+
+#ifdef WITH_ETHERNET
+
+  uip_setnetmask(config.netmask);
+  uip_setdraddr(config.gateway);
+  uip_ethaddr.addr[5] = config.maclsb;
+
+#endif /* WITH_ETHERNET */
+
+  resolv_conf(config.dnsserver);
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static int
+config_save(void)
+{
+  int fd, written = 0;
+
+  fd = cfs_open(strcat(kfs_getdir(), "contiki.cfg"), CFS_WRITE);
+  if(fd != -1) {
+    written = cfs_write(fd, &config, sizeof(config));
+    cfs_close(fd);
+  }
+  return written == sizeof(config);
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(config_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 30, 19, "Config editor");
+#ifdef __APPLE2ENH__
+    CTK_WIDGET_ADD(&window, &backgroundlabel);
+    CTK_WIDGET_ADD(&window, &backgroundtextentry);
+    CTK_WIDGET_ADD(&window, &backgrounddescr);
+#endif /* __APPLE2ENH__ */
+    CTK_WIDGET_ADD(&window, &screensaverlabel);
+    CTK_WIDGET_ADD(&window, &screensavertextentry);
+    CTK_WIDGET_ADD(&window, &timeoutlabel);
+    CTK_WIDGET_ADD(&window, &timeouttextentry);
+    CTK_WIDGET_ADD(&window, &timeoutdescr);
+    CTK_WIDGET_ADD(&window, &driverlabel);
+    CTK_WIDGET_ADD(&window, &drivertextentry);
+    CTK_WIDGET_ADD(&window, &slotlabel);
+    CTK_WIDGET_ADD(&window, &slottextentry);
+    CTK_WIDGET_ADD(&window, &slotdescr);
+    CTK_WIDGET_ADD(&window, &prefixlabel);
+    CTK_WIDGET_ADD(&window, &prefixtextentry);
+    CTK_WIDGET_ADD(&window, &ipaddrlabel);
+    CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+#ifdef WITH_ETHERNET
+    CTK_WIDGET_ADD(&window, &netmasklabel);
+    CTK_WIDGET_ADD(&window, &netmasktextentry);
+    CTK_WIDGET_ADD(&window, &gatewaylabel);
+    CTK_WIDGET_ADD(&window, &gatewaytextentry);
+#endif /* WITH_ETHERNET */
+    CTK_WIDGET_ADD(&window, &dnsserverlabel);
+    CTK_WIDGET_ADD(&window, &dnsservertextentry);
+#ifdef WITH_ETHERNET
+    CTK_WIDGET_ADD(&window, &maclsblabel);
+    CTK_WIDGET_ADD(&window, &maclsbtextentry);
+    CTK_WIDGET_ADD(&window, &maclsbdescr);
+#endif /* WITH_ETHERNET */
+    CTK_WIDGET_ADD(&window, &okbutton);
+    CTK_WIDGET_ADD(&window, &cancelbutton);
+#ifdef __APPLE2ENH__
+    CTK_WIDGET_FOCUS(&window, &backgroundtextentry);
+#else /* __APPLE2ENH__ */
+    CTK_WIDGET_FOCUS(&window, &screensavertextentry);
+#endif /* __APPLE2ENH__ */
+
+    ctk_dialog_new(&errordialog, 19, 5);
+    CTK_WIDGET_ADD(&errordialog, &errormsg);
+    CTK_WIDGET_ADD(&errordialog, &errorokbutton);
+    CTK_WIDGET_FOCUS(&errordialog, &errorokbutton);
+
+    /* Fill the configuration strings with values from the current
+       configuration */
+    makestrings();
+    ctk_window_open(&window);
+  } else if(ev == ctk_signal_button_activate) {   
+    if(data == (ek_data_t)&okbutton) {
+
+      /* Fill the configuration with values from the current
+         configuration strings */
+      makeconfig();
+      config_apply();
+      if(config_save()) {
+	goto quit;
+      }
+      ctk_dialog_open(&errordialog);
+    } else if(data == (ek_data_t)&errorokbutton) {
+      ctk_dialog_close();
+      goto quit;
+    } else if(data == (ek_data_t)&cancelbutton) {
+      goto quit;
+    }
+
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    goto quit;
+  }
+  return;
+
+quit:
+  ctk_window_close(&window);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/plasma-dsc.c b/contiki-apple2/apps/plasma-dsc.c
new file mode 100644
index 0000000..bd8940b
--- /dev/null
+++ b/contiki-apple2/apps/plasma-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+    "Screensaver with a plasma",
+    "plasma.sav",
+    plasma_init,
+    &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+  '.', ' ', '.',
+  ' ', 'O', ' ',
+  '.', ' ', '.'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon plasma_icon =
+  {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/plasma.c b/contiki-apple2/apps/plasma.c
new file mode 100644
index 0000000..1936363
--- /dev/null
+++ b/contiki-apple2/apps/plasma.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+  128, 131, 134, 137, 140, 143, 146, 149, 
+  152, 156, 159, 162, 165, 168, 171, 174, 
+  176, 179, 182, 185, 188, 191, 193, 196, 
+  199, 201, 204, 206, 209, 211, 213, 216, 
+  218, 220, 222, 224, 226, 228, 230, 232, 
+  234, 236, 237, 239, 240, 242, 243, 245, 
+  246, 247, 248, 249, 250, 251, 252, 252, 
+  253, 254, 254, 255, 255, 255, 255, 255, 
+  255, 255, 255, 255, 255, 255, 254, 254, 
+  253, 252, 252, 251, 250, 249, 248, 247, 
+  246, 245, 243, 242, 240, 239, 237, 236, 
+  234, 232, 230, 228, 226, 224, 222, 220, 
+  218, 216, 213, 211, 209, 206, 204, 201, 
+  199, 196, 193, 191, 188, 185, 182, 179, 
+  176, 174, 171, 168, 165, 162, 159, 156, 
+  152, 149, 146, 143, 140, 137, 134, 131, 
+  128, 124, 121, 118, 115, 112, 109, 106, 
+  103,  99,  96,  93,  90,  87,  84,  81, 
+   79,  76,  73,  70,  67,  64,  62,  59, 
+   56,  54,  51,  49,  46,  44,  42,  39, 
+   37,  35,  33,  31,  29,  27,  25,  23, 
+   21,  19,  18,  16,  15,  13,  12,  10, 
+    9,   8,   7,   6,   5,   4,   3,   3, 
+    2,   1,   1,   0,   0,   0,   0,   0, 
+    0,   0,   0,   0,   0,   0,   1,   1, 
+    2,   3,   3,   4,   5,   6,   7,   8, 
+    9,  10,  12,  13,  15,  16,  18,  19, 
+   21,  23,  25,  27,  29,  31,  33,  35, 
+   37,  39,  42,  44,  46,  49,  51,  54, 
+   56,  59,  62,  64,  67,  70,  73,  76, 
+   78,  81,  84,  87,  90,  93,  96,  99, 
+  103, 106, 109, 112, 115, 118, 121, 124, 
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+  {
+    0x00, 0x22, 0x55, 0x33,
+    0xBB, 0xAA, 0xDD, 0xFF,
+    0xDD, 0xAA, 0xBB, 0x99,
+    0x11, 0x88, 0x00, 0x00
+  };
+
+#define XSIZE 25
+#define YSIZE 24
+
+#define XADD01 0xfe
+#define YADD01 0x05
+
+#define XADD1 0x04
+#define YADD1 0x02
+#define XADD2 0xfc
+#define YADD2 0xf9
+
+#define XADD 0x03
+#define YADD 0xfe
+
+#define MOVADD 0xfb
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char movcnt;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Plasma screensaver", idle,
+		   sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  *(char *)0xC051 = 0;
+
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+  static int i;
+  
+  /* Make sine tables */
+  for(i = 0; i < 256; ++i) {
+    sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+    sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;    
+  }
+    
+  /* Make color table */
+  for(i = 0; i < 256; ++i) {
+    colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+  }
+    
+  *(char *)0xC056 = 0;
+  *(char *)0xC054 = 0;
+  *(char *)0xC052 = 0;
+  *(char *)0xC050 = 0;
+
+  for(ycnt = 0; ycnt < 24; ++ycnt) {
+    gotoy(ycnt);
+    for(xcnt = 0; xcnt < 40; ++xcnt) {
+      (*(unsigned char **)0x28)[xcnt] = 0x00;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  static unsigned char i, x, y, xofs;
+  
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+    xcnt1 = xcnt01;
+    xcnt2 = xcnt02;
+    
+    for(i = 0; i < XSIZE; ++i) {
+      xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+      xcnt1 += XADD1;
+      xcnt2 += XADD2;
+    }
+
+    ycnt1 = ycnt01;
+    ycnt2 = ycnt02;
+    
+    for(i = 0; i < YSIZE; ++i) {
+      yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+      ycnt1 += YADD1;
+      ycnt2 += YADD2;
+    }
+
+    xcnt01 += XADD01;
+    xcnt02 += xadd02;
+    ycnt01 += YADD01;
+    ycnt02 += yadd02;
+
+    
+    yadd02 = sinetab3[ycnt] / 4;
+    xadd02 = sinetab3[xcnt] / 4;
+
+    ycnt += YADD;
+    xcnt += XADD;
+
+    movcnt += MOVADD;
+    xofs = sinetab1[movcnt]/16;
+
+    for(y = 0; y < YSIZE; ++y) {
+      gotoy(y);
+      for(x = 0; x < XSIZE; ++x) {
+	(*(unsigned char **)0x28)[x + xofs] = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+   
+    scrninit();
+
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+    /*    ctk_mode_set(CTK_MODE_NORMAL);*/
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+ 
diff --git a/contiki-apple2/apps/ssfire-dsc.c b/contiki-apple2/apps/ssfire-dsc.c
new file mode 100644
index 0000000..0fe625d
--- /dev/null
+++ b/contiki-apple2/apps/ssfire-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+    "Screensaver with two fires",
+    "ssfire.sav",
+    ssfire_init,
+    &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon ssfire_icon =
+  {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/ssfire.c b/contiki-apple2/apps/ssfire.c
new file mode 100644
index 0000000..574a652
--- /dev/null
+++ b/contiki-apple2/apps/ssfire.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+		   ssfire_sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+	   ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+static const unsigned char flamecolors[16] =
+  {0x00, 0x00, 0x00, 0x11, 0x99, 0xDD, 0xFF, 0xFF,
+   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+   
+static unsigned char *flameptr;
+static unsigned char x, y;
+
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+  *(char *)0xC051 = 0;
+
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+  *(char *)0xC056 = 0;
+  *(char *)0xC054 = 0;
+  *(char *)0xC052 = 0;
+  *(char *)0xC050 = 0;
+
+  for(y = 0; y < 24; ++y) {
+    gotoy(y);
+    for(x = 0; x < 40; ++x) {
+      (*(unsigned char **)0x28)[x] = 0x00;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+    fire_init();
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    fire_quit();
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+fire_burn(void)
+{
+  /* Calculate new flames. */
+  asm("ldy #$00");
+loop1:
+  asm("lda %v+7,y", flames);
+  asm("clc");
+  asm("adc %v+8,y", flames);
+  asm("adc %v+9,y", flames);
+  asm("adc %v+16,y", flames);
+  asm("lsr");
+  asm("lsr");
+  asm("sta %v,y", flames);
+  asm("iny");
+  asm("cpy #(8*15)");
+  asm("bne %g", loop1);
+
+  /* Fill last line with pseudo-random data. */
+  asm("ldy #$05");
+loop2:
+  asm("jsr %v", rand);
+  asm("and #$0F");
+  asm("sta %v+8*15+1,y", flames);
+  asm("dey");
+  asm("bpl %g", loop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+    fire_burn();
+  
+    /* Display flames on screen. */  
+    flameptr = flames;
+    for(y = 9; y < 24; ++y) {
+      gotoy(y);
+      for(x = 0; x < 8; ++x) {
+	(*(unsigned char **)0x28)[x   ] =
+	(*(unsigned char **)0x28)[x+32] = flamecolors[flameptr[x]];
+      }
+      flameptr += 8;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-apple2/apps/welcome.c b/contiki-apple2/apps/welcome.c
new file mode 100644
index 0000000..10acca3
--- /dev/null
+++ b/contiki-apple2/apps/welcome.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.3 2006/05/30 21:02:32 oliverschmidt Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+static struct ctk_label welcomelabel1 =
+  {CTK_LABEL(2, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING " !")};
+static struct ctk_label welcomelabel2 =
+  {CTK_LABEL(2, 4, 30, 1, "Esc        - open menus")};
+static struct ctk_label welcomelabel3 =
+  {CTK_LABEL(2, 6, 30, 1, "Ctrl-W     - cycle windows")};
+static struct ctk_label welcomelabel4 =
+  {CTK_LABEL(2, 8, 30, 1, "Ctrl-A     - select up")};
+static struct ctk_label welcomelabel5 =
+  {CTK_LABEL(2, 10, 30, 1, "Tab        - select down")};
+static struct ctk_label welcomelabel6 =
+  {CTK_LABEL(2, 12, 30, 1, "Return     - activate selected")};
+#ifdef __APPLE2__
+static struct ctk_label welcomelabel7 =
+  {CTK_LABEL(2, 14, 30, 1, "Ctrl-D     - delete character")};
+static struct ctk_label welcomelabel8 =
+  {CTK_LABEL(2, 16, 30, 1, "Ctrl-Reset - quit Contiki")};
+static struct ctk_label welcomeclose =
+  {CTK_BUTTON(13, 19, 5, "Close")};
+#else /* __APPLE2__ */
+static struct ctk_label welcomelabel7 =
+  {CTK_LABEL(2, 14, 30, 1, "Ctrl-Reset - quit Contiki")};
+static struct ctk_label welcomeclose =
+  {CTK_BUTTON(13, 17, 5, "Close")};
+#endif /* __APPLE2__ */
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+  ctk_dialog_close();
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+#ifdef __APPLE2__
+    ctk_dialog_new(&welcomedialog, 34, 21);
+#else /* __APPLE2__ */
+    ctk_dialog_new(&welcomedialog, 34, 19);
+#endif /* __APPLE2__ */
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);
+#ifdef __APPLE2__
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel8);
+#endif /* __APPLE2__ */
+    CTK_WIDGET_ADD(&welcomedialog, &welcomeclose);
+    CTK_WIDGET_FOCUS(&welcomedialog, &welcomeclose);
+    
+    ctk_dialog_open(&welcomedialog);
+    
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_button_activate) {
+    welcome_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/wget-dsc.c b/contiki-apple2/apps/wget-dsc.c
new file mode 100644
index 0000000..59f58cb
--- /dev/null
+++ b/contiki-apple2/apps/wget-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.2 2005/04/19 22:01:22 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon wget_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+    "Downloads files or disks from the web",
+    "wget.prg",
+    wget_init,
+    &wget_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char wgeticon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char wgeticon_textmap[9] = {
+  'w', 'e', 'b',
+  'p', 'r', 'g',
+  'd', 's', 'k'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon wget_icon =
+  {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/wget-dsc.h b/contiki-apple2/apps/wget-dsc.h
new file mode 100644
index 0000000..1d217b8
--- /dev/null
+++ b/contiki-apple2/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2005/03/29 23:12:31 oliverschmidt Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-apple2/apps/wget.c b/contiki-apple2/apps/wget.c
new file mode 100644
index 0000000..ec74e8a
--- /dev/null
+++ b/contiki-apple2/apps/wget.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.3 2005/04/24 13:37:06 oliverschmidt Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "uiplib.h"
+#include "loader.h"
+#include "cfs.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <dio.h>
+
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+  {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+  {CTK_TEXTENTRY(5, 1, 30, 1, urledit, 78)};
+
+static struct ctk_label savefilenamelabel =
+  {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+  {CTK_TEXTENTRY(15, 3, 20, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+  {CTK_BUTTON(0, 5, 16, "Download to file")};
+
+static struct ctk_button dskbutton =
+  {CTK_BUTTON(19, 5, 16, "Download to disk")};
+
+static struct ctk_label statustext =
+  {CTK_LABEL(0, 7, 37, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window dskdialog;
+static struct ctk_label overwritelabel =
+  {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+  {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+  {CTK_LABEL(4, 4, 28, 1, "right disk in slot 6 drive 1")};
+static struct ctk_button overwritebutton =
+  {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+	   wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_DSK  2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+static int savefile;
+static void* savedsk;
+
+static char buffer[16][256];
+static u16_t bufferptr;
+static u8_t relsector;
+static u16_t absblock;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+  if(arg != NULL) {
+    strncpy(url, arg, sizeof(url));
+    strncpy(urledit, arg, sizeof(urledit));
+  } else {
+#ifdef WGET_CONF_URL
+    strncpy(url, WGET_CONF_URL, sizeof(url));
+    strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL  */
+  }
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&statustext, text);
+  CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+dload_close(char *text)
+{
+  show_statustext(text);
+  if(dload_state == DLOAD_FILE) {
+    cfs_close(savefile);
+  } else if(dload_state == DLOAD_DSK) {
+    dio_close(savedsk);
+  }
+  dload_state = DLOAD_NONE;
+  webclient_close();
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+  u16_t addr[2];
+  unsigned char i;
+  static char host[32];
+  char *file;
+  register char *urlptr;
+
+  /* Trim off any spaces in the end of the url. */
+  urlptr = url + strlen(url) - 1;
+  while(*urlptr == ' ' && urlptr > url) {
+    *urlptr = 0;
+    --urlptr;
+  }
+
+  /* Don't even try to go further if the URL is empty. */
+  if(urlptr == url) {
+    return;
+  }
+
+  /* See if the URL starts with http://, otherwise prepend it. */
+  if(strncmp(url, http_http, 7) != 0) {
+    while(urlptr >= url) {
+      *(urlptr + 7) = *urlptr;
+      --urlptr;
+    }
+    strncpy(url, http_http, 7);
+  } 
+
+  /* Find host part of the URL. */
+  urlptr = &url[7];  
+  for(i = 0; i < sizeof(host); ++i) {
+    if(*urlptr == 0 ||
+       *urlptr == '/' ||
+       *urlptr == ' ' ||
+       *urlptr == ':') {
+      host[i] = 0;
+      break;
+    }
+    host[i] = *urlptr;
+    ++urlptr;
+  }
+
+  /* XXX: Here we should find the port part of the URL, but this isn't
+     currently done because of laziness from the programmer's side
+     :-) */
+  
+  /* Find file part of the URL. */
+  while(*urlptr != '/' && *urlptr != 0) {
+    ++urlptr;
+  }
+  if(*urlptr == '/') {
+    file = urlptr;
+  } else {
+    file = "/";
+  }
+      
+  /* First check if the host is an IP address. */
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    
+    /* Try to lookup the hostname. If it fails, we initiate a hostname
+       lookup and print out an informative message on the
+       statusbar. */
+    if(resolv_lookup(host) == NULL) {
+      resolv_query(host);
+      show_statustext("Resolving host...");
+      return;
+    }
+  }
+
+  /* The hostname we present in the hostname table, so we send out the
+     initial GET request. */
+  if(webclient_get(host, 80, file) == 0) {
+    show_statustext("Out of memory error.");
+  } else {
+    show_statustext("Connecting...");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create the main window. */
+    ctk_window_new(&window, 37, 8, "Web downloader");
+
+    CTK_WIDGET_ADD(&window, &urllabel);
+    CTK_WIDGET_ADD(&window, &urltextentry);
+    CTK_WIDGET_ADD(&window, &savefilenamelabel);
+    CTK_WIDGET_ADD(&window, &savefilenametextentry);
+    CTK_WIDGET_ADD(&window, &filebutton);
+    CTK_WIDGET_ADD(&window, &dskbutton);
+    CTK_WIDGET_ADD(&window, &statustext);
+
+    CTK_WIDGET_FOCUS(&window, &urltextentry);
+
+    dload_state = DLOAD_NONE;
+      
+    memset(savefilename, 0, sizeof(savefilename));
+    memset(url, 0, sizeof(url));
+
+    ctk_dialog_new(&dskdialog, 36, 8);
+    CTK_WIDGET_ADD(&dskdialog, &overwritelabel);
+    CTK_WIDGET_ADD(&dskdialog, &makesurelabel1);
+    CTK_WIDGET_ADD(&dskdialog, &makesurelabel2);
+    CTK_WIDGET_ADD(&dskdialog, &overwritebutton);
+    CTK_WIDGET_ADD(&dskdialog, &cancelbutton);
+    
+    CTK_WIDGET_FOCUS(&dskdialog, &cancelbutton);
+
+    ctk_window_open(&window);
+  } else if(ev == tcpip_event) {
+    webclient_appcall(data);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (void *)&filebutton) {
+      dload_close("");
+      savefile = cfs_open(savefilename, CFS_WRITE);
+      if(savefile == -1) {
+	sprintf(statusmsg, "Open error with '%s'", savefilename);
+	show_statustext(statusmsg);
+      } else {
+	strncpy(url, urledit, sizeof(url));
+	start_get();
+	dload_bytes = 0;
+	dload_state = DLOAD_FILE;
+      }
+    } else if(data == (void *)&dskbutton) {
+      ctk_dialog_open(&dskdialog);
+    } else if(data == (void *)&cancelbutton) {
+      ctk_dialog_close();
+    } else if(data == (void *)&overwritebutton) {
+      ctk_dialog_close();
+      dload_close("");
+      savedsk = dio_open(/*slot*/6 * 2 + /*drive*/1 - 1);
+      if(savedsk == NULL) {
+	sprintf(statusmsg, "Access error with slot 6 drive 1");
+	show_statustext(statusmsg);
+      } else {
+	strncpy(url, urledit, sizeof(url));
+	start_get();
+	dload_bytes = 0;
+	dload_state = DLOAD_DSK;
+	bufferptr = 0;
+	relsector = 0;
+	absblock = 0;
+      }
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    if(dload_state == DLOAD_NONE) {
+      /*      open_link(w->widget.hyperlink.url);*/
+      strncpy(urledit,
+	      ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+      CTK_WIDGET_REDRAW(&urltextentry);
+      CTK_WIDGET_FOCUS(&window, &urltextentry);
+    }
+  } else if(ev == resolv_event_found) {
+    /* Either found a hostname, or not. */
+    if((char *)data != NULL &&
+       resolv_lookup((char *)data) != NULL) {
+      start_get();
+    } else {
+      show_statustext("Host not found.");
+    }
+  } else if(ev == ctk_signal_window_close) {
+    dload_close("");
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+  show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+  dload_close("Connection timed out");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{
+  if(dload_state == DLOAD_NONE) {
+    return;
+  }
+  show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{    
+  show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+write_buffer(void)
+{
+  u8_t sector;
+
+  for(sector = 0; sector < 16; sector += 2) {
+    if(dio_write(savedsk, absblock++, buffer[sector]) != 0) {
+      return 0;
+    }
+  }
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+handle_dsk_data(char *data, u16_t len)
+{
+  static u8_t skew[16] = {0x0, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8,
+			  0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0xF};
+  u16_t bufferlen;
+
+  while(len > 0) {
+    bufferlen = sizeof(buffer[0]) - bufferptr;
+    if(len < bufferlen) {
+      bufferlen = len;
+    }
+    
+    memcpy(&buffer[skew[relsector]][bufferptr], data, bufferlen);
+
+    data += bufferlen;
+    bufferptr += bufferlen;
+    len -= bufferlen;
+    
+    if(bufferptr == sizeof(buffer[0])) {
+      bufferptr = 0;
+      if(++relsector == 16) {
+	relsector = 0;
+	if(write_buffer() == 0) {
+	  return 0;
+	}
+      }
+    }
+  }
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():   
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+  int ret;
+  
+  if(len > 0) {
+    dload_bytes += len;    
+    sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+    show_statustext(statusmsg);
+    if(dload_state == DLOAD_DSK) {
+      if(handle_dsk_data(data, len) == 0) {
+	dload_close("Write error with slot 6 drive 1");
+      }
+    } else if(dload_state == DLOAD_FILE) {      
+      ret = cfs_write(savefile, data, len);       
+      if(ret != len) {
+	sprintf(statusmsg, "Wrote only %d bytes", ret);
+	dload_close(statusmsg);
+      }
+    }
+  }
+  
+  if(data == NULL) {
+    sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+    dload_close(statusmsg);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/conf/cc-conf.h b/contiki-apple2/conf/cc-conf.h
new file mode 100644
index 0000000..a358a3f
--- /dev/null
+++ b/contiki-apple2/conf/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/10 07:25:27 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-apple2/conf/clock-conf.h b/contiki-apple2/conf/clock-conf.h
new file mode 100644
index 0000000..8417343
--- /dev/null
+++ b/contiki-apple2/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND 2
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-conf.h b/contiki-apple2/conf/ctk-conf.h
new file mode 100644
index 0000000..8c304f0
--- /dev/null
+++ b/contiki-apple2/conf/ctk-conf.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.13 2006/05/07 23:08:42 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_ESC
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     0x17	/* Ctrl-W */
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         0x01	/* Ctrl-A */
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       '\t'	/* Tab or Ctrl-I */
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#ifdef __APPLE2__
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+#else /* __APPLE2__ */
+#define CTK_CONF_MOUSE_SUPPORT        1 /* 1342 bytes */
+#endif /* __APPLE2__ */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         0
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#ifdef __APPLE2__
+#define CTK_CONF_WINDOWMOVE           0 /* 333 bytes */
+#else /* __APPLE2__ */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+#endif /* __APPLE2__ */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#ifdef __APPLE2__
+#define CTK_CONF_MAXMENUITEMS         5
+#else /* __APPLE2__ */
+#define CTK_CONF_MAXMENUITEMS         6
+#endif /* __APPLE2__ */
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          1
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-conio-conf.h b/contiki-apple2/conf/ctk-conio-conf.h
new file mode 100644
index 0000000..3a646d5
--- /dev/null
+++ b/contiki-apple2/conf/ctk-conio-conf.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.1 2005/02/17 22:36:19 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+#define BACKGROUNDCOLOR     COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 1
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+#define BACKGROUNDCOLOR     COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-mouse-conf.h b/contiki-apple2/conf/ctk-mouse-conf.h
new file mode 100644
index 0000000..f9a3285
--- /dev/null
+++ b/contiki-apple2/conf/ctk-mouse-conf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse-conf.h,v 1.1 2006/04/09 16:13:31 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_MOUSE_CONF_H__
+#define __CTK_MOUSE_CONF_H__
+
+#define MOUSE_CONF_DRIVER  "a2e.stdmou.mou"
+#define MOUSE_CONF_XTOC(x) ((x) * 2 / 7)
+#define MOUSE_CONF_YTOC(y) ((y) / 8)
+
+#endif /* __CTK_MOUSE_CONF_H__ */
diff --git a/contiki-apple2/conf/ek-conf.h b/contiki-apple2/conf/ek-conf.h
new file mode 100644
index 0000000..354d7d9
--- /dev/null
+++ b/contiki-apple2/conf/ek-conf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.5 2005/04/16 14:10:31 oliverschmidt Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_num_events_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_MAXPROCS 32
+#define EK_CONF_NUMEVENTS 16
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-apple2/conf/email-conf.h b/contiki-apple2/conf/email-conf.h
new file mode 100644
index 0000000..e2d2d2c
--- /dev/null
+++ b/contiki-apple2/conf/email-conf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: email-conf.h,v 1.2 2005/05/04 23:49:37 oliverschmidt Exp $
+ */
+#ifndef __EMAIL_CONF_H__
+#define __EMAIL_CONF_H__
+
+#ifdef __APPLE2__
+#define EMAIL_CONF_WIDTH 37
+#else /* __APPLE2__ */
+#define EMAIL_CONF_WIDTH 48
+#endif /* __APPLE2__ */
+#define EMAIL_CONF_HEIGHT 16
+
+#endif /* __EMAIL_CONF_H__ */
diff --git a/contiki-apple2/conf/irc-conf.h b/contiki-apple2/conf/irc-conf.h
new file mode 100644
index 0000000..d050bbc
--- /dev/null
+++ b/contiki-apple2/conf/irc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.1 2004/12/26 14:13:34 oliverschmidt Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#ifdef __APPLE2__
+#define IRC_CONF_WIDTH 38
+#else /* __APPLE2__ */
+#define IRC_CONF_WIDTH 78
+#endif /* __APPLE2__ */
+#define IRC_CONF_HEIGHT 20
+
+#define IRC_CONF_SYSTEM_STRING "apple2"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-apple2/conf/log-conf.h b/contiki-apple2/conf/log-conf.h
new file mode 100644
index 0000000..9ff4810
--- /dev/null
+++ b/contiki-apple2/conf/log-conf.h
@@ -0,0 +1,6 @@
+#ifndef __LOG_CONF_H__
+#define __LOG_CONF_H__
+
+#define LOG_CONF_ENABLED 0
+
+#endif /* __LOG_CONF__H__ */
diff --git a/contiki-apple2/conf/program-handler-conf.h b/contiki-apple2/conf/program-handler-conf.h
new file mode 100644
index 0000000..e2bc71d
--- /dev/null
+++ b/contiki-apple2/conf/program-handler-conf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.6 2006/05/14 23:34:13 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#ifdef __APPLE2__
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 5
+#define PROGRAM_HANDLER_CONF_QUIT_MENU   0
+#else /* __APPLE2__ */
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 6
+#define PROGRAM_HANDLER_CONF_QUIT_MENU   1
+#endif /* __APPLE2__ */
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-apple2/conf/shell-gui-conf.h b/contiki-apple2/conf/shell-gui-conf.h
new file mode 100644
index 0000000..eaf02e6
--- /dev/null
+++ b/contiki-apple2/conf/shell-gui-conf.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: shell-gui-conf.h,v 1.1 2005/05/04 22:12:05 oliverschmidt Exp $
+ */
+#ifndef __SHELL_GUI_CONF_H__
+#define __SHELL_GUI_CONF_H__
+
+#define SHELL_GUI_CONF_XSIZE 38
+#define SHELL_GUI_CONF_YSIZE 12
+
+#endif /* __SHELL_GUI_CONF_H__ */
diff --git a/contiki-apple2/conf/uip-conf.h b/contiki-apple2/conf/uip-conf.h
new file mode 100644
index 0000000..b4e379b
--- /dev/null
+++ b/contiki-apple2/conf/uip-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.4 2006/05/17 15:55:29 oliverschmidt Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE     1024 - 2
+#define UIP_CONF_RECEIVE_WINDOW  UIP_TCP_MSS
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+#define UIP_CONF_EXTERNAL_BUFFER
+
+#ifdef UIP_CODE
+
+#pragma codeseg("UIP");
+
+#include "ek-conf.h"
+
+#undef  EK_PROCESS_INIT
+#define EK_PROCESS_INIT(name, arg)					\
+  void _tcpip_init(void *arg)
+
+#undef  EK_EVENTHANDLER
+#define EK_EVENTHANDLER(name, ev, data)					\
+  void _tcpip_eventhandler(ek_event_t ev, ek_data_t data)
+
+#undef  EK_POLLHANDLER
+#define EK_POLLHANDLER(name)						\
+  void _tcpip_pollhandler(void)
+
+#undef  EK_PROCESS
+#define EK_PROCESS(name, strname, prio, eventh, pollh, stateptr)	\
+  void tcpip_eventhandler(ek_event_t ev, ek_data_t data);		\
+  void tcpip_pollhandler(void);						\
+  static struct ek_proc name = {NULL, EK_ID_NONE, strname, prio, tcpip_eventhandler, tcpip_pollhandler, stateptr}
+
+#define htons                _htons
+#define uiplib_ipaddrconv    _uiplib_ipaddrconv
+#define tcp_markconn         _tcp_markconn
+#define tcp_listen           _tcp_listen
+#define tcp_unlisten         _tcp_unlisten
+#define tcp_connect          _tcp_connect
+#define udp_new              _udp_new
+#define tcpip_set_forwarding _tcpip_set_forwarding
+#define tcpip_input          _tcpip_input
+#define tcpip_output         _tcpip_output
+#define tcpip_poll_tcp       _tcpip_poll_tcp
+#define tcpip_poll_udp       _tcpip_poll_udp
+
+#define ek_post_synch        _ek_post_synch
+void _ek_post_synch(ek_id_t id, ek_event_t ev, ek_data_t data);
+
+#endif /* UIP_CODE */
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-apple2/conf/www-conf.h b/contiki-apple2/conf/www-conf.h
new file mode 100644
index 0000000..1c3a761
--- /dev/null
+++ b/contiki-apple2/conf/www-conf.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.8 2005/05/23 22:39:56 oliverschmidt Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://www.sics.se/~adam/contiki/"
+
+/* The size of the HTML viewing area. */
+#ifdef __APPLE2__
+#define WWW_CONF_WEBPAGE_WIDTH 38
+#else /* __APPLE2__ */
+#define WWW_CONF_WEBPAGE_WIDTH 78
+#endif /* __APPLE2__ */
+#define WWW_CONF_WEBPAGE_HEIGHT 16
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 78
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 26
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  30
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-apple2/contiki.icon b/contiki-apple2/contiki.icon
new file mode 100644
index 0000000..56a5c8e
--- /dev/null
+++ b/contiki-apple2/contiki.icon
Binary files differ
diff --git a/contiki-apple2/ctk/ctk-arch.h b/contiki-apple2/ctk/ctk-arch.h
new file mode 100644
index 0000000..02d08e7
--- /dev/null
+++ b/contiki-apple2/ctk/ctk-arch.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.9 2005/04/17 22:40:11 oliverschmidt Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include "ctk-conio.h"
+
+#ifndef CH_CURS_UP
+#define CH_CURS_UP  	0x0B	/* Ctrl-K */
+#endif /* CH_CURS_UP */
+
+#ifndef CH_CURS_DOWN
+#define CH_CURS_DOWN	0x0A	/* Ctrl-J */
+#endif /* CH_CURS_DOWN */
+
+#ifndef CH_DEL
+#define CH_DEL		0x04	/* Ctrl-D */
+#endif /* CH_DEL */
+
+#ifdef __APPLE2ENH__
+
+extern unsigned char ctk_draw_background;
+
+#define ctk_draw_getbackground()      ctk_draw_background
+#define ctk_draw_setbackground(bkgnd) ctk_draw_background = (bkgnd)
+
+#endif /* __APPLE2ENH__ */
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-apple2/ctk/ctk-mousetext.c b/contiki-apple2/ctk/ctk-mousetext.c
new file mode 100644
index 0000000..0a3a925
--- /dev/null
+++ b/contiki-apple2/ctk/ctk-mousetext.c
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mousetext.c,v 1.22 2006/05/29 20:57:32 oliverschmidt Exp $
+ *
+ */
+
+#include <conio.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "uip.h"
+#include "config.h"
+
+#include "ctk-conio-conf.h"
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+unsigned char ctk_draw_background;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+cputsn(char *str, unsigned char len)
+{
+  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  ctk_draw_clear(0, 24);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    chlinexy(xpos, ypos, w->w);
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      gotoxy(xpos, ypos);
+      cputsn(text, w->w);
+      if(w->w - (wherex() - xpos) > 0) {
+	cclear(w->w - (wherex() - xpos));
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    revers(wfocus != 0);
+    cputcxy(xpos, ypos, '[');
+    cputsn(w->widget.button.text, w->w);
+    cputc(']');
+    revers(0);
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    revers(wfocus == 0);
+    gotoxy(xpos, ypos);
+    cputsn(w->widget.button.text, w->w);
+    revers(0);
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	 w->widget.textentry.ypos == j) {
+	revers(0);
+	cputcxy(xpos, ypos, '>');
+	c = 1;
+	for(i = 0; i < w->w; ++i) {
+	  if(c != 0) {
+	    c = text[i + xscroll];
+	  }
+	  revers(i == w->widget.textentry.xpos - xscroll);
+	  if(c == 0) {
+	    cputc(' ');
+	  } else {
+	    cputc(c);
+	  }
+	}
+	revers(0);
+	cputc('<');
+      } else {
+	revers(wfocus != 0 && j == w->widget.textentry.ypos);
+	cvlinexy(xpos, ypos, 1);
+	gotoxy(xpos + 1, ypos);          
+	cputsn(text, w->w);
+	i = wherex();
+	if(i - xpos - 1 < w->w) {
+	  cclear(w->w - (i - xpos) + 1);
+	}
+	cvline(1);
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+#if CTK_CONF_ICONS
+  case CTK_WIDGET_ICON:
+    revers(wfocus != 0);
+#if CTK_CONF_ICON_TEXTMAPS
+    if(w->widget.icon.textmap != NULL) {
+      for(i = 0; i < 3; ++i) {
+	gotoxy(xpos, ypos);
+	cputc(w->widget.icon.textmap[0 + 3 * i]);
+	cputc(w->widget.icon.textmap[1 + 3 * i]);
+	cputc(w->widget.icon.textmap[2 + 3 * i]);
+	++ypos;
+      }
+    }
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+    len = strlen(w->widget.icon.title);
+    if(xpos + len >= 80) {
+      xpos = 80 - len;
+    }
+
+    gotoxy(xpos, ypos);
+    cputs(w->widget.icon.title);
+    revers(0);
+    break;
+#endif /* CTK_CONF_ICONS */
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy, posx + win->w, posy + win->h, focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+  
+  h = window->y + 2 + window->h;
+
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    cclearxy(window->x + 1, i, window->w);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2, focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma codeseg(push, "CODE");
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char x1, y1, x2, y2;
+
+  x = window->x;
+  y = window->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  if(draw_borders) {
+
+    /* Draw window frame. */  
+    _textframexy(x, y, window->w + 2, window->h + 2, _TEXTFRAME_TALL);
+  }
+
+  draw_window_contents(window, focus, x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  x = dialog->x;
+  y = dialog->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+  /* Draw dialog frame. */
+  _textframexy(x, y, dialog->w + 2, dialog->h + 2, _TEXTFRAME_WIDE);
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma codeseg(pop);
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  char c1, c2;
+  unsigned char i;
+
+  if(ctk_draw_background) {
+    c1 = 'V';
+    c2 = 'W';
+  } else {
+    c1 = ' ' | 0x80;
+    c2 = ' ' | 0x80;
+  }
+
+  for(i = 1; i < 24; ++i) {
+    gotoy(i);
+    *(char *)0xC055 = 0;
+    memset(*(char **)0x28, c1, 40);
+    *(char *)0xC054 = 0;
+    memset(*(char **)0x28, c2, 40);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m, unsigned char open)
+{
+  unsigned char x, x2, y;
+
+  if(open) {
+    x = x2 = wherex();
+    if(x2 + CTK_CONF_MENUWIDTH > 80) {
+      x2 = 80 - CTK_CONF_MENUWIDTH;
+    }
+
+    for(y = 0; y < m->nitems; ++y) {
+      if(y == m->active) {
+	revers(0);
+      } else {
+	revers(1);
+      }
+      gotoxy(x2, y + 1);
+      if(m->items[y].title[0] == '-') {
+	chline(CTK_CONF_MENUWIDTH);
+      } else {
+	cputs(m->items[y].title);
+      }
+      if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
+	cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
+      }
+    }
+
+    gotoxy(x, 0);
+    revers(0);
+  }
+
+  cputs(m->title);
+  cputc(' ');
+  revers(1);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+
+  /* Draw menus */
+  gotoxy(0, 0);
+  revers(1);
+  cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    draw_menu(m, m == menus->open);
+  }
+
+  /* Draw desktopmenu */
+  if(wherex() + strlen(menus->desktopmenu->title) + 1 >= 80) {
+    gotoxy(80 - strlen(menus->desktopmenu->title) - 1, 0);
+  } else {
+    cclear(80 - wherex() -
+	   strlen(menus->desktopmenu->title) - 1);
+  }
+  draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
+
+  revers(0);
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return 24;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return 80;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+ctk_arch_isprint(char c)
+{
+  return isprint(c);
+}
diff --git a/contiki-apple2/lib/bank.S b/contiki-apple2/lib/bank.S
new file mode 100644
index 0000000..9d3d866
--- /dev/null
+++ b/contiki-apple2/lib/bank.S
@@ -0,0 +1,138 @@
+;
+; Bank switching code for Contiki (Apple2 version)
+;
+
+	.segment	"CONTIKI"
+
+	.export		VTABZ
+
+VTABZ:
+	; Switch in ROM and call VTABZ
+	bit	$C082
+	jsr	$FC24
+
+	; Switch in LC bank 2 for R/O and return
+	bit	$C080
+	rts
+
+.ifdef  __APPLE2ENH__
+
+	.code
+
+main2aux:
+	; Switch in $2000-$3FFF from aux memory
+	bit	$C055		; Page2
+	bit	$C057		; HiRes
+	rts
+	
+aux2main:
+	; Switch in $2000-$3FFF from main memory
+	bit	$C056		; LoRes
+	bit	$C054		; Page1
+	rts
+
+	.export		_tcpip_init
+	.import		__tcpip_init
+
+_tcpip_init:
+	jsr	main2aux
+	jsr	__tcpip_init
+	jmp	aux2main
+	
+	.export		_tcpip_eventhandler
+	.import		__tcpip_eventhandler
+
+_tcpip_eventhandler:
+	jsr	main2aux
+	jsr	__tcpip_eventhandler
+	jmp	aux2main
+	
+	.export		_tcpip_pollhandler
+	.import		__tcpip_pollhandler
+
+_tcpip_pollhandler:
+	jsr	main2aux
+	jsr	__tcpip_pollhandler
+	jmp	aux2main
+	
+	.export		_htons
+	.import		__htons
+
+_htons:
+	jsr	main2aux
+	jsr	__htons
+	jmp	aux2main
+	
+	.export		_uiplib_ipaddrconv
+	.import		__uiplib_ipaddrconv
+
+_uiplib_ipaddrconv:
+	jsr	main2aux
+	jsr	__uiplib_ipaddrconv
+	jmp	aux2main
+	
+	.export		_tcp_markconn
+	.import		__tcp_markconn
+
+_tcp_markconn:
+	jsr	main2aux
+	jsr	__tcp_markconn
+	jmp	aux2main
+
+	.export		_tcp_listen
+	.import		__tcp_listen
+
+_tcp_listen:
+	jsr	main2aux
+	jsr	__tcp_listen
+	jmp	aux2main
+
+	.export		_tcp_unlisten
+	.import		__tcp_unlisten
+
+_tcp_unlisten:
+	jsr	main2aux
+	jsr	__tcp_unlisten
+	jmp	aux2main
+
+	.export		_tcp_connect
+	.import		__tcp_connect
+
+_tcp_connect:
+	jsr	main2aux
+	jsr	__tcp_connect
+	jmp	aux2main
+
+	.export		_udp_new
+	.import		__udp_new
+
+_udp_new:
+	jsr	main2aux
+	jsr	__udp_new
+	jmp	aux2main
+
+	.export		_tcpip_input
+	.import		__tcpip_input
+
+_tcpip_input:
+	jsr	main2aux
+	jsr	__tcpip_input
+	jmp	aux2main
+
+	.export		_tcpip_poll_udp
+	.import		__tcpip_poll_udp
+
+_tcpip_poll_udp:
+	jsr	main2aux
+	jsr	__tcpip_poll_udp
+	jmp	aux2main
+	
+	.export		__ek_post_synch
+	.import		_ek_post_synch
+
+__ek_post_synch:
+	jsr	aux2main
+	jsr	_ek_post_synch
+	jmp	main2aux
+
+.endif
diff --git a/contiki-apple2/lib/cfs.c b/contiki-apple2/lib/cfs.c
new file mode 100644
index 0000000..be57120
--- /dev/null
+++ b/contiki-apple2/lib/cfs.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.c,v 1.4 2006/04/09 23:28:10 oliverschmidt Exp $
+ */
+
+
+#include <string.h>
+
+#include "contiki.h"
+#include "kfs.h"
+
+#include "cfs.h"
+
+
+/*---------------------------------------------------------------------------*/
+int
+cfs_opendir(struct cfs_dir *dirp, const char *name)
+{
+  if(strcmp(name, "/") == 0) {
+    name = kfs_getdir();
+  }
+
+  dirp->dir = opendir(name);
+  if(dirp->dir == NULL) {
+    return -1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+int
+cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *direntp)
+{
+  struct dirent *dirent = readdir(dirp->dir);
+  if(dirent == NULL) {
+    return -1;
+  }
+
+  strcpy(direntp->name, dirent->d_name);
+  direntp->size = 0;
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+int
+cfs_closedir(struct cfs_dir *dirp)
+{
+  return closedir(dirp->dir);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/lib/cfs.h b/contiki-apple2/lib/cfs.h
new file mode 100644
index 0000000..bae94c5
--- /dev/null
+++ b/contiki-apple2/lib/cfs.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.h,v 1.4 2006/04/09 23:28:10 oliverschmidt Exp $
+ */
+#ifndef __CFS_H__
+#define __CFS_H__
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#define CFS_READ  (O_RDONLY)
+#define CFS_WRITE (O_WRONLY | O_CREAT | O_TRUNC)
+
+#define cfs_open  open
+#define cfs_close close
+#define cfs_read  read
+#define cfs_write write
+
+struct cfs_dir {
+  DIR *dir;
+};
+
+struct cfs_dirent {
+  char name[16];
+  unsigned int size;
+};
+
+int cfs_opendir(struct cfs_dir *dirp, const char *name);
+int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *direntp);
+int cfs_closedir(struct cfs_dir *dirp);
+
+#endif /* __CFS_H__ */
diff --git a/contiki-apple2/lib/clock-arch.S b/contiki-apple2/lib/clock-arch.S
new file mode 100644
index 0000000..5d9c39d
--- /dev/null
+++ b/contiki-apple2/lib/clock-arch.S
@@ -0,0 +1,34 @@
+;
+; Clock tick code for Contiki (Apple2 version)
+;
+
+        .constructor    inittick
+	.export		_tick
+
+	.segment	"INIT"
+
+inittick:
+	; Switch in ROM
+	bit	$C082
+
+	; Check for IIgs
+	sec
+	jsr     $FE1F
+	bcs     done
+
+	; Check for fast speed
+	bit	$C036
+	bpl	done
+
+	; Adjust tick (5/14 = 1.0MHz/2.8MHz)
+	lda	#5
+	sta	_tick
+
+	; Switch in LC bank 2 for R/O
+done:	bit	$C080
+
+	rts
+
+        .data
+
+_tick:	.byte	14
diff --git a/contiki-apple2/lib/clock-arch.h b/contiki-apple2/lib/clock-arch.h
new file mode 100644
index 0000000..78a9270
--- /dev/null
+++ b/contiki-apple2/lib/clock-arch.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock-arch.h,v 1.1 2005/05/16 21:20:53 oliverschmidt Exp $
+ */
+#ifndef __CLOCK_ARCH_H__
+#define __CLOCK_ARCH_H__
+
+extern unsigned char tick;
+
+#endif /* __CLOCK_ARCH_H__ */
diff --git a/contiki-apple2/lib/crt0.S b/contiki-apple2/lib/crt0.S
new file mode 100644
index 0000000..acf5533
--- /dev/null
+++ b/contiki-apple2/lib/crt0.S
@@ -0,0 +1,559 @@
+;
+; Startup code for Contiki (Apple2 version)
+;
+; This must be the *first* file on the linker command line
+;
+
+	.export		_exit
+	.import	   	zerobss, initlib, callmain, donelib
+.ifdef  __APPLE2ENH__
+	.import		_uip_buf, callirq
+.endif
+	.import	       	__STARTUP_RUN__			; Linker generated
+	.import	       	__BSS_RUN__, __BSS_SIZE__	; Linker generated
+	.import	       	__INIT_RUN__, __INIT_SIZE__	; Linker generated
+	.import	       	__CODE_RUN__, __CODE_SIZE__	; Linker generated
+	.import	       	__BOOT_SIZE__, __UIP_SIZE__	; Linker generated
+	.importzp	sp
+	.linecont	+
+
+; ------------------------------------------------------------------------
+; The executable header
+
+.segment	"EXEHDR"
+
+	.word  	__STARTUP_RUN__				; Start address
+	.word  	__BSS_RUN__   + __BOOT_SIZE__ +		\
+		__INIT_SIZE__ + __CODE_SIZE__ +		\
+		__UIP_SIZE__ - __STARTUP_RUN__		; Size
+
+; ------------------------------------------------------------------------
+; Place the startup code in a special segment
+
+.segment       	"STARTUP"
+
+; Forward control to the code in the "BOOT" segment
+
+	jmp	__BSS_RUN__
+
+.ifdef  __APPLE2ENH__
+
+; ProDOS TechRefMan, chapter 6.2:
+; "Each installed routine must begin with a CLD instruction."
+
+irq:	cld
+
+; Switch in LC bank 2 for R/O
+
+	bit	$C080
+
+; Call interruptors
+
+	jsr     callirq
+	
+; Switch in LC bank 1 for R/W
+
+	bit	$C08B
+	bit	$C08B
+
+; Check for success
+
+	bcc	:+
+
+; ProDOS TechRefMan, chapter 6.2:
+; "When the routine that can process the interrupt is called, it
+;  should ... return (via an RTS) with the carry flag clear."
+
+	clc
+	rts
+
+; ProDOS TechRefMan, chapter 6.2:
+; "When a routine that cannot process the interrupt is called,
+;  it should return (via an RTS) with the cary flag set ..."
+
+:       sec
+	rts
+
+.endif
+
+; Avoid re-entrance of donelib. This is also the _exit entry
+
+_exit:	ldx	#$02
+:	lda	rvsave,x
+	sta	$03F2,x
+	dex
+	bpl	:-
+
+; Switch in LC bank 2 for R/O
+
+	bit	$C080
+
+; Call module destructors
+
+	jsr	donelib
+
+.ifdef  __APPLE2ENH__
+	
+; Switch in $2000-$3FFF from aux memory
+
+	lda	$C018		; 80Store ?
+	pha
+	sta	$C001		; 80Store On
+	
+	bit	$C055		; Page2
+	bit	$C057		; HiRes
+
+; Call the cleanup code in the "UIP" segment
+
+	jsr	cleanup
+
+; Switch in $2000-$3FFF from main memory
+
+	bit	$C056		; LoRes
+	bit	$C054		; Page1
+	
+	pla
+	bmi	:+
+	sta	$C000		; 80Store Off
+
+.endif
+
+; Switch in ROM
+
+:	bit	$C082
+
+; Back to DOS
+
+	jmp	$03D0
+
+.ifdef  __APPLE2ENH__
+; ------------------------------------------------------------------------
+; There's space left in the "UIP" segment so we move all cleanup code here
+
+.segment	"UIP"
+
+.proc	cleanup
+
+; Deallocate interrupt vector table entry
+
+	dec     intrpt		; Adjust parameter count
+	jsr     $BF00
+	.byte   $41		; Dealloc interrupt
+	.addr   intrpt
+
+; Save last used device number
+
+	lda	$BF30		; DEVNUM
+	sta	devnum
+
+; Read ProDOS dispatcher from /RAM
+
+	jsr     $BF00
+	.byte   $C8		; Open file
+	.addr   open
+	
+	lda	o_ref
+	sta	r_ref
+	sta	c_ref
+
+	jsr     $BF00
+	.byte   $CA		; Read file
+	.addr   read
+
+	jsr     $BF00
+	.byte   $CC		; Close file
+	.addr   close
+	
+; Destroy /RAM files
+
+	jsr     $BF00
+	.byte   $C1		; Destroy file
+	.addr   destr
+
+	dec	n_ext		; CONTIKI.2 -> CONTIKI.1
+
+	jsr     $BF00
+	.byte   $C1		; Destroy file
+	.addr   destr
+
+; Restore last used device number
+
+	lda	devnum
+	sta	$BF30		; DEVNUM
+
+; Switch in LC bank 2 for W/O
+
+	bit	$C081
+	bit	$C081
+
+; Set source start
+
+	lda	#<__BSS_RUN__
+	ldx	#>__BSS_RUN__
+	sta	$3C
+	stx	$3D
+
+; Set source end
+
+	lda	#<(__BSS_RUN__ + $0300)
+	ldx	#>(__BSS_RUN__ + $0300)
+	sta	$3E
+	stx	$3F
+
+; Set destination
+
+	lda	#<$D100
+	ldx	#>$D100
+	sta	$42
+	stx	$43
+
+; Reset index and call MOVE to copy ProDOS dispatcher into LC
+
+	ldy	#$00
+	jmp	$FE2C
+
+open:	.byte	$03		; Parameter count
+	.addr	name		; Pathname
+	.addr	_uip_buf	; IO buffer
+o_ref:	.byte	$00		; Reference number
+
+read:	.byte	$04		; Parameter count
+r_ref:	.byte	$00		; Reference number
+	.addr	__BSS_RUN__	; Data buffer
+	.word	$0300		; Requested count
+	.word	$0000		; Transfered count
+
+close:	.byte	$01		; Parameter count
+c_ref:	.byte	$00		; Reference number
+
+destr:	.byte	$01		; Parameter count
+	.addr	name		; Pathname
+
+name:	.byte	.strlen("/RAM/CONTIKI.2")
+	.byte	"/RAM/CONTIKI."
+n_ext:	.byte	'2'
+
+devnum:	.res	1
+
+.endproc
+.endif
+
+; ------------------------------------------------------------------------
+; The linker doesn't understand that the "BOOT" segment overlays the "BSS"
+; segment so the automatic fixup of references to the "BOOT" segment does
+; not work. Therefore references to this segment have to be expressed as
+; offsets to __BSS_RUN__.
+
+.segment	"BOOT"
+
+.ifdef  __APPLE2ENH__
+
+; Save potential command line arguments from being overwritten by
+; a slot-based realtime clock being called by ProDOS on file I/O
+
+	ldx	#$7F
+:	lda	$0200,x
+	sta	$0100,x
+	dex
+	bpl	:-
+
+; ProDOS TechRefMan, chapter 5.2.2.1:
+; "... you may protect those areas of auxiliary memory. If you save a
+;  dummy 8K file as the first entry in /RAM, it will always be saved
+;  at $2000 to $3FFF."
+;
+; Read /RAM directory
+
+	jsr     $BF00
+	.byte   $C8		; Open file
+	.addr   open
+	
+	lda	o_ref
+	sta	r_ref
+	sta	c_ref
+
+	jsr     $BF00
+	.byte   $CA		; Read file
+	.addr   read
+
+	jsr     $BF00
+	.byte   $CC		; Close file
+	.addr   close
+	
+; ProDOS TechRefMan, chapter B.2.5:
+; "FileCount := ThisBlock[$25] + (256 * ThisBlock[$26]);"
+;
+; Make sure /RAM is empty
+
+	lda	END + $25
+	ora	END + $26
+	beq	:++
+	
+	ldx	#.strlen("Fatal error: /RAM not empty !")
+:	lda	error,x
+	jsr	$FDED		; COUT
+	dex
+	bpl     :-
+	
+	jsr	$FD0C		; RDKEY
+	jmp	$03D0		; DOSWARM
+
+; Switch to 80 column mode here to show some progress
+
+:	lda	#$0D
+	jsr	$C300
+	
+; Relocate the "UIP" segment by writing it to /RAM as the first file
+
+	lda	#.strlen("/RAM/CONTIKI.1")
+	sta	name
+	jsr	ramfile
+	
+; Switch in LC bank 2 for R/O
+
+	bit	$C080
+
+; Copy ProDOS dispatcher out of LC
+
+	ldx	#$00
+l_mod	= __BSS_RUN__ + *
+:	lda	$D100,x
+s_mod	= __BSS_RUN__ + *
+	sta	UIP,x
+	inx
+	bne	:-
+	inc	l_mod+2
+	inc	s_mod+2
+	lda	l_mod+2
+	cmp	#>$D400
+	bne	:-
+
+; Write ProDOS dispatcher to /RAM
+
+	lda	#>$0300
+	sta	w_cnt+1
+	inc	n_ext		; CONTIKI.1 -> CONTIKI.2
+	jsr	ramfile
+	
+; Restore potential command line arguments
+
+	ldx	#$7F
+:	lda	$0100,x
+	sta	$0200,x
+	dex
+	bpl	:-
+
+; Allocate interrupt vector table entry
+
+	jsr     $BF00
+	.byte   $40		; Alloc interrupt
+	.addr   intrpt
+
+.endif
+
+; Setup the stack at HIMEM
+
+	lda    	$73
+	ldx	$73+1
+	sta	sp
+	stx	sp+1
+
+; Save the original RESET vector
+
+	ldx	#$02
+:	lda	$03F2,x
+	sta	rvsave,x
+	dex
+	bpl	:-
+
+; ProDOS TechRefMan, chapter 5.3.5:
+; "Your system program should place in the RESET vector the address of a
+;  routine that ... closes the files."
+
+	lda	#<_exit
+	sta	$03F2
+	lda	#>_exit
+	sta	$03F3
+	eor	#$A5
+	sta	$03F4
+		
+; Switch in LC bank 2 for W/O
+
+	bit	$C081
+	bit	$C081
+
+; Set source start
+
+	lda	#<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+	ldx	#>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+	sta	$3C
+	stx	$3D
+
+; Set source end
+
+	lda	#<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__)
+	ldx	#>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__)
+	sta	$3E
+	stx	$3F
+
+; Set destination
+
+	lda	#<__CODE_RUN__
+	ldx	#>__CODE_RUN__
+	sta	$42
+	stx	$43
+
+; Reset index and call MOVE to relocate the "CODE" segment
+
+	ldy	#$00
+	jsr	$FE2C
+
+; Set source start
+
+	lda	#<(__BSS_RUN__ + __BOOT_SIZE__)
+	ldx	#>(__BSS_RUN__ + __BOOT_SIZE__)
+	sta	$3C
+	stx	$3D
+
+; Set source end
+
+	lda	#<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+	ldx	#>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+	sta	$3E
+	stx	$3F
+
+; Set destination
+
+	lda	#<__INIT_RUN__
+	ldx	#>__INIT_RUN__
+	sta	$42
+	stx	$43
+
+; Reset index and call MOVE to relocate the "INIT" segment
+
+	ldy	#$00
+	jsr	$FE2C
+
+; Switch in LC bank 2 for R/O
+
+	bit	$C080
+
+; Forward control to code in the "INIT" segment
+
+	jmp	init
+	
+.ifdef  __APPLE2ENH__
+
+; Create a temporary file in /RAM
+
+ramfile	= __BSS_RUN__ + *
+	jsr     $BF00
+	.byte   $C0		; Create file
+	.addr   create
+
+	jsr     $BF00
+	.byte   $C8		; Open file
+	.addr   open
+	
+	lda	o_ref
+	sta	w_ref
+	sta	c_ref
+
+	jsr     $BF00
+	.byte   $CB		; Write file
+	.addr   write
+
+	jsr     $BF00
+	.byte   $CC		; Close file
+	.addr   close
+	
+	rts
+
+UIP	= __BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__
+END	= __BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__ + __UIP_SIZE__
+
+create	= __BSS_RUN__ + *
+	.byte	$07		; Parameter count
+	.addr	name		; Pathname
+	.byte	%11000011	; Access:	Standard full access
+	.byte	$00		; File type:	Typeless file
+	.word	$0000		; Aux type:	N/A
+	.byte	$01		; Storage type:	Standard seedling file
+	.word	$0000		; Create date:	Current date
+	.word	$0000		; Create time:	Current time
+
+open	= __BSS_RUN__ + *
+	.byte	$03		; Parameter count
+	.addr	name		; Pathname
+	.addr	_uip_buf	; IO buffer
+o_ref	= __BSS_RUN__ + *
+	.byte	$00		; Reference number
+
+read	= __BSS_RUN__ + *
+	.byte	$04		; Parameter count
+r_ref	= __BSS_RUN__ + *
+	.byte	$00		; Reference number
+	.addr	END		; Data buffer
+	.word	$0200		; Requested count
+	.word	$0000		; Transfered count
+
+write	= __BSS_RUN__ + *
+	.byte	$04		; Parameter count
+w_ref	= __BSS_RUN__ + *
+	.byte	$00		; Reference number
+	.addr	UIP		; Data buffer
+w_cnt	= __BSS_RUN__ + *
+	.word	$2000		; Requested count
+	.word	$0000		; Transfered count
+
+close	= __BSS_RUN__ + *
+	.byte	$01		; Parameter count
+c_ref	= __BSS_RUN__ + *
+	.byte	$00		; Reference number
+
+name	= __BSS_RUN__ + *
+	.byte	.strlen("/RAM")
+	.byte	"/RAM/CONTIKI."
+n_ext	= __BSS_RUN__ + *
+	.byte	'1'
+
+error	= __BSS_RUN__ + *
+	.byte	$8D,     '!'|$80, ' '|$80, 'y'|$80, 't'|$80, 'p'|$80
+	.byte	'm'|$80, 'e'|$80, ' '|$80, 't'|$80, 'o'|$80, 'n'|$80
+	.byte	' '|$80, 'M'|$80, 'A'|$80, 'R'|$80, '\'|$80, ' '|$80
+	.byte	':'|$80, 'r'|$80, 'o'|$80, 'r'|$80, 'r'|$80, 'e'|$80
+	.byte	' '|$80, 'l'|$80, 'a'|$80, 't'|$80, 'a'|$80, 'F'|$80
+
+.endif
+
+; ------------------------------------------------------------------------
+; The "INIT" segment will be overwritten by the heap
+
+.segment	"INIT"
+
+; Clear the BSS data (and thus overwrite the "BOOT" segment)
+
+init:	jsr	zerobss
+
+; Call module constructors
+
+	jsr	initlib
+
+; Push arguments and call main()
+
+	jmp	callmain
+
+; ------------------------------------------------------------------------
+; Data
+
+.data
+
+rvsave:	.res	3
+
+.ifdef  __APPLE2ENH__
+
+intrpt: .byte   $02		; Parameter count
+	.byte   $00		; Interrupt number
+	.addr   irq		; Interrupt handler
+
+.endif
\ No newline at end of file
diff --git a/contiki-apple2/lib/import.S b/contiki-apple2/lib/import.S
new file mode 100644
index 0000000..4ab774c
--- /dev/null
+++ b/contiki-apple2/lib/import.S
@@ -0,0 +1,11 @@
+;
+; Forced importing code for Contiki (Apple2 version)
+;
+; These symbols are necessary for (at least some) apps, but are
+; initialized by constructors which are currently not supported
+; for apps. Therefore we include these symbols into the Contiki
+; kernel to make them thus available to the apps indirectly via
+; the contiki-labels mechanism.
+
+	.forceimport	__dos_type
+	.forceimport	__cwd
diff --git a/contiki-apple2/lib/kfs.S b/contiki-apple2/lib/kfs.S
new file mode 100644
index 0000000..414170e
--- /dev/null
+++ b/contiki-apple2/lib/kfs.S
@@ -0,0 +1,178 @@
+;
+; Contiki kernel file system (Apple2 version)
+;
+; int __fastcall__ kfs_open(const char* name);
+; int __fastcall__ kfs_read(int fd, void* buf, unsigned count);
+; int __fastcall__ kfs_close(int fd);
+; char* kfs_getdir(void);
+;
+
+	.constructor	init_kfs
+        .destructor     done_kfs
+	.export		_kfs_open, _kfs_read, _kfs_close, _kfs_getdir
+	.import		_uip_buf, popax
+	.importzp 	ptr1
+
+PATHNAME	:= $0280
+MLI		:= $BF00
+
+GET_PREFIX_CALL	= $C7
+OPEN_CALL	= $C8
+READ_CALL	= $CA
+CLOSE_CALL	= $CC
+
+; ------------------------------------------------------------------------
+
+	.bss
+
+PREFIX:		.res	1
+
+; ------------------------------------------------------------------------
+
+	.data
+
+OPEN_PARAM:
+		.byte	$03		;PARAM_COUNT
+		.addr	PATHNAME	;PATHNAME
+		.addr	_uip_buf	;IO_BUFFER
+OPEN_FD:	.byte	$00		;REF_NUM
+
+READ_PARAM:
+		.byte	$04		;PARAM_COUNT
+READ_FD:	.byte	$00		;REF_NUM
+READ_BUFFER:	.addr	$0000		;DATA_BUFFER
+READ_COUNT_IN:	.word	$0000		;REQUEST_COUNT
+READ_COUNT_OUT:	.word	$0000		;TRANS_COUNT
+
+CLOSE_PARAM:
+		.byte	$01		;PARAM_COUNT
+CLOSE_FD:	.byte	$00		;REF_NUM
+
+; ------------------------------------------------------------------------
+
+	.segment	"INIT"
+
+init_kfs:
+        ; Check for full pathname
+	lda	PATHNAME+1
+	cmp	#'/'
+	beq	prefix
+
+	; Save name incl. length
+	ldx	PATHNAME
+:	lda	PATHNAME,x
+	sta	_uip_buf,x
+	dex
+	bpl	:-
+
+	jsr	MLI
+	.byte	GET_PREFIX_CALL
+	.addr	GET_PREFIX_PARAM
+
+	; Append name to prefix
+	lda	PATHNAME
+	clc
+	adc	_uip_buf
+	sta	PATHNAME
+	tax
+	ldy	_uip_buf
+:	lda	_uip_buf,y
+	sta	PATHNAME,x
+	dex
+	dey
+	bne	:-
+
+prefix:	lda	PATHNAME
+	sec
+	sbc	#.strlen("CONTIKI")
+	sta	PREFIX
+	rts
+
+GET_PREFIX_PARAM:
+		.byte	$01		; PARAM_COUNT
+		.addr	PATHNAME	; DATA_BUFFER
+
+; ------------------------------------------------------------------------
+
+	.segment	"CONTIKI"
+
+_kfs_open:
+	; Append name to prefix
+	sta	ptr1
+	stx	ptr1+1
+	ldy	#$00
+	ldx	PREFIX
+:	lda	(ptr1),y
+	beq	:+
+	sta	PATHNAME+1,x
+	iny
+	inx
+	bne	:-	; bra
+:	stx	PATHNAME
+
+	jsr	MLI
+	.byte	OPEN_CALL
+	.addr	OPEN_PARAM
+	bcs	ERROR
+
+	; Return fd
+	lda	OPEN_FD
+	ldx	#$00
+	rts
+
+_kfs_read:
+	; Store count
+	sta	READ_COUNT_IN
+	stx	READ_COUNT_IN+1
+
+	; Pop and store buf
+	jsr	popax
+	sta	READ_BUFFER
+	stx	READ_BUFFER+1
+
+	; Pop and store fd
+	jsr     popax
+	sta	READ_FD
+
+	jsr	MLI
+	.byte	READ_CALL
+	.addr	READ_PARAM
+	bcs	ERROR
+
+	; Return bytes transfered
+	lda	READ_COUNT_OUT
+	ldx	READ_COUNT_OUT+1
+	rts
+
+done_kfs:
+	lda	#$00
+
+_kfs_close:
+	; Store	fd
+	sta	CLOSE_FD
+
+	jsr	MLI
+	.byte	CLOSE_CALL
+	.addr	CLOSE_PARAM
+	bcs	ERROR
+
+	; Return 0
+	tax
+	rts
+
+_kfs_getdir:
+	; Append '\0' to prefix
+	lda	#$00
+	ldx	PREFIX
+	sta	PATHNAME+1,x
+
+	; Return prefix
+	lda	#<(PATHNAME+1)
+	ldx	#>(PATHNAME+1)
+	rts
+
+ERROR:
+	; Return -1
+	lda     #$FF
+        tax
+        rts
diff --git a/contiki-apple2/lib/kfs.h b/contiki-apple2/lib/kfs.h
new file mode 100644
index 0000000..a305103
--- /dev/null
+++ b/contiki-apple2/lib/kfs.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: kfs.h,v 1.2 2005/04/14 21:01:07 oliverschmidt Exp $
+ */
+#ifndef __KFS_H__
+#define __KFS_H__
+
+int __fastcall__ kfs_open(const char* name);
+int __fastcall__ kfs_read(int fd, void* buf, unsigned count);
+int __fastcall__ kfs_close(int fd);
+char* kfs_getdir(void);
+
+#endif /* __KFS_H__ */
diff --git a/contiki-apple2/loader/loader-arch.c b/contiki-apple2/loader/loader-arch.c
new file mode 100644
index 0000000..8ab73d8
--- /dev/null
+++ b/contiki-apple2/loader/loader-arch.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.3 2005/05/07 14:25:47 oliverschmidt Exp $
+ *
+ */
+
+#include <modload.h>
+
+#include "loader.h"
+#include "kfs.h"
+
+struct mod_ctrl ctrl = {
+  kfs_read
+};
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  
+  /* Now open the file */
+  ctrl.callerdata = kfs_open(name);
+  if(ctrl.callerdata < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+
+  /* Load the module */
+  res = mod_load(&ctrl);
+  
+  /* Close the input file */
+  kfs_close(ctrl.callerdata);
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/main.c b/contiki-apple2/main.c
new file mode 100644
index 0000000..0332ee3
--- /dev/null
+++ b/contiki-apple2/main.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: main.c,v 1.18 2006/06/28 23:10:43 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "www-dsc.h"
+#include "email-dsc.h"
+#include "ftp-dsc.h"
+#include "directory-dsc.h"
+
+#include "clock.h"
+#include "clock-arch.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+#define TICK_COUNT 2800
+#else
+#define TICK_COUNT 4200
+#endif
+
+unsigned char lanslot;
+unsigned char prefixok;
+
+#pragma bssseg(push, "UIPBUF");
+u8_t uip_buf[UIP_BUFSIZE + 2];
+#pragma bssseg(pop);
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    program_handler_load("config.prg", NULL);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+  static clock_time_t count, clock;
+
+  count += tick;
+
+  if(count == TICK_COUNT) {
+    count = 0;
+    ++clock;
+  }
+
+  return clock;
+}
+/*-----------------------------------------------------------------------------------*/
+#define STACK_SIZE 0
+#if STACK_SIZE
+#include <conio.h>
+#include <stdlib.h>
+void
+stack_size(void)
+{
+  static unsigned char *c;
+  static unsigned int s;
+  c = (unsigned char *)(0xBF00 - STACK_SIZE);
+  while(*c++ == 0xA2) {
+  }
+  s = (unsigned char *)0xBF00 - c;
+  clrscr();
+  cputc('0' + s / 100 % 10);
+  cputc('0' + s / 10  % 10);
+  cputc('0' + s       % 10);
+  cgetc();
+}
+#endif /* STACK_SIZE */
+/*-----------------------------------------------------------------------------------*/
+void
+#ifdef __APPLE2__
+main(void)
+#else /* __APPLE2__ */
+main(int argc, char *argv[])
+#endif /* __APPLE2__ */
+{
+
+#if STACK_SIZE
+  memset((void *)(0xBF00 - STACK_SIZE),
+         0xA2, STACK_SIZE - (0xBF00 - *(unsigned int *)0x80) - 10);
+  atexit(stack_size);
+#endif /* STACK_SIZE */
+
+  ek_init();
+  ek_start(&init);
+
+  tcpip_init(NULL);
+  resolv_init(NULL);
+  
+  ctk_init();
+  
+  program_handler_init();
+
+  program_handler_add(&www_dsc,       "Web browser", 1);
+  program_handler_add(&email_dsc,     "E-mail",      1);
+  program_handler_add(&ftp_dsc,       "FTP client",  1);
+  program_handler_add(&directory_dsc, "Directory",   1);
+
+  while(1) {
+    if(ek_run() == 0) {
+
+#ifdef __APPLE2__
+
+      program_handler_load("welcome.prg", NULL);
+
+#else /* __APPLE2__ */
+
+      static char *startup;
+      static char *slash;
+
+      if(argc == 1) {
+        startup = "welcome.prg";
+      } else {
+	startup = argv[1];
+	while(slash = strchr(startup, '/')) {
+	  startup = slash + 1;
+	}
+      }
+      program_handler_load(startup, NULL);
+
+#endif /* __APPLE2__ */
+
+      break;
+    }
+  }
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/readme.txt b/contiki-apple2/readme.txt
new file mode 100644
index 0000000..88a7e11
--- /dev/null
+++ b/contiki-apple2/readme.txt
@@ -0,0 +1,186 @@
+
+Contiki on the Apple ][ (Oliver Schmidt)
+========================================
+
+
+Contiki for the Apple ][ comes in two variants:
+
+1. 'Contiki40' runs in 40 column text mode and requires at least an Apple ][+
+   with Language Card resulting in 64kB memory.
+
+2. 'Contiki80' runs in 80 column text mode and requires at least an enhanced
+   Apple //e with Extended 80 Column Board resulting in 128kB memory.
+   
+The remainder of this text describes Contiki80.
+
+
+Installation
+------------
+
+1. Get the 'cc65 complete cross development package' from 06/01/2006 or later:
+   http://www.cc65.org
+
+
+2. Build the two targets apple2enh and programsenh.
+
+
+3. Get the 'a2tools' by Terry Kyriacopoulos:
+   ftp://ftp.apple.asimov.net/pub/apple_II/unsorted/a2tools.zip
+
+
+4. Get the 'Apple][ ProDOS 8 system program for loading binary programs':
+   ftp://ftp.musoftware.de/pub/uz/cc65/contrib/loader-1.2.zip
+
+
+5. Use the 'a2tools' to copy these files into a DOS 3.3 disk image:
+
+   a2tools in b      dos33.dsk CONTIKI.SYSTEM loader~1.sys
+   a2tools in -r b   dos33.dsk CONTIKI        contiki
+   a2tools in b.0000 dos33.dsk A2E.STDMOU.MOU a2estd~1.mou
+   a2tools in b.0000 dos33.dsk ABOUT.PRG      about.prg
+   a2tools in b.0000 dos33.dsk ABOUT.DSC      about.dsc
+   a2tools in b.0000 dos33.dsk CALC.PRG       calc.prg
+   a2tools in b.0000 dos33.dsk CALC.DSC       calc.dsc
+   a2tools in b.0000 dos33.dsk CONFIG.PRG     config.prg
+   a2tools in b.0000 dos33.dsk CONFIGEDIT.PRG config~1.prg
+   a2tools in b.0000 dos33.dsk CONFIGEDIT.DSC config~1.dsc
+   a2tools in b.0000 dos33.dsk DHCP.PRG       dhcp.prg
+   a2tools in b.0000 dos33.dsk DHCP.DSC       dhcp.dsc
+   a2tools in b.0000 dos33.dsk DIRECTORY.PRG  direct~1.prg
+   a2tools in b.0000 dos33.dsk DIRECTORY.DSC  direct~1.dsc
+   a2tools in b.0000 dos33.dsk EMAIL.PRG      email.prg
+   a2tools in b.0000 dos33.dsk EMAIL.DSC      email.dsc
+   a2tools in b.0000 dos33.dsk FTP.PRG        ftp.prg
+   a2tools in b.0000 dos33.dsk FTP.DSC        ftp.dsc
+   a2tools in b.0000 dos33.dsk IRC.PRG        irc.prg
+   a2tools in b.0000 dos33.dsk IRC.DSC        irc.dsc
+   a2tools in b.0000 dos33.dsk MEMSTAT.PRG    memstat.prg
+   a2tools in b.0000 dos33.dsk MEMSTAT.DSC    memstat.dsc
+   a2tools in b.0000 dos33.dsk PROCESSES.PRG  proces~1.prg
+   a2tools in b.0000 dos33.dsk PROCESSES.DSC  proces~1.dsc
+   a2tools in b.0000 dos33.dsk SHELL.PRG      shell.prg
+   a2tools in b.0000 dos33.dsk SHELL.DSC      shell.dsc
+   a2tools in b.0000 dos33.dsk TELNET.PRG     telnet.prg
+   a2tools in b.0000 dos33.dsk TELNET.DSC     telnet.dsc
+   a2tools in b.0000 dos33.dsk WEBSERVER.PRG  webser~1.prg
+   a2tools in b.0000 dos33.dsk WEBSERVER.DSC  webser~1.dsc
+   a2tools in b.0000 dos33.dsk WELCOME.PRG    welcome.prg
+   a2tools in b.0000 dos33.dsk WGET.PRG       wget.prg
+   a2tools in b.0000 dos33.dsk WGET.DSC       wget.dsc
+   a2tools in b.0000 dos33.dsk WWW.PRG        www.prg
+   a2tools in b.0000 dos33.dsk WWW.DSC        www.dsc
+   a2tools in b.0000 dos33.dsk LANCEGS.DRV    lancegs.drv
+   a2tools in b.0000 dos33.dsk LANCEGS.DSC    lancegs.dsc
+   a2tools in b.0000 dos33.dsk UTHER.DRV      uther.drv
+   a2tools in b.0000 dos33.dsk UTHER.DSC      uther.dsc
+   a2tools in b.0000 dos33.dsk BOUNCE.SAV     bounce.sav
+   a2tools in b.0000 dos33.dsk BOUNCE.DSC     bounce.dsc
+   a2tools in b.0000 dos33.dsk PLASMA.SAV     plasma.sav
+   a2tools in b.0000 dos33.dsk PLASMA.DSC     plasma.dsc
+   a2tools in b.0000 dos33.dsk SSFIRE.SAV     ssfire.sav
+   a2tools in b.0000 dos33.dsk SSFIRE.DSC     ssfire.dsc
+
+
+6. Use any ProDOS 8 file utility program capable of reading DOS 3.3 files to
+   copy the files from the DOS 3.3 disk to a ProDOS 8 disk.
+
+
+7. Use BASIC.SYSTEM to convert the loader from a BIN to a SYS file:
+
+   BLOAD  CONTIKI.SYSTEM
+   DELETE CONTIKI.SYSTEM
+   CREATE CONTIKI.SYSTEM,TSYS
+   BSAVE  CONTIKI.SYSTEM,TSYS,A$2000,L465
+
+
+Usage
+-----
+
+Select CONTIKI.SYSTEM from the ProDOS 8 dispatcher or use BASIC.SYSTEM:
+
+   - CONTIKI.SYSTEM
+
+1. CONTIKI.SYSTEM supports the ProDOS 8 startup file protocol. The startup file
+   will be initially launched instead of WELCOME.PRG.
+
+   The startup file support allows to open *.PRG files from the GS/OS finder:
+   
+   a) Give your Contiki disk the volume name /CONTIKI
+   b) Copy contiki.icon to /CONTIKI/ICONS/CONTIKI.ICON
+   c) Set the filetype of CONTIKI.ICON to $CA aka ICN
+   d) Set the filetype of the *.PRG files to $FE aka REL
+   
+2. Contiki includes mouse support for the AppleMouse II Card, the Apple //c and
+   the Apple IIgs. All slots are searched for mouse firmware but if non is found
+   the mouse support is silently turned off.
+   
+   IIgs ROM 3 users: Make sure to have set 'Slot 4' in the 'Control Panel' to
+                     'Mouse Port' although this isn't necessary for GS/OS.
+
+
+Implementation Notes
+--------------------
+
+1. File I/O
+
+   Contiki loads programs, drivers and screensavers from disk using ProDOS 8.
+   The ProDOS 8 file I/O library in the cc65 C-library is to large to be used
+   to load WWW.PRG into a 64k Apple ][. Fortunately WWW.PRG itself does no file
+   I/O but delegates that to WGET.PRG which is a lot smaller than WWW.PRG. so
+   the solution is to have two different file I/O libaries.
+   
+   The first one is as small as possible and is only capable of reading one file
+   at a time and only from the directory CONTIKI resides in. It is part of the
+   Contiki kernel and thus called 'KernelFileSystem' (kfs). ProDOS 8 needs a 1kB
+   I/O buffer aligned to a page boundary for every opoen file. The one and only
+   I/O buffer necessary for fks is placed at $0800-$0BFF and serves as buffer
+   for incoming/outgoing IP data as well.
+   
+   The other one which is called 'ContikiFileSystem' (cfs) is mapped to the
+   existing cc65 C-library and linked into the programs (like WGET.PRG).
+   
+2. Memory Layout
+
+   The Contiki memory layout is based on the standard cc65 layout which means
+   that the binary is loaded to the lowest available address ($0C00 here) and
+   contains the CODE, RODATA and DATA segments. The BSS segment is located
+   directly above those and set to zero programatically. The cc65 stack (not
+   to be confused with the 6502 stack at $0100-$01FF) starts at the highest
+   available address and grows downwards. The heap is located between the BSS
+   and the stack.
+   
+   But to satisfy the memory requirements of the larger Contiki programs
+   several modifications were necessary:
+   
+   Generally it's very hard to make use of memory mapping for an event driven
+   system like Contiki but the Apple //e allows to map only 8kB of Aux memory
+   to the address space $2000-$3FFF to facilitate double hires graphics. This
+   feature is accompanied by ProDOS 8 which allows to keep /RAM generally active
+   while doing double hires graphics by saving a 8kB file as first file to /RAM
+   and thus preserving $2000-$3FFF of Aux memory. Contiki makes use of all this
+   double hires support while just staying in text mode and using the 8kB as
+   additional memory.
+
+   The additional 8kB are used to store the code of the uIP TCP/IP stack. They
+   are mapped in both on calls from the Contiki event kernel to the TCP/IP stack
+   process (poll and event handler) and calls to the uIP API from programs. Most
+   of the time the 8kB are just kept mapped in when the uIP code calls other
+   code. This is possible because the only memory not reachable from the uIP
+   code are the corresponding 8kB of Main memory - and the Contiki kernel
+   objects are linked in an order which makes only CTK code (which is never
+   called by uIP code) use that 8kB of Main memory. The only call from uIP code
+   that triggers mapping out the 8kB of Aux memory is the uIP upcall into a
+   program for processing incoming IP data as some program may potentially call
+   CTK code while processing that data.
+
+   Beside that Contiki makes use of the Language Card bank 2 to store the code
+   of the C-libary. Most of this 4 kB can be considered free although officially
+   marked as reserved by ProDOS 8. Only $D100-$D3FF are actually used to store
+   the ProDOS 8 dispatcher. As it is only used after terminating Contiki it can
+   be saved to /RAM on startup and restored from there while cleanup.
+
+   The code doing all that code relocation gets overwritten on setting the BSS
+   segment to zero. The code doing this (and the C-library initialization) gets
+   overwritten later by the heap content.
+   
+eof
\ No newline at end of file
diff --git a/contiki-apple2/uip/cs8900a.c b/contiki-apple2/uip/cs8900a.c
new file mode 100644
index 0000000..872691b
--- /dev/null
+++ b/contiki-apple2/uip/cs8900a.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.8 2005/05/22 14:04:21 oliverschmidt Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+   written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+extern u8_t lanslot;
+extern u8_t *cs8900a_rxtxreg,
+            *cs8900a_txcmd,
+            *cs8900a_txlen,
+            *cs8900a_packetpp,
+            *cs8900a_ppdata;
+
+static u8_t idx;
+static u16_t len;
+static u16_t cnt;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+  asm("lda %v", lanslot);
+  asm("beq %g", bailout);
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("sta %v", idx);
+  asm("tax");
+
+  /* Turn on transmission and reception of frames. */
+  /* PACKETPP = 0x0112;
+     PPDATA   = 0x00c0; */
+  asm("lda #$12");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda #$c0");
+  asm("sta %v,x", cs8900a_ppdata);
+  asm("lda #$00");
+  asm("sta %v+1,x", cs8900a_ppdata);
+
+  /* Accept valid unicast+broadcast frames. */
+  /* PACKETPP = 0x0104;
+     PPDATA   = 0x0d05; */
+  asm("lda #$04");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda #$05");
+  asm("sta %v,x", cs8900a_ppdata);
+  asm("lda #$0d");
+  asm("sta %v+1,x", cs8900a_ppdata);
+
+  /* Set MAC address. */
+  /* PACKETPP = 0x0158;
+     PPDATA   = (ETHADDR1 << 8) | (ETHADDR0); */
+  asm("lda #$58");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v", uip_ethaddr);
+  asm("sta %v,x", cs8900a_ppdata);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %v+1,x", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015a;
+     PPDATA   = (ETHADDR3 << 8) | (ETHADDR2); */
+  asm("lda #$5a");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %v,x", cs8900a_ppdata);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %v+1,x", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015c;
+     PPDATA   = (ETHADDR5 << 8) | (ETHADDR4); */
+  asm("lda #$5c");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %v,x", cs8900a_ppdata);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %v+1,x", cs8900a_ppdata);
+bailout:
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+  asm("ldx %v", idx);
+  asm("beq %g", bailout);
+
+  /* Transmit command. */
+  asm("lda #$c0");
+  asm("sta %v,x", cs8900a_txcmd);
+  asm("lda #$00");
+  asm("sta %v+1,x", cs8900a_txcmd);
+  asm("lda %v", uip_len);
+  asm("sta %v,x", cs8900a_txlen);
+  asm("lda %v+1", uip_len);
+  asm("sta %v+1,x", cs8900a_txlen);
+
+  asm("ldy #8");
+tryagain:
+  /* Check for avaliable buffer space. */
+  asm("lda #$38");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v+1,x", cs8900a_ppdata);
+  asm("and #1");
+  asm("bne %g", send);
+
+  /* No space avaliable, skip a received frame and try again. */
+  asm("lda #$02");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v,x", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v,x", cs8900a_ppdata);
+
+  asm("dey");
+  asm("bne %g", tryagain);
+bailout:
+  return;
+
+  /* Send the frame. */
+send:
+
+  /* First, send 14+40=54 bytes of header. */
+  asm("ldy #0");
+sendloop1:
+  asm("lda %v,y", uip_buf);
+  asm("sta %v,x", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda %v,y", uip_buf);
+  asm("sta %v+1,x", cs8900a_rxtxreg);
+  asm("iny");
+  asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+  asm("bne %g", sendloop1);
+
+  if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+    return;
+  }
+
+  /* Next, send rest of the packet. */
+  cnt = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+  asm("ldx %v", idx);
+
+  asm("lda %v", cnt);
+  asm("lsr");
+  asm("bcc %g", noinc);
+  asm("inc %v", cnt);
+  asm("bne %g", noinc);
+  asm("inc %v+1", cnt);
+noinc:
+
+  asm("lda %v", uip_appdata);
+  asm("sta ptr1");
+  asm("lda %v+1", uip_appdata);
+  asm("sta ptr1+1");  
+
+  asm("ldy #0");
+sendloop2:
+  asm("lda (ptr1),y");
+  asm("sta %v,x", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("sta %v+1,x", cs8900a_rxtxreg);
+  asm("iny");
+  asm("bne %g", check);
+  asm("inc ptr1+1");
+check:
+  asm("cpy %v", cnt);
+  asm("bne %g", sendloop2);
+  asm("dec %v+1", cnt);
+  asm("bpl %g", sendloop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+  asm("ldx %v", idx);
+
+  /* PACKETPP = 0x0102;
+     PPDATA   = PPDATA | 0x0040; */
+  asm("lda #$02");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v,x", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v,x", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+cs8900a_poll(void)
+{
+  asm("ldx %v", idx);
+  asm("beq %g", bailout);
+
+  /* Check receiver event register to see if there are any valid
+     unicast frames avaliable.  */
+  /* PACKETPP = 0x0124;
+     if(PPDATA & 0x000d == 0x0000) {
+       return 0;
+     }
+  */
+  asm("lda #$24");
+  asm("sta %v,x", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1,x", cs8900a_packetpp);
+  asm("lda %v+1,x", cs8900a_ppdata);
+  asm("and #$0d");
+  asm("cmp #$00");
+  asm("bne %g", noreturn);
+  /* No frame ready. */
+bailout:
+  return 0;
+  
+noreturn:
+  /* Process the incoming frame. */
+  
+  /* Read receiver event and discard it. */
+  /* RXTXREG; */
+  asm("lda %v+1,x", cs8900a_rxtxreg);
+  asm("lda %v,x", cs8900a_rxtxreg);
+  
+  /* Read frame length. */
+  /* cnt = len = RXTXREG; */
+  asm("lda %v+1,x", cs8900a_rxtxreg);
+  asm("sta %v+1", len);
+  asm("sta %v+1", cnt);
+  asm("lda %v,x", cs8900a_rxtxreg);
+  asm("sta %v", len);
+  asm("sta %v", cnt);
+
+  asm("lsr");
+  asm("bcc %g", noinc);
+  asm("inc %v", cnt);
+  asm("bne %g", noinc);
+  asm("inc %v+1", cnt);
+noinc:
+
+  if(cnt > UIP_BUFSIZE) {
+    skip_frame();
+    return 0;
+  }
+
+  /* Read bytes into uip_buf. */
+  asm("ldx %v", idx);
+
+  asm("lda #<%v", uip_buf);
+  asm("sta ptr1");
+  asm("lda #>%v", uip_buf);
+  asm("sta ptr1+1");  
+  
+  asm("ldy #0");
+readloop:
+  asm("lda %v,x", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1,x", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne %g", check);
+  asm("inc ptr1+1");
+check:
+  asm("cpy %v", cnt);
+  asm("bne %g", readloop);
+  asm("dec %v+1", cnt);
+  asm("bpl %g", readloop);
+  return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-apple2/uip/cs8900a.h b/contiki-apple2/uip/cs8900a.h
new file mode 100644
index 0000000..2beae51
--- /dev/null
+++ b/contiki-apple2/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.2 2005/01/26 21:33:30 oliverschmidt Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u16_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-apple2/uip/lan91c96.c b/contiki-apple2/uip/lan91c96.c
new file mode 100644
index 0000000..28d1c10
--- /dev/null
+++ b/contiki-apple2/uip/lan91c96.c
@@ -0,0 +1,359 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.6 2005/05/22 14:04:21 oliverschmidt Exp $
+ *
+ */
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+#define ETHBASE 0xc080
+
+#define ETHBSR     ETHBASE+0x0e	 /* Bank select register             R/W (2B) */
+
+/* Register bank 0 */
+
+#define ETHTCR     ETHBASE       /* Transmition control register     R/W (2B) */
+#define ETHEPHSR   ETHBASE+2     /* EPH status register              R/O (2B) */
+#define ETHRCR     ETHBASE+4     /* Receive control register         R/W (2B) */
+#define ETHECR     ETHBASE+6     /* Counter register                 R/O (2B) */
+#define ETHMIR     ETHBASE+8     /* Memory information register      R/O (2B) */
+#define ETHMCR     ETHBASE+0x0a  /* Memory Config. reg.    +0 R/W +1 R/O (2B) */
+
+/* Register bank 1 */
+
+#define ETHCR      ETHBASE       /* Configuration register           R/W (2B) */
+#define ETHBAR     ETHBASE+2     /* Base address register            R/W (2B) */
+#define ETHIAR     ETHBASE+4     /* Individual address register      R/W (6B) */
+#define ETHGPR     ETHBASE+0x0a  /* General address register         R/W (2B) */
+#define ETHCTR     ETHBASE+0x0c  /* Control register                 R/W (2B) */
+
+/* Register bank 2 */
+
+#define ETHMMUCR   ETHBASE       /* MMU command register             W/O (1B) */
+#define ETHAUTOTX  ETHBASE+1     /* AUTO TX start register           R/W (1B) */
+#define ETHPNR     ETHBASE+2     /* Packet number register           R/W (1B) */
+#define ETHARR     ETHBASE+3     /* Allocation result register       R/O (1B) */
+#define ETHFIFO    ETHBASE+4     /* FIFO ports register              R/O (2B) */
+#define ETHPTR     ETHBASE+6     /* Pointer register                 R/W (2B) */
+#define ETHDATA    ETHBASE+8     /* Data register                    R/W (4B) */
+#define ETHIST     ETHBASE+0x0c  /* Interrupt status register        R/O (1B) */
+#define ETHACK     ETHBASE+0x0c  /* Interrupt acknowledge register   W/O (1B) */
+#define ETHMSK     ETHBASE+0x0d  /* Interrupt mask register          R/W (1B) */
+
+/* Register bank 3 */
+
+#define ETHMT      ETHBASE       /* Multicast table                  R/W (8B) */
+#define ETHMGMT    ETHBASE+8     /* Management interface             R/W (2B) */
+#define ETHREV     ETHBASE+0x0a  /* Revision register                R/W (2B) */
+#define ETHERCV    ETHBASE+0x0c  /* Early RCV register               R/W (2B) */
+
+#define BANK(num) asm("lda #%b", num); asm("sta %w,x", ETHBSR);
+
+extern u8_t lanslot;
+
+static u8_t slot_index;
+static u8_t packet_status;
+static u16_t packet_length;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+  asm("lda %v", lanslot);
+  asm("beq %g", L1);
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+
+  /* Check if high byte is 0x33 */
+  asm("lda %w,x", ETHBSR+1);
+  asm("cmp #$33");
+  asm("bne %g", L1);
+  asm("stx %v", slot_index);
+
+  /* Reset ETH card */
+  BANK(0);
+  asm("lda #%%10000000");        /* Software reset */
+  asm("sta %w,x", ETHRCR+1);
+
+  asm("lda #0");
+  asm("sta %w,x", ETHRCR);
+  asm("sta %w,x", ETHRCR+1);
+
+  /* Enable transmit and receive */
+  asm("lda #%%10000001");        /* Enable transmit TXENA, PAD_EN */
+  asm("sta %w,x", ETHTCR);
+  asm("lda #%%00000011");        /* Enable receive, strip CRC ??? */
+  asm("sta %w,x", ETHRCR+1);
+
+  BANK(1);
+  asm("lda %w,x", ETHCR+1);
+  asm("ora #%%00010000");        /* No wait (IOCHRDY) */
+  asm("sta %w,x", ETHCR+1);
+
+  asm("lda #%%00001001");        /* Auto release */
+  asm("sta %w,x", ETHCTR+1);
+  
+  /* Set MAC address */
+  asm("lda %v", uip_ethaddr);
+  asm("sta %w,x", ETHIAR);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %w,x", ETHIAR+1);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %w,x", ETHIAR+2);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %w,x", ETHIAR+3);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %w,x", ETHIAR+4);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %w,x", ETHIAR+5);
+
+  BANK(2);
+  asm("lda #%%00000000");        /* No interrupts */
+  asm("sta %w,x", ETHMSK);
+L1:
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t lan91c96_poll(void)
+{
+  asm("ldx %v", slot_index);
+  asm("beq %g", L0);
+
+  asm("lda %w,x", ETHIST);
+  asm("and #%%00000001");        /* RCV INT */
+  asm("bne %g", L1);
+
+  /* No packet available */
+L0:
+  return 0;
+
+L1:
+  asm("lda #0");
+  asm("sta %w,x", ETHPTR);
+  asm("lda #%%11100000");        /* RCV,AUTO INCR.,READ */
+  asm("sta %w,x", ETHPTR+1);
+
+  asm("lda %w,x", ETHDATA);      /* Status word */
+  asm("lda %w,x", ETHDATA);
+  asm("sta %v", packet_status);  /* High byte only */
+
+  asm("lda %w,x", ETHDATA);      /* Total number of bytes */
+  asm("sta %v", packet_length);
+  asm("lda %w,x", ETHDATA);
+  asm("sta %v+1", packet_length);
+
+  /* Last word contain 'last data byte' and 0x60 */
+  /* or 'fill byte' and 0x40 */
+
+  packet_length -= 6;            /* The packet contains 3 extra words */
+
+  asm("lda %v", packet_status);
+  asm("and #$10");
+  asm("beq %g", L2);
+
+  packet_length++;
+
+L2:
+  if(packet_length > UIP_BUFSIZE) {
+
+    asm("ldx %v", slot_index);
+
+    /* Remove and release RX packet from FIFO */ 
+    asm("lda #%%10000000");
+    asm("sta %w,x", ETHMMUCR);
+    return 0;
+  }
+
+  asm("ldx %v", slot_index);
+
+  asm("lda #<%v", uip_buf);
+  asm("sta ptr1");
+  asm("lda #>%v", uip_buf);
+  asm("sta ptr1+1");
+
+  asm("lda %v+1", packet_length);
+  asm("sta tmp1");
+
+  asm("ldy #0");
+L3:
+  asm("lda %w,x", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne %g", L4);
+  asm("inc ptr1+1");
+L4:
+  asm("cpy %v", packet_length);
+  asm("bne %g", L3);
+  asm("dec tmp1");
+  asm("bpl %g", L3);
+
+  /* Remove and release RX packet from FIFO */ 
+  asm("lda #%%10000000");
+  asm("sta %w,x", ETHMMUCR);
+  return packet_length;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+  /* First 14+40 (IP and TCP header) is send from uip_buf */
+  /* than data from uip_appdata */
+
+  asm("ldx %v", slot_index);
+  asm("beq %g", L0);
+
+  asm("lda %v+1", uip_len);
+  asm("ora #%%00100000");        /* Allocate memory for TX */
+  asm("sta %w,x", ETHMMUCR);
+
+  asm("ldy #8");                 /* Wait... */
+L1:                              /* Wait for allocation ready */
+  asm("lda %w,x", ETHIST);
+  asm("and #%%00001000");        /* ALLOC INT */
+  asm("bne %g", L2);
+  asm("dey");
+  asm("bne %g", L1);
+L0:
+  return;
+
+L2:
+  asm("lda #%%00001000");        /* Acknowledge int, is it necessary ??? */
+  asm("sta %w,x", ETHACK);
+
+  asm("lda %w,x", ETHARR);
+  asm("sta %w,x", ETHPNR);       /* Set packet address */
+
+  asm("lda #0");
+  asm("sta %w,x", ETHPTR);
+  asm("lda #%%01000000");        /* AUTO INCR. */
+  asm("sta %w,x", ETHPTR+1);
+
+  asm("lda #0");                 /* Status written by CSMA */
+  asm("sta %w,x", ETHDATA);
+  asm("sta %w,x", ETHDATA);
+
+  asm("lda %v", uip_len);
+  asm("and #$01");
+  asm("beq %g", L3);
+
+  packet_length = uip_len + 5;
+  asm("jmp %g", L4);
+
+L3:
+  packet_length = uip_len + 6;   /* +6 for status word, length and ctl byte */
+
+L4:
+  asm("ldx %v", slot_index);
+
+  asm("lda %v", packet_length);
+  asm("sta %w,x", ETHDATA);
+  asm("lda %v+1", packet_length);
+  asm("sta %w,x", ETHDATA);
+
+  /* Send 14+40=54 bytes of header */
+
+  if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+
+    asm("ldx %v", slot_index);
+
+    asm("ldy #0");
+L5:
+    asm("lda %v,y", uip_buf);
+    asm("sta %w,x", ETHDATA);
+    asm("iny");
+    asm("cpy %v", uip_len);
+    asm("bne %g", L5);
+
+  } else {
+
+    asm("ldx %v", slot_index);
+
+    asm("ldy #0");
+L6:
+    asm("lda %v,y", uip_buf);
+    asm("sta %w,x", ETHDATA);
+    asm("iny");
+    asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+    asm("bne %g", L6);
+
+    packet_length = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+    asm("ldx %v", slot_index);
+
+    asm("lda %v", uip_appdata);  /* uip_appdata is pointer */
+    asm("sta ptr1");
+    asm("lda %v+1", uip_appdata);
+    asm("sta ptr1+1");
+
+    asm("ldy #0");
+L7:
+    asm("lda (ptr1),y");
+    asm("sta %w,x", ETHDATA);
+    asm("iny");
+    asm("bne %g", L8);
+    asm("inc ptr1+1");
+L8:
+    asm("cpy %v", packet_length);
+    asm("bne %g", L7);
+    asm("dec %v+1", packet_length);
+    asm("bpl %g", L7);
+  }
+
+  asm("lda %v", packet_length);
+  asm("and #$01");
+  asm("beq %g", L9);
+
+  asm("lda #%%00100000");
+  asm("sta %w,x", ETHDATA);      /* Control byte */
+
+  asm("lda #%%11000000");        /* ENQUEUE PACKET - transmit packet */
+  asm("sta %w,x", ETHMMUCR);
+  return;
+
+L9:
+  asm("lda #0");
+  asm("sta %w,x", ETHDATA);      /* Fill byte */
+  asm("sta %w,x", ETHDATA);      /* Control byte */
+
+  asm("lda #%%11000000");        /* ENQUEUE PACKET - transmit packet */
+  asm("sta %w,x", ETHMMUCR);
+}
+#pragma optimize(pop)
diff --git a/contiki-apple2/uip/lan91c96.h b/contiki-apple2/uip/lan91c96.h
new file mode 100644
index 0000000..494653c
--- /dev/null
+++ b/contiki-apple2/uip/lan91c96.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.1 2005/03/13 21:33:57 oliverschmidt Exp $
+ */
+
+#ifndef __LAN91C96_H__
+#define __LAN91C96_H__
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_send(void);
+u16_t lan91c96_poll(void);
+
+#endif /* __LAN91C96_H__ */
diff --git a/contiki-apple2/uip/lancegs-drv.c b/contiki-apple2/uip/lancegs-drv.c
new file mode 100644
index 0000000..e25c2d0
--- /dev/null
+++ b/contiki-apple2/uip/lancegs-drv.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: lancegs-drv.c,v 1.3 2005/05/13 00:01:56 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:80:0F is the OUI of Standard Microsystems, A2:A2 just means Apple2 */
+static const struct uip_eth_addr addr =
+  {{0x00,0x80,0x0f,0xa2,0xa2,0x00}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": LANceGS", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(lancegs_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    /* Don't overwrite LSB */
+    memcpy(&uip_ethaddr, &addr, 5);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/lancegs-dsc.c b/contiki-apple2/uip/lancegs-dsc.c
new file mode 100644
index 0000000..80fa020
--- /dev/null
+++ b/contiki-apple2/uip/lancegs-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: lancegs-dsc.c,v 1.1 2005/05/06 22:34:58 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lancegs_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+    "LANceGS driver",
+    "lancegs.drv",
+    lancegs_init,
+    &lancegs_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lancegsicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lancegsicon_textmap[9] = {
+  'L', 'A', 'N',
+  '\\', 'c', 'e',
+  'G', 'S', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon lancegs_icon =
+  {CTK_ICON("LANceGS driver", lancegsicon_bitmap, lancegsicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/uther-drv-asm.S b/contiki-apple2/uip/uther-drv-asm.S
new file mode 100644
index 0000000..69ccb8b
--- /dev/null
+++ b/contiki-apple2/uip/uther-drv-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $c080
+	_cs8900a_txcmd		= $c084
+	_cs8900a_txlen		= $c086
+	_cs8900a_packetpp	= $c08a
+	_cs8900a_ppdata		= $c08c
diff --git a/contiki-apple2/uip/uther-drv.c b/contiki-apple2/uip/uther-drv.c
new file mode 100644
index 0000000..d05e8b5
--- /dev/null
+++ b/contiki-apple2/uip/uther-drv.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uther-drv.c,v 1.2 2005/05/13 00:01:56 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:0E:3A is the OUI of Cirrus Logic, A2:A2 just means Apple2 */
+static const struct uip_eth_addr addr =
+  {{0x00,0x0e,0x3a,0xa2,0xa2,0x00}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": Uther", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(uther_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    /* Don't overwrite LSB */
+    memcpy(&uip_ethaddr, &addr, 5);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/uther-dsc.c b/contiki-apple2/uip/uther-dsc.c
new file mode 100644
index 0000000..f088268
--- /dev/null
+++ b/contiki-apple2/uip/uther-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: uther-dsc.c,v 1.1 2005/05/06 22:34:58 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon uther_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+    "Uther driver",
+    "uther.drv",
+    uther_init,
+    &uther_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char uthericon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char uthericon_textmap[9] = {
+  '/', 'U', '\\',
+  't', 'h', 'e',
+  '\\', 'r', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon uther_icon =
+  {CTK_ICON("Uther driver", uthericon_bitmap, uthericon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-atari/Makefile b/contiki-atari/Makefile
new file mode 100644
index 0000000..3567720
--- /dev/null
+++ b/contiki-atari/Makefile
@@ -0,0 +1,127 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# Makefile for Atari 8-bit version
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.3 2005/04/18 22:43:22 oliverschmidt Exp $
+#
+
+all: contiki.com
+
+CONTIKI=../contiki
+SYS=atari
+
+include $(CONTIKI)/Makefile.common
+
+CC=cc65
+AS=ca65
+CFLAGS=-I ctk -I loader -I uip -I conf -I lib \
+       -I $(CONTIKI)/apps -I $(CONTIKI)/ctk -I $(CONTIKI)/ek \
+       -I $(CONTIKI)/lib -I $(CONTIKI)/uip \
+       -t $(SYS) --add-source -DWITH_ASCII \
+       -DCTK_CONIO -DWITH_CC65 -DWITH_UIP -DWITH_RS232 -DWITH_WWW # -DWITH_TELNET
+OPT=-Or
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: apps/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: ctk/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: lib/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: loader/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: uip/%.c
+	$(CC) $(CFLAGS)  -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/apps/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ctk/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ek/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/lib/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/uip/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+
+%.o: ctk/%.S
+	$(AS) -o $@ $(AFLAGS) $<
+
+%.o: loader/%.S
+	$(AS) -o $@ $(AFLAGS) $<
+
+contiki.com: contiki-main.o strncasecmp.o petsciiconv.o \
+ ctk-conio.o ctk.o ek.o dispatcher.o \
+ program-handler.o $(WWW) $(UIP) rs232dev.o \
+ about.o netconf.o processes.o
+	cl65 -C atari.cfg -Ln contiki-labels -o $@ -t $(SYS) $^
+	@if [ ! -f Makefile.depend ]; then \
+		echo ; \
+		echo "*** warning: you didn't make depend, result may be unaccurate!"; \
+		echo ; \
+	fi
+
+clean:
+	rm -f *.o *~ *core contiki *.s *.prg contiki-labels contiki.com Makefile.depend
+
+depend:
+	gcc -MM -MG -Iapps -Ictk -Iuip -Iconf -Ilib -I$(CC65_INC) \
+	-I$(CONTIKI)/lib -I$(CONTIKI)/ek \
+	-I$(CONTIKI)/ctk -I$(CONTIKI)/apps -I$(CONTIKI)/uip \
+	*.c */*.c $(CONTIKI)/*/*.c > Makefile.depend
+
+-include Makefile.depend
+
+codesize:
+	od65 --dump-segsize *.o | egrep '\.o|CODE'
diff --git a/contiki-atari/atari.cfg b/contiki-atari/atari.cfg
new file mode 100644
index 0000000..807ec78
--- /dev/null
+++ b/contiki-atari/atari.cfg
@@ -0,0 +1,27 @@
+MEMORY {
+    ZP: start = $82, size = $7E, type = rw, define = yes;
+    HEADER: start = $0000, size = $6, file = %O;
+    RAM: start = $10B0, size = $AB6F, file = %O;    # $AB6F: matches upper bound $BC1F
+}
+SEGMENTS {
+    EXEHDR: load = HEADER, type = wprot;
+    CODE: load = RAM, type = wprot, define = yes;
+    RODATA: load = RAM, type = wprot;
+    DATA: load = RAM, type = rw;
+    BSS: load = RAM, type = bss, define = yes;
+    ZEROPAGE: load = ZP, type = zp;
+    AUTOSTRT: load = RAM, type = wprot;
+}
+FEATURES {
+    CONDES: segment = RODATA,
+	    type = constructor,
+	    label = __CONSTRUCTOR_TABLE__,
+	    count = __CONSTRUCTOR_COUNT__;
+    CONDES: segment = RODATA,
+	    type = destructor,
+	    label = __DESTRUCTOR_TABLE__,
+	    count = __DESTRUCTOR_COUNT__;
+}
+SYMBOLS {
+    __STACKSIZE__ = $800;	# 2K stack
+}
diff --git a/contiki-atari/conf/cc-conf.h b/contiki-atari/conf/cc-conf.h
new file mode 100644
index 0000000..6216176
--- /dev/null
+++ b/contiki-atari/conf/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/12 01:54:07 sannyx Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-atari/conf/ctk-conf.h b/contiki-atari/conf/ctk-conf.h
new file mode 100644
index 0000000..31dc02b
--- /dev/null
+++ b/contiki-atari/conf/ctk-conf.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.2 2004/06/27 12:37:34 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         0
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           0 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          0 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-atari/conf/ek-conf.h b/contiki-atari/conf/ek-conf.h
new file mode 100644
index 0000000..d48499c
--- /dev/null
+++ b/contiki-atari/conf/ek-conf.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2003/04/12 00:47:16 sannyx Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   32    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  32    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_UNLISTEN 0
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-atari/conf/program-handler-conf.h b/contiki-atari/conf/program-handler-conf.h
new file mode 100644
index 0000000..8bade50
--- /dev/null
+++ b/contiki-atari/conf/program-handler-conf.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.1 2005/02/15 14:56:01 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-atari/conf/www-conf.h b/contiki-atari/conf/www-conf.h
new file mode 100644
index 0000000..b9418fa
--- /dev/null
+++ b/contiki-atari/conf/www-conf.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2003/04/12 01:54:07 sannyx Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 70  /* 100 in c64 version */
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 5  /* 20 in c64 version :-( */
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 0
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       0
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+#define WWW_CONF_MAX_INPUTVALUELEN  34
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-atari/contiki-main.c b/contiki-atari/contiki-main.c
new file mode 100644
index 0000000..1daf814
--- /dev/null
+++ b/contiki-atari/contiki-main.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: contiki-main.c,v 1.1 2003/04/12 01:55:45 sannyx Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+
+
+#include "uip_main.h"
+#include "uip.h"
+#include "uip_arp.h"
+#if WITH_TFE
+#include "cs8900a.h"
+#endif /* WITH_TFE */
+#include "resolv.h"
+
+#include "program-handler.h"
+
+/*-----------------------------------------------------------------------------------*/
+int
+main(void /*int argc, char **argv*/)  /* no args, cc65 rt lib needs to be adapted first! */
+{
+
+#ifdef WITH_UIP
+  uip_init();
+  uip_main_init();
+  resolv_init();
+
+#ifdef WITH_RS232
+  rs232dev_init();
+#endif /* WITH_RS232 */
+  
+#endif /* WITH_UIP */
+  
+  ek_init();
+  dispatcher_init();
+  ctk_init();
+  
+  program_handler_init();
+  
+  ctk_redraw();
+  ek_run();
+
+  clrscr();
+  
+  return 0;
+
+  /*
+  argv = argv;
+  argc = argc;
+  */
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-atari/ctk/ctk-arch.h b/contiki-atari/ctk/ctk-arch.h
new file mode 100644
index 0000000..b8fef53
--- /dev/null
+++ b/contiki-atari/ctk/ctk-arch.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2003/04/12 01:47:05 sannyx Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include "ctk-conio.h"
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-atari/ctk/ctk-conio-conf.h b/contiki-atari/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..dc57256
--- /dev/null
+++ b/contiki-atari/ctk/ctk-conio-conf.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.2 2004/08/12 21:53:46 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+#define BACKGROUNDCOLOR     COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 1
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+#define BACKGROUNDCOLOR     COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-atari/uip/rs232dev.c b/contiki-atari/uip/rs232dev.c
new file mode 100644
index 0000000..ca24885
--- /dev/null
+++ b/contiki-atari/uip/rs232dev.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.4 2005/02/23 22:42:12 oliverschmidt Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <rs232.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c)  (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c)  rs232_put(c)
+
+#define MAX_SIZE UIP_BUFSIZE
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+
+  SIO_SEND(SLIP_END);
+
+  ptr = uip_buf;
+  for(i = 0; i < uip_len; ++i) {
+    if(i == UIP_TCPIP_HLEN) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  while(SIO_POLL(c)) {
+    /*    printf("c %x\n", c);*/
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(uip_buf, slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+      
+      
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  
+  err = rs232_init(0);
+  rs232_err(err);
+  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);
+  rs232_err(err);
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-atari/uip/rs232dev.h b/contiki-atari/uip/rs232dev.h
new file mode 100644
index 0000000..c6bd09d
--- /dev/null
+++ b/contiki-atari/uip/rs232dev.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.2 2005/01/26 23:36:23 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+u16_t rs232dev_poll(void);
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-atari/uip/uip_arch.c b/contiki-atari/uip/uip_arch.c
new file mode 100644
index 0000000..57ca785
--- /dev/null
+++ b/contiki-atari/uip/uip_arch.c
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.4 2005/02/24 22:03:15 oliverschmidt Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  asm("ldy #3");
+  asm("jsr ldaxysp");
+  asm("sta ptr1");
+  asm("stx ptr1+1");
+  asm("ldy #0");
+  asm("lda (sp),y");
+  asm("ldy #3");
+  asm("clc");
+  asm("adc (ptr1),y");
+  asm("sta _uip_acc32+3");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("ldy #1");
+  asm("adc (sp),y");
+  asm("sta _uip_acc32+2");
+  asm("ldy #1");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+1");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+0");  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add_rcv_nxt(u16_t n) {
+  uip_add32(uip_conn->rcv_nxt, n);
+  uip_conn->rcv_nxt[0] = uip_acc32[0];
+  uip_conn->rcv_nxt[1] = uip_acc32[1];
+  uip_conn->rcv_nxt[2] = uip_acc32[2];
+  uip_conn->rcv_nxt[3] = uip_acc32[3];
+  /*  asm("pha");
+  asm("lda _uip_conn");
+  asm("sta ptr1");
+  asm("lda _uip_conn+1");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("clc");
+  asm("ldy #3");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("txa");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+
+  n=n;*/
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+chksum(void) {
+
+  asm("lda #0");
+  asm("sta tmp1");
+  asm("sta tmp1+1");
+  asm("lda _chksum_ptr");
+  asm("sta ptr1");
+  asm("lda _chksum_ptr+1");
+  asm("sta ptr1+1");
+
+
+  asm("lda _chksum_len+1");
+  asm("beq chksumlast");
+
+
+  /* If checksum is > 256, do the first runs. */
+  asm("ldy #0");
+  asm("clc");
+  asm("chksumloop_256:");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("iny");
+  asm("bne chksumloop_256");
+  asm("inc ptr1+1");
+  asm("dec _chksum_len+1");
+  asm("bne chksumloop_256");
+
+  asm("chksum_endloop_256:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop_256");
+  
+  asm("chksumlast:");
+  asm("lda _chksum_len");
+  asm("lsr");
+  asm("bcc chksum_noodd");  
+  asm("ldy _chksum_len");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("clc");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("bcc noinc1");
+  asm("inc tmp1+1");
+  asm("bne noinc1");
+  asm("inc tmp1");
+  asm("noinc1:");
+  asm("dec _chksum_len");
+
+  asm("chksum_noodd:");
+  asm("clc");
+  asm("php");
+  asm("ldy _chksum_len");
+  asm("chksum_loop1:");
+  asm("cpy #0");
+  asm("beq chksum_loop1_end");
+  asm("plp");
+  asm("dey");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("dey");
+  asm("php");
+  asm("jmp chksum_loop1");
+  asm("chksum_loop1_end:");
+  asm("plp");
+  
+  asm("chksum_endloop:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop");
+  
+  asm("lda tmp1");
+  asm("ldx tmp1+1");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *buf, u16_t len)
+{
+  /*  unsigned long sum;
+
+  sum = 0;
+
+  chksum_ptr = (u16_t)buf;
+  while(len >= 256) {  
+    chksum_len = 256;
+    sum += chksum();
+    len -= 256;
+    chksum_ptr += 256;
+  }
+
+  if(len < 256) {
+    chksum_len = len;
+    sum += chksum();
+  }
+
+  while((sum >> 16) != 0) {
+    sum = (sum >> 16) + (sum & 0xffff);
+  }
+
+  return sum;*/
+
+  chksum_len = len;
+  chksum_ptr = (u16_t)buf;
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{  
+  chksum_ptr = (u16_t)uip_buf + UIP_LLH_LEN;
+  chksum_len = UIP_IPH_LEN;  
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+uip_tcpchksum(void)
+{  
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+#ifdef WITH_TFE
+  asm("lda _uip_buf+3+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+3");
+#endif /* WITH_TFE */
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+2+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+2");
+#endif /* WITH_TFE */
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+#ifdef WITH_TFE
+  asm("lda _uip_buf+3+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+3");
+#endif /* WITH_TFE */
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+2+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+2");
+#endif /* WITH_TFE */
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+14,y");
+#else /* WITH_TFE */
+  asm("lda _uip_buf,y");
+#endif /* WITH_TFE */  
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+#ifdef WITH_TFE 
+  asm("lda _uip_buf+14,y");
+#else /* WITH_TFE */
+  asm("lda _uip_buf,y");
+#endif /* WITH_TFE */  
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #6");  /* IP_PROTO_TCP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-atari/uip/uip_arch.h b/contiki-atari/uip/uip_arch.h
new file mode 100644
index 0000000..f7ccbb3
--- /dev/null
+++ b/contiki-atari/uip/uip_arch.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.2 2005/01/26 23:36:23 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki-avr/Makefile b/contiki-avr/Makefile
new file mode 100644
index 0000000..7327917
--- /dev/null
+++ b/contiki-avr/Makefile
@@ -0,0 +1,121 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.9 2005/04/18 22:43:55 oliverschmidt Exp $
+#
+
+all: contiki.srec
+
+CONTIKI=../contiki
+
+include $(CONTIKI)/Makefile.common
+include Makefile.depend
+
+CC=avr-gcc
+LD=avr-ld
+AS=avr-as
+OBJCOPY=avr-objcopy
+CFLAGS=-Os -Iapps -Ictk -Ilib -Iuip -Iconf \
+	-I$(CONTIKI)/apps -I$(CONTIKI)/ctk -I$(CONTIKI)/ek \
+       -I$(CONTIKI)/lib -I$(CONTIKI)/uip \
+	-DWITH_UIP -DWITH_ASCII -DWITH_AVR \
+	-Wall -g -fpack-struct -I../uip -I. -mmcu=atmega128 
+LDFLAGS=-mmcu=atmega128 -Wl,-Map=contiki.map,--cref,-Tdata,0x801100
+
+%.o: %.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+
+%.o: apps/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+
+%.o: ctk/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+
+%.o: uip/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+
+%.o: $(CONTIKICC65)/uip/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+%.o: $(CONTIKI)/apps/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+%.o: $(CONTIKI)/ctk/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+%.o: $(CONTIKI)/ek/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+%.o: $(CONTIKI)/lib/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+%.o: $(CONTIKI)/uip/%.c
+	$(CC) $(CFLAGS) -c $< -o $(notdir $(<:.c=.o))
+
+%.srec:
+	$(OBJCOPY) -O srec $< $@
+
+SYSTEM=ek.o ek-service.o loader-arch.o
+CONTIKIFILES= $(SYSTEM) $(UIP) uip-fw.o uip-fw-service.o timer.o 
+
+CTKVNC=ctk-vncserver.o libconio.o vnc-server.o vnc-out.o ctk-vncfont.o
+CTKTELNET=libconio.o ctk-term.o ctk-term-in.o ctk-term-out.o ctk-termtelnet.o
+
+IRC=irc.o ircc.o socket.o uipbuf.o ctk-textedit.o irc-dsc.o ircc-strings.o
+
+clean:
+	rm -f *.o *~ *core contiki contiki.srec *.lst *.map
+
+depend:
+	gcc $(CCDEPFLAGS) -MM -Iapps -Ictk -Iuip -Iconf \
+	-I$(CONTIKI)/lib -I$(CONTIKI)/ek \
+	-I$(CONTIKI)/ctk -I$(CONTIKI)/apps -I$(CONTIKI)/uip \
+	*.c */*.c $(CONTIKI)/*/*.c > Makefile.depend
+
+contiki: $(CONIKIFILES) contiki-main.o strncasecmp.o \
+ ctk.o ek.o arg.o timer.o ek-service.o \
+ uip.o uip_arch.o uip_arp.o resolv.o uiplib.o tcpip.o uip-split.o \
+ rtl8019.o rtl8019dev.o delay.o debug.o rtl8019-drv.o \
+ $(CTKVNC) program-handler.o  \
+ webserver.o httpd.o httpd-cgi.o httpd-fs.o webserver-dsc.o \
+ netconf.o netconf-dsc.o \
+ $(WWW) weblinks.o weblinks-dsc.o \
+ about.o about-dsc.o \
+ processes.o processes-dsc.o calc.o calc-dsc.o 
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
+
+
+contiki.srec: contiki
+
+erase:
+	uisp -dprog=stk200 --erase -v
+
+upload: erase
+	uisp -dprog=stk200 --upload -v if=contiki.srec
+
+upload-remote: contiki.srec
+	scp contiki.srec sidewalker:/tmp
+	ssh sidewalker.sics.se "uisp -dprog=stk200 --erase -v"
+	ssh sidewalker.sics.se "uisp -dprog=stk200 --upload -v if=/tmp/contiki.srec"
+
diff --git a/contiki-avr/Makefile.depend b/contiki-avr/Makefile.depend
new file mode 100644
index 0000000..8629f89
--- /dev/null
+++ b/contiki-avr/Makefile.depend
@@ -0,0 +1,448 @@
+http-user-agent-string.o: apps/http-user-agent-string.c
+httpd-cgi.o: apps/httpd-cgi.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h apps/httpd.h \
+ ../contiki/ek/contiki.h ../contiki/ek/contiki-version.h \
+ ../contiki/uip/uiplib.h ../contiki/uip/resolv.h ../contiki/lib/memb.h \
+ ../contiki/lib/timer.h ../contiki/lib/clock.h conf/clock-conf.h \
+ apps/httpd-cgi.h apps/httpd-fs.h ../contiki/lib/petsciiconv.h
+httpd-fs.o: apps/httpd-fs.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h apps/httpd.h \
+ ../contiki/ek/contiki.h ../contiki/ek/contiki-version.h \
+ ../contiki/uip/uiplib.h ../contiki/uip/resolv.h ../contiki/lib/memb.h \
+ ../contiki/lib/timer.h ../contiki/lib/clock.h conf/clock-conf.h \
+ apps/httpd-fs.h apps/httpd-fsdata.h apps/httpd-fsdata.c
+httpd-fsdata.o: apps/httpd-fsdata.c
+httpd.o: apps/httpd.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h apps/httpd.h apps/httpd-fs.h \
+ apps/httpd-fsdata.h apps/httpd-cgi.h apps/webserver.h
+shell.o: apps/shell.c ../contiki/apps/program-handler.h \
+ ../contiki/ek/dsc.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uip_arp.h \
+ ../contiki/uip/resolv.h ../contiki/apps/shell.h
+webclient.o: apps/webclient.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/tcpip.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/apps/webclient.h \
+ ../contiki/apps/http-strings.h \
+ ../contiki/apps/http-user-agent-string.h ../contiki/uip/resolv.h \
+ ../contiki/uip/uiplib.h conf/www-conf.h
+weblinks-dsc.o: apps/weblinks-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+weblinks.o: apps/weblinks.c ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/apps/program-handler.h ../contiki/ek/dsc.h \
+ ../contiki/apps/www.h
+webserver.o: apps/webserver.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h \
+ ../contiki/apps/http-strings.h ../contiki/lib/petsciiconv.h \
+ apps/webserver.h apps/httpd.h
+delay.o: uip/delay.c uip/delay.h
+rtl8019-drv.o: uip/rtl8019-drv.c ../contiki/uip/packet-service.h \
+ ../contiki/ek/ek-service.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h uip/rtl8019dev.h uip/rtl8019.h \
+ uip/compiler.h ../contiki/uip/uip_arp.h
+rtl8019dev.o: uip/rtl8019dev.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h uip/rtl8019dev.h \
+ uip/rtl8019.h uip/compiler.h
+uip_arch.o: uip/uip_arch.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h uip/uip_arch.h
+about-dsc.o: ../contiki/apps/about-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+about.o: ../contiki/apps/about.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/lib/petsciiconv.h
+calc-dsc.o: ../contiki/apps/calc-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+calc.o: ../contiki/apps/calc.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h
+directory.o: ../contiki/apps/directory.c ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/lib/cfs.h ../contiki/lib/cfs-service.h \
+ ../contiki/ek/ek-service.h ../contiki/apps/program-handler.h \
+ ../contiki/ek/dsc.h
+editor-dsc.o: ../contiki/apps/editor-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+editor.o: ../contiki/apps/editor.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/lib/cfs.h ../contiki/lib/cfs-service.h \
+ ../contiki/ek/ek-service.h ../contiki/lib/ctk-filedialog.h
+email-dsc.o: ../contiki/apps/email-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+email.o: ../contiki/apps/email.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/apps/smtp.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/lib/petsciiconv.h ../contiki/lib/ctk-textedit.h
+ftp-dsc.o: ../contiki/apps/ftp-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+ftp.o: ../contiki/apps/ftp.c ../contiki/apps/ftpc.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/lib/cfs.h ../contiki/lib/cfs-service.h \
+ ../contiki/ek/ek-service.h
+ftpc.o: ../contiki/apps/ftpc.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/apps/ftpc.h
+html-strings.o: ../contiki/apps/html-strings.c
+htmlparser.o: ../contiki/apps/htmlparser.c \
+ ../contiki/apps/htmlparser.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h \
+ ../contiki/apps/html-strings.h conf/www-conf.h
+http-strings.o: ../contiki/apps/http-strings.c
+http-user-agent-string.o: ../contiki/apps/http-user-agent-string.c
+httpd-fsdata.o: ../contiki/apps/httpd-fsdata.c
+irc-dsc.o: ../contiki/apps/irc-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+ircc-strings.o: ../contiki/apps/ircc-strings.c
+netconf-dsc.o: ../contiki/apps/netconf-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+netconf.o: ../contiki/apps/netconf.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/uip_arp.h ../contiki/uip/resolv.h ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/ctk/ctk-draw.h
+popc-strings.o: ../contiki/apps/popc-strings.c
+processes-dsc.o: ../contiki/apps/processes-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+processes.o: ../contiki/apps/processes.c ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h
+program-handler.o: ../contiki/apps/program-handler.c \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h \
+ ../contiki/lib/petsciiconv.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/ek/log.h conf/log-conf.h ../contiki/apps/program-handler.h \
+ ../contiki/ek/dsc.h
+shell-dsc.o: ../contiki/apps/shell-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+simpletelnet.o: ../contiki/apps/simpletelnet.c ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/lib/petsciiconv.h \
+ ../contiki/uip/uiplib.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/uip/resolv.h ../contiki/apps/telnet.h \
+ ../contiki/apps/simpletelnet.h
+smtp-strings.o: ../contiki/apps/smtp-strings.c
+smtp.o: ../contiki/apps/smtp.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/apps/smtp.h \
+ ../contiki/apps/smtp-strings.h
+telnet-dsc.o: ../contiki/apps/telnet-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+telnet.o: ../contiki/apps/telnet.c ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/apps/telnet.h
+telnetd-dsc.o: ../contiki/apps/telnetd-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+telnetd-gui.o: ../contiki/apps/telnetd-gui.c \
+ ../contiki/apps/program-handler.h ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/lib/petsciiconv.h \
+ ../contiki/uip/uip_arp.h ../contiki/uip/resolv.h \
+ ../contiki/apps/telnetd.h ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/uip/uiplib.h \
+ ../contiki/lib/memb.h ../contiki/lib/timer.h ../contiki/lib/clock.h \
+ conf/clock-conf.h ../contiki/apps/shell.h
+telnetd.o: ../contiki/apps/telnetd.c ../contiki/ek/loader.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/lib/petsciiconv.h ../contiki/uip/uip_arp.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/apps/shell.h \
+ ../contiki/apps/telnetd.h ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/uip/uiplib.h \
+ ../contiki/lib/timer.h ../contiki/lib/clock.h conf/clock-conf.h \
+ conf/telnetd-conf.h
+vnc-dsc.o: ../contiki/apps/vnc-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+vnc-viewer.o: ../contiki/apps/vnc-viewer.c ../contiki/apps/vnc-draw.h \
+ uip/uip_arch.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/apps/vnc-viewer.h
+vnc.o: ../contiki/apps/vnc.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/lib/petsciiconv.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ctk/ctk-mouse.h \
+ ../contiki/apps/telnet.h ../contiki/apps/vnc.h \
+ ../contiki/apps/vnc-draw.h uip/uip_arch.h \
+ ../contiki/apps/vnc-viewer.h conf/vnc-conf.h
+webclient.o: ../contiki/apps/webclient.c ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/tcpip.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/apps/webclient.h \
+ ../contiki/apps/http-strings.h \
+ ../contiki/apps/http-user-agent-string.h ../contiki/uip/resolv.h \
+ ../contiki/uip/uiplib.h conf/www-conf.h
+webserver-dsc.o: ../contiki/apps/webserver-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+www-dsc.o: ../contiki/apps/www-dsc.c ../contiki/ek/dsc.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+www.o: ../contiki/apps/www.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/apps/webclient.h ../contiki/apps/http-strings.h \
+ ../contiki/apps/http-user-agent-string.h ../contiki/uip/resolv.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/apps/htmlparser.h \
+ ../contiki/lib/petsciiconv.h ../contiki/apps/program-handler.h \
+ ../contiki/ek/dsc.h ../contiki/uip/uiplib.h conf/www-conf.h
+ctk-draw.o: ../contiki/ctk/ctk-draw.c ../contiki/ek/ek-service.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/ctk/ctk-draw-service.h
+ctk-term-in.o: ../contiki/ctk/ctk-term-in.c ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/ctk/ctk-term.h \
+ ../contiki/ctk/ctk-term-int.h ../contiki/ctk/ctk-term-ascii.h
+ctk-term-out.o: ../contiki/ctk/ctk-term-out.c \
+ ../contiki/lib/libconio.h conf/libconio-conf.h \
+ ../contiki/ctk/ctk-term-int.h
+ctk-vncfont.o: ../contiki/ctk/ctk-vncfont.c
+ctk-vncserver.o: ../contiki/ctk/ctk-vncserver.c ../contiki/ctk/ctk.h \
+ conf/ctk-conf.h ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/ek/contiki.h ../contiki/ek/contiki-version.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/ctk/vnc-server.h \
+ ../contiki/ctk/vnc-out.h ../contiki/ctk/ctk-vncfont.h \
+ ../contiki/ctk/ctk-vncserver.h conf/ctk-vncserver-conf.h \
+ ../contiki/lib/libconio.h conf/libconio-conf.h
+ctk.o: ../contiki/ctk/ctk.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ctk/ctk-draw.h \
+ ../contiki/ctk/ctk-mouse.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h
+vnc-out.o: ../contiki/ctk/vnc-out.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h \
+ ../contiki/ctk/vnc-server.h ../contiki/ctk/vnc-out.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h ../contiki/lib/libconio.h \
+ conf/libconio-conf.h conf/ctk-vncserver-conf.h \
+ ../contiki/ctk/ctk-vncfont.h ../contiki/ctk/ctk-mouse.h
+vnc-server.o: ../contiki/ctk/vnc-server.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h \
+ ../contiki/ctk/vnc-server.h ../contiki/ctk/vnc-out.h \
+ ../contiki/ctk/ctk.h conf/ctk-conf.h ctk/ctk-arch.h \
+ ../contiki/ctk/ctk-vncarch.h
+arg.o: ../contiki/ek/arg.c ../contiki/ek/arg.h
+ek-service.o: ../contiki/ek/ek-service.c ../contiki/ek/ek-service.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/ek/log.h \
+ conf/log-conf.h
+ek.o: ../contiki/ek/ek.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+cfs-posix.o: ../contiki/lib/cfs-posix.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/lib/cfs.h \
+ ../contiki/lib/cfs-service.h ../contiki/ek/ek-service.h
+cfs.o: ../contiki/lib/cfs.c ../contiki/ek/contiki.h \
+ ../contiki/ek/contiki-version.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ conf/uip-conf.h ../contiki/uip/tcpip.h ../contiki/uip/uiplib.h \
+ ../contiki/uip/resolv.h ../contiki/lib/memb.h ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h ../contiki/lib/cfs.h \
+ ../contiki/lib/cfs-service.h ../contiki/ek/ek-service.h
+ctk-filedialog.o: ../contiki/lib/ctk-filedialog.c \
+ ../contiki/ek/contiki.h ../contiki/ek/contiki-version.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/uip/uiplib.h ../contiki/uip/resolv.h ../contiki/lib/memb.h \
+ ../contiki/lib/timer.h ../contiki/lib/clock.h conf/clock-conf.h \
+ ../contiki/lib/ctk-filedialog.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/lib/cfs.h \
+ ../contiki/lib/cfs-service.h ../contiki/ek/ek-service.h
+ctk-textedit.o: ../contiki/lib/ctk-textedit.c \
+ ../contiki/lib/ctk-textedit.h ../contiki/ctk/ctk.h conf/ctk-conf.h \
+ ctk/ctk-arch.h ../contiki/ctk/ctk-vncarch.h ../contiki/ek/ek.h \
+ conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+libconio.o: ../contiki/lib/libconio.c ../contiki/lib/libconio.h \
+ conf/libconio-conf.h
+list.o: ../contiki/lib/list.c ../contiki/lib/list.h
+memb.o: ../contiki/lib/memb.c ../contiki/lib/memb.h
+petsciiconv.o: ../contiki/lib/petsciiconv.c
+strncasecmp.o: ../contiki/lib/strncasecmp.c
+timer.o: ../contiki/lib/timer.c ../contiki/lib/timer.h \
+ ../contiki/lib/clock.h conf/clock-conf.h
+resolv.o: ../contiki/uip/resolv.c ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/tcpip.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/resolv.h
+slipdev.o: ../contiki/uip/slipdev.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip-fw.h \
+ ../contiki/uip/slipdev.h
+tcpip.o: ../contiki/uip/tcpip.c ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/ek/ek-service.h \
+ ../contiki/uip/uip-fw.h ../contiki/lib/timer.h ../contiki/lib/clock.h \
+ conf/clock-conf.h ../contiki/uip/packet-service.h \
+ ../contiki/uip/uip-split.h
+uip-fw-service.o: ../contiki/uip/uip-fw-service.c \
+ ../contiki/uip/packet-service.h ../contiki/ek/ek-service.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/uip/uip-fw.h
+uip-fw.o: ../contiki/uip/uip-fw.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip_arch.h \
+ ../contiki/uip/uip-fw.h
+uip-split.o: ../contiki/uip/uip-split.c ../contiki/uip/uip-split.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h ../contiki/uip/uip-fw.h \
+ ../contiki/uip/uip_arch.h
+uip.o: ../contiki/uip/uip.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip_arch.h
+uip_arp.o: ../contiki/uip/uip_arp.c ../contiki/uip/uip_arp.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+uipbuf.o: ../contiki/uip/uipbuf.c ../contiki/uip/uipbuf.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h conf/uip-conf.h \
+ ../contiki/uip/tcpip.h ../contiki/ek/ek.h conf/ek-conf.h \
+ ../contiki/lib/cc.h conf/cc-conf.h ../contiki/ek/arg.h \
+ ../contiki/ek/loader.h
+uiplib.o: ../contiki/uip/uiplib.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h conf/uip-conf.h ../contiki/uip/tcpip.h \
+ ../contiki/ek/ek.h conf/ek-conf.h ../contiki/lib/cc.h conf/cc-conf.h \
+ ../contiki/ek/arg.h ../contiki/ek/loader.h ../contiki/uip/uip_arp.h \
+ ../contiki/uip/uiplib.h
diff --git a/contiki-avr/apps/http-user-agent-string b/contiki-avr/apps/http-user-agent-string
new file mode 100644
index 0000000..f44e3a7
--- /dev/null
+++ b/contiki-avr/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.2-devel0 (Atmel AVR Atmega128; http://www.sics.se/~adam/contiki/)\r\n\r\n"
diff --git a/contiki-avr/apps/http-user-agent-string.c b/contiki-avr/apps/http-user-agent-string.c
new file mode 100644
index 0000000..bc8f7d3
--- /dev/null
+++ b/contiki-avr/apps/http-user-agent-string.c
@@ -0,0 +1,3 @@
+char http_user_agent_fields[111] = 
+/* "Connection: close\r\nUser-Agent: Contiki/1.2-devel0 (Atmel AVR Atmega128; http://www.sics.se/~adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x32, 0x2d, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x30, 0x20, 0x28, 0x41, 0x74, 0x6d, 0x65, 0x6c, 0x20, 0x41, 0x56, 0x52, 0x20, 0x41, 0x74, 0x6d, 0x65, 0x67, 0x61, 0x31, 0x32, 0x38, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki-avr/apps/http-user-agent-string.h b/contiki-avr/apps/http-user-agent-string.h
new file mode 100644
index 0000000..077b525
--- /dev/null
+++ b/contiki-avr/apps/http-user-agent-string.h
@@ -0,0 +1 @@
+extern char http_user_agent_fields[111];
diff --git a/contiki-avr/apps/httpd-cgi.c b/contiki-avr/apps/httpd-cgi.c
new file mode 100644
index 0000000..835c6b5
--- /dev/null
+++ b/contiki-avr/apps/httpd-cgi.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.2 2004/08/09 22:22:47 adamdunkels Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#include <stdio.h>
+#include <string.h>
+
+static u8_t file_stats(void);
+static u8_t tcp_stats(void);
+static u8_t processes(void);
+
+static u8_t d64output(void);
+
+static u8_t file_totals(void);
+
+httpd_cgifunction httpd_cgitab[] = {
+  file_stats,    /* CGI function "a" */
+  tcp_stats,     /* CGI function "b" */
+  processes,     /* CGI function "c" */
+
+  d64output,     /* CGI function "d" */
+
+  file_totals,   /* CGI function "e" */
+};
+
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49, 
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+file_stats(void)
+{
+  char tmp[40];
+  
+  /* We use sprintf() to print the number of file accesses to a
+     particular file (given as an argument to the function in the
+     script). We then use uip_send() to actually send the data. */
+  if(uip_acked()) {
+    return 1;
+  }
+  memcpy_P(tmp, &hs->script[4], sizeof(tmp));
+  uip_send(uip_appdata, sprintf((char *)uip_appdata, "%10lu", httpd_fs_count(tmp)));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+file_totals(void)
+{
+  /* We use sprintf() to print the number of file accesses to a
+     particular file (given as an argument to the function in the
+     script). We then use uip_send() to actually send the data. */
+  if(uip_acked()) {
+    return 1;
+  }
+  uip_send(uip_appdata, sprintf((char *)uip_appdata, "%10lu", httpd_fs_total()));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+tcp_stats(void)
+{
+  struct uip_conn *conn;  
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+  
+  conn = &uip_conns[hs->count];
+  while((conn->tcpstateflags & TS_MASK) == CLOSED) {
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+    conn = &uip_conns[hs->count];
+  }
+  
+  uip_send(uip_appdata, sprintf((char *)uip_appdata,
+				"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+				htons(conn->lport),
+				htons(conn->ripaddr[0]) >> 8,
+				htons(conn->ripaddr[0]) & 0xff,
+				htons(conn->ripaddr[1]) >> 8,
+				htons(conn->ripaddr[1]) & 0xff,
+				htons(conn->rport),
+				states[conn->tcpstateflags & TS_MASK],
+				conn->nrtx,
+				conn->timer,
+				(uip_outstanding(conn))? '*':' ',
+				(uip_stopped(conn))? '!':' '));
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+processes(void)
+{
+  u8_t i;
+  struct ek_proc *p;
+  char name[40];
+
+  p = EK_PROCS();
+  for(i = 0; i < hs->count; ++i) {
+    if(p != NULL) {
+      p = p->next;
+    }
+  }
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    ++hs->count;
+    if(p != NULL) {
+      p = p->next;
+    }
+    if(p == NULL) {
+      /* If all processes have been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  strncpy(name, p->name, 40);
+  petsciiconv_toascii(name, 40);
+  uip_send(uip_appdata,
+	   sprintf((char *)uip_appdata,
+		   "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%02x</td><td>0x%04x</td><td>0x%04x</td></tr>\r\n",
+		   p->id, name, p->prio,
+		   p->pollhandler, p->eventhandler));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+d64output(void)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/httpd-cgi.h b/contiki-avr/apps/httpd-cgi.h
new file mode 100644
index 0000000..718ded7
--- /dev/null
+++ b/contiki-avr/apps/httpd-cgi.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.h,v 1.1 2003/07/04 10:54:51 adamdunkels Exp $
+ *
+ */
+
+#ifndef __HTTPD_CGI_H__
+#define __HTTPD_CGI_H__
+
+typedef u8_t (* httpd_cgifunction)(void);
+
+extern httpd_cgifunction httpd_cgitab[];
+
+#endif /* __HTTPD_CGI_H__ */
diff --git a/contiki-avr/apps/httpd-fs.c b/contiki-avr/apps/httpd-fs.c
new file mode 100644
index 0000000..16cf1c0
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Swedish Institute
+ *      of Computer Science and its contributors.
+ * 4. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.c,v 1.2 2004/08/09 22:19:35 adamdunkels Exp $
+ */
+
+#define HTTPD_FS_STATISTICS 1
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+
+#include <avr/pgmspace.h>
+
+#include "httpd-fsdata.c"
+
+#if HTTPD_FS_STATISTICS
+static unsigned long count[HTTPD_FS_NUMFILES];
+#endif /* HTTPD_FS_STATISTICS */
+
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+httpd_fs_strcmp(const char *str1, prog_char *str2p)
+{
+  char str2[40];
+  u8_t i;
+  i = 0;
+
+  memcpy_P(str2, str2p, sizeof(str2) - 1);
+  str2[39] = 0;
+ loop:
+
+  if(str2[i] == 0 ||
+     str1[i] == '\r' || 
+     str1[i] == '\n') {
+    return 0;
+  }
+
+  if(str1[i] != str2[i]) {
+    return 1;
+  }
+
+
+  ++i;
+  goto loop;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_open(const char *name, struct httpd_fs_file *file)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i = 0;
+#endif /* HTTPD_FS_STATISTICS */
+  struct httpd_fsdata_file_noconst *f;
+
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      file->data = f->data;
+      file->len = f->len;
+#if HTTPD_FS_STATISTICS
+      ++(count[i]);
+#endif /* HTTPD_FS_STATISTICS */
+      return 1;
+    }
+#if HTTPD_FS_STATISTICS
+    ++i;
+#endif /* HTTPD_FS_STATISTICS */
+
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_fs_init(void)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i;
+  for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
+    count[i] = 0;
+  }
+#endif /* HTTPD_FS_STATISTICS */
+}
+/*-----------------------------------------------------------------------------------*/
+#if HTTPD_FS_STATISTICS
+unsigned long httpd_fs_count
+(char *name)
+{
+  struct httpd_fsdata_file_noconst *f;
+  u16_t i;
+
+  i = 0;
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      return count[i];
+    }
+    ++i;
+  }
+  return 0;
+}
+static unsigned long total;
+unsigned long
+httpd_fs_total(void)
+{
+  return total;
+}
+void
+httpd_fs_inc(void)
+{
+  ++total;
+}
+#endif /* HTTPD_FS_STATISTICS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/httpd-fs.h b/contiki-avr/apps/httpd-fs.h
new file mode 100644
index 0000000..71d6428
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Swedish Institute
+ *      of Computer Science and its contributors.
+ * 4. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.2 2004/09/13 23:21:03 adamdunkels Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 1
+
+struct httpd_fs_file {
+  prog_char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#if HTTPD_FS_STATISTICS
+unsigned long httpd_fs_count(char *name);
+unsigned long httpd_fs_total(void);
+void httpd_fs_inc(void);
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki-avr/apps/httpd-fs/404.html b/contiki-avr/apps/httpd-fs/404.html
new file mode 100644
index 0000000..a17711d
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/404.html
@@ -0,0 +1,8 @@
+<html>
+  <body bgcolor="white">
+    <center>
+      <h1>404 - file not found</h1>
+      <h3>Go <a href="/">here</a> instead.</h3>
+    </center>
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/cgi/files b/contiki-avr/apps/httpd-fs/cgi/files
new file mode 100644
index 0000000..eb3fbf5
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/cgi/files
@@ -0,0 +1,24 @@
+i /header.html
+t <h1>File statistics</h1><br><center><b>Total numer of page loads:
+c e
+t </b></center><br><table width="100%"><tr><td><a href="/index.html">/index.html</a></td><td>
+c a /index.html
+t </td></tr> <tr><td><a href="/vnc.html">/vnc.html</a></td><td>
+c a /vnc.html
+t </td></tr> <tr><td><a href="/vncviewer.jar">/vncviewer.jar</a></td><td>
+c a /vncviewer.jar
+t </td></tr> <tr><td><a href="/cgi/files">/cgi/files</a></td><td>
+c a /cgi/files
+t </td></tr> <tr><td><a href="/cgi/tcp">/cgi/tcp</a></td><td>
+c a /cgi/tcp
+t </td></tr> <tr><td><a href="/cgi/processes">/cgi/processes</a></td><td>
+c a /cgi/processes
+t </td></tr> <tr><td><a href="/style.css">/style.css</a></td><td>
+c a /style.css
+t </td></tr> <tr><td><a href="/404.html">/404.html</a></td><td>
+c a /404.html
+t </td></tr> <tr><td><a href="/img/screenshot.png">/img/screenshot.png</a></td><td>
+c a /img/screenshot.png
+t </td></tr></table>
+i /footer.plain
+.
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/cgi/processes b/contiki-avr/apps/httpd-fs/cgi/processes
new file mode 100644
index 0000000..f34c940
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/cgi/processes
@@ -0,0 +1,7 @@
+i /header.html
+t <h1>System processes</h1><br><table width="100%">
+t <tr><th>ID</th><th>Name</th><th>Priority</th><th>Poll handler</th><th>Event handler</th></th></tr>
+c c
+t </table>
+i /footer.plain
+.
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/cgi/tcp b/contiki-avr/apps/httpd-fs/cgi/tcp
new file mode 100644
index 0000000..a441142
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/cgi/tcp
@@ -0,0 +1,7 @@
+i /header.html
+t <h1>Current connections</h1><br><table width="100%">
+t <tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
+c b
+t </table>
+i /footer.plain
+.
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/footer.plain b/contiki-avr/apps/httpd-fs/footer.plain
new file mode 100644
index 0000000..1fd5f4f
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/footer.plain
@@ -0,0 +1,2 @@
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/header.html b/contiki-avr/apps/httpd-fs/header.html
new file mode 100644
index 0000000..9a4b340
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/header.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title>Welcome to the Contiki-demo server!</title>
+    <link rel="stylesheet" type="text/css" href="/style.css">  
+  </head>
+  <body bgcolor="#fffeec" text="black">
+
+  <div class="menublock">
+
+  <div class="menu">
+  <p class="border-title">Menu</p>
+  <p class="menu">
+  
+  <a href="/">Front page</a><br>
+  <a href="/vnc.html">Remote display</a><br>
+  <a href="/cgi/files">File statistics</a><br>
+  <a href="/cgi/tcp">Network connections</a><br>
+  <a href="/cgi/processes">System processes</a><br>
+
+  </p>
+  </div>
+  </div>
+
+  <div class="contentblock">
+  <p class="border-title">
+  Welcome to the <a href="http://www.sics.se/~adam/contiki/">Contiki</a> 
+  demo server!
+  </p>
diff --git a/contiki-avr/apps/httpd-fs/img/screenshot.png b/contiki-avr/apps/httpd-fs/img/screenshot.png
new file mode 100644
index 0000000..d895e2e
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/img/screenshot.png
Binary files differ
diff --git a/contiki-avr/apps/httpd-fs/index.html b/contiki-avr/apps/httpd-fs/index.html
new file mode 100644
index 0000000..07c56ce
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/index.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title>Welcome to the Contiki-demo server!</title>
+    <link rel="stylesheet" type="text/css" href="/style.css">  
+  </head>
+  <body bgcolor="#fffeec" text="black">
+
+  <div class="menublock">
+
+  <div class="menu">
+  <p class="border-title">Menu</p>
+  <p class="menu">
+  
+  <a href="/">Front page</a><br>
+  <a href="/vnc.html">Remote display</a><br>
+  <a href="/cgi/files">File statistics</a><br>
+  <a href="/cgi/tcp">Network connections</a><br>
+  <a href="/cgi/processes">System processes</a><br>
+
+  </p>
+  </div>
+  </div>
+
+  <div class="contentblock">
+  <p class="border-title">
+  Welcome to the <a href="http://www.sics.se/~adam/contiki/">Contiki</a> 
+  demo server!
+  </p>
+	      
+	  <p class="intro">
+	    The web pages you are watching are served by a <a
+	    href="http://www.sics.se/~adam/contiki/apps/webserver.html">web
+	    server</a> running under the <a
+	    href="http://www.sics.se/~adam/contiki/">Contiki operating
+	    system</a> on an an <a
+	    href="http://www.ethernut.de/en/">Ethernut</a> embedded
+	    Ethernet board, which consists of a 14 MHz AVR Atmega128
+	    microcontroller with 32 kilobytes of RAM and 128 kilobytes
+	    of flash ROM, and a RealTek RTL8019AS Ethernet chip.
+	  </p>
+
+	      <p class="clink">
+	    <a href="http://contiki-demo.sics.se"><b><tt>http://contiki-demo.sics.se/</tt></b></a>
+	  </p>
+	  
+	  
+	  <h2>Remote display</h2>
+	  <p>
+	    It it possible to remotely access the Contiki desktop of
+	    this server directly from your web browser! See the <a
+	    href="vnc.html">remote display</a> page.
+	  </p>
+	  <h2>Screenshot</h2>
+	  <p>
+	    This is what the virtual desktop of this server looks
+	    like:
+	  </p>
+	  <center>
+	    <img src="/img/screenshot.png" alt="Screenshot">
+	  </center>
+	  <h2>Memory usage</h2>
+	  <p>
+	    The entire Contiki AVR system uses slightly more than 20 k
+	    RAM, of which 6 k is used for the virtual display 8 k for
+	    	    the web browser. All code and these web pages are stored
+	    in the microcontroller's on-chip flash ROM.
+	  </p>
+	  <p align="right">
+	    /<a href="http://www.sics.se/%7eadam/">Adam Dunkels</a>
+	  </p>
+    
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/style.css b/contiki-avr/apps/httpd-fs/style.css
new file mode 100644
index 0000000..84abd08
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/style.css
@@ -0,0 +1,184 @@
+h1 
+{
+  text-align: center;
+  font-size:14pt;
+  font-family:arial,helvetica;
+  font-weight:bold;
+  padding:10px; 
+}
+
+body
+{
+
+  background-color: #fffeec;
+  color:TEXTCOLOR;
+
+  font-size:8pt;
+  font-family:arial,helvetica;
+}
+
+.menublock
+{
+  position:absolute;
+  top:10px;
+  left:0%;
+  width:14%;
+  float:left;
+
+  padding:10px;
+  margin:4px;
+	
+  border: solid 1px;
+  background-color: #fffcd2;
+  text-align:left;
+  
+  font-size:10pt;
+}
+
+.contentblock
+{  
+  position:absolute;
+  top:10px;
+  left:17%;
+  width:52%;
+  float:left;
+
+  padding:10px;
+  margin:4px;
+  margin-bottom:30px;
+
+  border: 1px dotted;
+  background-color: white;
+
+  font-size:8pt;
+  font-family:arial,helvetica;  
+
+}
+
+.newsblock
+{
+  position:absolute;
+  top:10px;
+  left:72%;
+  width:24%;
+  float:left;
+
+  padding:10px;
+  margin:4px;
+
+  border: solid 1px;
+  background-color: #fffcd2;
+  text-align:left;
+  font-size:8pt;
+
+}
+
+
+
+p.intro
+{
+  margin-left:20px;
+  margin-right:20px;
+
+  font-size:10pt;
+  font-weight:bold;
+  font-family:arial,helvetica;  
+}
+
+p.clink
+{
+  font-size:12pt;
+  font-family:courier,monospace;  
+  text-align:center;
+}
+
+p.related
+{
+  font-size:10pt;
+  font-family:arial,helvetica;  
+  text-align:center;
+}
+
+
+
+img.right
+{
+  float:right;
+  margin:10px;
+}
+
+img.left
+{
+  float:left;
+  margin:10px;
+}
+
+p.fig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+}
+
+p.rfig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+
+  float:right;
+}
+
+p.lfig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+
+  float:left;
+}
+
+p
+{
+  padding-left:10px;
+}
+
+p.right
+{
+  text-align:right; 
+}
+
+p.border-title
+{
+  text-align:center;
+
+  font-size:14pt;
+
+  padding:0px;
+  margin:4px;
+  margin-bottom:10px;
+
+  color: TITLECOLOR;
+  background-color: #fffcba;
+  border: solid 1px;
+
+} 
+
+
+
+
diff --git a/contiki-avr/apps/httpd-fs/vnc.html b/contiki-avr/apps/httpd-fs/vnc.html
new file mode 100644
index 0000000..496525c
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/vnc.html
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title>Welcome to the Contiki-demo server!</title>
+    <link rel="stylesheet" type="text/css" href="/style.css">  
+  </head>
+  <body bgcolor="#fffeec" text="black">
+
+  <div class="menublock">
+
+  <div class="menu">
+  <p class="border-title">Menu</p>
+  <p class="menu">
+  
+  <a href="/">Front page</a><br>
+  <a href="/vnc.html">Remote display</a><br>
+  <a href="/cgi/files">File statistics</a><br>
+  <a href="/cgi/tcp">Network connections</a><br>
+  <a href="/cgi/processes">System processes</a><br>
+
+  </p>
+  </div>
+  </div>
+
+  <div class="contentblock">
+  <p class="border-title">
+  Welcome to the <a href="http://www.sics.se/~adam/contiki/">Contiki</a> 
+  demo server!
+  </p>
+
+		  <p class="intro">
+	    The Contiki VNC server lets you access the desktop from
+	    the Contiki server in your web browser, from anywhere in
+	    the world. Note that the device on which this is running
+	    does not have any monitor or any other kind of display; in
+	    fact, it does not even have a graphics chip.
+	  </p>
+
+	  <h3>Java client</h3>
+	  <p>
+	    The Java client makes it possible to access the virtual
+	    Contiki display directly from the web browser. It requires
+	    Java to be turned on in the browser.
+	  </p>
+	  <p>
+	    When asked for a password, just click the "Ok" button
+	    without typing in any password.
+	  </p>
+	  <center>
+	    <b><a href="#" onClick='window.open("vncjava.html",
+	    "Contiki",
+	    "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");'>Click
+	    here to launch in new window</a></b></center>
+	  <br>
+	    <center><b><a href="vncjava.html">Click here to launch in
+	    this window</a></b>
+	    </center>
+
+	    <p>
+	      The server is able to keep 8 connections up. In order to
+	      avoid monopolization of the connections, each user is
+	      only allowed to use the display for a short while.
+	    </p>
+	    
+	    <h3>Download VNC client</h3>
+	    <p>
+	      If you don't have Java installed, you can download a
+	      free VNC client program from <a
+	      href="http://www.realvnc.com">RealVNC</a>. Start the
+	      program with <b>contiki-demo.sics.se:0</b> as the
+	      display.
+	    </p>
+	   
+	   <h3>Unix/X clients</h3>
+ 	   <p>
+	     Unix/X VNC clients need the <tt>-bgr233</tt> option
+	     to work. Use the following command:
+	   </p>
+	   <center><tt>vncviewer -bgr233 contiki-demo.sics.se:0</tt></center>
+	  <p align="right">
+	    /<a href="http://dunkels.com/adam/">Adam Dunkels</a>
+	  </p>
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fs/vncjava.html b/contiki-avr/apps/httpd-fs/vncjava.html
new file mode 100644
index 0000000..3d6d04b
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/vncjava.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <title>Virtual Contiki Screen</title>
+  </head>
+
+  <body>
+    <center>
+      <applet code="vncviewer.class" archive="vncviewer.jar"
+	      width="480" height="400">
+	<param name="PORT" value="5900">
+	  Java must be enabled in your web browser for this to work.
+      </applet>
+    </center>
+  </body>
+</html>
diff --git a/contiki-avr/apps/httpd-fs/vncviewer.jar b/contiki-avr/apps/httpd-fs/vncviewer.jar
new file mode 100644
index 0000000..c1ebd81
--- /dev/null
+++ b/contiki-avr/apps/httpd-fs/vncviewer.jar
Binary files differ
diff --git a/contiki-avr/apps/httpd-fsdata.c b/contiki-avr/apps/httpd-fsdata.c
new file mode 100644
index 0000000..8c08165
--- /dev/null
+++ b/contiki-avr/apps/httpd-fsdata.c
@@ -0,0 +1,3316 @@
+static prog_char data_cgi_processes[] = {
+	/* /cgi/processes */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x74, 0x20, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 
+	0x6d, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 
+	0x6c, 0x6c, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 
+	0x76, 0x65, 0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 
+	0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x63, 0x20, 
+	0x63, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 
+	0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 
+	0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0x2e, 
+};
+
+static prog_char data_cgi_files[] = {
+	/* /cgi/files */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 
+	0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31, 
+	0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0x3c, 0x62, 0x3e, 0x54, 0x6f, 0x74, 0x61, 
+	0x6c, 0x20, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x20, 0x6f, 0x66, 
+	0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x6c, 0x6f, 0x61, 0x64, 
+	0x73, 0x3a, 0xa, 0x63, 0x20, 0x65, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x62, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0x3c, 0x74, 0x72, 0x3e, 
+	0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x69, 0x6e, 0x64, 
+	0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 
+	0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x76, 0x6e, 
+	0x63, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x76, 
+	0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x76, 0x6e, 0x63, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 
+	0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c, 0x74, 
+	0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x76, 0x6e, 0x63, 0x76, 
+	0x69, 0x65, 0x77, 0x65, 0x72, 0x2e, 0x6a, 0x61, 0x72, 0x22, 
+	0x3e, 0x2f, 0x76, 0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 
+	0x72, 0x2e, 0x6a, 0x61, 0x72, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa, 0x63, 
+	0x20, 0x61, 0x20, 0x2f, 0x76, 0x6e, 0x63, 0x76, 0x69, 0x65, 
+	0x77, 0x65, 0x72, 0x2e, 0x6a, 0x61, 0x72, 0xa, 0x74, 0x20, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 
+	0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3e, 
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 
+	0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0xa, 0x74, 
+	0x20, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 
+	0x3e, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 
+	0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e, 0x2f, 
+	0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x63, 0x67, 0x69, 0x2f, 
+	0x74, 0x63, 0x70, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 
+	0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3e, 
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 
+	0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 
+	0x61, 0x20, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 
+	0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 
+	0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 
+	0x64, 0x3e, 0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x74, 0x20, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 
+	0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34, 
+	0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 
+	0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 
+	0x3e, 0xa, 0x63, 0x20, 0x61, 0x20, 0x2f, 0x34, 0x30, 0x34, 
+	0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, 0x6d, 0x67, 
+	0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 
+	0x74, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x69, 0x6d, 
+	0x67, 0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 
+	0x6f, 0x74, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa, 
+	0x63, 0x20, 0x61, 0x20, 0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 
+	0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 0x74, 0x2e, 
+	0x70, 0x6e, 0x67, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 
+	0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 
+	0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 
+	0xa, 0x2e, };
+
+static prog_char data_cgi_meminfo[] = {
+	/* /cgi/meminfo */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x6d, 0x65, 0x6d, 0x69, 0x6e, 0x66, 0x6f, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x74, 0x6a, 0x75, 
+	0x6e, 0x6b, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 
+	0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0x2e, 
+	0xa, };
+
+static prog_char data_cgi_tcp[] = {
+	/* /cgi/tcp */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x74, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 
+	0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 
+	0x3c, 0x74, 0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 
+	0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x74, 0x68, 0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 
+	0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 
+	0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x63, 0x20, 0x62, 
+	0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 
+	0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 
+	0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0x2e, };
+
+static prog_char data_img_screenshot_png[] = {
+	/* /img/screenshot.png */
+	0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 0x74, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 0x1, 0xbb, 00, 00, 0x1, 0x65, 0x8, 0x3, 
+	00, 00, 00, 0x45, 0x83, 0xb6, 0x73, 00, 00, 0x3, 
+	00, 0x50, 0x4c, 0x54, 0x45, 00, 0x1, 00, 0x2, 00, 
+	0x5, 00, 0x2, 00, 0x4, 00, 0x6, 0x7, 00, 00, 
+	0x9, 0x1, 00, 0x5, 0x2, 0x7, 0x6, 0x3, 0x9, 0xd, 
+	00, 0x8, 0xa, 0x3, 0x1, 0x10, 00, 0x1, 0xb, 0x4, 
+	0x3, 0x8, 0x5, 0xa, 0x9, 0x6, 0xc, 0xd, 0x6, 0x5, 
+	0x10, 0x4, 0xc, 0xc, 0x9, 0xe, 0x12, 0x7, 0xe, 0x22, 
+	0x24, 00, 0x16, 00, 0xff, 0x22, 0x22, 0x43, 0x2a, 0x24, 
+	0x37, 0x2d, 0x25, 0x49, 0x27, 0x29, 0x45, 0x2e, 0x29, 0x3c, 
+	0x2d, 0x28, 0x46, 0x2c, 0x2a, 0x42, 0x2c, 0x2c, 0x3e, 0x2d, 
+	0x2b, 0x43, 0x2f, 0x2d, 0x3b, 0x2b, 0x2d, 0x4a, 0x31, 0x2c, 
+	0x3f, 0x30, 0x2b, 0x49, 0x2e, 0x2f, 0x41, 0x33, 0x2d, 0x41, 
+	0x31, 0x2f, 0x3c, 0x31, 0x2e, 0x47, 0x34, 0x2e, 0x42, 0x32, 
+	0x2f, 0x48, 0x34, 0x31, 0x3f, 0x34, 0x2f, 0x4d, 0x32, 0x32, 
+	0x45, 0x33, 0x31, 0x49, 0x36, 0x2e, 0x53, 0x31, 0x35, 0x42, 
+	0x34, 0x32, 0x4a, 0x31, 0x2f, 0x63, 0x38, 0x32, 0x46, 0x35, 
+	0x33, 0x4b, 0x31, 0x35, 0x4c, 0x38, 0x32, 0x51, 0x36, 0x34, 
+	0x4c, 0x3a, 0x34, 0x48, 0x37, 0x35, 0x4e, 0x36, 0x37, 0x4a, 
+	0x39, 0x34, 0x53, 0x3b, 0x35, 0x49, 0x39, 0x37, 0x45, 0x39, 
+	0x36, 0x4f, 0x38, 0x38, 0x4b, 0x38, 0x36, 0x5a, 0x3a, 0x37, 
+	0x50, 0x3b, 0x36, 0x55, 0x39, 0x39, 0x4c, 0x40, 0x34, 0x55, 
+	0x3c, 0x39, 0x47, 0x3c, 0x37, 0x56, 0x38, 0x39, 0x57, 0x3e, 
+	0x38, 0x4c, 0x3e, 0x38, 0x4d, 0x3b, 0x39, 0x52, 0x3c, 0x3e, 
+	0x3b, 0x3d, 0x3b, 0x49, 0x3c, 0x3a, 0x53, 0x3a, 0x3b, 0x58, 
+	0x3a, 0x3c, 0x59, 0x41, 0x3e, 0x4d, 0x44, 0x3e, 0x52, 0x46, 
+	0x4a, 0x57, 0x6e, 0x6d, 0x54, 0x73, 0x75, 0x72, 0x8d, 0x8d, 
+	0xa3, 0x90, 0x90, 0xa6, 0x94, 0x91, 0xa1, 0x92, 0x92, 0xa8, 
+	0x95, 0x91, 0xaf, 0x94, 0x94, 0xaa, 0x93, 0x93, 0xb5, 0x95, 
+	0x95, 0xab, 0x92, 0x96, 0xb1, 0x9c, 0x95, 0xa1, 0x99, 0x95, 
+	0xb2, 0x97, 0x97, 0xad, 0x9b, 0x98, 0xa9, 0x9a, 0x9a, 0xb0, 
+	0x9d, 0x9a, 0xab, 0x99, 0x99, 0xbc, 0xa0, 0x9a, 0xa5, 0x91, 
+	0x91, 0xff, 0x98, 0x9b, 0xb7, 0x95, 0x99, 0xce, 0x9c, 0x9c, 
+	0xb2, 0x9a, 0x9e, 0xad, 0x9f, 0x9c, 0xac, 0xa0, 0x9d, 0xae, 
+	0xa3, 0x9b, 0xb4, 0xa0, 0x9c, 0xb9, 0x9e, 0x9e, 0xb5, 0xa4, 
+	0x9e, 0xa9, 0x9c, 0x9f, 0xbb, 0xa2, 0x9f, 0xaf, 0xa0, 0xa1, 
+	0xab, 0xa2, 0x9e, 0xbb, 0xa0, 0xa0, 0xb6, 0x9e, 0xa2, 0xb1, 
+	0x9d, 0xa1, 0xbc, 0xa3, 0x9f, 0xbd, 0xa1, 0xa0, 0xc3, 0xa3, 
+	0xa4, 0xad, 0xa3, 0xa3, 0xb9, 0xa5, 0xa1, 0xbf, 0xa6, 0xa3, 
+	0xb4, 0xa0, 0xa4, 0xc0, 0xa8, 0xa4, 0xb5, 0xa7, 0xa3, 0xc1, 
+	0xa7, 0xa9, 0xa6, 0xaa, 0xa6, 0xb7, 0xa7, 0xa7, 0xbd, 0xa5, 
+	0xa8, 0xc4, 0xa9, 0xaa, 0xb4, 0xab, 0xa7, 0xc5, 0xa7, 0xaa, 
+	0xc6, 0xa8, 0xab, 0xc7, 0xb9, 0xb5, 0xa7, 0xb6, 0xb1, 0xd0, 
+	0xb8, 0xb4, 0xd2, 0xbc, 0xb3, 0xd9, 0xba, 0xb6, 0xd4, 0xbf, 
+	0xb7, 0xdd, 0xb5, 0xb6, 0xff, 0xbf, 0xba, 0xd9, 0xbc, 0xbc, 
+	0xe0, 0xc4, 0xbc, 0xd5, 0xc3, 0xbb, 0xe1, 0xc1, 0xc1, 0xd8, 
+	0xc6, 0xc2, 0xe1, 0xc6, 0xc7, 0xd1, 0xcb, 0xc3, 0xdc, 0xc8, 
+	0xc4, 0xe3, 0xc7, 0xc7, 0xde, 0xcd, 0xc5, 0xde, 0xca, 0xc6, 
+	0xe5, 0xce, 0xc6, 0xdf, 0xc9, 0xc9, 0xe0, 0xca, 0xcb, 0xd5, 
+	0xca, 0xca, 0xe1, 0xd0, 0xc8, 0xe1, 0xcb, 0xcb, 0xe2, 0xcd, 
+	0xc9, 0xe8, 0xcd, 0xcd, 0xd7, 0xcb, 0xca, 0xee, 0xd2, 0xca, 
+	0xe4, 0xd1, 0xcc, 0xeb, 0xcf, 0xce, 0xe6, 0xd2, 0xce, 0xe0, 
+	0xd4, 0xcc, 0xe6, 0xcd, 0xcc, 0xfe, 0xd5, 0xcc, 0xf3, 0xd2, 
+	0xd3, 0xdd, 0xd4, 0xcf, 0xef, 0xd5, 0xd1, 0xe3, 0xd7, 0xcf, 
+	0xe9, 0xdc, 0xda, 0xab, 0xd6, 0xd1, 0xf0, 0xd2, 0xd6, 0xe6, 
+	0xd7, 0xd2, 0xf1, 0xda, 0xd2, 0xeb, 0xd6, 0xd6, 0xee, 0xdb, 
+	0xd7, 0xf6, 0xdd, 0xd9, 0xeb, 0xe0, 0xd7, 0xf1, 0xdc, 0xdd, 
+	0xe7, 0xdb, 0xda, 0xff, 0xdb, 0xdf, 0xef, 0xde, 0xde, 0xf5, 
+	0xe2, 0xde, 0xf0, 0xe5, 0xde, 0xea, 0xe3, 0xe0, 0xe5, 0xe5, 
+	0xdd, 0xf7, 0xe3, 0xe0, 0xf2, 0xe2, 0xe2, 0xed, 0xe7, 0xe0, 
+	0xed, 0xe4, 0xe1, 0xf3, 0xe7, 0xdf, 0xf9, 0xe3, 0xe4, 0xef, 
+	0xe6, 0xe2, 0xf4, 0xea, 0xde, 0xff, 0xe8, 0xe0, 0xfa, 0xe9, 
+	0xe2, 0xee, 0xe7, 0xe4, 0xe9, 0xe4, 0xe3, 0xfb, 0xe6, 0xe2, 
+	0xff, 0xe5, 0xe6, 0xf0, 0xe8, 0xe4, 0xf6, 0xeb, 0xe4, 0xf0, 
+	0xee, 0xe4, 0xea, 0xe6, 0xe5, 0xfd, 0xe9, 0xe5, 0xf7, 0xec, 
+	0xe5, 0xf1, 0xef, 0xe3, 0xf7, 0xe7, 0xe8, 0xf2, 0xe8, 0xea, 
+	0xe7, 0xec, 0xe4, 0xfd, 0xea, 0xe6, 0xf8, 0xed, 0xe6, 0xf2, 
+	0xeb, 0xe8, 0xed, 0xe8, 0xe9, 0xf3, 0xeb, 0xe7, 0xfa, 0xee, 
+	0xe7, 0xf3, 0xe9, 0xea, 0xf4, 0xea, 0xec, 0xe9, 0xee, 0xe6, 
+	0xff, 0xe9, 0xe9, 0xff, 0xed, 0xea, 0xef, 0xef, 0xe8, 0xf5, 
+	0xe7, 0xeb, 0xfc, 0xec, 0xe9, 0xfb, 0xea, 0xeb, 0xf6, 0xea, 
+	0xea, 0xff, 0xf0, 0xe9, 0xf6, 0xed, 0xea, 0xfc, 0xec, 0xec, 
+	0xf7, 0xef, 0xec, 0xf1, 0xf2, 0xea, 0xf7, 0xef, 0xeb, 0xfd, 
+	0xed, 0xed, 0xf8, 0xf0, 0xed, 0xf2, 0xf6, 0xeb, 0xf2, 0xf0, 
+	0xec, 0xfe, 0xf3, 0xec, 0xf8, 0xee, 0xef, 0xf9, 0xf1, 0xed, 
+	0xff, 0xf4, 0xed, 0xf9, 0xef, 0xf0, 0xfa, 0xf0, 0xf1, 0xfb, 
+	0xf3, 0xef, 0xff, 0xf6, 0xef, 0xfb, 0xf7, 0xf0, 0xfc, 0xf2, 
+	0xf3, 0xfd, 0xf6, 0xf3, 0xf8, 0xf9, 0xf2, 0xff, 0xf5, 0xf5, 
+	0xff, 0xf6, 0xf6, 0xff, 0xff, 0xf5, 0xfc, 0xfd, 0xfb, 0xff, 
+	0xfe, 0xff, 0xfc, 0x6a, 0x56, 0x98, 0x6e, 00, 00, 00, 
+	0x9, 0x70, 0x48, 0x59, 0x73, 00, 00, 0xb, 0x13, 00, 
+	00, 0xb, 0x13, 0x1, 00, 0x9a, 0x9c, 0x18, 00, 00, 
+	00, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xd4, 0x7, 0x1c, 
+	0x7, 0x20, 0x1e, 0x87, 0x50, 0xcf, 0xea, 00, 00, 0x1e, 
+	0x78, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9d, 0x9, 
+	0xf0, 0x2c, 0x47, 0x5d, 0xc7, 0xa9, 0x7e, 0xff, 0x54, 0x21, 
+	0xa4, 0x40, 0x7b, 0x3c, 0x30, 0x96, 0x1a, 0x15, 0x2f, 0xd4, 
+	0x10, 0x9, 0xa5, 0x18, 0xbc, 0xe2, 0x11, 0x83, 0xca, 0x4e, 
+	0xd4, 0xbf, 0x7, 0x6a, 0x40, 0xff, 0x1e, 0x29, 0x8d, 0xa0, 
+	0xf1, 00, 0xcb, 0x78, 0x4b, 0x83, 0x3a, 0x82, 0x57, 0xd4, 
+	0x60, 0x40, 0x25, 0x9a, 0xa0, 0xb2, 0x78, 0x3b, 0x9a, 0x60, 
+	0x41, 0x51, 0xcf, 0x32, 0x1a, 0xa2, 0xd1, 0x68, 0x12, 0x2a, 
+	0x2f, 0x88, 0x56, 0x99, 0x8a, 0x3c, 0x35, 0xf8, 0x2, 0x5, 
+	0x42, 0x4a, 0xdb, 0x9d, 0x3e, 0x7f, 0xdd, 0x3d, 0xb3, 0x3b, 
+	0x3d, 0x77, 0xef, 0xfe, 0xfa, 0xed, 0x9b, 0xff, 0x6c, 0xef, 
+	0x6c, 0xef, 0xec, 0x7c, 0xf6, 0xdb, 0xbf, 0xfe, 0x75, 0xf7, 
+	0xfc, 0xfa, 0x31, 0x4, 0x53, 0xaa, 0xe9, 0x31, 0xe4, 0x16, 
+	0x4c, 0x29, 0x26, 0x2e, 0xd8, 0x3d, 0x80, 0x29, 0xc1, 0x84, 
+	0xec, 0x52, 0x49, 0xb7, 0x9f, 0xfb, 0x8b, 0xb3, 0xf7, 0x3c, 
+	0xf2, 0xc6, 0x7b, 0xfe, 0xef, 0xf6, 0xfb, 0xee, 0xfa, 0x7, 
+	0xc0, 0xee, 0xca, 0x2b, 0xaf, 0x7c, 0xe0, 0x22, 0x9b, 0x1e, 
+	0xb8, 0x72, 0xe9, 0x69, 0x94, 0xab, 0xb3, 0xec, 0xaf, 0x7c, 
+	0xf6, 0x73, 0x3f, 0xf8, 0xb3, 0x9f, 0x72, 0xc9, 0x25, 0x17, 
+	0x7e, 0xe8, 0xd3, 0x9f, 0xfa, 0xe9, 0x6f, 0x15, 0x39, 0x56, 
+	0x77, 0x17, 0xd9, 0x8a, 0x34, 0xa5, 0x9f, 0x23, 0x21, 0xea, 
+	0xbf, 0x7c, 0x26, 0x72, 0x8, 0xe9, 0x73, 0xe0, 0x42, 0xd3, 
+	0xc3, 0x9f, 0xf4, 0x9a, 0x5f, 0xb9, 0xfe, 0xd5, 0x37, 0xbd, 
+	0xe6, 0x8f, 0x5e, 0xf9, 0xca, 0x9b, 0xfe, 0xd2, 0xd7, 0xdd, 
+	0x2d, 0x3f, 0x24, 0xd3, 0x45, 0xb7, 0xa4, 0xa4, 0x3b, 0x83, 
+	0x84, 0x28, 0x24, 0x62, 0x87, 0x6c, 0x61, 0xd7, 0x78, 0xe0, 
+	0xb2, 0xbf, 0xf2, 0xdf, 0x3f, 0xed, 0xa6, 0xef, 0xfa, 0x91, 
+	0xaf, 0xbf, 0xf6, 0xf3, 0xbe, 0xf2, 0xdb, 0x3e, 0xeb, 0xfa, 
+	0x73, 0x81, 0xee, 0x2c, 0xbb, 0x14, 0x75, 0xa7, 0x51, 0x68, 
+	0x2d, 0xc1, 0xbf, 0xee, 0x7f, 0xef, 0xc0, 0x44, 0xd2, 0x1d, 
+	0x97, 0xbc, 0xee, 0xf8, 0xb9, 0x2f, 0x78, 0xd1, 0x85, 0xdf, 
+	0xfb, 0xc3, 0x1f, 0xf4, 0x27, 0x6f, 0xda, 0x37, 0xdd, 0xa9, 
+	0xa, 0xb1, 0x5, 0x3b, 0x52, 0xcf, 0x6e, 0xd9, 0x5f, 0xf9, 
+	0xbd, 0x1f, 0xf9, 0xaa, 0xeb, 0xbe, 0xfb, 0x5b, 0xbf, 0xe2, 
+	0x59, 0xd7, 0x5c, 0x75, 0xc5, 0x1f, 0xbe, 0x69, 0xcf, 0x74, 
+	0x27, 0x4, 0x55, 0x83, 0x24, 0x60, 0xd7, 0x74, 0xe0, 0xc2, 
+	0xd3, 0xeb, 0x9f, 0x71, 0xe3, 0x35, 0x57, 0x5f, 0x77, 0xcd, 
+	0xc5, 0xcf, 0xbf, 0xfa, 0xd3, 0x7e, 0xfe, 0xdc, 0x9e, 0xe9, 
+	0xce, 0x28, 0x6a, 0x27, 0xbb, 0x86, 0x3, 0x17, 0xfe, 0xad, 
+	0xff, 0xf4, 0xf3, 0x7f, 0xe7, 0x23, 0x2e, 0xfe, 0xd4, 0x8f, 
+	0xfb, 0xcc, 0x6f, 0xb8, 0xe6, 0xd2, 0x5f, 0xfb, 0x9b, 0x7d, 
+	0xd3, 0x9d, 0x32, 0x65, 0x2d, 0xd8, 0xd5, 0x1f, 0xb8, 0xf0, 
+	0xf4, 0xee, 0xb, 0x5f, 0xf6, 0x3, 0xdf, 0xf4, 0x2d, 0x3f, 
+	0xfa, 0xd5, 0xdf, 0xf7, 0x13, 0x1f, 0xf2, 0x1b, 0xef, 0xd9, 
+	0x23, 0xdd, 0xe9, 0x6, 0x23, 0x1, 0xcd, 0xc7, 0x5a, 0x7b, 
+	0x57, 0x77, 0x60, 0x22, 0xba, 0x3b, 0x73, 0xf9, 0xeb, 0xae, 
+	0xbd, 0xf6, 0x6b, 0x5e, 0xf4, 0xfd, 0xcf, 0xf9, 0xf2, 0x8f, 
+	0xfd, 0xfd, 0x50, 0x77, 0xda, 0x35, 0x4f, 0x4c, 0x77, 0xa6, 
+	0xd1, 0xef, 0xba, 0x6d, 0x46, 0x56, 0x44, 0x57, 0x91, 0xd, 
+	0x7, 0x26, 0x92, 0xce, 0x5c, 0x72, 0xc3, 0x5, 0x1f, 0xf5, 
+	0xc9, 0x9f, 0xf8, 0x94, 0x4b, 0x2f, 0xfb, 0xd2, 0x1b, 0xff, 
+	0x29, 0xd0, 0x9d, 0xf5, 0xcd, 0xb1, 0x5f, 0x65, 0x79, 0xe9, 
+	0xf6, 0x67, 0xbf, 0xe2, 0xb7, 0x7e, 0xef, 0xd7, 0x7f, 0xfb, 
+	0x37, 0x6f, 0xfc, 0xd5, 0x5f, 0xf8, 0xdd, 0xbf, 0xf3, 0x74, 
+	0x87, 0x69, 0xd9, 0xe9, 0xd1, 0x3f, 0x7f, 0xeb, 0xbf, 0x9d, 
+	0xfe, 0xd7, 0x3f, 0x3b, 0xf7, 0xcf, 0xff, 0xf1, 0xae, 0xbf, 
+	0x3e, 0x87, 0x7d, 0xd1, 0xfb, 0x30, 0x8e, 0xf0, 0xcd, 0x98, 
+	0x52, 0x4c, 0x82, 0x1d, 0xa6, 0x24, 0xd3, 0x17, 0x55, 0xec, 
+	0xfe, 0x11, 0x53, 0x92, 0x9, 0xd9, 0x21, 0x3b, 0x4c, 0xc8, 
+	0xe, 0x13, 0xb2, 0x43, 0x76, 0x98, 0x90, 0x1d, 0x26, 0x64, 
+	0x87, 0xa9, 0x99, 0x1d, 0x17, 0x69, 0xbd, 0x71, 0xfc, 0xd6, 
+	0xdc, 0x49, 0xc4, 0x6e, 0x9, 0xcc, 0xc1, 0xd4, 0x3b, 0x35, 
+	0x5d, 0xec, 0xa6, 0x2b, 0xbc, 0x9d, 0xdd, 0xa6, 0xac, 0xb5, 
+	0xfb, 0xc6, 0xb5, 0x2c, 0x7e, 0xd, 0x8a, 0x5c, 0xe3, 0x55, 
+	0x1f, 0x88, 0xdd, 0x7a, 0xed, 0xc1, 0x23, 0xf0, 0x9a, 0xc7, 
+	0xb2, 0xd3, 0xea, 0x5b, 0xeb, 0x5f, 0xc5, 0x66, 0x2b, 0x7e, 
+	0x21, 0xf2, 0xd5, 0xa, 0x2c, 0x41, 0xdd, 0xd, 0xc5, 0xae, 
+	0xba, 0xd4, 0xea, 0x6a, 0xaf, 0xc5, 0x85, 0xd6, 0x57, 0x98, 
+	0x78, 0x14, 0xda, 0xb3, 0xab, 0x7e, 0xf, 0x7a, 0x2b, 0x7f, 
+	0x3, 0x52, 0x8c, 0x64, 0x2d, 0x3f, 0x5, 0xaf, 0xfa, 0x60, 
+	0xec, 0x36, 0xff, 0xcd, 0xd5, 0x6, 0x57, 0x78, 0xed, 0x51, 
+	0x88, 0x60, 0x7, 0x1e, 0x8e, 0xbd, 0x23, 0x6b, 0xb4, 0x77, 
+	0x83, 0xeb, 0x8e, 0x8, 0x99, 0x69, 0x95, 0xad, 0x61, 0xeb, 
+	0xc2, 0x52, 0x68, 0x6d, 0xef, 0x14, 0x71, 0xc5, 0xe, 0x94, 
+	0xa6, 0x7e, 0x10, 0x78, 0xd5, 0x87, 0xb4, 0x77, 0x52, 0x71, 
+	0x5c, 0xa9, 0x4c, 0x49, 0xae, 0x83, 0xee, 0x64, 0x3b, 0x53, 
+	0xfd, 0x6, 0x24, 0xa5, 0x35, 0x1, 0xbf, 0x84, 0x35, 0x41, 
+	0x76, 0x43, 0xb7, 0x33, 0xd7, 0xaa, 0x45, 0x21, 0xaf, 0xf9, 
+	0xda, 0x5c, 0xf3, 0x58, 0x7b, 0x87, 0x69, 0x79, 0xda, 0xdc, 
+	0xdd, 0xce, 0x3c, 0xd9, 0xa3, 0x44, 0xf3, 0x2a, 0x1d, 0x8b, 
+	0x44, 0x37, 0x49, 0xed, 0x46, 0xa7, 0xbc, 0x53, 0x6a, 0x28, 
+	0x87, 0xf6, 0xff, 0x5e, 0x7, 0xc1, 0x4e, 0x5e, 0x32, 0xb6, 
+	0x49, 0xc7, 0x1b, 0x70, 0x39, 0x3d, 0x9e, 0x34, 0x89, 0xcf, 
+	0xd, 0x12, 0xb2, 0x8b, 0xd1, 0x9d, 0xb8, 0x80, 0x92, 0x1d, 
+	0xcd, 0xe9, 0x6, 0x60, 0x2e, 0x24, 0xe8, 0x6d, 0x29, 0xd8, 
+	0x9a, 0x9c, 0x5e, 0xba, 0x3, 0x9f, 0x8b, 0xba, 0xeb, 0xaa, 
+	0x3b, 0x5b, 0x67, 0xca, 0x7a, 0x73, 0xc3, 0x94, 0x6, 0xdb, 
+	0x63, 0xb0, 0x35, 0x39, 0xfd, 0x74, 0x27, 0x78, 0x6d, 0x7e, 
+	0x2e, 0x39, 0xea, 0xae, 0xaf, 0xee, 0xec, 0x56, 0x3f, 0x72, 
+	0xc9, 0xd4, 0xd5, 0x20, 0xcc, 0xe9, 0xaf, 0xbb, 0xe3, 0xdc, 
+	0x2b, 0x7, 0xd9, 0xc5, 0xeb, 0xee, 0x18, 0x6c, 0x3, 0xc5, 
+	0x1d, 0x8b, 0xfd, 0xe3, 0x30, 0x7, 0x75, 0xb7, 0x4, 0xdd, 
+	0x1, 0x76, 0x9e, 0xa5, 0x93, 0x35, 0x6a, 0xae, 0xb7, 0x30, 
+	0x7, 0xed, 0xdd, 0x6c, 0xec, 0x58, 0x7d, 0x53, 0xaf, 0x4b, 
+	0x83, 0x31, 0x3e, 0x35, 0x94, 0x83, 0xec, 0x22, 0xd8, 0x2d, 
+	0x2c, 0x21, 0xbb, 0x7d, 0x67, 0xb7, 0xaa, 0x4d, 0xc8, 0x2e, 
+	0x9, 0x76, 0x12, 0xa0, 0x45, 0x69, 0x32, 0x91, 0x5d, 0x2, 
+	0xec, 0x4, 0x2f, 0xa3, 0xb7, 0x6a, 0x83, 0xec, 0x12, 0x61, 
+	0x67, 0x45, 0x67, 0xa4, 0x87, 0xec, 0x52, 0x61, 0xe7, 0x1a, 
+	0x3d, 0x95, 0x85, 0xec, 0x52, 0x68, 0xab, 0x6c, 0xc9, 0x43, 
+	0x76, 0x4b, 0x67, 0x17, 0x34, 0x32, 0xf, 0x97, 0x5d, 0x4e, 
+	0xc5, 0x86, 0xd2, 0x5c, 0x5f, 0x44, 0xb3, 0x31, 0x7f, 0x82, 
+	0xfd, 0x79, 0xdb, 0x99, 0x4d, 0x99, 0x7, 0xc7, 0x8e, 0x56, 
+	0xcf, 0x36, 0xe0, 0x72, 0x9d, 0x2b, 0x20, 0x52, 0xb0, 0xcf, 
+	0xc2, 0xfd, 0x59, 0xdb, 0x2a, 0xa1, 0xf0, 0xe, 0x5a, 0x77, 
+	0x14, 0xe8, 0x4a, 0xf4, 0x12, 0x57, 0x3, 0x7a, 0x79, 0x5, 
+	0xd6, 0x12, 0x93, 0xfb, 0xd5, 0xb, 0x42, 0xa7, 0xb9, 0xa4, 
+	0x29, 0x8e, 0x4, 0x39, 0x94, 0xa2, 0xee, 0xa6, 0xb3, 0x77, 
+	0xf5, 0xec, 0xaa, 0xd1, 0x84, 0x8a, 0x85, 0x91, 0xa3, 0xda, 
+	0x97, 0x30, 0xe5, 0xbe, 0x39, 0xd2, 0x7b, 0x75, 0x42, 0xdd, 
+	0x21, 0x3b, 0x87, 0x9d, 0x46, 0x52, 0x29, 0x88, 0x82, 0x6c, 
+	0xf5, 0x34, 0xb7, 0xfb, 0x9e, 0x42, 0x69, 0xaf, 0x7a, 0xb5, 
+	0xa3, 0xee, 0xe, 0xbb, 0x4f, 0xcc, 0xb7, 0x77, 0xa2, 0xe6, 
+	0x63, 0x50, 0x4d, 0x8e, 0xee, 0xc0, 0xbe, 0x84, 0xc7, 0xb4, 
+	0x42, 0xfb, 0xb5, 0x67, 0x3a, 0xe8, 0xce, 0x78, 0x7a, 0x7, 
+	0xcd, 0xe, 0xb6, 0x33, 0x25, 0x3b, 0x69, 0xb8, 0x6a, 0xec, 
+	0x9d, 0x92, 0xa6, 0xd2, 0x5f, 0x45, 0x99, 0x4a, 0xbb, 0x47, 
+	0xa7, 0x61, 0x57, 0xd7, 0x33, 0x8d, 0xfe, 0x5d, 0x32, 0xfd, 
+	0x99, 0x9e, 0xea, 0xa2, 0xd8, 0x39, 0xf3, 0x1b, 0xed, 0xb0, 
+	0xf3, 0x31, 0x9d, 0x70, 0x96, 0x63, 0x9f, 0x99, 0x90, 0xd4, 
+	0x69, 0x66, 0x52, 0x51, 0x61, 0x5a, 0x81, 0x39, 0xbe, 0x5e, 
+	0x80, 0x99, 0x8e, 0xe5, 0xf2, 0xc5, 0xf7, 0xab, 0x98, 0xde, 
+	0xe8, 0x28, 0x76, 0xee, 0xfc, 0x46, 0xcb, 0x2e, 0x3f, 0x5e, 
+	0x56, 0x6a, 0x98, 0x9, 0xe9, 0x5c, 0x7e, 0x61, 0xe9, 0x3c, 
+	0xff, 0x2e, 0xa7, 0xd0, 0x81, 0x60, 0x81, 0x4b, 0x61, 0x1b, 
+	0x35, 0x73, 0xb0, 0x3, 0xb2, 0x8b, 0xef, 0x13, 0x83, 0xf3, 
+	0x3d, 0x6c, 0x5b, 0xcb, 0x9b, 0xcb, 0x1, 0x66, 0x55, 0xc9, 
+	0xd9, 0x8f, 0x72, 0x86, 0x6, 0xcc, 0x19, 0x5d, 0x77, 0xd, 
+	0x33, 0x43, 0x68, 0xd0, 0xca, 0x74, 0xd8, 0x69, 0x81, 0x99, 
+	0xc6, 0x47, 0xae, 0x2d, 0x9d, 0x35, 0x69, 0xba, 0x6d, 0xc9, 
+	0x6, 0xf0, 0xec, 0xa2, 0xfb, 0xa2, 0x1d, 0xd9, 0xc5, 0xb2, 
+	0xf3, 0xe7, 0x3b, 0x51, 0x38, 0xc3, 0x4a, 0x6b, 0x10, 0xcc, 
+	0x69, 0x14, 0x48, 0xe5, 0xcc, 0x28, 0x98, 0x33, 0xbe, 0xee, 
+	0xea, 0x67, 0x64, 0x85, 0xec, 0x94, 0x4b, 00, 0xd9, 0xe5, 
+	0xc6, 0x69, 0xb7, 0x2d, 0x4c, 0xcb, 0x4e, 0xfb, 0x77, 0x43, 
+	0x78, 0x76, 0xf1, 0x63, 0x40, 0xaa, 0x1b, 0xb3, 0xaf, 0xee, 
+	0x8e, 0x8d, 0x37, 0xa4, 0x27, 0x37, 0x1e, 0x83, 0x39, 0x57, 
+	0x2a, 0x3f, 0x57, 0x38, 0xa9, 0x97, 0x33, 0x89, 0xee, 0xc2, 
+	0x99, 0x90, 0xb4, 0xc6, 0xbb, 0xf3, 0x75, 0x27, 0x7b, 0x4b, 
+	0x4c, 0xe7, 0xa6, 0xa7, 0x3b, 0xef, 0x55, 0x3a, 0x40, 0x8f, 
+	0x59, 0xdc, 0xd8, 0x2b, 0xf0, 0xec, 0x56, 0x9d, 0x75, 0x27, 
+	0x91, 0x40, 0x95, 0x99, 0xcb, 0x64, 0xe7, 0x15, 0x1f, 0xdb, 
+	0x6b, 0xe8, 0xe4, 0x2c, 0x41, 0x77, 0xb9, 0xee, 0x8d, 0xce, 
+	0x3d, 0xb, 0x18, 0xe8, 0x2e, 0xc8, 0x61, 0x50, 0x77, 0x93, 
+	0xcf, 0x79, 0xe8, 0x36, 0x5f, 0xc5, 0xd1, 0x9d, 0x60, 0x17, 
+	0xce, 0x5d, 0x74, 0xe6, 0x34, 0x1e, 0xdb, 0x76, 0xa8, 0x9b, 
+	0x33, 0xbf, 0xbd, 0x53, 0xad, 0x4a, 0x50, 0xe5, 0xd9, 0x96, 
+	0xa7, 0x6b, 0xef, 0xbc, 0x1c, 0xa, 0xc6, 0x20, 0xf2, 0xe9, 
+	0xd8, 0xf5, 0x9d, 0x6b, 0x34, 0xd4, 0xfc, 0xc6, 0x3e, 0xb3, 
+	0x1c, 0xfb, 0xcc, 0x84, 0x3c, 0xe4, 0x39, 0x7e, 0x34, 0x74, 
+	0x6e, 0xc2, 0xcb, 0x11, 0x7b, 0x81, 0xa6, 0xbb, 0xa0, 0x3b, 
+	0xfc, 0x3b, 0x4a, 0xe3, 0xda, 0x1d, 0x94, 0x36, 0xc, 0xf5, 
+	0xd1, 0x1e, 0xec, 0xb8, 0xdd, 0x65, 0x9c, 0x73, 0x76, 0x52, 
+	0xf3, 0x2a, 0x7, 0x7, 0xf2, 0xee, 0xec, 0x42, 0x4f, 0x27, 
+	0xd6, 0xf7, 0xc9, 0x47, 0x1e, 0x1e, 0x6b, 0x74, 0xaf, 0xb7, 
+	0xfa, 0x77, 0xed, 0xce, 0x5c, 0xfe, 0x9, 0xbe, 0x4b, 0xde, 
+	0x9d, 0x1d, 0x3, 0xb4, 0x36, 0xbb, 0x8c, 0x9f, 0xd4, 0xbc, 
+	0xca, 00, 0x3b, 0xd6, 0x89, 0x5d, 0xe0, 0xe9, 0x48, 0x5b, 
+	0x40, 0xa9, 0xd3, 0xb7, 0x4b, 0xbd, 0x57, 0x55, 0x3f, 0xbc, 
+	0x7f, 0x7c, 0x4e, 0x27, 0xa8, 0xd0, 0x76, 0xf9, 0x77, 0x8a, 
+	0xa6, 0x73, 0xce, 0xb9, 0x7b, 0xb6, 0xce, 0x79, 0x52, 0x5b, 
+	0x28, 0xfc, 0x2e, 0x94, 0xda, 0x5e, 0xd0, 0x16, 0xdf, 0x8b, 
+	0x32, 0x21, 0x2f, 0x2e, 0x1f, 0x9c, 0x7b, 0x22, 0x53, 0xaf, 
+	0xea, 0x6d, 0x95, 0xaf, 0x74, 0xc7, 0xb8, 0xde, 0x8f, 0x66, 
+	0x17, 0x7a, 0x3a, 0xa2, 0x47, 0x1d, 0xea, 0x88, 0xba, 0xaf, 
+	0x52, 0xdb, 0xae, 0xf6, 0x8f, 0x97, 0xfb, 0xd3, 0xb3, 0xb, 
+	0xeb, 0xcc, 0x9a, 0x73, 0x86, 0xe3, 0x5, 0xf0, 0x3c, 0x81, 
+	0x8b, 0x1, 0xbf, 0x4b, 0x1e, 0xb6, 0x51, 0xb7, 0x9e, 0x15, 
+	0x67, 0x8c, 0x6b, 0x76, 0x8e, 0xee, 0x94, 0xfa, 0xc4, 0xab, 
+	0x62, 0x2b, 0x5f, 0x95, 0x62, 0xe4, 0xe2, 0x9, 0xeb, 0xc4, 
+	0xce, 0xf1, 0x74, 0xc0, 0x8, 0x32, 0xac, 0x52, 0x55, 0x9f, 
+	0x3b, 0x50, 0x9c, 0x7a, 0x4, 0xc7, 0xe7, 0x74, 0x82, 0xaa, 
+	0x73, 0xb7, 0xee, 0x98, 0x3b, 0x4e, 0xa7, 0xfc, 0x3b, 0xea, 
+	0x2b, 0x31, 0xb4, 0x6e, 0xce, 0x77, 0xa7, 0x4e, 0x9, 0xbb, 
+	0xd9, 0x19, 0xd1, 0xb9, 0xf6, 0xce, 0x18, 0x37, 0xff, 0x55, 
+	0xc9, 0x8e, 0xb3, 0x2e, 0xf6, 0x2e, 0xaf, 0xf1, 0x74, 0x40, 
+	0x8f, 0x44, 0xf0, 0xe5, 0xf2, 0x9a, 0x5f, 0xb2, 0x7f, 0x7c, 
+	0x9e, 0xd3, 0xd9, 0xed, 0x9d, 0x7b, 0xce, 0xf5, 0x67, 0xb, 
+	0xcf, 0xd3, 0xf9, 0x29, 0x83, 0xef, 0xe2, 0x78, 0xee, 0xad, 
+	0x75, 0x27, 0xb6, 0x27, 0x81, 0xbd, 0x83, 0xaa, 0x3c, 0x1, 
+	0xbc, 0xa4, 0xee, 0xa2, 0xd9, 0xc1, 0x9a, 0x5f, 0x7b, 0x3a, 
+	0x76, 0xcc, 0x2b, 0xf8, 0x72, 0x39, 0xb0, 0x68, 0x66, 0xeb, 
+	0x1d, 0x4f, 0x27, 0xd7, 0x5d, 0x4d, 0x3b, 0xd3, 0x3d, 0x67, 
+	0x68, 0xe9, 0xec, 0x28, 0x5e, 0x83, 0xee, 0x9c, 0xef, 0x4e, 
+	0xe1, 0x8, 0x7b, 0x5b, 0x7b, 0xc7, 0xa4, 0x31, 0x3, 0xad, 
+	0x13, 0xd9, 0xce, 0x84, 0xd6, 0x50, 0x57, 0x97, 0xd6, 0xde, 
+	0xc5, 0xb2, 0xeb, 0x9a, 0xf2, 0xb9, 0xdd, 0xab, 0x39, 0xfc, 
+	0xbb, 0x16, 0xba, 0x9b, 0xd2, 0xbf, 0x4b, 0x36, 0xd5, 0xe8, 
+	0x8e, 0xfa, 0x7d, 0xd1, 0x74, 0x6a, 0xa7, 0x13, 0xd9, 0x75, 
+	0xb5, 0x77, 0x4e, 0x5f, 0x74, 0xc3, 0xfc, 0x4c, 0x64, 0xb7, 
+	0x38, 0x76, 0xb6, 0x7b, 0x79, 0xc7, 0xfc, 0xcc, 0x70, 0x1e, 
+	0xa6, 0xe4, 0x3e, 0xe9, 0xf8, 0x1d, 0xb2, 0xab, 0x61, 0x97, 
+	0xfb, 0x53, 0xfc, 0xea, 0xe6, 0x67, 0x7a, 0xa3, 0x75, 0x72, 
+	0x9a, 0xd8, 0xa4, 0xe3, 0x77, 0xc8, 0xae, 0x86, 0x1d, 0xb8, 
+	0xf4, 0xd, 0xf3, 0x33, 0x6b, 0xe6, 0x61, 0xd2, 0x9c, 0xe, 
+	0x30, 0x33, 0x13, 0xd9, 0xf5, 0xb4, 0x77, 0x6e, 0x5e, 0xdd, 
+	0xfc, 0xcc, 0x9a, 0x79, 0x98, 0xb9, 0xac, 0x2d, 0x7b, 0xce, 
+	0xcc, 0x44, 0x76, 0xbd, 0xda, 0x99, 0x21, 0xbb, 0xa6, 0xf9, 
+	0x99, 0xee, 0x3c, 0x4c, 0xe0, 0xd5, 0x22, 0xbb, 0x7d, 0xf5, 
+	0xef, 0x90, 0xdd, 0x78, 0xba, 0x3, 0xad, 0xc4, 0xe8, 0xf1, 
+	0xbb, 0x86, 0x4c, 0x4a, 0x91, 0xdd, 0x14, 0xf6, 0xce, 0x19, 
+	0xf5, 0x88, 0x1c, 0xbf, 0xab, 0x3, 0x2d, 0xc7, 0x56, 0x46, 
+	0x60, 0x37, 0xd0, 0x9c, 0x87, 0x7d, 0x6a, 0x67, 0x7a, 0xf7, 
+	0x48, 0x86, 0xe3, 0x77, 0xd4, 0x78, 0x70, 0xc6, 0xef, 0xd3, 
+	0xef, 0xd1, 0x6, 0xd3, 0xfa, 0x83, 0xe1, 0x5c, 0x97, 0x16, 
+	0xde, 0xdf, 0x44, 0xf1, 0x55, 0xf6, 0x90, 0x5d, 0x9b, 0xf1, 
+	0x3b, 0x30, 0xd2, 0x51, 0xe5, 0xe4, 0xa6, 0xef, 0xc5, 0x8e, 
+	0x2c, 0x34, 0xcd, 0x28, 0x6b, 0x51, 0xb, 0x4f, 0x14, 0x5f, 
+	0x65, 0x2f, 0x75, 0xb7, 0x7d, 0xfc, 0xce, 0x78, 0x70, 0x60, 
+	0xdc, 0xdf, 0xf6, 0x79, 0x52, 0x77, 0x3e, 00, 0x9c, 0xc9, 
+	0xd9, 0xda, 0xfb, 0x9b, 0x28, 0xbe, 0xca, 0xfe, 0xd9, 0xbb, 
+	0x56, 0xe3, 0x77, 0x30, 0x27, 0x60, 0x17, 0xce, 0x7, 0x60, 
+	0x60, 0x24, 0x9d, 0xb2, 0xe1, 0xd8, 0xf5, 0x8b, 0xaf, 0xb2, 
+	0x7f, 0xed, 0xcc, 0x9d, 0xe3, 0x77, 0xd4, 0x9d, 0x27, 0xb0, 
+	0x5d, 0x77, 0x9e, 0xbd, 0x1b, 0x94, 0x5d, 0xdf, 0xf8, 0x2a, 
+	0x7, 0xe7, 0xdf, 0x4d, 0x32, 0x9a, 0x3f, 0x4d, 0x7c, 0x95, 
+	0x6e, 0x53, 0x2f, 0xcd, 0x3a, 0x29, 0xd5, 0x4a, 0x29, 0x6b, 
+	0xf0, 0x27, 0xd8, 0x6f, 0x91, 0xca, 0x14, 0x7f, 0x34, 0x6a, 
+	0x6d, 0x17, 0xff, 0x5b, 0xd0, 0xd8, 0x76, 0x66, 0x9f, 0x38, 
+	0xf, 0xd1, 0xec, 0xc4, 0x89, 0xf2, 0x72, 0x93, 0xd6, 0x84, 
+	0x1, 0x76, 0xc, 0xb0, 0x63, 0x31, 0xe8, 0x8a, 0x72, 0x9d, 
+	0x60, 0x92, 0x57, 0x20, 0xf8, 0x16, 0x71, 0xec, 0x7a, 0xc6, 
+	0x57, 0xe9, 0xa8, 0x3b, 0x71, 0xa6, 0x8c, 0xc8, 0x7f, 0x15, 
+	0x2b, 0x42, 0x2c, 0x31, 0xb9, 0x5f, 0xbd, 0x50, 0x1d, 0x23, 
+	0xf7, 0xe5, 0xd1, 0x30, 0x87, 0x10, 0xfd, 0xad, 0x93, 0xd4, 
+	0x5d, 0xa9, 0x7e, 0xa5, 0x8c, 0xc0, 0x6f, 0x91, 0x84, 0xee, 
+	0x2c, 0x3b, 0xc2, 0xaa, 0xd3, 0x97, 0x5b, 0xad, 0x3b, 0x91, 
+	0x23, 0x65, 0x29, 0xf6, 0xcd, 0x91, 0xde, 0xab, 0x29, 0xeb, 
+	0xce, 0x5c, 0x81, 0xa1, 0x74, 0x37, 0x3e, 0x3b, 0xf0, 0xab, 
+	0xd3, 0x48, 0x88, 0x58, 0x20, 0xcc, 0x9a, 0x39, 0xf5, 0x94, 
+	0xd9, 0x7d, 0x4f, 0xa1, 0x4, 0xd6, 0xab, 0x29, 0xeb, 0x6e, 
+	0xad, 0xd1, 0xd, 0xa2, 0xbb, 0xb1, 0xfb, 0xc4, 0xa0, 0xee, 
+	0x44, 0xcd, 0xb7, 0x86, 0x6a, 0x72, 0x74, 0x7, 0xf6, 0xd5, 
+	0xf, 0x54, 0x2b, 0xd4, 0x69, 0xcf, 0xa0, 0xee, 0xba, 0xc6, 
+	0x57, 0xe9, 0xa5, 0x3b, 0xc1, 0x4e, 0x1a, 0xae, 0x1a, 0x7b, 
+	0xa7, 0x7e, 0x98, 0x4a, 0x7f, 0x15, 0x65, 0x22, 0xed, 0x1e, 
+	0xb1, 0xec, 0x8a, 0x4d, 0x4a, 0xdf, 0xde, 0xd9, 0x6f, 0xd1, 
+	0x5d, 0x77, 0x13, 0xf4, 0x45, 0xd3, 0xa0, 0x71, 0xdc, 0x27, 
+	0x95, 0x22, 0x25, 0xb9, 0x58, 0x5d, 0xfd, 0xb7, 0x88, 0x64, 
+	0xd7, 0x33, 0xbe, 0x4a, 0x37, 0x76, 0x7a, 0x2d, 0x45, 0xcf, 
+	0x1d, 00, 0x9e, 0x5d, 0xb9, 0x73, 0x1d, 0xc6, 0x66, 0x4f, 
+	0x62, 0x44, 0x9a, 0xc, 0x56, 0xa, 0x3d, 0x3e, 0x97, 0xf9, 
+	0x5f, 0xa0, 0x3, 0xbb, 0xde, 0xf1, 0x55, 0xba, 0xb1, 0xd3, 
+	0xfe, 0x1d, 0x23, 0xd, 0xec, 0x8a, 0xe6, 0xeb, 0xa0, 0xde, 
+	0xcb, 0x1a, 0xe1, 0x15, 0xe3, 0xb0, 0x3, 0xe7, 0x5c, 0xff, 
+	0xd9, 0x2d, 0x3f, 0xb7, 0xf6, 0xbb, 0x17, 0xdd, 0xd8, 0xf5, 
+	0x8b, 0xaf, 0xd2, 0x91, 0x1d, 0xa8, 0xed, 0xb5, 0x15, 0x13, 
+	0x3f, 0x67, 0x46, 0x76, 0xb3, 0x53, 0x94, 0xa5, 0xad, 0x34, 
+	0xde, 0x9f, 0xfd, 0x21, 0x8f, 0xc5, 0xce, 0xf6, 0x1b, 0x88, 
+	0xa6, 0xee, 0xda, 0xf7, 0x4c, 0xdb, 0xb2, 0xd3, 0xbf, 0x52, 
+	0x66, 0xac, 0x79, 0x37, 0x76, 0xbd, 0xe3, 0xab, 0xf4, 0x61, 
+	0xa7, 0x1a, 0x1f, 0xd6, 0xbf, 0x23, 0xac, 0xc5, 0x75, 0x30, 
+	0xdf, 0x9d, 0xf8, 0xde, 0x1f, 0x19, 0x9f, 0x9d, 0xac, 0xeb, 
+	0x18, 0xf0, 0x3d, 0xa3, 0x3f, 0x57, 0x9f, 0x3f, 0x21, 0xe1, 
+	0x7b, 0x63, 0xdb, 0x99, 0xfd, 0xe2, 0xab, 0xf4, 0xd6, 0x1d, 
+	0xd3, 0xfe, 0x1d, 0x73, 0x3d, 0xee, 0x36, 0xba, 0x83, 0xde, 
+	0x9f, 0xf5, 0x10, 0xc7, 0x64, 0x27, 0xf0, 0xa9, 0x4f, 0x22, 
+	0xe0, 0xd1, 0x81, 0x9d, 0x39, 0xff, 0xce, 0xec, 0xfa, 0xc6, 
+	0x57, 0xe9, 0xcd, 0x8e, 0x74, 0xd3, 0x9d, 0xb0, 0x77, 0xd0, 
+	0xfb, 0x9b, 0x86, 0x9d, 0xae, 0xe7, 0x7b, 0xeb, 0xe, 0x7c, 
+	0xf7, 0xee, 0xec, 0x7a, 0xc6, 0x57, 0xe9, 0x5d, 0x67, 0x3a, 
+	0xbd, 0x94, 0xd2, 0xde, 0x9, 0x7f, 0x67, 0xc7, 0x77, 0x7, 
+	0x56, 0x52, 0x79, 0x7f, 0x92, 0xdd, 0xf6, 0xf7, 0xe, 0x54, 
+	0x67, 0xae, 0x59, 0x60, 0xef, 0xda, 0x7f, 0xae, 0x53, 0xf7, 
+	0x7a, 0xef, 0x8d, 0x6b, 0xab, 0x4c, 0x3c, 0xd7, 0xa8, 0x8d, 
+	0x7f, 0xb7, 0xc3, 0x6b, 0x9b, 0xcb, 0xe3, 0x6b, 0xf8, 0x44, 
+	0xf9, 0xeb, 0x89, 0xf8, 0xdc, 0x6d, 0xe7, 0x1c, 0xc3, 0x6e, 
+	0xf2, 0x39, 0x7e, 0x54, 0x9d, 0x3e, 0xf1, 0x87, 0xee, 0x6a, 
+	0x3c, 0x26, 0x59, 0x9f, 0x30, 0x12, 0xef, 0xb3, 0x93, 0x1d, 
+	0xef, 0xe9, 0x52, 0xe6, 0x98, 0xa9, 0x3a, 0x9d, 0x26, 0x76, 
+	0x3c, 0x8c, 0xa9, 0xb2, 0x4, 0x76, 0xcc, 0x76, 0xc7, 0xd6, 
+	0x79, 0x4c, 0xba, 0x3e, 0x8c, 0xbf, 0x16, 0xbb, 0xd8, 0x74, 
+	0x29, 0x73, 0x36, 0x76, 0x41, 0x4c, 0x95, 0x45, 0xb0, 0xd3, 
+	0xf6, 0x62, 0xd, 0xb6, 0xb6, 0xd3, 0x2, 0xc8, 0xce, 0xda, 
+	0x36, 0x66, 0xcd, 0x8d, 0xb2, 0x1a, 0xfe, 0x2b, 0xb6, 0xbb, 
+	0x93, 0x81, 0xae, 0xb, 0x78, 0xe4, 0xe2, 0x64, 0xd7, 0x82, 
+	0x1d, 0x67, 0x9c, 0xeb, 0xc8, 0x2a, 0xde, 0x96, 0x83, 0xad, 
+	0xc9, 0x19, 0x5f, 0x77, 0xca, 0x3b, 0x33, 0xba, 0x83, 0xa3, 
+	0x9, 0x50, 0x76, 0x7a, 0xc, 0xc8, 0xfe, 0x73, 0x46, 0x1c, 
+	0x82, 0xad, 0x6a, 0xc3, 0xbb, 0x63, 0x13, 0x36, 0x67, 0x69, 
+	0xb2, 0x6b, 0x51, 0x67, 0xca, 0x7a, 0x13, 0xc6, 0x7f, 0x30, 
+	0xdb, 0x13, 0xb0, 0x35, 0x39, 0x13, 0xd8, 0x3b, 0xe2, 0xda, 
+	0x3b, 0x38, 0x8a, 0x7, 0xad, 0x5d, 0x23, 0xbb, 0x86, 0x87, 
+	0x2a, 0x8d, 0x10, 0x50, 0x9a, 0x1d, 0xfb, 0x5b, 0x9c, 0xec, 
+	0x76, 0xe9, 0xe, 0x86, 0xe2, 0x50, 0x1, 0x73, 0x24, 0x53, 
+	0x57, 0x83, 0x30, 0x67, 0x2a, 0x76, 0x56, 0x5f, 0xae, 0x52, 
+	0x80, 0x65, 0x52, 0xe3, 0x77, 0x60, 0xdb, 0x4e, 0x77, 0xc0, 
+	0x4, 0x82, 0xb1, 0x3f, 0x96, 0x14, 0xbb, 0x86, 0x88, 0x46, 
+	0x52, 0x5f, 0x27, 0x32, 0x6, 0x4b, 0x90, 0x33, 0x11, 0x3b, 
+	0x68, 0xd7, 0x80, 0xbd, 0x73, 0x9b, 0x9f, 0x44, 0x55, 0x76, 
+	0x60, 0xdb, 0xc6, 0xde, 0x99, 0x32, 0x6a, 0xc6, 0xfe, 0x12, 
+	0x64, 0xe7, 0x59, 0xba, 0x13, 0x10, 0x55, 0xcc, 0xcb, 0x19, 
+	0x9b, 0xdd, 00, 0xed, 0x3f, 0x16, 0xd4, 0x7f, 0x6c, 0x79, 
+	0x35, 0x62, 0x3f, 0x76, 0x4b, 0xf3, 0xef, 0x30, 0x35, 0x24, 
+	0x64, 0x87, 0xec, 0x90, 0x1d, 0xb2, 0xab, 0x61, 0xc7, 0x30, 
+	0xd5, 0xcf, 0x72, 0x47, 0x76, 0xc8, 0xe, 0xeb, 0x4c, 0xac, 
+	0x33, 0x91, 0x1d, 0xb2, 0x43, 0x76, 0xc8, 0xe, 0xd9, 0x21, 
+	0xbb, 0xb9, 0xd9, 0xcd, 0x35, 0xe7, 0x1, 0xd3, 00, 0xec, 
+	0xe0, 0x5c, 0xbf, 0xd5, 0x14, 0xf7, 0xdf, 0x21, 0x9f, 0x61, 
+	0xd9, 0xad, 0xea, 0x9f, 0x22, 0xbb, 0xc5, 0xb3, 0x5b, 0x35, 
+	0x65, 0x20, 0xbb, 0xa5, 0xb3, 0x5b, 0x35, 0xe6, 0x20, 0xbb, 
+	0x24, 0xec, 0xdd, 0x9, 0x68, 0xa2, 0x20, 0xbb, 0x54, 0xd8, 
+	0xc1, 0xe8, 0x6f, 0x2b, 0xf7, 0xf6, 0x12, 0x64, 0x87, 0x6d, 
+	0x15, 0x64, 0x37, 0x92, 0x7f, 0x37, 0x71, 0x4c, 0x2a, 0x64, 
+	0x37, 0xac, 0xee, 0x56, 0xd, 0xcf, 0x91, 0xdd, 0xf2, 0x75, 
+	0xb7, 0x72, 0xc3, 0x9e, 0xa2, 0xee, 0x90, 0x1d, 0xb2, 0xc3, 
+	0x3a, 0x13, 0xd9, 0xed, 0x6a, 0xab, 0xd4, 0xec, 0x21, 0xbb, 
+	0x44, 0x7c, 0x4, 0x5b, 0x7b, 0xee, 0xa5, 0xee, 0x4a, 0x42, 
+	0x48, 0xdd, 0xad, 0x8d, 0x84, 0x24, 0xef, 0x9b, 0xaf, 0xa0, 
+	0x9f, 0xbe, 0x67, 0xec, 0xca, 0xa, 0xcf, 0x6, 0x5c, 0x49, 
+	0x9a, 0x5e, 0xd4, 0x1c, 0xcb, 0x4, 0x75, 0xe7, 0x86, 0xf8, 
+	0xde, 0x33, 0x76, 0xa5, 0x40, 0x52, 0x21, 0xaa, 0xf0, 0x55, 
+	0x4f, 0xcc, 0x96, 0xa8, 0x17, 0x4c, 0x4e, 0x99, 0x18, 0xbb, 
+	0x95, 0x17, 0x5d, 0x65, 0xdf, 0xd8, 0x49, 0x20, 0x44, 0x54, 
+	0x8f, 0xa4, 0xac, 0x74, 0x6, 0xb7, 0x92, 0x9d, 0xda, 0x2f, 
+	0x49, 0x6a, 0xba, 0x33, 0xf5, 0xe5, 0x6a, 0x2f, 0xc7, 0x80, 
+	0x8c, 0xee, 0x36, 0x64, 0x8, 0xf7, 0x1f, 0x8a, 0x9d, 0xd0, 
+	0x60, 0x7a, 0xba, 0x33, 0x91, 0x18, 0x8d, 0xa5, 0xdb, 0x5f, 
+	0x7b, 0xb7, 0x45, 0x77, 0xe9, 0xda, 0x3b, 0x67, 0x9e, 0xca, 
+	0xfe, 0xb6, 0x33, 0xb7, 0xd8, 0xbb, 0x14, 0xfd, 0x3b, 0xa8, 
+	0xb8, 0xd5, 0xc9, 0x21, 0xcd, 0x35, 0x2a, 0xcb, 0x65, 0xf9, 
+	0x7, 0xb1, 0xec, 0x7c, 0x84, 0x7b, 0x3b, 0xc7, 0xaf, 0xc9, 
+	0xbf, 0xe3, 0xb, 0xf6, 0xef, 0xb8, 0xbd, 0xe1, 0xf5, 0x24, 
+	0x36, 0x4a, 0xc7, 0x3e, 0xb1, 0x6b, 0xf2, 0xef, 0x78, 0xb9, 
+	0x60, 0x76, 0xc, 0xb0, 0x63, 0x7, 0xcd, 0xce, 0x10, 0x94, 
+	0xf6, 0x8e, 0x8, 0x23, 0x47, 0xb4, 0xbd, 0x23, 0xda, 0xe, 
+	0x2e, 0x87, 0x1d, 0xe3, 0xf2, 0x9f, 0xbd, 0xa3, 0x5c, 0xe7, 
+	0xdb, 0x78, 0xe, 0x32, 0xee, 0x8a, 0x8c, 0xc1, 0x2, 0x73, 
+	0xf6, 0xb1, 0xad, 0x52, 0xf9, 0x1, 0xaa, 0x9d, 0x29, 0x40, 
+	0x95, 0xc0, 0xbf, 0x23, 0xf3, 0x5b, 0xc0, 0x1a, 0x76, 0x30, 
+	0xb6, 0x83, 0xd6, 0x20, 0x88, 0xa6, 0x22, 0x90, 0x8a, 0x23, 
+	0x9d, 0x9c, 0x3d, 0x6b, 0xab, 0x48, 0x3c, 0x44, 0x7b, 0x73, 
+	0x4a, 0x63, 0x44, 0x7b, 0xee, 0x3a, 0x7f, 0x41, 0x6d, 0x15, 
+	0x5, 0x8f, 0x9b, 0xb0, 0x2a, 0x27, 0x20, 0xda, 0x83, 0xca, 
+	0x67, 0xa, 0x27, 0x77, 0x73, 0xf6, 0xd0, 0xde, 0x95, 0xb2, 
+	0xb6, 0x2c, 0x6d, 0x23, 0xc5, 0xd5, 0xdd, 0xc2, 0xda, 0x99, 
+	0x5c, 0x44, 0xa3, 0xb2, 0x2a, 0xd3, 0xf0, 0x40, 0x44, 0x23, 
+	0x43, 0xd9, 0xcd, 0xd9, 0xc7, 0x76, 0x26, 0x31, 0xde, 0x1c, 
+	0x64, 0x67, 0xec, 0xdd, 0x2, 0xd9, 0xc1, 0xa8, 0x29, 0x26, 
+	0x4a, 0x95, 0x8d, 0xa6, 0x2, 0xa2, 0xb0, 0xc0, 0x9c, 0x3, 
+	0x1a, 0xbf, 0x5b, 0x8a, 0xaf, 0x87, 0xf7, 0x70, 0xa5, 0x9b, 
+	0x90, 0x1d, 0xb2, 0x43, 0x76, 0xc8, 0xe, 0xd9, 0x21, 0x3b, 
+	0x64, 0x87, 0xec, 0x90, 0x1d, 0xb2, 0x43, 0x76, 0x98, 0x92, 
+	0x64, 0x47, 0xec, 0xac, 0x11, 0x93, 0xb5, 0xfb, 0xeb, 0x65, 
+	0x9b, 0x54, 0x6c, 0xfe, 0xc8, 0x7d, 0x9d, 0x19, 0x7f, 0x99, 
+	0xa, 0x59, 0xce, 0x40, 0x29, 0xab, 0xa, 0xe4, 0xad, 0xce, 
+	0x26, 0x1b, 0x86, 0x1d, 0x6d, 0x48, 0x53, 0xb1, 0x2b, 0x39, 
+	0x71, 0x66, 0xf8, 0xb4, 0x99, 0xed, 0xb3, 0xb9, 0xe0, 0xd5, 
+	0x55, 0x2a, 0xe4, 0xf5, 0xd7, 0x1c, 0x3a, 0x5c, 0xed, 0xa2, 
+	0xd3, 0xdb, 0x1a, 0x81, 0x14, 0xe6, 0x97, 0x50, 0x6c, 0xff, 
+	0x4d, 0x14, 0x3, 0xb1, 0x53, 0xef, 0x30, 0x49, 0x3d, 0x9f, 
+	0x88, 0x5d, 0x35, 0x24, 0xc3, 0x65, 0xe7, 0xbd, 0x1a, 0x53, 
+	0x6b, 0xd1, 0xa3, 0x28, 0xaf, 0xb9, 0x52, 0x5c, 0xa6, 0x15, 
+	0x24, 0xb6, 0x95, 0x1c, 0x8b, 0x2c, 0x6b, 0xad, 0x94, 0xcd, 
+	0x65, 0x94, 0xc7, 0xab, 0x87, 0x2c, 0x41, 0x6c, 0xa3, 0x4b, 
+	0x93, 0xc0, 0x74, 0x9, 0x5c, 0x97, 0x10, 0x9e, 0x5b, 0x36, 
+	0x94, 0xee, 0x38, 0x44, 0xa6, 0x21, 0x4e, 0xcb, 0x4e, 0xcd, 
+	0xc1, 0x2b, 0xcb, 0x96, 0xb3, 0xec, 0x64, 0x9d, 0x59, 00, 
+	0x76, 0x59, 0x51, 0x3d, 0x53, 0xdb, 0xd6, 0xf5, 0xa0, 0xbc, 
+	0x8c, 0xf2, 0x78, 0xc5, 0xe, 0x96, 0x13, 0x5b, 0x9a, 0x3c, 
+	0x52, 0xbc, 0x4b, 0x61, 0x6c, 0x28, 0xad, 0xc8, 0x86, 0xd3, 
+	0x1d, 0xa5, 0x16, 0x9a, 0x7e, 0x36, 0x11, 0x3b, 0xd9, 0x73, 
+	0xf, 0x66, 0x48, 0xb6, 0xb2, 0x77, 0x12, 0x1c, 0x64, 0xa7, 
+	0x55, 0x23, 0xae, 0x52, 0x9c, 0x85, 0x92, 0xc7, 0x67, 0xe1, 
+	0x23, 0xb6, 0xb4, 0xc2, 0xaa, 0x4c, 0xdb, 0xe2, 0xcc, 0x2f, 
+	0xb3, 0x18, 0xd4, 0xde, 0x71, 0x41, 0x4c, 0x6e, 0xb8, 0xa1, 
+	0x37, 0x19, 0x3b, 0x6e, 0x6, 0x41, 0xd5, 0xd8, 0x59, 0x7b, 
+	0x7b, 0x57, 0xa7, 0xbb, 0xa8, 0x46, 0x8b, 0xaa, 0x7b, 0x39, 
+	0xaf, 0xd7, 0x48, 0x6c, 0x69, 0x42, 0x6d, 0xf2, 0xbd, 0x5c, 
+	0xeb, 0xce, 0x2f, 0x99, 0xf, 0xcd, 0x8e, 0xeb, 0xff, 0xd4, 
+	0x3c, 0x9b, 0x8e, 0x5d, 0xa9, 0xfe, 0xeb, 0xb1, 0xb3, 0x16, 
+	0x43, 0x31, 0xb0, 0x9d, 0xe9, 0xd9, 0xbb, 0xa8, 0xab, 0x2d, 
+	0xdb, 0x99, 0x19, 0xb7, 0x25, 0x78, 0xf6, 0x2e, 0x92, 0x5d, 
+	0xf5, 0x4b, 0x28, 0xb4, 0xa9, 0xe3, 0xba, 0x4, 0xc7, 0xde, 
+	0xd, 0xdd, 0xce, 0x84, 0x2d, 0x15, 0xaa, 0x9f, 0x1f, 0xa6, 
+	0x7f, 0xa7, 0xea, 0xcf, 0x62, 0xd0, 0x42, 0x8b, 0xa8, 0xc6, 
+	0x6c, 0x24, 0x3b, 0x59, 0x51, 0xca, 0x87, 0x12, 0x1f, 0x45, 
+	0xdf, 0x7c, 0xf9, 0xbe, 0x79, 0x28, 0x3b, 0x99, 0x83, 0xec, 
+	0x92, 0x60, 0xa7, 0x65, 0xe7, 0x8, 0xf, 0xd9, 0xa5, 0xc2, 
+	0x4e, 0xd6, 0x9c, 0x66, 0x7, 0xd9, 0xa5, 0xc3, 0x2e, 0xa8, 
+	0x34, 0x91, 0x5d, 0x32, 0xf6, 0xe, 0xd4, 0x99, 0x1c, 0x75, 
+	0x87, 0x75, 0x26, 0xb2, 0xc3, 0x3a, 0xf3, 0xe0, 0xd8, 0xc1, 
+	0x71, 0x9c, 0x36, 0x3e, 0x2, 0x7, 0x3e, 0x1e, 0xfa, 0x8, 
+	0xf3, 0xb2, 0x6b, 0x3f, 0xba, 0x4a, 0x9d, 0x4a, 0x93, 0x6b, 
+	0xd9, 0x21, 0xbb, 0x44, 0xd8, 0xd9, 0xee, 0x4c, 0xdb, 0x33, 
+	0x8d, 0xec, 0x12, 0x60, 0xc7, 0xfd, 0x9e, 0x95, 0x29, 0xfb, 
+	0xa2, 0x31, 0xf5, 0x65, 0xa7, 0xbb, 0x32, 0xc1, 0x78, 0x10, 
+	0xb2, 0x4b, 0x82, 0x9d, 0x19, 0xb4, 0x33, 0x63, 0xaf, 0x94, 
+	0x23, 0xbb, 0x64, 0x74, 0x37, 0xdb, 0x9c, 0x7, 0x4c, 0x3d, 
+	0x75, 0xc7, 0x7d, 0x7b, 0xc7, 0x51, 0x77, 0xa9, 0xb4, 0x33, 
+	0x67, 0x9c, 0xe3, 0x27, 0xd7, 0x64, 0x67, 0x84, 0xf8, 0x4b, 
+	0xd2, 0x13, 0xbb, 0x25, 0x30, 0x27, 0xf9, 0x64, 0xd6, 0xa0, 
+	0xdf, 0xc1, 0xce, 0x74, 0x73, 0x51, 0xb7, 0xf7, 0x84, 0xd3, 
+	0xb6, 0x69, 0x1a, 0x76, 0x1b, 0x70, 0xcc, 0x45, 0xc3, 0x24, 
+	0x4b, 0x6, 0xa0, 0xb1, 0x3, 0x63, 0x97, 0x3, 0x76, 0x39, 
+	0x60, 0x97, 0x2f, 0x8c, 0x9d, 0xe2, 0x55, 0x1, 0x23, 0x7a, 
+	0x5b, 0xe5, 0x2b, 0xdd, 0x55, 0x60, 0xc9, 0x81, 0xe9, 0x2e, 
+	0xe7, 0xf2, 0x5f, 0xc5, 0x8a, 0x73, 0x4b, 0x4c, 0xee, 0x57, 
+	0x2f, 0x50, 0xaa, 0x5e, 0xcd, 0xab, 0xbd, 0x9c, 0xc3, 0x9c, 
+	0x6a, 0x7f, 0x4a, 0x76, 0x84, 0x9, 0x46, 0x62, 0x2b, 0x75, 
+	0x27, 0xc5, 0x48, 0xc4, 0x13, 0x76, 0x90, 0xec, 0x78, 0x9e, 
+	0x57, 0xde, 0xb6, 0xd8, 0x6a, 0xdd, 0x89, 0x1c, 0x29, 0x4b, 
+	0xb1, 0x6f, 0x8e, 0xf4, 0x5e, 0x9d, 0x94, 0x1d, 0x78, 0x38, 
+	0xf6, 0x8e, 0xb0, 0x3, 0xb4, 0x77, 0x1a, 0x9, 0x98, 0x42, 
+	0xa4, 0xed, 0x1d, 0xd7, 0x35, 0xa7, 0xdc, 0xf7, 0x14, 0x6a, 
+	0x5e, 0x9d, 0xd2, 0xde, 0x29, 0xdd, 0x99, 0x2c, 0xc3, 0x4e, 
+	0x8a, 0xf0, 0xd0, 0xd8, 0x55, 0x35, 0x1f, 0x85, 0x6a, 0x72, 
+	0x74, 0x7, 0xf6, 0x25, 0x3c, 0xaa, 0x15, 0x6a, 0xcc, 0xe4, 
+	0x94, 0xed, 0x4c, 0x65, 0xef, 0x74, 0x16, 0x68, 0x67, 0x32, 
+	0x72, 0xa8, 0xec, 0x72, 0xdd, 0x73, 0xe2, 0xdb, 0x3b, 0xb1, 
+	0x9f, 0xab, 0x7c, 0x41, 0x99, 0x4b, 0xbb, 0xc7, 0x27, 0x66, 
+	0x77, 0x48, 0xa9, 0x3d, 0xbb, 0xbe, 0x69, 0x9, 0xbe, 0x79, 
+	0x8d, 0xf7, 0x27, 0xaf, 0x2, 0xd9, 0x75, 0x8d, 0xea, 0x9f, 
+	0x98, 0xe4, 0x4c, 0x9e, 0x6f, 0x3a, 0x8c, 0xb4, 0xfa, 0x80, 
+	0xfa, 0x32, 0xc7, 0xf6, 0xcd, 0x17, 0x7d, 0xdf, 0x6b, 0xb9, 
+	0x49, 0x35, 0xde, 0x9f, 0xf6, 0x1, 0x5b, 0xb3, 0xab, 0xf5, 
+	0xd, 0x8b, 0x12, 0x7e, 0x4a, 0x23, 0xbb, 0x6, 0xbf, 0x92, 
+	0xd5, 0xbe, 0x50, 0x20, 0x3b, 0xc3, 0x4e, 0x5f, 0x51, 0x6d, 
+	0xd, 0xcd, 0xd6, 0x58, 0x40, 0xe3, 0x15, 0x12, 0x9d, 0x2f, 
+	0xb7, 0xda, 0x2b, 0x94, 0xaf, 0x4a, 0x9d, 0x82, 0xf7, 0x3a, 
+	0xec, 00, 0x6f, 0xef, 0x18, 0xfd, 0x2e, 0x99, 0xbf, 0x69, 
+	0x35, 0xc1, 0x7c, 0xdb, 0x36, 0x66, 0x41, 0x99, 0xc8, 0xae, 
+	0x34, 0x57, 0xd4, 0xf1, 0xfe, 0xe4, 0x56, 0xb7, 0x42, 0xad, 
+	0xfe, 0x36, 0xfb, 0x60, 0x2b, 0xaf, 0xb6, 0xf4, 0x16, 0x7d, 
+	0xff, 0xb1, 0x91, 0x9d, 0x77, 0x8c, 0xd9, 0x97, 0xf9, 0x40, 
+	0x6b, 0xa6, 0xf1, 0xeb, 0xe4, 0x23, 0xbb, 0x80, 0x5d, 0xe5, 
+	0x41, 0xac, 0xfd, 0x87, 0xf6, 0xfe, 0xac, 0x16, 0xa0, 0x36, 
+	0x9, 0xb8, 0xb6, 0xa6, 0x5f, 0xd4, 0xbe, 0x37, 0x60, 0x47, 
+	0x54, 0x8b, 0x96, 0x38, 0xc7, 0xe8, 0x7d, 0x95, 0xcf, 0xfc, 
+	0x4a, 0x59, 0xeb, 0xe, 0xeb, 0xcc, 0x6, 0x76, 0xd0, 0xfb, 
+	0xab, 0xd3, 0x1d, 0x30, 0x42, 0x40, 0x23, 0xc, 0x78, 0x1c, 
+	0xce, 0x75, 0xae, 0xd7, 0x5d, 0xf8, 0x29, 0x90, 0x9d, 0xf1, 
+	0x3d, 0x3d, 0x43, 0xe8, 0xe7, 0x23, 0x3b, 0x97, 0x1d, 0xf4, 
+	0xfe, 0x6a, 0xed, 0xdd, 0xda, 0xb5, 0x4d, 0x6a, 0xbb, 0x66, 
+	0xa4, 0x8e, 0x9d, 0x7a, 0x6f, 0xb1, 0x49, 0x65, 0xed, 0xa7, 
+	0x10, 0xcf, 0xde, 0x41, 0xdd, 0x5, 0x4d, 0x25, 0x27, 0x1f, 
+	0x96, 0x89, 0xec, 0x9a, 0x1a, 0x91, 0xac, 0x47, 0xef, 0xa6, 
+	0x78, 0x6f, 0x29, 0x52, 0xe3, 0xa7, 0x74, 0x2a, 0xdf, 0x29, 
+	0x13, 0xd9, 0x45, 0xa7, 0xac, 0xe7, 0x1b, 0xb2, 0x5e, 0x85, 
+	0x4d, 0x3d, 0xf6, 0xba, 0x57, 0xec, 0x8a, 0xd8, 0x3b, 0x56, 
+	0x8b, 0x6d, 0xec, 0x8a, 0xc5, 0xb3, 0x93, 0x2b, 0xc8, 0xac, 
+	0x56, 0x76, 0x2d, 0x99, 0x55, 0xb2, 0x6b, 0x86, 0x66, 0xf2, 
+	0xae, 0x7c, 0x6e, 0xc2, 0x61, 0xc0, 0x48, 0x29, 0x4e, 0xbc, 
+	0x14, 0x10, 0xf9, 0x44, 0x53, 0x94, 0x31, 0x19, 0xa, 0x70, 
+	0xd7, 0xb9, 0x28, 0x32, 0x38, 0x72, 0x49, 0xec, 0xec, 0x8a, 
+	0x32, 0xa9, 0xaf, 0xe5, 0x54, 0x88, 0x30, 0x19, 0x85, 0xa, 
+	0x96, 0x51, 0x6c, 0x8b, 0x97, 0x2, 0x72, 0x34, 0x76, 0x19, 
+	0x93, 0x41, 0xf2, 0x2d, 0x4c, 0x80, 0xa9, 0x2c, 0x38, 0x72, 
+	0x59, 0xba, 0x73, 0x65, 0x97, 0x6e, 0x9d, 0x99, 0xe9, 0x90, 
+	0x28, 0x99, 0xd5, 0x91, 0x7a, 0x14, 0x6e, 0xbc, 0x14, 0xf8, 
+	0xaa, 0xd1, 0x5d, 0xc1, 0x9d, 0x38, 0x39, 0x4e, 0xe4, 0x96, 
+	0xe9, 0xac, 0x5f, 0xac, 0xee, 0x7c, 0xd9, 0x25, 0xaa, 0x3b, 
+	0x1d, 0x67, 0xcc, 0x6a, 0xc7, 0x8b, 0x56, 0x64, 0x2c, 0x5a, 
+	0x8d, 0x9a, 0x54, 0x8e, 0x8a, 0xa4, 0xe1, 0xb3, 0x5b, 0xae, 
+	0xee, 0x56, 0x7b, 0xa2, 0x3b, 0xf0, 0x1f, 0x2a, 0xab, 0x8, 
+	0xe2, 0xa5, 0x98, 0x98, 0x27, 0x19, 0xd0, 0x6c, 0x61, 0xec, 
+	0x5d, 0xc0, 0x6e, 0xc1, 0xf6, 0xae, 0x9, 0x1d, 0xce, 0xcf, 
+	0x74, 0x54, 0xb9, 0x40, 0xdd, 0x1, 0xd9, 0xd9, 0xa6, 0x66, 
+	0x2c, 0xbb, 0x6a, 00, 0x37, 0xaf, 0xfe, 0x54, 0x74, 0xaa, 
+	0xa4, 0x51, 0x89, 0x1c, 0xb5, 0x15, 0x7f, 0xe6, 0x60, 0x97, 
+	0xd5, 0x66, 0x64, 0x6e, 0x4, 0xce, 0xf9, 0x7c, 0xba, 0x1e, 
+	0xba, 0x5b, 0x41, 0x5f, 0xa1, 0xa3, 0xee, 0x36, 0xe0, 0x4, 
+	0x18, 0xcd, 0x28, 0x37, 0x32, 0xa3, 0x76, 0x9b, 0xd3, 0x85, 
+	0xb0, 0x2b, 0x40, 0x3c, 0x3d, 0x47, 0x51, 0x45, 0x72, 0xec, 
+	0x56, 0x60, 0x85, 0xec, 0xee, 0x75, 0x66, 0xc5, 0x4e, 0xab, 
+	0xcc, 0xa0, 0x83, 0xba, 0xdb, 0x64, 0xcf, 0xc8, 0xe, 0x7a, 
+	0x6a, 0xca, 0x7c, 0xc1, 0x68, 0x72, 0x4d, 0x3e, 0x5d, 0x64, 
+	0x14, 0xcd, 0x89, 0xd9, 0x35, 0xb6, 0x54, 0xe2, 0xd8, 0x49, 
+	0x60, 0x4a, 0x65, 00, 0x1e, 0x35, 0x5b, 0x9a, 0x57, 0xc7, 
+	0xcc, 0xc6, 0xe, 0xb4, 0x36, 0xb, 0x13, 0x78, 0x91, 0x3b, 
+	0x91, 00, 0x6b, 0x7c, 0xba, 0xc8, 0x28, 0x9a, 0x49, 0xb2, 
+	0x53, 0x5a, 0xa3, 0x50, 0x6d, 0x3e, 0x3b, 0x61, 0x7, 0x67, 
+	0x63, 0x7, 0xda, 0x9c, 0x90, 0x1a, 0x6c, 0x4f, 0x86, 0x3e, 
+	0x5d, 0x11, 0x19, 0x45, 0x73, 0xe2, 0xfe, 0xcc, 0x66, 0x74, 
+	0x51, 0x6d, 0x95, 0x1c, 0xe8, 0xab, 0x9e, 0x9d, 0x3c, 0x6a, 
+	0x5e, 0x76, 0x1c, 0xc4, 0xb7, 0xdc, 0xc1, 0x2e, 0x8c, 0x7b, 
+	0xb9, 0x38, 0x76, 0xab, 0x41, 0xd8, 0xe9, 0xb6, 0x25, 0xb5, 
+	0x6d, 0x4e, 0x87, 0x1a, 0x35, 0x20, 0xe7, 0x65, 0x97, 0xc1, 
+	0xb0, 0xbf, 0x5b, 0xd9, 0x41, 0x1f, 0x70, 0xf1, 0xec, 0x6a, 
+	0xf8, 0x1d, 0xb4, 0x7f, 0x37, 0x9d, 0x4f, 0xd7, 0x6b, 0xc, 
+	0xa8, 0x7f, 0xbf, 0xca, 0x92, 0xfd, 0xbb, 0x70, 0x1d, 0x84, 
+	0x6c, 0xbb, 0x2f, 0x31, 0xa7, 0x97, 0x37, 0x43, 0x9f, 0xd8, 
+	0x92, 0xfd, 0xbb, 0x70, 0x1d, 0x84, 0xed, 0xec, 0x8a, 0xac, 
+	0x48, 0x84, 0x9d, 0x57, 0x6d, 0xee, 0xa1, 0x7f, 0xa7, 0x1a, 
+	0x26, 0x70, 0x85, 0x2, 0x6e, 0x47, 0xfa, 0x8a, 0x30, 0x3f, 
+	0xcb, 0xe6, 0xe8, 0xc9, 0xec, 0x38, 0x6, 0x64, 0xf0, 0xed, 
+	0xa5, 0x7f, 0xa7, 0x62, 0x7a, 0x3, 0x4f, 0x4d, 0xc7, 0xc3, 
+	0x2f, 0x9a, 0xf2, 0xe7, 0x18, 0x41, 0xe8, 0x3b, 0xf6, 0xba, 
+	0xda, 0x4f, 0xff, 0x4e, 0xc5, 0xd2, 0xcf, 0xac, 0x6, 0x55, 
+	0x50, 0x6f, 0x6f, 0x1d, 0x84, 0xc, 0xf8, 0xe, 0x93, 0x8f, 
+	0xdc, 0x75, 0xd2, 0xdd, 0xaa, 0xd1, 0x51, 0xd8, 0xf, 0xff, 
+	0x4e, 0xad, 0x83, 00, 0x3c, 0xb5, 0x4c, 0x77, 0x68, 0x16, 
+	0xfe, 0xb8, 0x9e, 0x92, 0x1f, 0x9f, 0x61, 0xc4, 0xbc, 0xa3, 
+	0xee, 0x3c, 0xe1, 0xad, 0xf6, 0xcb, 0xbf, 0x53, 0x75, 0xa6, 
+	0xb3, 0xa8, 0x82, 0x75, 0xf0, 0xe0, 0xb8, 0x5e, 0xa6, 0x17, 
+	0x36, 0xa8, 0x1d, 0xe3, 0x5b, 0xa4, 0xee, 0x74, 0x5f, 0x74, 
+	0xa0, 0xbd, 0x7d, 0xf2, 0xef, 0xa2, 0x1b, 0x8f, 0xa0, 0x3f, 
+	0x73, 0xc9, 0xfe, 0x5d, 0xff, 0x39, 0x7e, 0xdd, 0xfc, 0xbb, 
+	0x92, 0xc8, 0x55, 0xd4, 0xb6, 0x25, 0x2, 0xb6, 0x3b, 0xe, 
+	0x6a, 0xb5, 0x9a, 0x50, 0x9b, 0x62, 0x5a, 0x97, 0x5c, 0xd6, 
+	0x2f, 0x1b, 0x26, 0xbf, 0x57, 0xbb, 0xf, 0xd8, 0xcd, 0x8e, 
+	0x9b, 0x8d, 0xf9, 0x23, 0xf7, 0xb9, 0x9f, 0xc5, 0x27, 0xf4, 
+	0xef, 0x36, 0x5f, 0xb0, 0x5a, 0x43, 0x6d, 0xfb, 0xf5, 0x6c, 
+	0xb3, 0x4c, 0x50, 0xa9, 0xaf, 0xd9, 0xe0, 0xec, 0xb6, 0x96, 
+	0xdc, 0xb4, 0x6a, 0x98, 0xfc, 0x5e, 0xcd, 0xe7, 0x19, 0xc9, 
+	0x8e, 0x1, 0x76, 0xcc, 0xe6, 0x33, 0x99, 0xc7, 0xfa, 0xb2, 
+	0xeb, 0xe6, 0xdf, 0x29, 0x2e, 0xe2, 0x8b, 0x12, 0x2f, 0xbf, 
+	0x5a, 0x5e, 0x4d, 0xad, 0x88, 0x67, 0xb6, 0x30, 0xc7, 0xfe, 
+	0xc2, 0xe5, 0x82, 0x50, 0x7a, 0x5f, 0x1d, 0x3, 0x14, 0x51, 
+	0x73, 0xbc, 0xb8, 0xb6, 0xa5, 0x5b, 0x32, 0xd1, 0x67, 0xc2, 
+	0x61, 0xce, 0xae, 0x92, 0xb9, 0xce, 0x81, 0x9f, 0x62, 0x7e, 
+	0x6f, 0xf6, 0x53, 0xca, 0xfa, 0xd2, 0xda, 0xb0, 0x63, 0x5c, 
+	0xfe, 0xab, 0xb8, 0x71, 0xe, 0xe8, 0x71, 0xab, 0x3e, 0x99, 
+	0xcf, 0x5, 0xcf, 0xcd, 0x91, 0x7c, 0x7c, 0xff, 0x4e, 0xd5, 
+	0x99, 0xc1, 0xcf, 0xb7, 0x24, 0x92, 0x9c, 0x60, 0xda, 0xb0, 
+	0xd5, 0x57, 0xa9, 0x34, 0xaa, 0x70, 0x8e, 0x1, 0x45, 0xd6, 
+	0x1d, 0x5f, 0x8a, 0xcf, 0x75, 0xca, 0x94, 0x14, 0xc4, 0xcb, 
+	0x36, 0x67, 0x7b, 0xc9, 0x6a, 0xe5, 0x3e, 0xb0, 0x7e, 0x1f, 
+	0xfc, 0x5e, 0xce, 0xa7, 0x90, 0xfa, 0xd2, 0xda, 0xb3, 0xe3, 
+	0xac, 0xe2, 0x22, 0xb7, 0x90, 0x9d, 0x7c, 0xae, 0x5f, 0x15, 
+	0x4, 0x19, 0x9b, 0xc6, 0xbf, 0x13, 0xeb, 0x4e, 0x96, 0xbc, 
+	0x96, 0x1d, 0xb1, 0xeb, 0xc1, 0xaa, 0x7, 0xf1, 0x57, 0x88, 
+	0x55, 0xbf, 0x5e, 0xa2, 0x6a, 0x3c, 0xfb, 0x28, 0x9d, 0x9a, 
+	0x30, 0x38, 0xbe, 0xf4, 0x4a, 0xd3, 0x1a, 0x2c, 0x7d, 0x5d, 
+	0x6c, 0x2d, 0x59, 0xbd, 0x5a, 0xfa, 0x9f, 0xa2, 0x30, 0xc1, 
+	0x4f, 0x29, 0xc1, 0xf1, 0xe0, 0xbb, 0xb4, 0x6a, 0xab, 0x28, 
+	0x78, 0x95, 0x9a, 0x38, 0xac, 0x18, 0xb9, 0x63, 0xe, 0xab, 
+	0x87, 0x10, 0xa5, 0x54, 0xe8, 0xd8, 0xfe, 0x9d, 0xb2, 0x77, 
+	0x65, 0x3, 0xbc, 0xb2, 0xe4, 0xbc, 0x4e, 0x1d, 0xf0, 0x2a, 
+	0xc9, 0x5f, 0x6f, 0xa8, 0xe, 0xe7, 0x53, 0x4a, 0xff, 0xf8, 
+	0x52, 0xd6, 0x63, 0xa0, 0x34, 0xf5, 0x5e, 0x95, 0x4f, 0xda, 
+	0x95, 0x6c, 0x58, 0x78, 0x67, 0xa5, 0xec, 0x9d, 0xfb, 0x29, 
+	0x3c, 0x28, 0xad, 0x75, 0x3b, 0x73, 0x43, 0x4e, 0xa9, 0x29, 
+	0xd4, 0x9d, 0xc3, 0x8e, 0x49, 0x78, 0x8c, 0x8f, 0xef, 0xdf, 
+	0xe9, 0x76, 0x66, 0x70, 0x4d, 0xb8, 0x5c, 0x4b, 0x94, 0xf0, 
+	0xc0, 0xde, 0xf9, 0x57, 0x9, 0xa8, 0xc3, 0xb1, 0x4a, 0xb0, 
+	0x2c, 0x68, 0x89, 0x88, 0x51, 0x89, 0x53, 0x9a, 0xfa, 0x14, 
+	0x75, 0xc9, 0x81, 0xfd, 0xda, 0x5a, 0x72, 0x13, 0xbb, 0x12, 
+	0xbc, 0xb9, 0x84, 0xcb, 0x69, 0xba, 0xa5, 0x45, 0xb1, 0x63, 
+	0xc2, 0xb0, 0x85, 0xf6, 0xce, 0x61, 0x27, 0x6a, 0x50, 0x1e, 
+	0xa9, 0xbb, 0x25, 0xfb, 0x77, 0xa4, 0xe4, 0xcb, 0x4a, 0xe5, 
+	0x96, 0xf6, 0xf0, 0xc1, 0xde, 0x7f, 0xb7, 0x7, 0x9, 0xd9, 
+	0x21, 0x3b, 0x64, 0x87, 0xec, 0x90, 0x1d, 0xb2, 0x43, 0x76, 
+	0xc8, 0xe, 0xd9, 0x21, 0xbb, 0xf4, 0xd9, 0xc5, 0x26, 0xe4, 
+	0xb3, 0x18, 0x76, 0xb1, 0x9, 0xd9, 0x21, 0x3b, 0x64, 0xe7, 
+	0x4e, 0x69, 0xf7, 0xa7, 0x1c, 0x21, 0xbb, 0x65, 0xb3, 0x53, 
+	0x37, 0x2e, 0xdb, 0x5b, 0x98, 0x23, 0xef, 0x59, 0x46, 0x76, 
+	0x73, 0xb2, 0x5b, 0xd9, 0xb9, 0xd1, 0x8a, 0x1e, 0xb2, 0x4b, 
+	0x84, 0x9d, 0x3f, 0x29, 0xb3, 0x9a, 0x30, 0x86, 0xec, 0x12, 
+	0x61, 0xe7, 0xdf, 0x90, 0x80, 0xec, 0x92, 0x69, 0xab, 0x6c, 
+	0xc9, 0x43, 0x76, 0x4b, 0x67, 0x17, 0x34, 0x32, 0x91, 0x5d, 
+	0x42, 0xed, 0xcc, 0xa6, 0x4c, 0x64, 0xb7, 0xf8, 0xb6, 0x4a, 
+	0x28, 0x3c, 0x64, 0x87, 0xba, 0x43, 0x76, 0x53, 0xea, 0xe, 
+	0xd9, 0x25, 0xac, 0x3b, 0xec, 0x13, 0x4b, 0x53, 0x77, 0xfe, 
+	0xbd, 0xcb, 0xc8, 0x2e, 0x21, 0xdd, 0x61, 0x5f, 0x74, 0x72, 
+	0xfd, 0x99, 0x9e, 0xea, 0x90, 0x5d, 0x7a, 0xfd, 0x2a, 0xa6, 
+	0x37, 0x1a, 0xd9, 0x25, 0xc3, 0xe, 0xc8, 0xe, 0xfb, 0xc4, 
+	0x52, 0xeb, 0x8b, 0x76, 0x64, 0x87, 0xec, 0x52, 0x6a, 0x67, 
+	0x82, 0x50, 0x1, 0xc8, 0x2e, 0xb5, 0xb6, 0x8a, 0xeb, 0xd9, 
+	0xa1, 0xbd, 0x4b, 0xc9, 0x47, 0x58, 0x79, 0xd1, 0x8d, 0x90, 
+	0x5d, 0x22, 0x6d, 0x15, 0x9c, 0x6b, 0x94, 0x2a, 0x3b, 0x9c, 
+	0xe3, 0xb7, 0x48, 0x76, 0x9c, 0xd7, 0x87, 0x59, 0x41, 0x76, 
+	0xcb, 0x67, 0xc7, 0x78, 0x4d, 0xc0, 00, 0x64, 0xb7, 0x70, 
+	0x76, 0x32, 0x4a, 0xc3, 0x9, 0x88, 0x9a, 0x62, 0x22, 0xab, 
+	00, 0x8e, 0x9c, 0x9b, 0x7c, 0x71, 0x23, 0xfa, 0x66, 0x4f, 
+	0xde, 0x93, 0x6e, 0x72, 0x90, 0xdd, 0xf4, 0xec, 0x54, 0x24, 
+	0x7, 0x27, 0x6a, 0x8a, 0x8c, 0x78, 0x3, 0x82, 0x4, 0x80, 
+	0x98, 0xf, 0x3a, 0x2e, 0x47, 0xf5, 0x3a, 0xcc, 0x41, 0x76, 
+	0x33, 0xb0, 0x93, 0x2, 0x73, 0xa2, 0xa6, 0xd8, 0x1c, 0xa3, 
+	0x3b, 0xa6, 0xf3, 0x15, 0x52, 0xce, 0xb8, 0x9b, 0x83, 0xec, 
+	0x66, 0xd1, 0x5d, 0x10, 0x35, 0x45, 0xe6, 0xc0, 0x50, 0x62, 
+	0xcc, 0xe4, 0x73, 0x60, 0xe, 0x61, 0xe, 0xb2, 0x9b, 0xc5, 
+	0xde, 0x79, 0xec, 0x54, 0xe, 0xc, 0x8a, 0xa3, 0xed, 0x20, 
+	0x90, 0x23, 0x3f, 0x71, 0x73, 0x90, 0xdd, 0xfe, 0xf9, 0x77, 
+	0x34, 0xaf, 0xd2, 0xb1, 0x48, 0x22, 0x8a, 0x91, 0xdc, 0x3d, 
+	0xa6, 0xf4, 0xd8, 0x4b, 0x79, 0x90, 0x62, 0xd8, 0x8d, 0x1d, 
+	0x76, 0x54, 0x2e, 0xb4, 0xc5, 0xcd, 0x76, 0xfb, 0x7, 0x86, 
+	0xeb, 0x2c, 0xa8, 0x52, 0xb2, 0xa4, 0xd8, 0x49, 0x30, 0xd5, 
+	0x2d, 0xc8, 0xc7, 0x1b, 0x70, 0xb9, 0x46, 0x96, 0x7, 0xec, 
+	0xc2, 0x14, 0xc1, 0x6e, 0xec, 0x85, 0xa, 0x54, 0x54, 0x76, 
+	0xb9, 0xbb, 0xfb, 0x3, 0xc3, 0x75, 0x16, 0x74, 0x31, 0x9, 
+	0xea, 0x8e, 0x9, 0x16, 0x5a, 0x72, 0xb9, 0x7e, 0x92, 0x5b, 
+	0x21, 0xf6, 0xd3, 0x5d, 0x6, 0x57, 0x1b, 0x7, 0x6b, 0x94, 
+	0xbb, 0x2b, 0xd9, 0x99, 0xd5, 0xd, 0xa, 0x98, 0xf, 0xd6, 
+	0x31, 0xaf, 0x8e, 0xd1, 0x50, 0x9c, 0xe8, 0x79, 0x59, 0x1, 
+	0x43, 0x45, 0x73, 0xb3, 0x2e, 0x9e, 0x56, 0x99, 0xf7, 0x5e, 
+	0x11, 0x82, 0xd8, 0x59, 0x2d, 0xbd, 0xc8, 0x6c, 0xb0, 0xe9, 
+	0x2, 0x88, 0xb2, 0x21, 0x46, 0xdf, 0xa2, 0x74, 0x7, 0xd8, 
+	0xe5, 0x42, 0x73, 0xe2, 0x9, 0xcd, 0xb7, 0xe9, 0x8f, 0xc6, 
+	0xc8, 0xc2, 0xae, 0x5f, 0x50, 0xb7, 0xe5, 0xdc, 0x5b, 0xdd, 
+	0xa0, 0x79, 0x1d, 0xf3, 0x3a, 0x6d, 0x14, 0x66, 0x59, 0x65, 
+	0x7b, 0xfd, 0xb, 00, 0xd6, 0x7f, 0xaf, 0x28, 0xb6, 0xe6, 
+	0x4c, 0xe0, 0xa, 0x7a, 0x29, 0xea, 0xae, 0xb2, 0x7a, 0x86, 
+	0xdd, 0xe6, 0xe9, 0x10, 0xba, 0x93, 0xeb, 0x95, 0x67, 0xbc, 
+	0xfe, 0x51, 0x64, 0x76, 0x3d, 0x6b, 0xb3, 0xac, 0x41, 0xe6, 
+	0xe6, 0x80, 0xd5, 0x96, 0xb3, 0xa6, 0xf2, 0xc3, 0xb5, 0xf0, 
+	0x2c, 0x29, 0xf7, 0xbd, 0x19, 0x5c, 0x67, 0x1, 0xae, 0x9e, 
+	0xa0, 0x35, 0x9b, 0xa5, 0x64, 0xef, 0xa4, 0xca, 0x2a, 0x33, 
+	0x47, 0x47, 0xd0, 0x9d, 0x5a, 0xd7, 0xc0, 0x21, 0x2, 0xd6, 
+	0xb0, 0xe, 0xd6, 0xa7, 0xcb, 0x9a, 0x72, 0x9a, 0xd8, 0x15, 
+	0xbc, 0xf0, 0xd9, 0x5, 0xba, 0x83, 0xec, 0xe0, 0x3a, 0xb, 
+	0x75, 0xba, 0x4b, 0xce, 0xde, 0xc9, 0x76, 0x26, 0xd4, 0xdd, 
+	0x50, 0xf6, 0x4e, 0x5e, 0x96, 0x46, 0xad, 0x1, 0xdb, 0x97, 
+	0x1, 0xb, 0x5, 0x57, 0xac, 0xdb, 0xa1, 0x3b, 0xe, 0xd6, 
+	0x1d, 0xc9, 0xfc, 0x66, 0x7, 0xf8, 0xac, 0xc, 0xb6, 0x33, 
+	0xb7, 0xd8, 0xbb, 0x34, 0xd8, 0x89, 0x28, 0x37, 0xc7, 0x2d, 
+	0xd2, 0xd8, 0xb1, 0x71, 0x6a, 0x1a, 0x86, 0x53, 0xae, 0x68, 
+	0x30, 0xfc, 0x67, 0x4d, 0xc4, 0x2e, 0x26, 0xc9, 0x20, 0xee, 
+	0x74, 0xf0, 0x35, 0x65, 0x6, 0xf0, 0xb9, 0xb2, 0x3a, 0x3b, 
+	0x58, 0x5b, 0x5a, 0x36, 0x81, 0xe7, 0xb9, 0x3c, 0x76, 0x72, 
+	0x65, 0x4, 0x11, 0x47, 0x7a, 0x70, 0xdd, 0xf5, 0xf5, 0xb9, 
+	0x8a, 0xdd, 0x5a, 0x56, 0xa5, 0x15, 0x5b, 0xf5, 0x3e, 0x3d, 
+	0xbb, 0x4e, 0x73, 0x1e, 0x68, 0x34, 0xba, 0x7c, 0x2c, 0x76, 
+	0xad, 0x7d, 0xae, 0xc2, 0xf3, 0x10, 0x8d, 0xd7, 0x6, 0xd6, 
+	0x34, 0x87, 0x5c, 0xb2, 0xa0, 0xb4, 0x2c, 0x3, 0x36, 0x74, 
+	0xac, 0x65, 0xb3, 0x47, 0x8f, 0xaf, 0x12, 0x1d, 0xff, 0x4d, 
+	0xac, 0x8c, 0x30, 0x46, 0x9d, 0xd9, 0xde, 0xe7, 0xf2, 0x8f, 
+	0x29, 0x32, 0xa8, 0x29, 0xe7, 0xc8, 0x2c, 0xe3, 0x75, 0xa5, 
+	0x15, 0xa0, 0x3d, 0x39, 0xda, 0xfa, 0x5c, 0xa3, 0xc7, 0x57, 
+	0x89, 0x66, 0x27, 0x57, 0x46, 0x18, 0x47, 0x77, 0x2d, 0x7d, 
+	0xae, 0x4c, 0xd4, 0x79, 0xa1, 0xd7, 0xe6, 0xac, 0xb3, 0xc, 
+	0x75, 0x17, 0x94, 0x6, 0xb5, 0x3c, 0xda, 0xba, 0x78, 0xa3, 
+	0xc7, 0x57, 0xe9, 0xd2, 0x56, 0xc9, 0x47, 0xb4, 0x77, 0x6d, 
+	0x7c, 0x2e, 0xcf, 0xfb, 0x6b, 0xcb, 0xae, 0xf0, 0xfb, 0xcd, 
+	0x38, 0xf4, 0x31, 0x67, 0x67, 0x17, 0x1f, 0x5f, 0x25, 0x9e, 
+	0x1d, 0x1b, 0xb5, 0x9d, 0xb9, 0xcb, 0xe7, 0xca, 0x7c, 0x7b, 
+	0xb7, 0x9d, 0x9d, 0xf5, 0xa, 0x9d, 0xd2, 0x38, 0xb0, 0x8c, 
+	0xcb, 0x60, 0xd7, 0x25, 0xbe, 0x4a, 0x7, 0x76, 0xd3, 0xc5, 
+	0x3e, 0x1d, 0xd6, 0x12, 0x2d, 0x7a, 0xdd, 0xc9, 0x2e, 0xf1, 
+	0x55, 0x16, 0xcd, 0xee, 0x70, 0xc6, 0x5e, 0x3b, 0xc5, 0x79, 
+	0x40, 0x76, 0xb, 0x61, 0xd7, 0x21, 0xbe, 0xa, 0xb2, 0x43, 
+	0xdd, 0x61, 0x1a, 0x54, 0x77, 0xc8, 0x2e, 0x61, 0xdd, 0x8d, 
+	0xd1, 0x27, 0x86, 0xec, 0xc6, 0xd7, 0x5d, 0xdb, 0xf8, 0x2a, 
+	0xc8, 0x6e, 0x81, 0xba, 0x5b, 0x21, 0xbb, 0xb4, 0xd8, 0xc5, 
+	0xc7, 0x57, 0x81, 0x63, 0xaf, 0x70, 0x7e, 0x66, 0x1f, 0x76, 
+	0x7a, 0x7d, 0x5b, 0xbb, 0x85, 0x2b, 0x53, 0x37, 0xad, 0x18, 
+	0xbe, 0x7d, 0x3e, 0xd6, 0x8e, 0xf5, 0xd3, 0x23, 0xe6, 0x72, 
+	0x85, 0xeb, 0xf0, 0x8a, 0x92, 0xe1, 0x84, 0x30, 0xb5, 0x18, 
+	0x29, 0x3c, 0x7f, 0x79, 0x86, 0xd5, 0x31, 0xfa, 0xc8, 0x9d, 
+	0xab, 0x78, 0x8f, 0x1e, 0x5f, 0x45, 0xb1, 0xb, 0xe6, 0x67, 
+	0xf6, 0x61, 0xa7, 0xd7, 0x7e, 0xb5, 0x5b, 0xb8, 0xac, 0x66, 
+	0xd3, 0x8a, 0xe1, 0xdb, 0xaf, 0xc5, 0x8e, 0xf5, 0xd3, 0xcb, 
+	0x8, 0x74, 0xa4, 0xfe, 0x3c, 0xc1, 0xa2, 0xad, 0x6a, 0xbd, 
+	0x6c, 0x70, 0xfe, 0xee, 0x49, 0x96, 0xcd, 0xb, 0x85, 0xf6, 
+	0x60, 0x17, 0x1d, 0x5f, 0x45, 0xb3, 0x3, 0x73, 0xfc, 0x7a, 
+	0xb3, 0x93, 0xdf, 0x4e, 0xae, 0x8d, 0x2a, 0xb7, 0x25, 0x1, 
+	0x6b, 0x5b, 0x8b, 0x4b, 0x5d, 0x82, 0x55, 0xce, 0x4b, 0x62, 
+	0x17, 0x52, 0x2d, 0xdd, 0x15, 0x5d, 0xe1, 0x75, 0xe6, 0x60, 
+	0x15, 0xd7, 0x60, 0x75, 0x72, 0xad, 0x23, 0xee, 0xaf, 0x75, 
+	0xae, 0xf6, 0x89, 0x59, 0x99, 0xbe, 0xf4, 0xd6, 0x50, 0x56, 
+	0x8c, 0xdc, 0xa5, 0xd3, 0x9b, 0xd8, 0x81, 0xe5, 0xce, 0x87, 
+	0xd5, 0x5d, 0x97, 0xf8, 0x2a, 0xe3, 0xb0, 0x2b, 0x55, 0xfd, 
+	0x66, 0x8, 0x96, 0x76, 0x1, 0x66, 0xb9, 0xb0, 0x7b, 0xcd, 
+	0x2a, 0xe7, 0x60, 0xe5, 0xe2, 0xc6, 0x3a, 0x13, 0xac, 0x9e, 
+	0xec, 0xae, 0x4e, 0x6e, 0xdf, 0x5b, 0xbf, 0xd5, 0xa5, 0xc2, 
+	0x33, 0x91, 0xe7, 0x69, 0x6a, 0x45, 0xf0, 0xc1, 0xba, 0xce, 
+	0x24, 0x6a, 0x1b, 0xca, 0xce, 0x2d, 0x67, 0xa0, 0x31, 0xa0, 
+	0xc8, 0xf8, 0x2a, 0xa3, 0xb0, 0x2b, 0xf5, 0x2a, 0xc6, 0x86, 
+	0x1d, 0xb8, 0x2, 0x44, 0xab, 0xd2, 0x7b, 0x28, 0x76, 0xcd, 
+	0xf3, 0x90, 0xcd, 0xfa, 0xe9, 0xce, 0x3a, 0xe3, 0xc0, 0xde, 
+	0x85, 0x2b, 0xa7, 0x83, 0x7, 0x81, 0x36, 0xcb, 0x39, 0x4f, 
+	0xa3, 0x2c, 0xe2, 0x9b, 0x4f, 0x8b, 0xca, 0x97, 0x9d, 0x5b, 
+	0xce, 0x70, 0x63, 0xaf, 0x51, 0xf1, 0x55, 0x1c, 0x76, 0x3, 
+	0xd9, 0xbb, 0x52, 0x2d, 0x1a, 0xf, 0xeb, 0x1c, 0xa0, 0x3b, 
+	0x6d, 0x5f, 0x9a, 0x74, 0xb7, 0xd5, 0x86, 0x6, 0xeb, 0x8c, 
+	0x43, 0x76, 0xc1, 0xca, 0xe9, 0x66, 0x1d, 0x73, 0xc2, 0x5d, 
+	0x60, 0x8d, 0xe7, 0x9, 0xd9, 0x95, 0xaa, 0x95, 0x55, 0x7a, 
+	0xf9, 0xc4, 0x2b, 0x67, 0x28, 0x1f, 0x21, 0x36, 0xbe, 0xa, 
+	0x64, 0x37, 0x54, 0x3b, 0x93, 0x98, 0xda, 0x6, 0xd4, 0x48, 
+	0x61, 0xeb, 0xae, 0xc9, 0xde, 0x6d, 0x6d, 0x67, 0xda, 0x66, 
+	0x42, 0xc8, 0xe, 0xae, 0x36, 0x4e, 0x94, 0xc0, 0x55, 0xd, 
+	0x40, 0x3c, 0x51, 0x91, 0x86, 0xf3, 0x74, 0x16, 0x9e, 0x57, 
+	0x22, 0xf7, 0x17, 0xa4, 0x77, 0x9f, 0xc, 0xd5, 0x56, 0xe9, 
+	0x3c, 0xd7, 0xa8, 0xcd, 0x6c, 0xcc, 0x11, 0xfd, 0xbb, 0xb2, 
+	0x24, 0xd3, 0x96, 0xd3, 0x74, 0x5c, 0x6c, 0xfe, 0x60, 0xec, 
+	0x7a, 0xcf, 0xad, 0x15, 0x73, 0x51, 0xdc, 0x7b, 0xee, 0x80, 
+	0x12, 0x6b, 0xee, 0xd1, 0x9b, 0xd5, 0xf5, 0x25, 0xe1, 0x8f, 
+	0x9f, 0xc4, 0x7b, 0x7b, 0x53, 0xf9, 0xe6, 0x55, 0x3c, 0x7, 
+	0x76, 0xd2, 0x14, 0x71, 0xc5, 0xc9, 0xe1, 0x91, 0xec, 0x34, 
+	0x40, 0x7b, 0xfb, 0x41, 0xe0, 0xf1, 0x85, 0x39, 0x33, 0xb3, 
+	0x2b, 0xed, 0xd6, 0xf5, 0xf2, 0xca, 0x5, 0xb2, 0x93, 0x91, 
+	0x37, 0x9a, 0x23, 0xae, 0x6c, 0x8b, 0xbe, 0xd2, 0xc6, 0xde, 
+	0xc9, 0xe6, 0xca, 0x71, 0x70, 0x77, 0x49, 0x53, 0xe, 0x9d, 
+	0x85, 0x57, 0xd5, 0xde, 0xb7, 0x1e, 0x1c, 0x1, 0x16, 0xb3, 
+	0xc6, 0xcb, 0x2b, 0x9, 0x59, 0x8, 0x3b, 0x2d, 0x30, 0x13, 
+	0x2, 0x40, 0x45, 0x78, 0x90, 0xcf, 0xb8, 0x7d, 0x95, 0x73, 
+	0x7e, 0x72, 0xd2, 0x2a, 0xbe, 0x8a, 0xcb, 0xe, 0xdc, 0xf5, 
+	0x13, 0xb4, 0x5e, 0x6c, 0xce, 0x7c, 0xec, 0x2a, 0x6e, 0x15, 
+	0x95, 0x1a, 0xf, 0xae, 0xde, 0xcb, 0x23, 0x25, 0x5f, 0x14, 
+	0xbb, 0x30, 0xe2, 0xa, 0x64, 0x7, 0xa2, 0xaf, 0xb4, 0x89, 
+	0xaf, 0xe2, 0xb2, 0x3, 0xc6, 0xad, 0x41, 0x77, 0x10, 0xf0, 
+	0x6c, 0xec, 0x2, 0xf, 0xae, 0x4, 0xad, 0x41, 0xe7, 0xa5, 
+	0x92, 0x2f, 0x8a, 0x9d, 0x8c, 0x62, 0x64, 0x22, 0x3f, 0x78, 
+	0xba, 0xf3, 0x5e, 0xdd, 0x19, 0x5f, 0xc5, 0x63, 0x77, 0xbc, 
+	0x9b, 0x5d, 0x3e, 0x67, 0x5b, 0x45, 0xc2, 0x93, 0x1e, 0x1c, 
+	0xf4, 0xd, 0x83, 0x9e, 0x19, 0xe3, 0xd9, 0x2d, 0xca, 0xde, 
+	0x35, 0x45, 0x3a, 0x82, 0x39, 0x27, 0x50, 0x77, 0x27, 0xdd, 
+	0xd9, 0x85, 0x75, 0xe6, 0x31, 0xc8, 0x98, 0xa3, 0xad, 0x52, 
+	0x75, 0x6e, 0x29, 0xf, 0x2e, 0xb0, 0x7a, 0x3c, 0xb4, 0x77, 
+	0xb, 0x6b, 0x67, 0x42, 0x65, 0x31, 0x1d, 0x59, 0xc5, 0xd7, 
+	0x1d, 0xe3, 0xd0, 0x1a, 0xe, 0x72, 0xff, 0x5d, 0xaf, 0x38, 
+	0xf, 0x38, 0x7e, 0x37, 0xfa, 0xbd, 0x93, 0xfe, 0x1d, 0xca, 
+	0xa1, 0xc7, 0x57, 0x49, 0x11, 0xd9, 0x2d, 0x8a, 0x9d, 0x4, 
+	0x8, 0xb8, 0x68, 0x6f, 0x2e, 0xcf, 0xdd, 0x9c, 0x1c, 0x34, 
+	0x67, 0x90, 0xdd, 0x32, 0xd8, 0xa9, 0x56, 0x88, 0xe7, 0x23, 
+	0xd0, 0xc0, 0xde, 0xc1, 0x6e, 0x16, 0x64, 0xb7, 0x1c, 0x76, 
+	0xe2, 0xde, 0xba, 0x46, 0x8f, 0x20, 0xa4, 0x89, 0xec, 0x16, 
+	0xc4, 0xe, 0x5a, 0x37, 0x63, 0x3, 0x97, 0xd4, 0xaf, 0x82, 
+	0xec, 0xb6, 0xf5, 0xab, 0x2c, 0xbb, 0x4f, 0xc, 0xd9, 0x6d, 
+	0xeb, 0xcf, 0x6c, 0xd3, 0x27, 0x86, 0x75, 0xe6, 0x12, 0x7d, 
+	0x4, 0xf4, 0xef, 0x92, 0x65, 0x17, 0x4, 0xa0, 0xa, 0xc7, 
+	0xef, 0xe8, 0xac, 0x7d, 0xd1, 0xc8, 0xae, 0xd1, 0xbf, 0x83, 
+	0x7e, 0x78, 0xc3, 0xf8, 0xdd, 0xcc, 0xfd, 0x99, 0xc8, 0xae, 
+	0xc9, 0xde, 0xe5, 0x7e, 0x7f, 0x66, 0xe8, 0x23, 0xc0, 0xe6, 
+	0xc, 0xb2, 0x5b, 0x52, 0x5b, 0x25, 0x64, 0x97, 0x87, 0x7d, 
+	0xd1, 0x9e, 0xee, 0x18, 0xa6, 0x20, 0x2d, 0x82, 0x5d, 0xee, 
+	0x8f, 0xe8, 0x85, 0xe3, 0x77, 0x48, 0x6a, 0x99, 0xec, 0x20, 
+	0x3a, 0xf4, 0xef, 0xd2, 0xaa, 0x33, 0xc3, 0x9e, 0x16, 0xf4, 
+	0xef, 0xd0, 0xbf, 0x43, 0x76, 0x63, 0xb0, 0xb, 0x7d, 0xba, 
+	0x5d, 0x73, 0x6b, 0xcb, 0xc6, 0xa9, 0xcc, 0x31, 0x5f, 0x15, 
+	0x8e, 0x74, 0x13, 0x82, 0xec, 0xa2, 0xe7, 0x67, 0xfa, 0x7d, 
+	0x98, 0xad, 0xd8, 0xd5, 0xcf, 0xe8, 0x29, 0x23, 0x27, 0xfa, 
+	0xe8, 0x79, 0x26, 0xf6, 0xd7, 0x40, 0x7a, 0x4, 0xb8, 0x3f, 
+	0xc0, 0xfe, 0x4c, 0x65, 0xf3, 0xa2, 0xd8, 0x95, 0x60, 0xf6, 
+	0x48, 0xe9, 0xdc, 0x1, 0xc7, 0xdd, 0x79, 0x92, 0xe1, 0x9d, 
+	0x71, 0xce, 0xfd, 0x8, 0xf2, 0xde, 0x28, 0x38, 0xf3, 0xa4, 
+	0x4a, 0x7a, 0xee, 0x65, 0xb9, 0x94, 0x29, 0xb3, 0x7b, 0xc5, 
+	0x8e, 0x80, 0x59, 0x5b, 0x60, 0xbf, 0x6c, 0xc8, 0x6f, 0x9a, 
+	0x5d, 0xc9, 0xc1, 0xbd, 0x75, 0xf0, 0x5e, 0xf, 0x3d, 0xf7, 
+	0xb2, 0x9c, 0x75, 0xc2, 0xde, 0x7e, 0xb2, 0x2b, 0xe1, 0xac, 
+	0xc8, 0x52, 0x5f, 0x73, 0xee, 0xdc, 0x4f, 0x7, 0xf3, 0xed, 
+	0xa4, 0x4a, 0x9d, 0xa3, 0x67, 0x57, 0xda, 0x7b, 0xaf, 0x38, 
+	0xf1, 0xed, 0x20, 0x27, 0xa9, 0xc9, 0x6e, 0x16, 0x76, 0x91, 
+	0xf6, 0x4e, 0xdf, 0x17, 0x60, 0xe7, 0x43, 0x2a, 0x1d, 0x81, 
+	0xfb, 0xe9, 0x60, 0xbe, 0x73, 0x67, 0x9c, 0x52, 0x9c, 0x9c, 
+	0x63, 0xc9, 0x6b, 0xd9, 0xe9, 0x57, 0x53, 0x93, 0xdd, 0x1c, 
+	0xec, 0x62, 0xdb, 0x99, 0xba, 0x65, 0x68, 0x5b, 0x89, 0xaa, 
+	0x81, 0x9, 0xee, 0xa7, 0x83, 0xf9, 0x70, 0x26, 0x33, 0x9c, 
+	0x69, 0x9, 0x67, 0x35, 0x43, 0x76, 0xc1, 0xd, 0x7c, 0xc8, 
+	0x2e, 0xc2, 0xbf, 0x6b, 0x73, 0xff, 0x5d, 0x72, 0xaa, 0xd8, 
+	0x1b, 0x76, 0x18, 0x1b, 0x7, 0xd9, 0x61, 0x1a, 0x98, 0xdd, 
+	0xa9, 0x53, 0xa7, 0xce, 0x3f, 0x65, 0xd2, 0x13, 0x8f, 0xce, 
+	0x43, 0x76, 0xe9, 0xb0, 0x7b, 0xdb, 0x7d, 0x6f, 0xb9, 0xe3, 
+	0x7f, 0xee, 0xbf, 0xf3, 0x5d, 0xf, 0x3d, 0xf8, 0x9e, 0xb7, 
+	0xff, 0xd5, 0xdf, 0x1e, 0x1d, 0x21, 0xbb, 0x74, 0xd8, 0xbd, 
+	0xf7, 0xd, 0x67, 0xde, 0x71, 0xcf, 0xe9, 0xb3, 0xa7, 0x6f, 
+	0x3b, 0x77, 0xeb, 0xb9, 0x3b, 0xff, 0xb, 0xd9, 0xa5, 0xc4, 
+	0xee, 0xbe, 0x3b, 0xae, 0x78, 0xd2, 0xd3, 0x9f, 0x7d, 0xc1, 
+	0x17, 0x3c, 0x7a, 0xfa, 0xdc, 0x1f, 0xdf, 0xff, 0xe, 0x64, 
+	0x97, 0x10, 0xbb, 0xf7, 0xbf, 0xfb, 0xdd, 0x97, 0xfd, 0xdc, 
+	0xcd, 0x37, 0xbf, 0xf6, 0x17, 0x2f, 0xbe, 0xf8, 0xc9, 0x5f, 
+	0xf8, 0xf0, 0x7f, 0x9f, 0x42, 0x76, 0x9, 0xe9, 0xee, 0xcc, 
+	0xe9, 0xb, 0xfe, 0xe0, 0xe5, 0x2f, 0x79, 0xe9, 0x17, 0x5f, 
+	0x7f, 0xd3, 0x2f, 0xbf, 0xea, 0x9e, 0xbb, 0x4f, 0xbd, 0x9f, 
+	0xc3, 0xe, 0xd3, 0x68, 0x69, 00, 0x76, 0xe7, 0x3f, 0x72, 
+	0xcf, 0xb3, 0x5e, 0xfb, 0x92, 0x9f, 0xfe, 0xc9, 0xf, 0xfc, 
+	0xf1, 0x6f, 0xff, 0x9e, 0x4b, 0xef, 0xba, 0xdf, 0xd5, 0x1d, 
+	0xa6, 0x45, 0xa7, 0x53, 0xf7, 0x3e, 0x7c, 0xc1, 0xd, 0x3f, 
+	0xf3, 0xb3, 0x3f, 0xf5, 0x25, 0xcf, 0x79, 0xfe, 0x73, 0x2f, 
+	0xdd, 0xe8, 0xee, 0x9, 0xc8, 0x2e, 0x99, 0xf4, 0xd8, 0xdb, 
+	0xce, 0x7e, 0xf4, 0xcd, 0x9f, 0xf2, 0x9, 0x4f, 0x7b, 0xe6, 
+	0xf3, 0xae, 0xbe, 0xea, 0xc3, 0xdf, 0x79, 0xfb, 0x11, 0xea, 
+	0x2e, 0x21, 0xdd, 0xbd, 0xef, 0xd6, 0xf7, 0x3d, 0xf9, 0x86, 
+	0x1f, 0xfc, 0xaa, 0xe7, 0xbd, 0xf0, 0xc7, 0x5e, 0xf8, 0x31, 
+	0xf, 0xbd, 0xd, 0xd9, 0xa5, 0xc4, 0xee, 0xc1, 0xd3, 0xb7, 
+	0x5e, 0xfe, 0xea, 0xaf, 0x7b, 0xf1, 0x55, 0xdf, 0xf9, 0xb5, 
+	0xdf, 0x78, 0xc5, 0xdd, 0xf, 0xa2, 0xbd, 0x4b, 0x89, 0xdd, 
+	0x3b, 0xef, 0x3f, 0xfb, 0xd4, 0x57, 0xbc, 0xf8, 0xcb, 0xae, 
+	0xfb, 0x8e, 0xab, 0x5f, 0xf0, 0x19, 0xb7, 0xfd, 0x8b, 0xdb, 
+	0xce, 0xc4, 0xb4, 0xe8, 0x74, 0xfe, 0x1b, 0xce, 0xdc, 0xf9, 
+	0xcc, 0x5f, 0xfa, 0x9c, 0xcb, 0x3f, 0xec, 0xe3, 0x2f, 0x7b, 
+	0xd2, 0x33, 0xce, 0xde, 0x89, 0xba, 0x4b, 0x49, 0x77, 0xff, 
+	0x7e, 0xe6, 0x2d, 0xf7, 0x9e, 0x7d, 0xf3, 0xe9, 0xbb, 0x1e, 
+	0xbc, 0xeb, 0xcd, 0x67, 0xef, 0xbf, 0xf7, 0xb1, 0xc8, 0x2e, 
+	0x9d, 0xf4, 0xf8, 0xd7, 0xff, 0xe7, 0xed, 0x8f, 0xde, 0x71, 
+	0xe6, 0xa1, 0xbb, 0xdf, 0xfe, 0xe0, 0x23, 0x77, 0xbe, 0xf1, 
+	0x7f, 0xab, 0xb6, 0xa, 0xa6, 0x44, 0xd2, 0xd1, 0xd1, 0x79, 
+	0xe7, 0xe9, 0x11, 0xa0, 0xf, 0x38, 0x75, 0x84, 0xec, 0x12, 
+	0x4a, 0x8f, 0x3b, 0x3a, 0x7a, 0xfc, 0xd1, 0xd1, 0x13, 0x36, 
+	0x4, 0x8f, 0x8e, 0x9e, 0x78, 0x74, 0xf4, 0xb8, 0xf3, 0xfe, 
+	0x1f, 0xa8, 0x96, 0x18, 0xbe, 0xf6, 0x39, 0xb9, 0xfe, 00, 
+	00, 00, 00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 
+	0x82, };
+
+static prog_char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 
+	0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 
+	0x69, 0x74, 0x65, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 
+	0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 
+	0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 
+	0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 
+	0x2f, 0x68, 0x31, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x3c, 0x68, 0x33, 0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 
+	0x68, 0x65, 0x72, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 
+	0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 
+	0x33, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 
+	0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 
+	0x74, 0x6d, 0x6c, 0x3e, };
+
+static prog_char data_footer_plain[] = {
+	/* /footer.plain */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 
+	0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static prog_char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 
+	0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 
+	0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 
+	0x57, 0x33, 0x43, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 
+	0x54, 0x4d, 0x4c, 0x20, 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 
+	0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 
+	0x6c, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 
+	0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 
+	0x74, 0x6d, 0x6c, 0x34, 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 
+	0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 
+	0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 
+	0x64, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 
+	0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 
+	0x6f, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 
+	0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 
+	0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 
+	0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 
+	0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 
+	0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 
+	0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 
+	0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 
+	0x75, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 
+	0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 
+	0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0x4d, 0x65, 0x6e, 
+	0x75, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 
+	0x6e, 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 
+	0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 
+	0x22, 0x3e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 
+	0x67, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x2f, 0x76, 0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 
+	0x6c, 0x22, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x20, 
+	0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3e, 0x46, 
+	0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 
+	0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 
+	0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 
+	0x63, 0x70, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 
+	0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 
+	0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3e, 0x53, 
+	0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63, 
+	0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 
+	0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 
+	0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 
+	0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x57, 
+	0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 
+	0xa, 0x20, 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x21, 0xa, 0x20, 0x20, 0x3c, 0x2f, 
+	0x70, 0x3e, 0xa, };
+
+static prog_char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 
+	0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 
+	0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 
+	0x57, 0x33, 0x43, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 
+	0x54, 0x4d, 0x4c, 0x20, 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 
+	0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 
+	0x6c, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 
+	0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 
+	0x74, 0x6d, 0x6c, 0x34, 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 
+	0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 
+	0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 
+	0x64, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 
+	0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 
+	0x6f, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 
+	0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 
+	0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 
+	0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 
+	0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 
+	0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 
+	0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 
+	0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 
+	0x75, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 
+	0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 
+	0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0x4d, 0x65, 0x6e, 
+	0x75, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 
+	0x6e, 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 
+	0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 
+	0x22, 0x3e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 
+	0x67, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x2f, 0x76, 0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 
+	0x6c, 0x22, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x20, 
+	0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3e, 0x46, 
+	0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 
+	0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 
+	0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 
+	0x63, 0x70, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 
+	0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 
+	0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3e, 0x53, 
+	0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63, 
+	0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 
+	0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 
+	0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 
+	0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x57, 
+	0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 
+	0xa, 0x20, 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x21, 0xa, 0x20, 0x20, 0x3c, 0x2f, 
+	0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x22, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 
+	0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 
+	0x20, 0x79, 0x6f, 0x75, 0x20, 0x61, 0x72, 0x65, 0x20, 0x77, 
+	0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x72, 
+	0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x20, 0x62, 
+	0x79, 0x20, 0x61, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 
+	0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 
+	0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 
+	0x2f, 0x61, 0x70, 0x70, 0x73, 0x2f, 0x77, 0x65, 0x62, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 
+	0x22, 0x3e, 0x77, 0x65, 0x62, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x20, 
+	0x75, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 
+	0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 
+	0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x6f, 0x70, 0x65, 
+	0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x6e, 0x20, 0x61, 
+	0x6e, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x74, 0x68, 
+	0x65, 0x72, 0x6e, 0x75, 0x74, 0x2e, 0x64, 0x65, 0x2f, 0x65, 
+	0x6e, 0x2f, 0x22, 0x3e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 
+	0x75, 0x74, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x65, 0x6d, 0x62, 
+	0x65, 0x64, 0x64, 0x65, 0x64, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 
+	0x62, 0x6f, 0x61, 0x72, 0x64, 0x2c, 0x20, 0x77, 0x68, 0x69, 
+	0x63, 0x68, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74, 
+	0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x31, 0x34, 0x20, 
+	0x4d, 0x48, 0x7a, 0x20, 0x41, 0x56, 0x52, 0x20, 0x41, 0x74, 
+	0x6d, 0x65, 0x67, 0x61, 0x31, 0x32, 0x38, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x63, 0x6f, 
+	0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x20, 0x77, 
+	0x69, 0x74, 0x68, 0x20, 0x33, 0x32, 0x20, 0x6b, 0x69, 0x6c, 
+	0x6f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 
+	0x52, 0x41, 0x4d, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x31, 0x32, 
+	0x38, 0x20, 0x6b, 0x69, 0x6c, 0x6f, 0x62, 0x79, 0x74, 0x65, 
+	0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x20, 
+	0x66, 0x6c, 0x61, 0x73, 0x68, 0x20, 0x52, 0x4f, 0x4d, 0x2c, 
+	0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20, 0x52, 0x65, 0x61, 
+	0x6c, 0x54, 0x65, 0x6b, 0x20, 0x52, 0x54, 0x4c, 0x38, 0x30, 
+	0x31, 0x39, 0x41, 0x53, 0x20, 0x45, 0x74, 0x68, 0x65, 0x72, 
+	0x6e, 0x65, 0x74, 0x20, 0x63, 0x68, 0x69, 0x70, 0x2e, 0xa, 
+	0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6c, 0x69, 0x6e, 
+	0x6b, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x2e, 0x73, 0x69, 
+	0x63, 0x73, 0x2e, 0x73, 0x65, 0x22, 0x3e, 0x3c, 0x62, 0x3e, 
+	0x3c, 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x64, 
+	0x65, 0x6d, 0x6f, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x62, 
+	0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 
+	0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0xa, 0x9, 0x20, 
+	0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x68, 0x32, 0x3e, 0x52, 
+	0x65, 0x6d, 0x6f, 0x74, 0x65, 0x20, 0x64, 0x69, 0x73, 0x70, 
+	0x6c, 0x61, 0x79, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xa, 0x9, 
+	0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x49, 0x74, 0x20, 0x69, 0x74, 0x20, 0x70, 0x6f, 0x73, 
+	0x73, 0x69, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x72, 
+	0x65, 0x6d, 0x6f, 0x74, 0x65, 0x6c, 0x79, 0x20, 0x61, 0x63, 
+	0x63, 0x65, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x64, 0x65, 0x73, 
+	0x6b, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 
+	0x74, 0x6c, 0x79, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x79, 
+	0x6f, 0x75, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x62, 0x72, 
+	0x6f, 0x77, 0x73, 0x65, 0x72, 0x21, 0x20, 0x53, 0x65, 0x65, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x76, 
+	0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x72, 
+	0x65, 0x6d, 0x6f, 0x74, 0x65, 0x20, 0x64, 0x69, 0x73, 0x70, 
+	0x6c, 0x61, 0x79, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x70, 0x61, 
+	0x67, 0x65, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x68, 0x32, 0x3e, 0x53, 
+	0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 0x74, 0x3c, 
+	0x2f, 0x68, 0x32, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x69, 
+	0x73, 0x20, 0x69, 0x73, 0x20, 0x77, 0x68, 0x61, 0x74, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 
+	0x6c, 0x20, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x20, 
+	0x6f, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x20, 0x6c, 0x6f, 0x6f, 0x6b, 0x73, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x69, 0x6b, 0x65, 
+	0x3a, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 
+	0x9, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x69, 0x6d, 
+	0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x69, 0x6d, 
+	0x67, 0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 
+	0x6f, 0x74, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x61, 0x6c, 
+	0x74, 0x3d, 0x22, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 
+	0x68, 0x6f, 0x74, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 
+	0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x9, 
+	0x20, 0x20, 0x3c, 0x68, 0x32, 0x3e, 0x4d, 0x65, 0x6d, 0x6f, 
+	0x72, 0x79, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x3c, 0x2f, 
+	0x68, 0x32, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 0x20, 
+	0x65, 0x6e, 0x74, 0x69, 0x72, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x41, 0x56, 0x52, 0x20, 0x73, 
+	0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x75, 0x73, 0x65, 0x73, 
+	0x20, 0x73, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6c, 0x79, 0x20, 
+	0x6d, 0x6f, 0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 
+	0x32, 0x30, 0x20, 0x6b, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x52, 0x41, 0x4d, 0x2c, 0x20, 0x6f, 0x66, 0x20, 0x77, 0x68, 
+	0x69, 0x63, 0x68, 0x20, 0x36, 0x20, 0x6b, 0x20, 0x69, 0x73, 
+	0x20, 0x75, 0x73, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 
+	0x6c, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 
+	0x38, 0x20, 0x6b, 0x20, 0x66, 0x6f, 0x72, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x9, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x77, 0x65, 0x62, 0x20, 0x62, 0x72, 0x6f, 0x77, 
+	0x73, 0x65, 0x72, 0x2e, 0x20, 0x41, 0x6c, 0x6c, 0x20, 0x63, 
+	0x6f, 0x64, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x68, 
+	0x65, 0x73, 0x65, 0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 
+	0x67, 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 
+	0x6f, 0x72, 0x65, 0x64, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x69, 0x63, 
+	0x72, 0x6f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 
+	0x65, 0x72, 0x27, 0x73, 0x20, 0x6f, 0x6e, 0x2d, 0x63, 0x68, 
+	0x69, 0x70, 0x20, 0x66, 0x6c, 0x61, 0x73, 0x68, 0x20, 0x52, 
+	0x4f, 0x4d, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3d, 0x22, 0x72, 0x69, 0x67, 0x68, 0x74, 
+	0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 
+	0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x25, 0x37, 0x65, 
+	0x61, 0x64, 0x61, 0x6d, 0x2f, 0x22, 0x3e, 0x41, 0x64, 0x61, 
+	0x6d, 0x20, 0x44, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 
+	0x74, 0x6d, 0x6c, 0x3e, };
+
+static prog_char data_vnc_html[] = {
+	/* /vnc.html */
+	0x2f, 0x76, 0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 
+	0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 
+	0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 
+	0x57, 0x33, 0x43, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 
+	0x54, 0x4d, 0x4c, 0x20, 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 
+	0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 
+	0x6c, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 
+	0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 
+	0x74, 0x6d, 0x6c, 0x34, 0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 
+	0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 
+	0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 
+	0x64, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 
+	0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 
+	0x6f, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 
+	0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 0x20, 
+	0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 
+	0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 
+	0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 
+	0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 
+	0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 
+	0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 
+	0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 
+	0x75, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 
+	0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 
+	0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0x4d, 0x65, 0x6e, 
+	0x75, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 
+	0x6e, 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 
+	0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 
+	0x22, 0x3e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 
+	0x67, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x2f, 0x76, 0x6e, 0x63, 0x2e, 0x68, 0x74, 0x6d, 
+	0x6c, 0x22, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x20, 
+	0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3e, 0x46, 
+	0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 
+	0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 
+	0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 
+	0x63, 0x70, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 
+	0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 
+	0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3e, 0x53, 
+	0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 0x6f, 0x63, 
+	0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 
+	0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 
+	0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 
+	0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 
+	0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x57, 
+	0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 
+	0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 
+	0xa, 0x20, 0x20, 0x64, 0x65, 0x6d, 0x6f, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x21, 0xa, 0x20, 0x20, 0x3c, 0x2f, 
+	0x70, 0x3e, 0xa, 0xa, 0x9, 0x9, 0x20, 0x20, 0x3c, 0x70, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x69, 0x6e, 
+	0x74, 0x72, 0x6f, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x20, 0x56, 0x4e, 0x43, 0x20, 0x73, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x20, 0x6c, 0x65, 0x74, 0x73, 0x20, 0x79, 
+	0x6f, 0x75, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, 
+	0x70, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 
+	0x20, 0x69, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x77, 
+	0x65, 0x62, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 
+	0x2c, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x61, 0x6e, 0x79, 
+	0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x69, 0x6e, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x6f, 
+	0x72, 0x6c, 0x64, 0x2e, 0x20, 0x4e, 0x6f, 0x74, 0x65, 0x20, 
+	0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 
+	0x65, 0x76, 0x69, 0x63, 0x65, 0x20, 0x6f, 0x6e, 0x20, 0x77, 
+	0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 
+	0x69, 0x73, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x64, 0x6f, 0x65, 0x73, 
+	0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 
+	0x61, 0x6e, 0x79, 0x20, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 
+	0x72, 0x20, 0x6f, 0x72, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x6f, 
+	0x74, 0x68, 0x65, 0x72, 0x20, 0x6b, 0x69, 0x6e, 0x64, 0x20, 
+	0x6f, 0x66, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 
+	0x3b, 0x20, 0x69, 0x6e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x66, 0x61, 0x63, 0x74, 0x2c, 0x20, 0x69, 0x74, 0x20, 0x64, 
+	0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x76, 
+	0x65, 0x6e, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x61, 0x20, 
+	0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x20, 0x63, 
+	0x68, 0x69, 0x70, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 
+	0x70, 0x3e, 0xa, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x68, 0x33, 
+	0x3e, 0x4a, 0x61, 0x76, 0x61, 0x20, 0x63, 0x6c, 0x69, 0x65, 
+	0x6e, 0x74, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x9, 0x20, 
+	0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x54, 0x68, 0x65, 0x20, 0x4a, 0x61, 0x76, 0x61, 0x20, 0x63, 
+	0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x6b, 0x65, 
+	0x73, 0x20, 0x69, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x73, 0x69, 
+	0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x63, 0x63, 
+	0x65, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x76, 0x69, 
+	0x72, 0x74, 0x75, 0x61, 0x6c, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x64, 
+	0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x64, 0x69, 0x72, 
+	0x65, 0x63, 0x74, 0x6c, 0x79, 0x20, 0x66, 0x72, 0x6f, 0x6d, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x65, 0x62, 0x20, 0x62, 
+	0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x2e, 0x20, 0x49, 0x74, 
+	0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x73, 0xa, 
+	0x9, 0x20, 0x20, 0x20, 0x20, 0x4a, 0x61, 0x76, 0x61, 0x20, 
+	0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x74, 0x75, 0x72, 0x6e, 
+	0x65, 0x64, 0x20, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x74, 
+	0x68, 0x65, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 
+	0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 
+	0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x20, 0x57, 0x68, 0x65, 0x6e, 0x20, 0x61, 0x73, 0x6b, 
+	0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x70, 
+	0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2c, 0x20, 0x6a, 
+	0x75, 0x73, 0x74, 0x20, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x22, 0x4f, 0x6b, 0x22, 0x20, 0x62, 
+	0x75, 0x74, 0x74, 0x6f, 0x6e, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x74, 
+	0x79, 0x70, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x20, 0x61, 
+	0x6e, 0x79, 0x20, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 
+	0x64, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 
+	0xa, 0x9, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x62, 
+	0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 
+	0x23, 0x22, 0x20, 0x6f, 0x6e, 0x43, 0x6c, 0x69, 0x63, 0x6b, 
+	0x3d, 0x27, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x6f, 
+	0x70, 0x65, 0x6e, 0x28, 0x22, 0x76, 0x6e, 0x63, 0x6a, 0x61, 
+	0x76, 0x61, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x2c, 0xa, 
+	0x9, 0x20, 0x20, 0x20, 0x20, 0x22, 0x43, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x22, 0x2c, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x22, 0x74, 0x6f, 0x6f, 0x6c, 0x62, 0x61, 0x72, 0x3d, 
+	0x6e, 0x6f, 0x2c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 
+	0x6e, 0x3d, 0x6e, 0x6f, 0x2c, 0x73, 0x74, 0x61, 0x74, 0x75, 
+	0x73, 0x3d, 0x79, 0x65, 0x73, 0x2c, 0x6d, 0x65, 0x6e, 0x75, 
+	0x62, 0x61, 0x72, 0x3d, 0x6e, 0x6f, 0x2c, 0x73, 0x63, 0x72, 
+	0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x72, 0x73, 0x3d, 0x79, 0x65, 
+	0x73, 0x2c, 0x72, 0x65, 0x73, 0x69, 0x7a, 0x61, 0x62, 0x6c, 
+	0x65, 0x3d, 0x79, 0x65, 0x73, 0x22, 0x29, 0x3b, 0x27, 0x3e, 
+	0x43, 0x6c, 0x69, 0x63, 0x6b, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x68, 0x65, 0x72, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x6c, 
+	0x61, 0x75, 0x6e, 0x63, 0x68, 0x20, 0x69, 0x6e, 0x20, 0x6e, 
+	0x65, 0x77, 0x20, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x62, 0x3e, 0x3c, 0x2f, 0x63, 
+	0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x9, 0x20, 0x20, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x62, 
+	0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 
+	0x76, 0x6e, 0x63, 0x6a, 0x61, 0x76, 0x61, 0x2e, 0x68, 0x74, 
+	0x6d, 0x6c, 0x22, 0x3e, 0x43, 0x6c, 0x69, 0x63, 0x6b, 0x20, 
+	0x68, 0x65, 0x72, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x61, 
+	0x75, 0x6e, 0x63, 0x68, 0x20, 0x69, 0x6e, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x69, 
+	0x6e, 0x64, 0x6f, 0x77, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 
+	0x62, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x69, 0x73, 0x20, 0x61, 
+	0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x6b, 0x65, 0x65, 
+	0x70, 0x20, 0x38, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 
+	0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x75, 0x70, 0x2e, 0x20, 
+	0x49, 0x6e, 0x20, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x74, 
+	0x6f, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 
+	0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x6f, 0x6e, 0x6f, 0x70, 
+	0x6f, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 
+	0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 
+	0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 
+	0x65, 0x61, 0x63, 0x68, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 
+	0x69, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 
+	0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x20, 
+	0x74, 0x68, 0x65, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 
+	0x79, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x73, 0x68, 
+	0x6f, 0x72, 0x74, 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x2e, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x20, 0x3c, 0x68, 0x33, 0x3e, 0x44, 0x6f, 0x77, 0x6e, 
+	0x6c, 0x6f, 0x61, 0x64, 0x20, 0x56, 0x4e, 0x43, 0x20, 0x63, 
+	0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 
+	0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 
+	0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x66, 0x20, 
+	0x79, 0x6f, 0x75, 0x20, 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x20, 
+	0x68, 0x61, 0x76, 0x65, 0x20, 0x4a, 0x61, 0x76, 0x61, 0x20, 
+	0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x2c, 
+	0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x64, 
+	0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x61, 0xa, 
+	0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x72, 0x65, 
+	0x65, 0x20, 0x56, 0x4e, 0x43, 0x20, 0x63, 0x6c, 0x69, 0x65, 
+	0x6e, 0x74, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 
+	0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x3c, 0x61, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 
+	0x77, 0x77, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x76, 0x6e, 0x63, 
+	0x2e, 0x63, 0x6f, 0x6d, 0x22, 0x3e, 0x52, 0x65, 0x61, 0x6c, 
+	0x56, 0x4e, 0x43, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x20, 0x53, 
+	0x74, 0x61, 0x72, 0x74, 0x20, 0x74, 0x68, 0x65, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x72, 0x6f, 0x67, 
+	0x72, 0x61, 0x6d, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x3c, 
+	0x62, 0x3e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2d, 
+	0x64, 0x65, 0x6d, 0x6f, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 
+	0x73, 0x65, 0x3a, 0x30, 0x3c, 0x2f, 0x62, 0x3e, 0x20, 0x61, 
+	0x73, 0x20, 0x74, 0x68, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 
+	0x2e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 
+	0x20, 0x3c, 0x68, 0x33, 0x3e, 0x55, 0x6e, 0x69, 0x78, 0x2f, 
+	0x58, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x3c, 
+	0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20, 0x9, 0x20, 0x20, 0x20, 
+	0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x55, 0x6e, 0x69, 0x78, 0x2f, 0x58, 0x20, 0x56, 0x4e, 0x43, 
+	0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6e, 
+	0x65, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x74, 
+	0x74, 0x3e, 0x2d, 0x62, 0x67, 0x72, 0x32, 0x33, 0x33, 0x3c, 
+	0x2f, 0x74, 0x74, 0x3e, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 
+	0x6e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6f, 
+	0x20, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x20, 0x55, 0x73, 0x65, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 
+	0x77, 0x69, 0x6e, 0x67, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 
+	0x6e, 0x64, 0x3a, 0xa, 0x9, 0x20, 0x20, 0x20, 0x3c, 0x2f, 
+	0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x76, 
+	0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x20, 0x2d, 
+	0x62, 0x67, 0x72, 0x32, 0x33, 0x33, 0x20, 0x63, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x2e, 
+	0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x3a, 0x30, 0x3c, 
+	0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x20, 
+	0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x72, 0x69, 0x67, 
+	0x68, 0x74, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x2f, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 
+	0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 
+	0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 
+	0x64, 0x61, 0x6d, 0x2f, 0x22, 0x3e, 0x41, 0x64, 0x61, 0x6d, 
+	0x20, 0x44, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x3c, 0x2f, 
+	0x61, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 
+	0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static prog_char data_vncviewer_jar[] = {
+	/* /vncviewer.jar */
+	0x2f, 0x76, 0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x2e, 0x6a, 0x61, 0x72, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 
+	0x6e, 0xd, 0xa, 0xd, 0xa, 0x50, 0x4b, 0x3, 0x4, 0xa, 
+	00, 00, 00, 00, 00, 0x16, 0xa9, 0xda, 0x2c, 00, 
+	00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
+	00, 0x9, 00, 00, 00, 0x4d, 0x45, 0x54, 0x41, 0x2d, 
+	0x49, 0x4e, 0x46, 0x2f, 0x50, 0x4b, 0x3, 0x4, 0xa, 00, 
+	00, 00, 00, 00, 0x16, 0xa9, 0xda, 0x2c, 0x1e, 0xb9, 
+	0xd9, 0x17, 0x2d, 00, 00, 00, 0x2d, 00, 00, 00, 
+	0x14, 00, 00, 00, 0x4d, 0x45, 0x54, 0x41, 0x2d, 0x49, 
+	0x4e, 0x46, 0x2f, 0x4d, 0x41, 0x4e, 0x49, 0x46, 0x45, 0x53, 
+	0x54, 0x2e, 0x4d, 0x46, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 
+	0x73, 0x74, 0x2d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 
+	0x3a, 0x20, 0x31, 0x2e, 0x30, 0xa, 0x43, 0x72, 0x65, 0x61, 
+	0x74, 0x65, 0x64, 0x2d, 0x42, 0x79, 0x3a, 0x20, 0x30, 0x2e, 
+	0x39, 0x32, 0x2d, 0x67, 0x63, 0x63, 0xa, 0xa, 00, 0x50, 
+	0x4b, 0x3, 0x4, 0xa, 00, 00, 00, 0x8, 00, 0xe3, 
+	0xa5, 0xda, 0x2c, 0x5f, 0xeb, 0x71, 0x9a, 0xd7, 0xd, 00, 
+	00, 0x8, 0x19, 00, 00, 0xf, 00, 00, 00, 0x76, 
+	0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x2e, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x8d, 0x57, 0xb, 0x7c, 0x5c, 0x65, 
+	0x95, 0xff, 0x9f, 0xcc, 0x24, 0xf7, 0xe6, 0xf6, 0xb6, 0x99, 
+	0x4e, 0x9b, 0xb4, 0xa1, 0x25, 0xc, 0x2d, 0xa5, 0xc9, 0xa4, 
+	0x69, 0xa4, 0x90, 0x82, 0xd, 0x6d, 0x69, 0xd2, 0xa6, 0x1d, 
+	0x48, 0x93, 0x90, 0xf4, 0x41, 0x5a, 0x1e, 0xbd, 0x99, 0xb9, 
+	0x49, 0xa6, 0x9d, 0xdc, 0x19, 0xee, 0xdc, 0x49, 0x9a, 0xf2, 
+	0x70, 0x15, 0x5d, 0x5d, 0xb5, 0x2e, 0xec, 0xaa, 0xbb, 0xc5, 
+	0x67, 0x5, 0xd, 0x50, 0x94, 0x16, 0x9a, 0x69, 0x35, 0x55, 
+	0x4, 0x56, 0x50, 0xc4, 0x15, 0x4, 0x77, 0x75, 0x57, 0x59, 
+	0x16, 0x9f, 0xab, 0xeb, 0x1b, 0xd7, 0x7d, 0x9, 0x9e, 0x73, 
+	0xef, 0xbc, 0x92, 0xe, 0xbf, 0x9f, 0xc9, 0x6f, 0xbe, 0xef, 
+	0xbb, 0xe7, 0x3b, 0xe7, 0x7c, 0xe7, 0xfd, 0x9d, 0xef, 0xd9, 
+	0xd7, 0xbf, 0xf0, 0x25, 0xf8, 0xd0, 0x42, 0xef, 0xd2, 0x30, 
+	0x89, 0x7, 0xaa, 0x71, 0x18, 0xf, 0xca, 0xf0, 0x90, 0xc6, 
+	0xc3, 0x9, 0x5, 0xf, 0x6b, 0xa8, 0xf4, 0xc0, 0x9f, 0x55, 
+	0xf0, 0x39, 0xd, 0x2a, 0x1e, 0x91, 0x8f, 0x93, 0xb2, 0x3a, 
+	0xa5, 0xe0, 0x51, 0xd, 0xba, 0xb7, 0xfd, 0x98, 0x86, 0xd3, 
+	0x98, 0x56, 0x90, 0xd5, 0x10, 0xf0, 0x20, 0x67, 0x14, 0x9c, 
+	0xd5, 0xb0, 0x8, 0x9f, 0x57, 0xf0, 0x5, 0x15, 0x33, 0x1a, 
+	0x6a, 0x71, 0x4e, 0xe0, 0x5f, 0xd4, 0xf0, 0x25, 0x3c, 0x2e, 
+	0xe8, 0x5f, 0x56, 0xf0, 0x84, 0x86, 0x65, 0x82, 0xbe, 0xc, 
+	0x4f, 0xca, 0xf0, 0x94, 0xf0, 0xfb, 0x7, 0x39, 0xfb, 0x2b, 
+	0x32, 0x3c, 0xad, 0xe0, 0x19, 0xd, 0x2b, 0xf0, 0x55, 0xd9, 
+	0xfb, 0x9a, 0xc, 0xcf, 0xa, 0xdd, 0xd7, 0x85, 0xc3, 0x73, 
+	0xb2, 0xf1, 0xd, 0x5, 0xff, 0xa8, 0xe1, 0x9b, 0x78, 0x5e, 
+	0x86, 0x17, 0x84, 0xe4, 0x5b, 0x82, 0xf5, 0xa2, 0xc, 0x2f, 
+	0x69, 0xf8, 0x36, 0xfe, 0x49, 0xc1, 0x3f, 0x2b, 0xf8, 0x8e, 
+	0x9c, 0xfb, 0x5d, 0x19, 0xfe, 0x45, 0xc3, 0x65, 0xf8, 0x57, 
+	0x59, 0x7d, 0x4f, 0x56, 0xdf, 0xaf, 0xc6, 0xcb, 0xf8, 0x37, 
+	0x5, 0xaf, 0x68, 0xb8, 0xa, 0xf, 0xa8, 0xf8, 0x77, 0x99, 
+	0x5f, 0xad, 0xe6, 0x9d, 0x1f, 0xc8, 0xea, 0x87, 0x2a, 0x7e, 
+	0x24, 0x1f, 0x3f, 0x96, 0xf, 0x66, 0xff, 0x13, 0xfc, 0x54, 
+	0xa8, 0xfe, 0x43, 0x86, 0x9f, 0xa9, 0xf8, 0xb9, 0xec, 0xfd, 
+	0xa7, 0x86, 0x5f, 0xe0, 0x97, 0xd5, 0x6c, 0xa6, 0x5f, 0x69, 
+	0xf8, 0x35, 0x7e, 0xa3, 0xe1, 0xb7, 0xf8, 0x9d, 0xc, 0xaf, 
+	0x89, 0xe9, 0x7e, 0x2f, 0xab, 0xff, 0x12, 0xbc, 0x3f, 0x68, 
+	0xf8, 0x6f, 0xfc, 0x8f, 0x20, 0xff, 0xaf, 0x8a, 0xff, 0x53, 
+	0xf1, 0xff, 0xa, 0xfe, 0xa8, 0xe2, 0x75, 0xd, 0xfd, 0x38, 
+	0xa7, 0xe2, 0xd, 0xd6, 0x8b, 0xa0, 0x12, 0x31, 0x6b, 0xaa, 
+	0x90, 0xc1, 0xa7, 0x92, 0x9f, 0xe9, 0xa8, 0x52, 0xa5, 0x2a, 
+	0x99, 0x15, 0x95, 0x54, 0x99, 0xab, 0x59, 0x4b, 0xd2, 0x58, 
+	0x3, 0x9a, 0x27, 0x9f, 0xba, 0xe0, 0xce, 0xaf, 0xa6, 0x5, 
+	0x54, 0xa3, 0x52, 0x40, 0xb8, 0x2c, 0x14, 0x48, 0x50, 0xa1, 
+	0x45, 0x2a, 0x2d, 0xd6, 0x30, 0x8a, 0x73, 0xec, 0x2b, 0xaa, 
+	0x55, 0xa9, 0x4e, 0x8, 0x97, 0xb0, 0x9b, 0x69, 0xa9, 0x46, 
+	0xf5, 0x74, 0x81, 0x4a, 0xcb, 0x58, 0x38, 0x5a, 0xae, 0xd2, 
+	0x85, 0x2a, 0x35, 0x68, 0x74, 0x11, 0x85, 0x64, 0xf3, 0x62, 
+	0x95, 0x56, 0x8, 0xc5, 0x4a, 0x85, 0x2e, 0x51, 0x68, 0x95, 
+	0x42, 0x97, 0x12, 0xfc, 0xa3, 0xc9, 0xb4, 0x43, 0x8, 0x76, 
+	0x1f, 0x34, 0xc6, 0x8d, 0xd6, 0x84, 0x61, 0x8d, 0xb4, 0xe, 
+	0x38, 0x76, 0xdc, 0x1a, 0x69, 0xe7, 0xbd, 0x54, 0xd2, 0xe6, 
+	0x3d, 0x8a, 0x10, 0x7c, 0xf6, 0xf0, 0x10, 0x41, 0xeb, 0xe6, 
+	0xa9, 0xcf, 0x4e, 0x3a, 0x49, 0xde, 0xad, 0xe6, 0xf5, 0xae, 
+	0x51, 0xdb, 0x34, 0x62, 0xb3, 0xc9, 0x3d, 0x18, 0x23, 0x28, 
+	0x23, 0x76, 0x3c, 0x36, 0x64, 0x8c, 0x10, 0x96, 0x7a, 0xdb, 
+	0xc6, 0x84, 0xd3, 0xba, 0x9d, 0x61, 0x1d, 0xc6, 0x48, 0xb7, 
+	0x31, 0x99, 0xcc, 0x38, 0x8c, 0x34, 0x6f, 0x28, 0xe3, 0x38, 
+	0x49, 0xab, 0xcf, 0xb0, 0xcc, 0x4, 0x21, 0x50, 0x44, 0x74, 
+	0x21, 0x8c, 0x10, 0x88, 0xc5, 0xd3, 0xd1, 0xa4, 0x65, 0x99, 
+	0x51, 0xa7, 0xc3, 0x45, 0x25, 0x2c, 0x2c, 0x62, 0x79, 0x20, 
+	0x46, 0x9b, 0x6f, 0x64, 0x9c, 0x51, 0xd3, 0x72, 0xe2, 0x51, 
+	0xc3, 0x49, 0xda, 0x84, 0xda, 0xee, 0x12, 0x40, 0x3c, 0x77, 
+	0x80, 0x48, 0x6d, 0x5a, 0xd1, 0x64, 0x8c, 0xf5, 0x4b, 0x13, 
+	0x2a, 0xf6, 0xb3, 0x66, 0x9a, 0xb5, 0xad, 0x8, 0x51, 0x47, 
+	0x92, 0x4e, 0x57, 0x32, 0x9a, 0xe1, 0x25, 0xed, 0x23, 0x54, 
+	0x5d, 0x1d, 0xb7, 0xe2, 0xce, 0x26, 0x56, 0xbf, 0xb1, 0x69, 
+	0xf, 0xdb, 0xa3, 0x33, 0x19, 0x33, 0x9, 0x35, 0xdd, 0x71, 
+	0xcb, 0xec, 0xc9, 0x8c, 0xd, 0x99, 0xf6, 0x2e, 0x63, 0x28, 
+	0xc1, 0x10, 0xbf, 0xa0, 0x31, 0x7a, 0x26, 0x15, 0x33, 0x1c, 
+	0xfe, 0xae, 0x6b, 0x2c, 0x55, 0xd8, 0x48, 0x8d, 0xc6, 0xa3, 
+	0xe9, 0x76, 0xe1, 0xe0, 0xb3, 0x33, 0x2c, 0x7f, 0x5d, 0x4e, 
+	0x9f, 0x2d, 0x56, 0x6c, 0x4b, 0x51, 0x48, 0xa6, 0xd3, 0xb6, 
+	0x1d, 0x8e, 0x9a, 0x29, 0x11, 0x97, 0x5, 0x58, 0x1a, 0x4b, 
+	0xba, 0xa6, 0x8e, 0x26, 0x13, 0x11, 0x66, 0x1f, 0x37, 0x12, 
+	0xf1, 0xb4, 0xab, 0xa, 0x41, 0x4f, 0x9b, 0x4e, 0x89, 0xd4, 
+	0x55, 0x46, 0xd4, 0x83, 0xaf, 0x2a, 0x39, 0x77, 0xdb, 0x38, 
+	0xf3, 0x6d, 0x2f, 0xf1, 0x4b, 0xef, 0xd0, 0x41, 0x3e, 0xb3, 
+	0xbd, 0x89, 0xf5, 0xaa, 0x4e, 0xb0, 0xd3, 0x73, 0x7a, 0xea, 
+	0x6c, 0x10, 0x7b, 0x32, 0xe5, 0x74, 0x4c, 0x3a, 0x26, 0x7f, 
+	0x2e, 0x69, 0xdc, 0xdf, 0x71, 0x7e, 0x2c, 0x88, 0xec, 0xb, 
+	0xc4, 0xad, 0x7d, 0x86, 0x6d, 0x8c, 0x99, 0x8e, 0x69, 0x33, 
+	0xea, 0xfc, 0x59, 00, 0xc2, 0xea, 0xc6, 0xf3, 0x9, 0xf7, 
+	0x35, 0x95, 0xb, 0x2c, 0x6d, 0xd8, 0x70, 0x8c, 0xc4, 0x36, 
+	0xdb, 0x76, 0x3d, 0x55, 0x86, 0x4c, 0xce, 0xd3, 0x6, 0x92, 
+	0x19, 0x3b, 0x6a, 0x76, 0xc5, 0xc5, 0xc2, 0xb, 0xc6, 0xad, 
+	0xe8, 0x78, 0xdc, 0x9c, 0x30, 0xed, 0xb5, 0x82, 0xac, 0xe3, 
+	0x6e, 0xdc, 0xa3, 0xe3, 0x7d, 0x78, 0xbf, 0x8e, 0xf, 0xe0, 
+	0xaf, 0x75, 0x1c, 0xc7, 0x3d, 0x84, 0x45, 0x65, 0x5c, 0xae, 
+	0xe3, 0xaf, 0xf0, 0x5e, 0x8e, 0xa2, 0xb9, 0xf1, 0xc9, 0x1c, 
+	0x68, 0xb5, 0x8e, 0xb7, 0xe3, 0x1d, 0x3a, 0x35, 0xa, 0x71, 
+	0x5d, 0xf9, 0x10, 0xd5, 0x71, 0x17, 0xde, 0xa9, 0x50, 0x93, 
+	0x4e, 0x61, 0x6a, 0x66, 0x39, 0x66, 0xc7, 0xa7, 0x8e, 0x77, 
+	0xe1, 0x2f, 0xf9, 0xe0, 0x2, 0xb4, 0x2b, 0x91, 0x9c, 0xc8, 
+	0x13, 0xde, 0x4d, 0x6b, 0x38, 0x58, 0xe6, 0x84, 0x2a, 0xeb, 
+	0xb5, 0xb5, 0x10, 0xd0, 0xa2, 0xc6, 0xa7, 0x75, 0xbc, 0x1b, 
+	0xef, 0x51, 0xa8, 0x45, 0xa7, 0xb5, 0xac, 0x13, 0xb5, 0xd2, 
+	0x5b, 0x8, 0xcb, 0xe6, 0xa, 0xd3, 0xc9, 0x21, 0xe1, 0xd8, 
+	0x46, 0xdc, 0x72, 0xd2, 0x3a, 0x5d, 0x86, 0x3b, 0x75, 0x5a, 
+	0x27, 0xc3, 0xe5, 0x74, 0x85, 0x8e, 0xbf, 0x17, 0x53, 0xdc, 
+	0x2b, 0x3a, 0x54, 0xb3, 0x95, 0x3a, 0xd, 0x6b, 0xdc, 0x48, 
+	0xcb, 0xe9, 0x6d, 0x3a, 0xad, 0xa7, 0x2b, 0x75, 0xba, 0x4a, 
+	0x86, 0xb7, 0xa, 0xef, 0xd, 0x32, 0xb4, 0xbb, 0xa6, 0x2a, 
+	0xda, 0xa3, 0x10, 0x73, 0xa, 0x5d, 0xad, 0xd3, 0x46, 0x41, 
+	0xd9, 0x44, 0x9b, 0x75, 0xdc, 0xcf, 0xa2, 0xd1, 0x35, 0x72, 
+	0xca, 0x16, 0xdc, 0xa9, 0x50, 0x87, 0x4e, 0x9d, 0x42, 0xd9, 
+	0x50, 0xa4, 0x8c, 0x58, 0xec, 0x77, 0x3b, 0x93, 0x72, 0xcc, 
+	0x58, 0x81, 0x9, 0xe7, 0x50, 0xbe, 0x46, 0xe8, 0xb8, 0xd, 
+	0xb7, 0xeb, 0xb8, 0x83, 0x59, 0xb0, 0x34, 0x5b, 0x75, 0xbc, 
+	0xd, 0x7f, 0xa1, 0xd3, 0x36, 0xdc, 0xa3, 0x50, 0x97, 0x4e, 
+	0xdb, 0x69, 0x47, 0xde, 0xe8, 0x25, 0x9e, 0xef, 0xc8, 0xc, 
+	0xf, 0x4b, 0x2c, 0xad, 0xea, 0xef, 0xea, 0x8, 0xa5, 0x4d, 
+	0x7b, 0xdc, 0xb4, 0x43, 0xe9, 0x4c, 0x4a, 0xa, 0x51, 0x3a, 
+	0x94, 0xca, 0xa5, 0x43, 0x88, 0xa1, 0x69, 0x3e, 0x2b, 0xa4, 
+	0x73, 0x69, 0xba, 0x56, 0xa7, 0xeb, 0x44, 0xc8, 0x8, 0x75, 
+	0x73, 0xd2, 0xae, 0xd5, 0x69, 0xa7, 0x48, 0xdb, 0xa3, 0x53, 
+	0xaf, 0xc8, 0xdf, 0x27, 0xea, 0x5c, 0x4f, 0xfd, 0x9c, 0x4e, 
+	0x3d, 0xc9, 0xd0, 0xec, 0xf8, 0x8, 0x59, 0xa6, 0x19, 0x33, 
+	0x63, 0x3a, 0xd, 0xd0, 0x2e, 0x85, 0x76, 0xeb, 0xb4, 0x87, 
+	0xf6, 0xea, 0x74, 0x3, 0xd, 0x2a, 0xb4, 0x4f, 0xa7, 0xfd, 
+	0xb4, 0x59, 0xa1, 0x1b, 0x75, 0xba, 0x89, 0xfa, 0x75, 0xba, 
+	0x99, 0x6e, 0xd1, 0xe9, 0x80, 0xf0, 0x32, 0x68, 0x48, 0xa7, 
+	0x28, 0xc5, 0x14, 0x32, 0x75, 0x1a, 0x16, 0x82, 0x11, 0xe1, 
+	0xbe, 0x7c, 0x4f, 0x4f, 0xe7, 0x5c, 0xf6, 0xe9, 0x4c, 0x34, 
+	0xea, 0x9e, 0x40, 0xa8, 0x2f, 0xb3, 0x3d, 0x6c, 0x70, 0x64, 
+	0xc7, 0xf2, 0xae, 0x88, 0x27, 0x5b, 0x23, 0xbd, 0x25, 0x56, 
+	0xc, 0xbf, 0x29, 0x45, 0xa8, 0x25, 0xe4, 0x24, 0x93, 0xa1, 
+	0x31, 0xc3, 0x9a, 0xc, 0xb1, 0xcd, 0x24, 0x69, 0x57, 0xec, 
+	0xb6, 0xe, 0x59, 0xc9, 0x9, 0x2b, 0x54, 0x86, 0xc8, 0x36, 
+	0xd3, 0x99, 0x84, 0xc3, 0xa6, 0x1a, 0xa5, 0x38, 0x1f, 0x96, 
+	0x36, 0x2d, 0xa9, 0x1a, 0xa1, 0x68, 0x22, 0xce, 0x48, 0x21, 
+	0x29, 0x5c, 0x3a, 0x1d, 0x14, 0xcd, 0xe, 0x89, 0x77, 0x3, 
+	0x5b, 0xcd, 0xf4, 0x21, 0x27, 0x99, 0xa, 0x59, 0x9c, 0xd5, 
+	0xa1, 0x78, 0x9a, 0xe9, 0x12, 0xb8, 0xbd, 0x4, 0x9e, 0x8e, 
+	0x1f, 0xc9, 0xc1, 0xc7, 0x70, 0x27, 0x17, 0xb4, 0xd0, 0x61, 
+	0x5e, 0x5a, 0xe2, 0xe2, 0x8f, 0x48, 0x18, 0x1e, 0x15, 0x57, 
+	0x24, 0x39, 0x23, 0x29, 0x45, 0xb7, 0x2a, 0x64, 0xeb, 0x94, 
+	0x26, 0xae, 0x8c, 0x5a, 0xb1, 0x88, 0xeb, 0x94, 0x91, 0xd3, 
+	0xc6, 0xe5, 0xb4, 0x62, 0x36, 0x75, 0x1b, 0x43, 0x52, 0xff, 
+	0xf5, 0x62, 0x6e, 0x88, 0x63, 0x26, 0x4, 0xc9, 0xbf, 0xa3, 
+	0x77, 0x60, 0x97, 0x8e, 0x4f, 0xe1, 0x3e, 0x9d, 0xe, 0xd3, 
+	0xa4, 0x42, 0x47, 0x74, 0xba, 0x8d, 0x36, 0x13, 0xa0, 0xd3, 
+	0xed, 0x74, 0x7, 0xdb, 0x5e, 0x10, 0x42, 0xa9, 0x7c, 0x21, 
+	0xa, 0x59, 0x49, 0x27, 0x94, 0x4e, 0x99, 0xd1, 0xf8, 0x70, 
+	0x5c, 0xec, 0xeb, 0xef, 0xeb, 0xed, 0x67, 0xff, 0xb2, 0x5c, 
+	0x6f, 0x23, 0x8e, 0xbf, 0xb7, 0xd3, 0x3b, 0x38, 0x18, 0xde, 
+	0xc, 0x5d, 0xa7, 0xbb, 0xe8, 0x9d, 0x5e, 0x22, 0x79, 0xe5, 
+	0x86, 0xef, 0x36, 0x4f, 0xc8, 0x54, 0x2a, 0x61, 0x3a, 0xad, 
+	0x5b, 0xdc, 0x29, 0xf, 0x74, 0x3, 0xb7, 0x3f, 0x63, 0x59, 
+	0xde, 0x35, 0xb0, 0xa4, 0xb4, 0x92, 0xe5, 0xc1, 0x6e, 0x2d, 
+	0xab, 0x4c, 0x3b, 0x86, 0x5d, 0x20, 0x13, 0x85, 0x39, 0xa1, 
+	0x1d, 0x4e, 0x67, 0x39, 0xa0, 0x9a, 0xab, 0xb9, 0x57, 0x33, 
+	0x38, 0xf1, 0x4b, 0x2a, 0xb8, 0x7, 0xdb, 0x69, 0x58, 0xc6, 
+	0x88, 0x69, 0xbb, 0x6c, 0xaa, 0x1a, 0x23, 0x91, 0x88, 0x2c, 
+	0x4a, 0xf9, 0x8c, 0xa5, 0x92, 0x16, 0xbb, 0x92, 0xef, 0x5b, 
+	0x36, 0xb2, 0x27, 0x88, 0xcf, 0x88, 0xb1, 0xe2, 0xe1, 0x12, 
+	0x5e, 0x5, 0xb4, 0xf6, 0xa6, 0x72, 0x40, 0x16, 0x42, 0x2e, 
+	0xeb, 0x89, 0x78, 0xcc, 0x19, 0x95, 0xfb, 0xc4, 0x8a, 0x8e, 
+	0x4a, 0x69, 0x5e, 0xc0, 0x92, 0x95, 0x54, 0x1e, 0xc2, 0x15, 
+	0x65, 0x59, 0x9e, 0x77, 0xbb, 0x97, 0xd0, 0x78, 0x57, 0x47, 
+	0x63, 0x77, 0xc1, 0xa0, 0x2e, 0x40, 0x99, 0x30, 0xe3, 0x23, 
+	0xa3, 0xce, 0x61, 0xce, 0xd8, 0xad, 0x85, 0xaf, 0x49, 0xae, 
+	0x1d, 0xe3, 0x7c, 0xcb, 0x79, 0x77, 0x68, 0x95, 0x99, 0xb3, 
+	0x6a, 0x2d, 0xa7, 0x7d, 0xd4, 0x4c, 0xa7, 0x7b, 0x92, 0xf6, 
+	0x98, 0x91, 0xc8, 0x5f, 0x89, 0xb3, 0x4a, 0x18, 0x97, 0xf4, 
+	0xe4, 0x84, 0x87, 0x5d, 0x93, 0xe2, 0x32, 0xe2, 0xc, 0x38, 
+	0x46, 0xf4, 0xd0, 0x2e, 0xdb, 0x88, 0x32, 0x44, 0x75, 0x92, 
+	0x5e, 0x6d, 0x21, 0x2c, 0x6e, 0x2c, 0x7b, 0x1d, 0x55, 0xc6, 
+	0x53, 0x46, 0xec, 0x70, 0x6e, 0x9e, 0x9c, 0x75, 0x59, 0x78, 
+	0x97, 0x26, 0x7, 0xd1, 0x84, 0x21, 0x37, 0xfc, 0xc5, 0x65, 
+	0xee, 0xaa, 0xc8, 0x1c, 0xdd, 0xdc, 0x7b, 0x72, 0x8f, 0x57, 
+	0xa1, 0x76, 0xa6, 0x47, 0x66, 0xb1, 0x1b, 0x98, 0x4c, 0x3b, 
+	0xe6, 0x18, 0x3b, 0xc8, 0x75, 0x76, 0x6d, 0x77, 0x3e, 0xf5, 
+	0xfb, 0x3c, 0xa1, 0x99, 0x72, 0xac, 0x5d, 0xec, 0x9f, 0x4a, 
+	0x71, 0x9a, 0x12, 0xd6, 0x94, 0xbb, 0x1a, 0xcf, 0x3, 0x79, 
+	0x35, 0x53, 0x7a, 0x29, 0xaf, 0x60, 0xee, 0x34, 0xe, 0x8a, 
+	0xf3, 0x96, 0x35, 0x46, 0xfe, 0xc, 0xdc, 0xb8, 0x25, 0xb8, 
+	0x8b, 0xca, 0x8, 0xc2, 0x7e, 0x71, 0x6d, 0x99, 0xe0, 0x6a, 
+	0x54, 0x33, 0x61, 0xc7, 0x1d, 0xb3, 0x54, 0x29, 0x57, 0x4b, 
+	0xe9, 0x5e, 0x6, 0xa2, 0xa3, 0xe6, 0x98, 0xe9, 0xb6, 0x48, 
+	0xdc, 0x4d, 0x55, 0xc4, 0x39, 0x4a, 0xea, 0xb, 0x7a, 0x6d, 
+	0xe5, 0x7b, 0x3e, 0x62, 0xa5, 0x32, 0x45, 0xdd, 0x96, 0xbc, 
+	0xc9, 0x96, 0xf4, 0x93, 0xcc, 0xb1, 0x2b, 0x93, 0x48, 0xb0, 
+	0x7, 0x2a, 0xb9, 0xb, 0x11, 0x5b, 0xaa, 0x29, 0x23, 0x9d, 
+	0x9e, 0x48, 0xda, 0x6c, 0x8b, 0xc5, 0xc5, 0x28, 0xdb, 0x65, 
+	0x1e, 0x76, 0xba, 0xe2, 0x66, 0x42, 0x9a, 0xcc, 0xba, 0x59, 
+	0xd0, 0xd2, 0x6c, 0x18, 0x31, 0x1d, 0x1, 0xcd, 0xb6, 0x7f, 
+	0x2e, 0x10, 0xaa, 0x12, 0xa6, 0x35, 0x22, 0xa1, 0x5e, 0x9d, 
+	0xce, 0xc, 0xa5, 0x73, 0xc0, 0x3a, 0xce, 0xae, 0xf2, 0xf1, 
+	0x61, 0x9b, 0x8e, 0x2d, 0xd1, 0xc9, 0x2c, 0x73, 0x6d, 0x92, 
+	0xca, 0xb8, 0xfb, 0x3b, 0xdc, 0x5c, 0xac, 0x48, 0xf2, 0x77, 
+	0x5d, 0x41, 0xe5, 0xde, 0x8c, 0x53, 0xaa, 0xef, 0xe2, 0x72, 
+	0x70, 0x66, 0xe9, 0x1a, 0x94, 0xa5, 0x14, 0xa5, 0x23, 0x22, 
+	0x6f, 0x95, 0x6d, 0x8e, 0x25, 0xc7, 0x4b, 0xaa, 0xc8, 0x9c, 
+	0xb4, 0xdd, 0x93, 0xf7, 0x42, 0xa7, 0x5b, 0xb9, 0x23, 0x6e, 
+	0xc7, 0xe9, 0x7a, 0x61, 0xc0, 0xf5, 0xa4, 0x7, 0x98, 0x17, 
+	0xf3, 0xea, 0x74, 0x8f, 0x21, 0x3e, 0x9, 0xc, 0x4b, 0x91, 
+	0x1b, 0x72, 0x7d, 0xbe, 0xd7, 0xcb, 0xed, 0x85, 0x25, 0xa0, 
+	0x1d, 0x6e, 0xda, 0x31, 0x5a, 0xdc, 0x9a, 0x9b, 0x5c, 0xb, 
+	0xdd, 0xa3, 0x6, 0x66, 0xb7, 0x99, 0x8d, 0xfb, 0xbd, 0xea, 
+	0x53, 0x2c, 0xdb, 0x6e, 0x93, 0xc9, 0x3b, 0x5c, 0xdd, 0x46, 
+	0xcc, 0x39, 0xcf, 0x88, 0x5c, 0xbf, 0xe9, 0x3a, 0x56, 0x34, 
+	0xdb, 0x92, 0x60, 0xbe, 0x95, 0x51, 0x6e, 0x3d, 0xa5, 0x63, 
+	0x4e, 0xb3, 0x90, 0x2c, 0xee, 0x88, 0x14, 0x98, 0x98, 0xd9, 
+	0x61, 0x8, 0x30, 0x90, 0x4f, 0x4f, 0x8b, 0x2b, 0xed, 0xee, 
+	0xfe, 0x6e, 0xa6, 0xd5, 0x4b, 0xbf, 0x3d, 0xa7, 0xee, 0x70, 
+	0x1f, 0x2c, 0x55, 0xe6, 0xad, 0x19, 0x23, 0x91, 0x9e, 0xd3, 
+	0x3e, 0x96, 0xf4, 0xb8, 0xb, 0x67, 0xf7, 0x29, 0x23, 0x52, 
+	0x69, 0x39, 0x9c, 0xec, 0xb4, 0xe9, 0x9a, 0xbb, 0x6c, 0xd7, 
+	0xc9, 0x1, 0xac, 0xf3, 0x9, 0x25, 0x3d, 0xed, 0xa5, 0x7f, 
+	0x56, 0x6, 0xca, 0xfb, 0x23, 0x9a, 0xb1, 0x6d, 0x36, 0x46, 
+	0xfe, 0x45, 0x34, 0xbb, 0xd4, 0xe4, 0xde, 0x44, 0xb8, 0x98, 
+	0x5f, 0xa7, 0x93, 0x20, 0x1c, 0xc1, 0x3c, 0x40, 0xda, 0x23, 
+	0xc8, 0x1f, 0x77, 0x48, 0xee, 0xcc, 0xfd, 0x91, 0x3b, 0x73, 
+	0x53, 0xea, 0xce, 0xdc, 0x79, 0xba, 0x33, 0xf7, 0x98, 0xee, 
+	0xcc, 0x7d, 0xa2, 0x3b, 0x73, 0x47, 0xeb, 0xce, 0xdc, 0xfe, 
+	0xba, 0xf3, 0xd1, 0x1c, 0x3d, 0x77, 0xc2, 0x3c, 0x2e, 0x60, 
+	0xfe, 0xdc, 0x1d, 0xf3, 0xf8, 0x37, 0xfc, 0xb5, 0x1e, 0x15, 
+	0xbc, 0x2, 0x82, 0xe1, 0x33, 0xa0, 0x70, 0x40, 0x3b, 0xa7, 
+	0x4d, 0xa3, 0x22, 0xec, 0x9b, 0x86, 0xef, 0x14, 0x43, 0x9, 
+	0x7f, 0x2b, 0x7b, 0xf0, 0xf3, 0x78, 0x21, 0xfc, 0x54, 0xc3, 
+	0x77, 0x6a, 0x1a, 0xb, 0x79, 0x4d, 0xf8, 0x60, 0x81, 0xc7, 
+	0x75, 0xbc, 0x2f, 0x3c, 0x56, 0x86, 0xb3, 0xf0, 0x87, 0x67, 
+	0x50, 0x39, 0x78, 0x6, 0x55, 0xd3, 0x50, 0x78, 0xa9, 0xe, 
+	0x32, 0xdf, 0xea, 0x69, 0x68, 0xe1, 0xd3, 0xd0, 0xb2, 0x98, 
+	0x57, 0x64, 0x5a, 0xc7, 0x4f, 0x64, 0xe0, 0x5a, 0x26, 0xed, 
+	0x41, 0xd, 0xfa, 0xf8, 0xd5, 0x7e, 0x3d, 0xbf, 0xea, 0xfb, 
+	0x79, 0xf7, 0x43, 0xf8, 0x70, 0x8e, 0x71, 0x3d, 0xff, 0x2a, 
+	0x84, 0xa2, 0x48, 0x56, 0xe5, 0x9e, 0xb4, 0x9b, 0xc7, 0xbf, 
+	0xcb, 0x9f, 0xcf, 0xfd, 0x67, 0x15, 0x7c, 0xc, 0x7d, 0x82, 
+	0xf, 0xd4, 0xf9, 0xec, 0xf9, 0xd3, 0x58, 0x10, 0xe6, 0x3, 
+	0x17, 0x64, 0x51, 0xc3, 0xa0, 00, 0x83, 0x16, 0x4e, 0xb3, 
+	0x86, 0xa7, 0x11, 0x9c, 0xc1, 0xa2, 0x41, 0x9f, 0xcf, 0x77, 
+	0x6, 0x8b, 0xbd, 0xbd, 0xda, 0xc1, 0x60, 0xdd, 0x19, 0x2c, 
+	0x99, 0xc6, 0x52, 0xde, 0x5d, 0x9a, 0x45, 0xbd, 0x20, 0x79, 
+	0xcb, 0xb, 0xf6, 0xce, 0x60, 0x19, 0x93, 0x2e, 0xef, 0x6e, 
+	0x66, 0x73, 0x5c, 0xd8, 0x1c, 0x8, 0x4e, 0xa3, 0x41, 0xb8, 
+	0xa, 0x4a, 0x73, 0x16, 0x17, 0xc9, 0x11, 0x41, 0xc1, 0x63, 
+	0xb5, 0x43, 0xfc, 0xbb, 0x78, 0x6, 0x2b, 0x44, 0xdd, 0x95, 
+	0x3b, 0x9b, 0x6b, 0xa6, 0x71, 0x89, 0xc, 0xab, 0x4, 0x7f, 
+	0x8d, 0x8b, 0xbc, 0x26, 0x87, 0x79, 0xa9, 0xc7, 0x7d, 0x35, 
+	0x7f, 0x37, 0x4e, 0x21, 0xb0, 0x93, 0xe7, 0xb0, 0x6c, 0x32, 
+	0xd2, 0x9a, 0x53, 0xac, 0xd0, 0x4, 0x4e, 0xe2, 0x31, 0x34, 
+	0xe5, 0xd4, 0x1d, 0x76, 0x6d, 0x70, 0x13, 0x87, 0xc3, 0xcd, 
+	0x58, 0x84, 0x3, 0x68, 0x80, 0x81, 0x56, 0xc, 0xe1, 0x6a, 
+	0x44, 0xd1, 0x89, 0x18, 0x7a, 0x61, 0x61, 0x2f, 0x92, 0xb8, 
+	0x11, 0x29, 0x86, 0xde, 0xca, 0x5f, 0x36, 0x73, 0xc8, 0x70, 
+	0xe8, 0x4c, 0x70, 0xb8, 0x4c, 0x72, 0x40, 0x1c, 0x61, 0xf7, 
+	0xdf, 0xc6, 0x66, 0xba, 0x9d, 0x1b, 0xb0, 0x3b, 0xf8, 0x1d, 
+	0x74, 0x17, 0x3e, 0xcd, 0xe1, 0xf2, 0x30, 0x87, 0xc8, 0x63, 
+	0xbc, 0x73, 0x96, 0x83, 0xe2, 0xcb, 0x6c, 0x48, 0xc8, 0x2b, 
+	0x81, 0x6d, 0xcd, 0xe6, 0xac, 0x78, 0x96, 0xcd, 0x59, 0xcd, 
+	0x66, 0x7d, 0xb9, 0x8c, 0xfe, 0x45, 0xcd, 0x9a, 0x3, 0xb1, 
+	0x69, 0xb4, 0x34, 0x7, 0xd6, 0x4d, 0x63, 0x6d, 0xce, 0x2a, 
+	0x4a, 0xde, 0x2a, 0x4a, 0x5e, 0x57, 0xdf, 0xc6, 0x29, 0x3a, 
+	0x2a, 0x80, 0x9e, 0x96, 0x27, 0x3d, 0x78, 0xeb, 0x14, 0x2a, 
+	0x37, 0xf8, 0x5b, 0x9e, 0x9a, 0x82, 0xb6, 0xa1, 0xb2, 0xe5, 
+	0xa9, 0xfa, 0xca, 0xc7, 0xd9, 0xb, 0x97, 0xd, 0xf2, 0xe6, 
+	0x3a, 0xfe, 0x5d, 0xce, 0xe6, 0xbb, 0x62, 0x1a, 0x6d, 0xbc, 
+	0x6c, 0xcb, 0x62, 0xfd, 0xa3, 0xb8, 0x72, 0x6, 0x57, 0xb1, 
+	0xc, 0x6f, 0xd, 0x6e, 0xc8, 0xa2, 0x5d, 0xa0, 0xa7, 0x71, 
+	0x75, 0x16, 0x1b, 0x83, 0x9b, 0xa, 0x9f, 0x9b, 0xf9, 0x33, 
+	0x8b, 0x6b, 0xb2, 0xd8, 0xe2, 0x11, 0x75, 0x78, 0x53, 0xe7, 
+	0x9, 0x89, 0x78, 0x5a, 0x9c, 0x8f, 0x20, 0xfe, 0x2d, 0xcb, 
+	0xad, 0x1b, 0x99, 0x6d, 0x70, 0x2b, 0x13, 0xf8, 0x37, 0x4e, 
+	0xe1, 0x57, 0x81, 0xc0, 0x39, 0x75, 0x83, 0xdf, 0xe3, 0xb5, 
+	0xad, 0xde, 0x9f, 0x45, 0x97, 0x8, 0x7a, 0x1a, 0xdb, 0xb3, 
+	0xd8, 0xb1, 0xa1, 0xb2, 0xbe, 0x32, 0x8b, 0x48, 0x40, 0xbd, 
+	0x1f, 0xf3, 0xeb, 0x2b, 0x7d, 0x1, 0x35, 0x8b, 0x6b, 0x73, 
+	0xb0, 0x7b, 0x31, 0xdf, 0x53, 0xe8, 0xba, 0x29, 0x9c, 0x8, 
+	0xa8, 0xcc, 0xa3, 0x8a, 0x31, 0xdc, 0xad, 0xfa, 0x2a, 0x5f, 
+	0x16, 0xdd, 0xee, 0x72, 0xbd, 0x32, 0x5, 0xbd, 0xbe, 0xaa, 
+	0x56, 0xf1, 0xed, 0xe2, 0x47, 0x62, 0xad, 0x12, 0x50, 0x8f, 
+	0xbf, 0xf1, 0x3b, 0xef, 0xac, 0x9d, 0x72, 0x56, 0x4f, 0xee, 
+	0xdc, 0x2c, 0x7a, 0xd7, 0xab, 0xb5, 0xea, 0x43, 0x6e, 0x9a, 
+	0x6e, 0x85, 0xf7, 0x57, 0x91, 0x93, 0xb9, 0x91, 0x7f, 0x1b, 
+	0x44, 0xe6, 0xbe, 0x9c, 0xcc, 0xed, 0xf2, 0x71, 0xbd, 0xa7, 
+	0xb1, 0x27, 0x41, 0xd3, 0xc, 0xfa, 0x7, 0x83, 0x3, 0x67, 
+	0xb0, 0xeb, 0x71, 0x59, 0xe5, 0x8d, 0xb6, 0x9b, 0xad, 0x54, 
+	0xab, 0x7a, 0x6, 0x92, 0xbd, 0xe5, 0xc7, 0x5e, 0xcf, 0xe4, 
+	0xfc, 0xb3, 0xe7, 0x14, 0xf3, 0xef, 0xe1, 0x44, 0xba, 0x1, 
+	0x6f, 0xe1, 0xf9, 0x16, 0xfe, 0xcf, 0xa7, 0xd8, 0xb3, 0x58, 
+	0xc7, 0xe3, 0xbd, 0x50, 0x39, 0x62, 0xe6, 0xe3, 0xa3, 0x1c, 
+	0x77, 0x1f, 0xc3, 0x52, 0x7c, 0x9c, 0x93, 0xfe, 0x13, 0x58, 
+	0x89, 0x4f, 0x72, 0x6c, 0x1e, 0x47, 0x1b, 0xf7, 0xdb, 0x9b, 
+	0x70, 0x1f, 0x3a, 0xf0, 0x20, 0xcb, 0x7b, 0x2, 0xdb, 0xf1, 
+	0x59, 0xe6, 0xf2, 0x8, 0x73, 0x3b, 0xc9, 0x9c, 0x1e, 0xe5, 
+	0xb8, 0x3d, 0xcd, 0x91, 0x97, 0xe5, 0x52, 0x75, 0x96, 0xa1, 
+	0x33, 0xbc, 0xfa, 0x22, 0xbe, 0xc3, 0x91, 0xf6, 0xa, 0x9e, 
+	0xc0, 0xab, 0x78, 0x12, 0x3f, 0xc2, 0x57, 0xf0, 0x73, 0x3c, 
+	0x8d, 0x3f, 0xe0, 0xab, 0xe4, 0xc3, 0xd7, 0x68, 0x9, 0xbe, 
+	0x4e, 0x17, 0xe1, 0x39, 0xba, 0x14, 0xdf, 0xa0, 0x26, 0x3c, 
+	0x4f, 0xad, 0x78, 0x81, 0x9f, 0x9a, 0x2f, 0xd2, 0x76, 0xbc, 
+	0xc4, 0xf, 0xb6, 0x17, 0x69, 0x2f, 0xbe, 0x47, 0x51, 0xbc, 
+	0xcc, 0x4f, 0x87, 0x57, 0xe8, 0xfd, 0x78, 0x95, 0x3e, 0x88, 
+	0x1f, 0xd0, 0x87, 0xf1, 0x43, 0x3a, 0x86, 0x1f, 0xd3, 0x71, 
+	0xfc, 0x84, 0x1e, 0xc0, 0x4f, 0xe9, 0x4, 0x7e, 0x46, 0xd3, 
+	0xf8, 0x5, 0xbd, 0x80, 0x13, 0xf4, 0x6d, 0xbc, 0x46, 0xdf, 
+	0xc7, 0xef, 0x71, 0x8c, 0x35, 0x91, 0xe2, 0xd4, 0xef, 0x6a, 
+	0x94, 0x8b, 0x70, 0x8e, 0x75, 0x9f, 0x1b, 0x11, 0xa3, 0x62, 
+	0xc8, 0xbd, 0x85, 0xd0, 0xb9, 0xc1, 0x9b, 0x6, 0x4b, 0xc2, 
+	0x6e, 0x5f, 0x21, 0xce, 0xf6, 0xf3, 0xca, 0x8b, 0xb3, 0x92, 
+	0xed, 0x1b, 0xb, 0xdb, 0x37, 0x49, 0x54, 0xde, 0x5c, 0xf8, 
+	0xbc, 0xa5, 0x18, 0x95, 0x59, 0x1c, 0x28, 0x96, 0xaf, 0x6, 
+	0x28, 0x3c, 0xfe, 0x91, 0x6d, 0xfb, 0x6, 0x6a, 0x88, 0xfb, 
+	0x2, 0xd6, 0xbe, 0x8d, 0xfc, 0x88, 0x92, 0x82, 0x11, 0x52, 
+	0x67, 0xc9, 0xfb, 0x91, 0x42, 0x81, 0xfd, 0x18, 0xd7, 0x4a, 
+	0x89, 0x6, 0x43, 0xa, 0xb3, 0xc1, 0x27, 0x54, 0x84, 0x7, 
+	0x4f, 0xc3, 0xd8, 0xe7, 0x3f, 0xc0, 0x9f, 0xfe, 0xde, 0x39, 
+	00, 0xdf, 0x5c, 0x40, 0xa5, 00, 0xda, 0x9e, 0xc6, 0x72, 
+	0x4f, 0xb6, 0xa1, 0x63, 0x6e, 0x89, 0x6b, 0x73, 0xb1, 0x18, 
+	0x29, 0x8b, 0xe8, 0x14, 0xd4, 0x6e, 0x4e, 0xde, 0xf0, 0x29, 
+	0xd7, 0x2c, 0x37, 0x60, 0x7f, 0xa1, 00, 0xad, 0x60, 0x51, 
+	0x25, 0x8d, 0x2a, 0xa9, 0x96, 0x85, 0xad, 0xc3, 0x6a, 0x76, 
+	0xd5, 0x55, 0xb4, 0x14, 0x11, 0xaa, 0xc7, 0x7e, 0x5a, 0x8e, 
+	0x3, 0xd4, 0xc0, 0xb7, 0xd6, 0x47, 0x59, 0x44, 0x4f, 0xd4, 
+	0xbb, 0xb9, 0x78, 0xc8, 0x6d, 0xd1, 0xd7, 0x7c, 0x1a, 0x31, 
+	0x29, 0x75, 0x9f, 0x41, 0x97, 0x58, 0xd9, 0xf4, 0x4c, 0x31, 
+	0xec, 0x99, 0x78, 0x24, 0xcc, 0x9e, 0x6a, 0x9b, 0xc1, 0xe8, 
+	0x60, 0x30, 0x7e, 0x6, 0x7, 0x7b, 0xc2, 0x6e, 0x5d, 0xe, 
+	0x34, 0x4, 0x1a, 0x72, 0x95, 0xb9, 0xa5, 0xa4, 0x5a, 0xf2, 
+	0xbd, 0x71, 0xc8, 0xf7, 0x70, 0xc1, 0x84, 0x6b, 0xe5, 0x6e, 
+	0xa4, 0x4d, 0x98, 0x47, 0xd7, 0x60, 0x11, 0x6d, 0xc3, 0x12, 
+	0xea, 0x42, 0x3, 0x7, 0xca, 0x4a, 0xda, 0x81, 0x16, 0x8a, 
+	0x60, 0x23, 0x5d, 0x8b, 0x4e, 0x7e, 0xf3, 0x6f, 0xa7, 0x6e, 
+	0xf4, 0xf0, 0xd3, 0x95, 0xb8, 0xc4, 0xe5, 0xa5, 0x5b, 0xc9, 
+	0x66, 0x94, 0x9b, 0x42, 0x9, 0xfb, 0xf9, 0x86, 0xf3, 0x17, 
+	0x99, 0x6a, 0x62, 0x5f, 0x7e, 0x74, 0x56, 0xf2, 0x9b, 0x92, 
+	0x38, 0xd6, 0xcf, 0x27, 0xf0, 0x95, 0x23, 0x38, 0xc2, 0x4, 
+	0xb7, 0xf1, 0xd7, 0x27, 0x38, 0x2d, 0x3c, 0x82, 0xdd, 0xec, 
+	0x2a, 0xb9, 0xd8, 0x9a, 0xa4, 0x26, 0xf4, 0xac, 0xf1, 0x71, 
+	0x65, 0x8f, 0xb4, 0x48, 0x3d, 0x90, 0xc5, 0x7a, 0xff, 0x14, 
+	0xe6, 0xb5, 0xd4, 0xfa, 0xb9, 0x1a, 0xf8, 0xa9, 0xd6, 0x2f, 
+	0xd5, 0xe0, 0xb5, 0x62, 0x6c, 0x5c, 0xc0, 0xa6, 0x3, 0xbd, 
+	0x97, 0x59, 0xbe, 0xf, 0x1, 0x3a, 0x8a, 0x7a, 0xfa, 00, 
+	0x2b, 0x76, 0x14, 0x8d, 0xf4, 0x21, 0xc6, 0x38, 0x5e, 0x88, 
+	0x6, 0x87, 0xd, 0x2c, 0xd1, 0x70, 0x4d, 0x38, 0x1c, 0x4c, 
+	0x30, 0xeb, 0xb1, 0x69, 0xb7, 0x76, 0xae, 0x7b, 0x86, 0x6f, 
+	0x21, 0x36, 0x99, 0x95, 0x45, 0x32, 0x7, 0x9, 0xa6, 0xb2, 
+	0xb8, 0xf5, 0x18, 0xaa, 0xc3, 0x41, 0x9b, 0x6f, 0x97, 0x70, 
+	0x30, 0xcd, 0x25, 0x67, 0xac, 0x3b, 0xdc, 0x7c, 0x16, 0xce, 
+	0x34, 0x2e, 0x2f, 0x9e, 0xec, 0x39, 0xf9, 0x93, 0x6c, 0xd2, 
+	0xe3, 0x8, 0xd2, 0xa7, 0x70, 0x21, 0xdd, 0x87, 0x26, 0xba, 
+	0x1f, 0xad, 0x9c, 0x57, 0x57, 0xd2, 0x83, 0xd8, 0x4c, 0xf, 
+	0x31, 0x26, 0xbf, 0xb0, 0xb, 0x17, 0xbe, 0xcf, 0x75, 0xf2, 
+	0xea, 0x30, 0x7, 0x4d, 0xa6, 0xa7, 0xe5, 0x19, 0x34, 0x2c, 
+	0x3f, 0x86, 0xb, 0xc2, 0xb9, 0xb4, 0x60, 0x60, 0x7b, 0x70, 
+	0x3c, 0x9f, 0x2f, 0x6b, 0x5a, 0x4e, 0xce, 0xee, 0x24, 0xe8, 
+	0x73, 0xa8, 0xa2, 0x47, 0xb0, 0x80, 0x4e, 0x62, 0x15, 0x3d, 
+	0xca, 0x3b, 0xf7, 0xf3, 0x95, 0xe4, 0x31, 0x8e, 0xe7, 0x6e, 
+	0xf2, 0x36, 0xe, 0x99, 0xe6, 0x5c, 0xc4, 0x48, 0x94, 0x34, 
+	0x73, 0x90, 0xec, 0x3c, 0x2f, 0x48, 0xa, 0x57, 0xea, 0x59, 
+	0x4c, 0x70, 0x8c, 0xcc, 0xd5, 0xe7, 0x39, 0x28, 0xf4, 0x4d, 
+	0xd6, 0xe9, 0x79, 0x2c, 0xa6, 0x6f, 0xe1, 0x12, 0x7a, 0x11, 
+	0x61, 0x7a, 0x9, 0x6b, 0xb9, 0x36, 0x5c, 0x41, 0xdf, 0x65, 
+	0xcc, 0xcf, 0xb8, 0x35, 0x76, 0xea, 0x4f, 0x50, 0x4b, 0x3, 
+	0x4, 0xa, 00, 00, 00, 0x8, 00, 0x16, 0xa9, 0xda, 
+	0x2c, 0xc9, 0xa0, 0xa1, 0x6c, 0x47, 0xf, 00, 00, 0x1f, 
+	0x1e, 00, 00, 0xe, 00, 00, 00, 0x72, 0x66, 0x62, 
+	0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x85, 0x57, 0xb, 0x7c, 0x54, 0xd5, 0x99, 0xff, 0xce, 
+	0x9d, 0xc7, 0xbd, 0x99, 0xdc, 0x90, 0x9b, 0x81, 0x49, 0x8, 
+	0x33, 0x81, 0x41, 0x4, 0xc2, 0x4c, 0x2, 0xd1, 0x20, 0xef, 
+	0x67, 0x22, 0x81, 0x48, 0x1e, 0x98, 0x4, 0x10, 0xf0, 0xc1, 
+	0x24, 0x73, 0x93, 0xc, 0x24, 0x33, 0x71, 0x66, 0x92, 0x40, 
+	0x5b, 0xa1, 0xf, 0xd9, 0x3e, 0x5c, 0xbb, 0x4b, 0x95, 0x5a, 
+	0xac, 0x94, 0xa0, 0x54, 0xdc, 0x15, 0x6d, 0xed, 0x92, 0x60, 
+	0x85, 0xea, 0x5a, 0x6b, 0x45, 0x57, 0xdd, 0x76, 0xeb, 0x76, 
+	0x77, 0xbb, 0xdb, 0x56, 0xd7, 0xdd, 0xfa, 0xd6, 0xee, 0x5a, 
+	0xbb, 0x8f, 0x3e, 0xe8, 0xff, 0xbb, 0xf7, 0xce, 0xdc, 0x99, 
+	0x21, 0xb4, 0xf3, 0xfb, 0xcd, 0xf7, 0x3a, 0xdf, 0xf9, 0xce, 
+	0xf9, 0x1e, 0xe7, 0x3b, 0xe7, 0xbe, 0xf0, 0xfb, 0x27, 0x9e, 
+	0x24, 0x7, 0xd5, 0x8a, 0x66, 0xf, 0x45, 0xe9, 0xa5, 0x22, 
+	0xea, 0xa1, 0x97, 0x19, 0xfc, 0x3d, 0x83, 0x1f, 0x30, 0xf8, 
+	0x21, 0x83, 0x7f, 0x60, 0xf0, 0x23, 0x99, 0x5e, 0xf1, 0x90, 
+	0x42, 0xff, 0xc8, 0xcc, 0x8f, 0x65, 0xfa, 0x27, 0x99, 0xfe, 
+	0x99, 0xf9, 0x7f, 0xf1, 0x90, 0x4a, 0x3f, 0xf1, 0x50, 0x31, 
+	0xfd, 0x2b, 0x8f, 0xfc, 0x1b, 0xcb, 0x7e, 0xca, 0xd4, 0xcf, 
+	0x98, 0xfa, 0xb9, 0x4c, 0xaf, 0x7a, 0xe8, 0x35, 0xfa, 0x77, 
+	0x56, 0x78, 0x5d, 0xa6, 0xff, 0x90, 0xe9, 0x3f, 0x3d, 0x34, 
+	0x9d, 0x5e, 0x52, 0xe8, 0x17, 0x8c, 0xdf, 0x50, 0xe8, 0x4d, 
+	0xc6, 0x6f, 0x29, 0xf4, 0x36, 0xe3, 0x77, 0x3c, 0x54, 0x41, 
+	0xef, 0xf2, 0xf4, 0xf7, 0x18, 0xbc, 0xaf, 0xd0, 0x7, 0x1e, 
+	0x9a, 0x4f, 0xbf, 0xf4, 0xd0, 0x7f, 0xd1, 0x7f, 0xb3, 0x8d, 
+	0xf, 0x65, 0xfa, 0x15, 0x4b, 0x3e, 0x52, 0xe8, 0xd7, 0x2c, 
+	0xfc, 0x1f, 0x16, 0xfe, 0x2f, 0xeb, 0xfe, 0x1f, 0x83, 0xff, 
+	0x67, 0xf6, 0x37, 0x4c, 0xfd, 0x96, 0xc1, 0xef, 0x18, 0xfc, 
+	0x9e, 0xc1, 0x45, 00, 0x41, 0xc, 0x4, 0x3, 0x89, 0x81, 
+	0x83, 0x81, 0x93, 0x81, 0xb, 0xd3, 0x84, 0x9b, 0x29, 0xd9, 
+	0x23, 0x14, 0x51, 0xc4, 0xac, 0x87, 0xd9, 0x62, 0x6, 0x2a, 
+	0x83, 0x12, 0x6, 0x53, 0x18, 0x94, 0x32, 0xd0, 0x14, 0x51, 
+	0xa6, 0x8, 0xaf, 0x22, 0xa6, 0x2a, 0x62, 0x9a, 0x22, 0x7c, 
+	0x2c, 0x2b, 0x67, 0x50, 0x51, 0x24, 0xa6, 0x8b, 0x4a, 0x6, 
+	0x33, 0x98, 0xf5, 0x7b, 00, 0x2, 0xcc, 0x56, 0x31, 0x98, 
+	0x89, 0x3d, 0x8b, 0x59, 0x4c, 0x5, 0x1d, 0x44, 0x17, 0xb7, 
+	0x30, 0xb8, 0x9e, 0x41, 0x7, 0x83, 0x4e, 0x6, 0x5d, 0xc, 
+	0x14, 0x6, 0x45, 0xc, 0x4a, 0x18, 0xf8, 0x19, 0x5c, 0x64, 
+	0x40, 0x6c, 0x6f, 0x36, 0x5b, 0xbe, 0x82, 0xd9, 0xd7, 0x19, 
+	0xbc, 0xc6, 0xe0, 0xd, 0x6, 0x6f, 0xc9, 0x62, 0x8e, 0x2c, 
+	0xae, 0x14, 0xe4, 0x19, 0xd1, 0x93, 0xa9, 0x58, 0x22, 0xde, 
+	0x9a, 0xea, 0x13, 0xe4, 0x6d, 0xd9, 0x13, 0x19, 0x89, 0x2c, 
+	0x1a, 0x88, 0xc4, 0xfb, 0x16, 0x75, 0xa6, 0x93, 0xb1, 0x78, 
+	0xdf, 0x4a, 0x41, 0x25, 0x8d, 0x89, 0x78, 0x2a, 0x1d, 0x89, 
+	0xa7, 0xb7, 0x45, 0x6, 0x86, 0x75, 0xcc, 00, 0x1f, 0x6f, 
+	0x8a, 0xc4, 0x6, 0xf4, 0xa8, 0x20, 0xd1, 0xc, 0x6b, 0x44, 
+	0x82, 0xdc, 0x6d, 0x89, 0xf5, 0xc3, 0xe9, 0x7e, 0xe6, 0x84, 
+	0x20, 0x79, 0x5b, 0xbc, 0x27, 0xc3, 0x4a, 0x88, 0xa6, 0xc5, 
+	0xb6, 0x6f, 0x86, 0x39, 0x8b, 0xce, 0x58, 0x98, 0x62, 0xf1, 
+	0x5d, 0x89, 0x44, 0x6b, 0x24, 0xbe, 0x5f, 0x50, 0x59, 0x53, 
+	0x32, 0x32, 0xa8, 0x77, 0xf, 0xf7, 0xf6, 0xea, 0xc9, 0xad, 
+	0x43, 0xd1, 0x48, 0x1a, 0x6b, 0x4e, 0xed, 0xd4, 0xd3, 0x8d, 
+	0x89, 0x81, 0xc4, 0x70, 0xb2, 0x35, 0x32, 0xb4, 0x21, 0x8e, 
+	0xad, 0xe9, 0x29, 0x41, 0xce, 0x6, 0x7d, 0x60, 00, 0x16, 
+	0x3b, 0xf5, 0x24, 0xbc, 0x68, 0x1c, 0x4e, 0x77, 0xe9, 0xfb, 
+	0xd2, 0xbc, 0xa4, 0x3, 0x66, 0x31, 0x63, 0x4b, 0x6c, 0x9f, 
+	0x3e, 0xd0, 0x94, 0x48, 0xe, 0x46, 0xd2, 0x30, 0xd1, 0x14, 
+	0xdb, 0x77, 0xa9, 0x9, 0x15, 0x6a, 0x1b, 0xe2, 0x3d, 0x89, 
+	0x28, 0x7c, 0x5, 0x3b, 0xfd, 0x92, 0xb5, 0x3b, 0xf4, 0x5b, 
+	0x87, 0xf5, 0x14, 0xe6, 0x2b, 0x9b, 0xf5, 0xfd, 0x1b, 0x46, 
+	0xf4, 0xb8, 0xb1, 0x80, 0x13, 0x33, 0xb7, 0x24, 0x62, 0xf1, 
+	0xb4, 0x9e, 0xcc, 0xca, 0x5c, 0x1c, 0xaa, 0x81, 0x18, 0xb8, 
+	0x9c, 0x9d, 0xb8, 0x5, 0x15, 0x67, 0xec, 0x77, 0x44, 0x46, 
+	0x5, 0x69, 0x19, 0xae, 0x31, 0x31, 0xb4, 0xbf, 0x43, 0xef, 
+	0x49, 0xe7, 0x2a, 0x74, 0x6c, 0x80, 0xd, 0x5b, 0xc1, 0xe0, 
+	0x4b, 0x33, 0xfc, 0x26, 0x98, 0x44, 0xc8, 0xe0, 0x76, 0x7f, 
+	0x82, 0x37, 0xe4, 0x1c, 0x4a, 0x24, 0x19, 0xa5, 0x12, 0x3d, 
+	0x7b, 0x11, 0x35, 0x33, 0x75, 0x71, 0x3d, 0xbd, 0xa8, 0x13, 
+	0x2, 0x3d, 0x8d, 0xcc, 0x49, 0x31, 0xb8, 0x54, 0x69, 0xe, 
+	0xc4, 0x12, 0x8b, 0xae, 0x8d, 0xa4, 0x23, 0xcd, 0xf1, 0xa1, 
+	0xe1, 0x34, 0x52, 0xab, 0x47, 0x6, 0x59, 0x21, 0x1, 0x85, 
+	0xf2, 0xac, 0x42, 0xfb, 0x70, 0x3a, 0x77, 0x54, 0x8b, 0xc5, 
+	0xdb, 0x38, 0x78, 0x3, 0x5b, 0x92, 0x89, 0x74, 0xa2, 0x27, 
+	0x81, 0x50, 0x8b, 0x9d, 0xf8, 0x8f, 0x60, 0xcb, 0x2d, 0x23, 
+	0xf1, 0x9e, 0x91, 0x98, 0x3e, 0xaa, 0x27, 0xa1, 0x58, 0x9c, 
+	0x32, 0x12, 0xd0, 0x1a, 0xd9, 0x93, 0x48, 0xda, 0x5c, 0x2c, 
+	0x6e, 0x70, 0x51, 0x3d, 0xb5, 0x37, 0x9d, 0x18, 0x6a, 0x43, 
+	0x5c, 0x61, 0xb2, 0xd7, 0x8e, 0xef, 0xf6, 0x58, 0x34, 0xdd, 
+	0x8f, 0x8d, 0xe7, 0x88, 0x36, 0xe9, 0xb1, 0xbe, 0x7e, 0xf8, 
+	0xa4, 0x76, 0xc7, 0xd2, 0xa9, 0x2d, 0x7a, 0xd2, 0x48, 0xa0, 
+	0x20, 0x57, 0x54, 0x1f, 0x62, 0xd5, 0xa2, 0xee, 0x58, 0xdf, 
+	0x86, 0x78, 0x34, 0x16, 0x89, 0xa3, 0xa, 0xd3, 0xc9, 0x61, 
+	0xdd, 0xcc, 0x27, 0x8a, 0x2f, 0xa9, 0x47, 0x5b, 0x23, 0xfb, 
+	0x90, 0xa4, 0xbe, 0xa4, 0xae, 0xc7, 0xd, 0x52, 0xee, 0x46, 
+	0xb5, 0x9a, 0x42, 0x8c, 0x76, 0xf6, 0xc7, 0x7a, 0x61, 0xd8, 
+	0x63, 0x8c, 0x5b, 0x4c, 0x11, 0x6b, 0x58, 0xb4, 0x3a, 0x6c, 
+	0x64, 0xbb, 0x8d, 0x33, 0x82, 0x98, 0x14, 0xf, 0x5b, 0xc9, 
+	0xef, 0x49, 0xdf, 0x90, 0xc7, 0xed, 0xc8, 0xe3, 0xb6, 0xe7, 
+	0x71, 0x9b, 0x70, 0x80, 0x6c, 0x2e, 0x93, 0x36, 0xd8, 0xee, 
+	0xb1, 0x52, 0xdd, 0x99, 0xec, 0xb9, 0x21, 0x9f, 0x85, 0x39, 
+	0x45, 0xe7, 0x2, 0x6a, 0x18, 0xee, 0x45, 0x3a, 0x76, 0x35, 
+	0xc0, 0x60, 0x86, 0x6f, 0xd1, 0xe1, 0x66, 0xf1, 0x90, 0x59, 
+	0x65, 0xad, 0x91, 0x14, 0x92, 0xac, 0x26, 0x6, 0xa2, 0xad, 
+	0xb0, 0xda, 0x1b, 0xc3, 0xa1, 0x85, 0xdb, 0xab, 0x62, 0xf1, 
+	0x58, 0x7a, 0x8d, 0xa0, 0xd9, 0xd5, 0x97, 0x1e, 0xdc, 0xe6, 
+	0x9c, 0x14, 0x2d, 0xd8, 0x86, 0x3a, 0x69, 0x4c, 0x44, 0x91, 
+	0x81, 0xd2, 0x96, 0x58, 0x5c, 0x6f, 0x1b, 0x1e, 0xec, 0xd6, 
+	0x93, 0x5d, 0x91, 0x6e, 0x2e, 0x27, 0xcf, 0x86, 0x7d, 0x3d, 
+	0x88, 0x2f, 0x7a, 00, 0x4c, 0xba, 0x7a, 0x6, 0x12, 0x29, 
+	0x8, 0x1d, 0xd5, 0x3c, 0x67, 0xa, 0x2a, 0x21, 0xba, 0x2d, 
+	0xa7, 0x41, 0x94, 0x8e, 0x26, 0x63, 0x69, 0x3d, 0x57, 0x62, 
+	0xa8, 0xf0, 0xf9, 0xed, 0xec, 0xe9, 0xd7, 0x7, 0xcd, 0x99, 
+	0xcd, 0x19, 0x45, 0xf3, 0x38, 0x34, 0x63, 0x93, 0x96, 0xa2, 
+	0x79, 0x52, 0x4d, 0x81, 0xcf, 0x16, 0xb4, 0xea, 0xa9, 0x54, 
+	0xa4, 0x4f, 0xef, 0xda, 0x3f, 0xa4, 0x5b, 0xf2, 0x49, 0x7a, 
+	0x40, 0x60, 0x52, 0xb9, 0x11, 0xf8, 0x28, 0x6a, 0x40, 0xe5, 
+	0x61, 0xfb, 0x50, 0x55, 0x19, 0x1b, 0xf8, 0x23, 0xc7, 0xb9, 
+	0xba, 0x19, 0xbf, 0x9d, 0xec, 0xe5, 0x54, 0x43, 0xb5, 0xb0, 
+	0x5f, 0x94, 0x40, 0x61, 0xe7, 0xce, 0x66, 0xe3, 0xc7, 0x5a, 
+	0x65, 0x19, 0xad, 0x9c, 0x76, 0xe1, 0xae, 0xde, 0x95, 0x3b, 
+	0x98, 0xdb, 0x11, 0x60, 0xd6, 0x4a, 0x4a, 0x64, 0x34, 0xbd, 
+	0xc8, 0x10, 0x19, 0x69, 0x28, 0x31, 0x34, 0x33, 0xbd, 0x4, 
+	0x1, 0xaf, 0x36, 0x37, 0x51, 0x6e, 0xc8, 0x33, 0xc9, 0xcd, 
+	0x8c, 0x73, 0x93, 0xab, 0x36, 0x56, 0xf0, 0x74, 0xa2, 0xd2, 
+	0x7b, 0xf4, 0x26, 0xa3, 0x3, 0x94, 0x24, 0x7b, 0xbb, 0x8d, 
+	0x43, 0xb9, 0x90, 0x57, 0x50, 0xe9, 0x51, 0x3a, 0xa3, 0xd2, 
+	0x17, 0xe9, 0x2f, 0x54, 0xfa, 0x2b, 0xfa, 0x6b, 0x95, 0x4e, 
+	0x53, 0x4c, 0xa5, 0xbf, 0xa4, 0xc3, 0x2a, 0xfd, 0x19, 0xf5, 
+	0xaa, 0xf4, 0x59, 0x8a, 0x21, 0x21, 0x5, 0xed, 0x1, 0x93, 
+	0xc4, 0x5c, 0x95, 0x3e, 0x47, 0x9f, 0x17, 0x54, 0x71, 0x99, 
+	0xe, 0x21, 0xc8, 0x9f, 0x19, 0x69, 0x30, 0x62, 0xa8, 0x47, 
+	0x73, 0x46, 0x55, 0x31, 0x4f, 0xcc, 0x67, 0x33, 0xd5, 0xc, 
+	0x16, 0xa8, 0xf4, 0x5, 0xba, 0x43, 0x15, 0x21, 0x11, 0x56, 
+	0xe9, 0xcf, 0xe9, 0x4e, 0x95, 0xfe, 0x86, 0xce, 0x20, 0x8, 
+	0x76, 0x5d, 0x66, 0xcb, 0x4c, 0x16, 0x35, 0xaa, 0xa8, 0xc5, 
+	0x96, 0xc5, 0x42, 0xb1, 0x28, 0xa3, 0x82, 0x35, 0x9a, 0xdb, 
+	0xb3, 0x2a, 0x88, 0x47, 0x61, 0x41, 0x9b, 0x3b, 0x40, 0xc0, 
+	0x36, 0xa1, 0xfb, 0x5, 0x55, 0x51, 0x27, 0xae, 0x42, 0x2, 
+	0x82, 0xdc, 0x4, 0xd, 0xee, 0x6a, 0x54, 0x4e, 0x30, 0x96, 
+	0xa, 0xc6, 0x13, 0xe9, 0x60, 0x24, 0x1e, 0xec, 0x68, 0x6a, 
+	0x8, 0x9a, 0x8d, 0x48, 0x15, 0xf5, 0x62, 0x31, 0x6f, 0xf1, 
+	0x1a, 0x95, 0xbe, 0xc4, 0x91, 0xb9, 0x8b, 0xe3, 0xa1, 0xb2, 
+	0x42, 0x5d, 0x5d, 0xfd, 0x42, 0xfc, 0x3d, 0xaa, 0x58, 0x22, 
+	0x96, 0xca, 0x62, 0x99, 0x2a, 0x96, 0x8b, 0x45, 0xaa, 0x58, 
+	0x41, 0x8f, 0xa3, 0x55, 0x15, 0x6e, 0x80, 0x4d, 0xa0, 0xd9, 
+	0x2d, 0xdc, 0x1a, 0xdf, 0x1b, 0x4f, 0x8c, 0xc6, 0x83, 0x11, 
+	0x14, 0x3d, 0x52, 0x14, 0xeb, 0x89, 0xf0, 0x8e, 0x83, 0x29, 
+	0xa3, 0xfe, 0x83, 0xbd, 0xc9, 0xc4, 0x60, 0xce, 0xe2, 0xd8, 
+	0xda, 0x72, 0x7a, 0x41, 0x15, 0xab, 0xe8, 0x71, 0x95, 0x8e, 
+	0xf0, 0xea, 0x5f, 0x6, 0x10, 0xab, 0x99, 0xbd, 0x87, 0xd9, 
+	0xaf, 0x30, 0x38, 0xca, 0xa9, 0xbb, 0x97, 0xc1, 0x57, 0x99, 
+	0xbd, 0x8f, 0xc1, 0x31, 0x6, 0x5f, 0x63, 0x70, 0x9c, 0xc1, 
+	0x18, 0x4f, 0x5b, 0x23, 0xd6, 0xaa, 0x74, 0x37, 0xf5, 0xca, 
+	0x62, 0x1d, 0x18, 0xd8, 0x10, 0xeb, 0x45, 0x83, 0x4a, 0x27, 
+	0x58, 0xe1, 0x7e, 0x6, 0xf, 0x30, 0x38, 0xc9, 0xe0, 0xeb, 
+	0xc, 0x1e, 0x64, 0x4f, 0xab, 0x73, 0xe, 0x41, 0xd0, 0xec, 
+	0x4f, 0xc1, 0x24, 0xce, 0x8, 0x3c, 0x1b, 0xd0, 0x83, 0xe9, 
+	0x44, 0x22, 0x38, 0x10, 0x49, 0xf6, 0xe9, 0x2b, 0x82, 0x68, 
+	0xed, 0xe8, 0x96, 0xae, 0x60, 0x24, 0x1d, 0xac, 0x6, 0x5d, 
+	0x83, 0x3f, 0xb2, 0x7a, 0x8a, 0xd, 0x3d, 0x44, 0x31, 0x59, 
+	0x34, 0xaa, 0xe2, 0x5a, 0xde, 0xc5, 0x6, 0x96, 0x3c, 0xcc, 
+	0xe0, 0x79, 0x76, 0xcd, 0xcb, 0xb2, 0x26, 0x6, 0xcb, 0xc5, 
+	0x46, 0x55, 0x6c, 0xe2, 0x81, 0xe7, 0xe8, 0x82, 0x4a, 0x8f, 
+	0xf0, 0xea, 0x4a, 0xa6, 0x54, 0xf3, 0x22, 0xda, 0xde, 0xbd, 
+	0xc7, 0x38, 0xa5, 0xe5, 0x93, 0x35, 0x2e, 0xa3, 0xf3, 0xf4, 
+	0xe9, 0xe9, 0xbc, 0x4a, 0xac, 0xa8, 0x5e, 0x90, 0xbd, 0xa7, 
+	0xf2, 0x2f, 0xb1, 0xca, 0xea, 0x49, 0x7, 0xc, 0x33, 0xd3, 
+	0x27, 0x1f, 0xe3, 0xa1, 0x52, 0xac, 0x90, 0x7b, 0xe1, 0xb1, 
+	0xf2, 0x82, 0xcb, 0x5d, 0x85, 0x39, 0x65, 0xdc, 0xd5, 0x9f, 
+	0x4c, 0x8c, 0x9a, 0x9d, 0xb3, 0x74, 0x8, 0x1b, 0x86, 0x52, 
+	0xa4, 0x67, 0x6f, 0x57, 0x32, 0xd2, 0x3, 0x49, 0x91, 0xd1, 
+	0xa3, 0x86, 0x7, 0x6, 0xf6, 0xf3, 0xc9, 0xde, 0xd5, 0xc0, 
+	0xb, 0xb9, 0x23, 0x43, 0x43, 0x7a, 0x1c, 0x2f, 0x9d, 0x9a, 
+	0x49, 0x9c, 0x5d, 0x70, 0x89, 0xc8, 0xac, 0x73, 0xac, 0xe9, 
+	0xc7, 0xc1, 0xbf, 0xfc, 0xa8, 0x92, 0x4e, 0x98, 0x12, 0x41, 
+	0xd3, 0xaa, 0x2f, 0xd5, 0x83, 0x86, 0x6f, 0xb2, 0xe5, 0xb6, 
+	0xf1, 0x1d, 0xa9, 0xa7, 0x1b, 0xf6, 0xa7, 0xf9, 0xf5, 0xc3, 
+	0x4d, 0x70, 0x57, 0x83, 0x11, 0xa9, 0x69, 0x93, 0x79, 0xe, 
+	0x27, 0x8c, 0xb6, 0x84, 0xdb, 0x94, 0x1d, 0x6b, 0xe6, 0x86, 
+	0x85, 0x9e, 0x67, 0xce, 0x28, 0x63, 0xd1, 0xd6, 0x78, 0x2a, 
+	0xd6, 0x17, 0xe7, 0xfb, 0xd5, 0x78, 0x8c, 0x68, 0xb9, 0x32, 
+	0x5e, 0x4, 0xfd, 0x8b, 0x45, 0x56, 0x34, 0x70, 0x31, 0x54, 
+	0x66, 0xd6, 0x41, 0x27, 0x4b, 0xf3, 0x55, 0x90, 0xb3, 0x98, 
+	0xc2, 0xaa, 0xe6, 0x2c, 0xdc, 0x22, 0xb8, 0xb, 0xa7, 0xe4, 
+	0x37, 0x50, 0x7e, 0xd1, 0xc0, 0x54, 0xd1, 0xa0, 0x7d, 0x5, 
+	0xa, 0x4, 0x5a, 0xe6, 0x1d, 0x19, 0x5b, 0x72, 0xec, 0xd5, 
+	0xf7, 0x53, 0x10, 0x8f, 0xf8, 0x28, 0x9e, 0x5e, 0xcb, 0xf1, 
+	0x95, 0xa0, 0x53, 0x2f, 0xde, 0xa6, 0x7d, 0xfc, 0xa, 0xa5, 
+	0x39, 0xe0, 0xfb, 0x29, 0x96, 0xe5, 0xf7, 0x80, 0xdf, 0x9b, 
+	0xc3, 0xf, 0x80, 0x1f, 0xcc, 0xe1, 0xe3, 0xe0, 0x13, 0x5, 
+	0xfa, 0x43, 0x5, 0xfa, 0xb7, 0x16, 0xe8, 0x27, 0xb, 0xf4, 
+	0x53, 0x5, 0xfa, 0xe9, 0x2, 0xfd, 0xe1, 0x1c, 0x7e, 0x4, 
+	0xfc, 0x68, 0xc1, 0xfc, 0x7d, 0x5, 0xf3, 0xf7, 0x17, 0xcc, 
+	0xff, 0x58, 0xc1, 0xfc, 0x8f, 0xe7, 0xf0, 0x9f, 00, 0x7f, 
+	0x5b, 0xe, 0x7f, 00, 0xfc, 0xc1, 0x1c, 0xfe, 0x93, 0xe0, 
+	0x3f, 0x55, 0xb0, 0xde, 0xa7, 0xb, 0xd6, 0xfb, 0x4c, 0xc1, 
+	0x7a, 0xb7, 0x17, 0xd8, 0x3f, 0x94, 0x67, 0x9f, 0xf8, 0xbe, 
+	0xe1, 0xcf, 0x1, 0xbe, 0x72, 0xc, 0x8c, 0xeb, 0xc5, 0xc0, 
+	0xb8, 0x1a, 0xc, 0x8c, 0x8b, 0xc1, 0xc0, 0xb8, 0xab, 0xc, 
+	0x8c, 0x4b, 0xca, 0xc0, 0x5f, 0xb2, 0xf4, 0xef, 0xb2, 0xf0, 
+	0xdd, 0x96, 0x9d, 0x23, 0x16, 0xff, 0x65, 0xb, 0xdf, 0x63, 
+	0xe1, 0xaf, 0x58, 0xf8, 0xa8, 0x65, 0xe7, 0x5e, 0xb, 0x7f, 
+	0xd5, 0x92, 0xdf, 0x67, 0xe1, 0x63, 0x16, 0xfe, 0x9a, 0x85, 
+	0x8f, 0x5b, 0x78, 0xcc, 0xc2, 0x27, 0x2c, 0x7c, 0xbf, 0x85, 
+	0x1f, 0xb0, 0xf0, 0x49, 0xb, 0x7f, 0xdd, 0xc2, 0xf, 0x5a, 
+	0xf8, 0x94, 0x85, 0x1f, 0xb2, 0x30, 0xae, 0x5b, 0x3, 0x3f, 
+	0x6c, 0xf1, 0xa7, 0x2d, 0xfc, 0x88, 0x81, 0xbd, 0xf8, 0x3f, 
+	0x4a, 0xdf, 0x40, 0x6c, 0xbe, 0x69, 0xac, 0x29, 0x93, 0x13, 
+	0x78, 0x77, 0xe8, 0x2c, 0x89, 0x90, 0x63, 0x9c, 0xa4, 0x90, 
+	0xb6, 0xe9, 0xbc, 0x32, 0x4e, 0xe, 0x66, 0x9c, 0xa1, 0xda, 
+	0x71, 0x72, 0x85, 0xc2, 0xe3, 0xe4, 0xe, 0x5, 0xc6, 0x49, 
+	0xe, 0x9d, 0x23, 0x65, 0x47, 0xe8, 0xc, 0xb8, 0x33, 0x24, 
+	0x9f, 0xa5, 0xa2, 0x71, 0xf2, 0x40, 0x54, 0xbc, 0xe3, 0x1c, 
+	0xa9, 0x2c, 0xf6, 0x4c, 0x50, 0x49, 0xd9, 0x3a, 0x3a, 0x4b, 
+	0x53, 0xce, 0x52, 0xe9, 0x38, 0x69, 0x21, 0x53, 0x56, 0x36, 
+	0x4e, 0xde, 0xc7, 0x88, 0xbf, 0xc7, 0x18, 0x2e, 0xc4, 0x27, 
+	0x2e, 0xd1, 0x66, 0xac, 0xda, 0x48, 0x45, 0xe2, 0x8, 0x95, 
+	0x89, 0xe3, 0x54, 0x4e, 0x2d, 0xe4, 0xa7, 0x56, 0x9c, 0x92, 
+	0x36, 0x9a, 0x4b, 0xed, 0xb4, 0x8c, 0xb6, 0x50, 0x17, 0x75, 
+	0xd0, 0x2d, 0xd4, 0x49, 0xdf, 0x82, 0xb6, 0x13, 0x73, 0x2b, 
+	0x80, 0x71, 0x7b, 0x83, 0xe2, 0x7d, 0x2f, 0x3, 0x96, 0x80, 
+	0x35, 0x73, 0x89, 0xa9, 0xa7, 0x48, 0x69, 0x9, 0x4f, 0x90, 
+	0xef, 0x31, 0xc8, 0x9, 0x3e, 0x79, 0x68, 0x9a, 0xb5, 0xde, 
+	0x14, 0xe2, 0x4f, 0x9e, 0x1b, 0x20, 0xd9, 0x49, 0xa5, 0x74, 
+	0x23, 0xe8, 0x71, 0x58, 0x31, 0xbc, 0x17, 0x1b, 0x61, 0x19, 
+	0x56, 0x44, 0x85, 0xa6, 0x9e, 0x57, 0x5a, 0x60, 0x4a, 0x83, 
+	0x8d, 0xf2, 0xb0, 0xa3, 0x5e, 0xeb, 0x18, 0xa3, 0x23, 0x61, 
+	0x67, 0xbd, 0xd6, 0x34, 0x46, 0x77, 0x86, 0x5d, 0xf5, 0x5a, 
+	0xc3, 0x18, 0x1d, 0xa, 0xbb, 0xeb, 0xb5, 0xe0, 0x18, 0xdd, 
+	0x16, 0x96, 0xeb, 0xb5, 0xba, 0x13, 0x34, 0xcc, 0x78, 0xf9, 
+	0x3, 0x34, 0x18, 0x56, 0xc, 0x5e, 0x67, 0xc, 0xfe, 0xa6, 
+	0xb0, 0xe6, 0x36, 0x4, 0x5d, 0x6, 0x1, 0xc9, 0xe6, 0xb0, 
+	0x6, 0xd5, 0x85, 0x63, 0xd4, 0x10, 0xd6, 0x4c, 0xdd, 0xe5, 
+	0x6, 0x81, 0xa1, 0xba, 0xb0, 0x56, 0x64, 0x48, 0xe6, 0x1b, 
+	0x4, 0x24, 0x33, 0xc3, 0x9a, 0xc7, 0x90, 0xf8, 0xc, 0x2, 
+	0x12, 0x35, 0xac, 0x15, 0xd7, 0x6b, 0x9e, 0xe3, 0x74, 0xf5, 
+	0x39, 0xaa, 0x40, 0xac, 0xa7, 0xef, 0x38, 0x4b, 0x95, 0xde, 
+	0x19, 0x13, 0xe4, 0xe7, 0x54, 00, 0x79, 0x3, 0x26, 0x2d, 
+	0x4f, 0x50, 0x95, 0x77, 0x26, 0xe8, 0x9, 0x9a, 0x75, 0x96, 
+	0x82, 0x4f, 0x85, 0x8c, 0x9d, 0x46, 0xb5, 0x68, 0xbf, 0xb1, 
+	0xc5, 0xa8, 0xe6, 0xe9, 0xdf, 0x6d, 0x6e, 0x2e, 0xba, 0x7b, 
+	0x9c, 0x66, 0x87, 0xcc, 0xdd, 0x18, 0xe3, 0xc6, 0x2e, 0x2c, 
+	0x5, 0x8f, 0xa5, 0x70, 0x85, 0x9d, 0xb4, 0x99, 0x8, 0x29, 
+	0xa1, 0xfc, 0x5d, 0x68, 0x56, 0x25, 0x38, 0x94, 0xa7, 0xd0, 
+	0x74, 0x7e, 0x8c, 0xc6, 0xf1, 0x11, 0xd, 0x8b, 0x72, 0x1c, 
+	0xf2, 0xdc, 0x24, 0x4d, 0x64, 0xc2, 0x4b, 0xab, 0xa0, 0xcf, 
+	0x49, 0x9a, 0x6e, 0x84, 0xd7, 0x3b, 0xc7, 0xa1, 0xa9, 0x61, 
+	0xc7, 0x4, 0x5d, 0x89, 0xad, 0x7a, 0x11, 0xe8, 0xb9, 0xb6, 
+	0x7d, 0xaf, 0x51, 0x84, 0x7, 0xa0, 0x7f, 0x10, 0x49, 0xfa, 
+	0x24, 0xec, 0x7c, 0x2a, 0xcf, 0xe6, 0x59, 0x7a, 0xdc, 0xb2, 
+	0x79, 0x2f, 0xb9, 0xd, 0xdd, 0x5e, 0xce, 0xd6, 0x4, 0xcd, 
+	0x5b, 0xe5, 0x37, 0x8b, 0xbd, 0x81, 0xcc, 0x1f, 0xaf, 0xe7, 
+	0xc7, 0x7f, 0x1d, 0xff, 0x2d, 0x9d, 0xd5, 0x81, 0xf3, 0x4a, 
+	0x1b, 0xd3, 0xb5, 0xc8, 0xae, 0x19, 0xc3, 0xf9, 0x3b, 0x6a, 
+	0x1d, 0x67, 0xa9, 0x9a, 0xa3, 0xe4, 0x3f, 0x9d, 0x1b, 0xd6, 
+	0x5, 0x8, 0x1f, 0xe2, 0x57, 0x65, 0x85, 0x30, 0xbb, 0xc3, 
+	0x2b, 0x48, 0x1, 0xfc, 0x3c, 0xe0, 0x1d, 0x74, 0x25, 0x5a, 
+	0x45, 0xd, 0xe, 0x77, 0x1d, 0x5a, 0xc5, 0x32, 0x34, 0x8b, 
+	0x66, 0xb4, 0x84, 0xcd, 0x38, 0xfe, 0xb9, 0x3b, 0xfe, 0x76, 
+	0x36, 0xa, 0x73, 0x81, 0xb9, 0x28, 0x8b, 0xd8, 0x6d, 0xb8, 
+	0x1f, 0xb2, 0xdd, 0xf6, 0x18, 0xdb, 0x45, 0xed, 0xe2, 0xc4, 
+	0xe6, 0x4e, 0x7e, 0x22, 0x5b, 0xa1, 0x35, 0x8, 0x9, 0xbb, 
+	0x7b, 0x21, 0x64, 0xfa, 0x82, 0xa3, 0x58, 0x63, 0x93, 0xb5, 
+	0x16, 0xb9, 0x70, 0x9c, 0x16, 0xd9, 0x64, 0x5d, 0x86, 0x3c, 
+	0x4a, 0xb2, 0xf3, 0x14, 0x39, 0x71, 0x90, 0xaf, 0xba, 0x54, 
+	0x74, 0xb5, 0x6d, 0xa6, 0xde, 0x26, 0x17, 0xdb, 0xe4, 0x35, 
+	0xb6, 0xc5, 0x25, 0x36, 0xb9, 0xd4, 0x26, 0x97, 0xb9, 0xed, 
+	0x43, 0xb3, 0x7c, 0xfb, 0x64, 0xb1, 0xe, 0x65, 0x3, 0x3d, 
+	0x4e, 0x2b, 0x42, 0x4e, 0x74, 0x17, 0xdb, 0xf7, 0xe, 0x9c, 
+	0x50, 0x42, 0x5a, 0x8b, 0x11, 0xaa, 0x72, 0x78, 0x3c, 0x9b, 
+	0xce, 0x21, 0xa8, 0xe7, 0x69, 0x2d, 0x7d, 0x7, 0x63, 0x4f, 
+	0xd2, 0x4d, 0xf4, 0x14, 0x8a, 0xed, 0x6f, 0x71, 0x5b, 0x3d, 
+	0x8d, 0xc2, 0xf8, 0x2e, 0x42, 0xff, 0xc, 0x3a, 0xf0, 0xf7, 
+	0x10, 0xe6, 0x67, 0xd1, 0x21, 0xbf, 0x8f, 0x2e, 0xf7, 0x1c, 
+	0x3a, 0xda, 0x5, 0x9c, 0xe6, 0xe7, 0x31, 0xfa, 0x77, 0xe0, 
+	0x5e, 0xcc, 0x8b, 0xe1, 0xb9, 0x6c, 0xc9, 0x4, 0x21, 0xe1, 
+	0x4, 0x28, 0xe6, 0x16, 0x57, 0x9e, 0xce, 0xee, 0xc1, 0x6d, 
+	0xc8, 0x5f, 0xc9, 0x9b, 0x77, 0x3e, 0x9b, 0xb8, 0xc5, 0x56, 
+	0xe2, 0xa6, 0x99, 0xf3, 0x56, 0x6d, 0xb7, 0x63, 0xb3, 0xda, 
+	0xf6, 0xc3, 0xec, 0x2f, 0x3f, 0x47, 0xe, 0x5f, 0xa5, 0xa9, 
+	0xf4, 0x5a, 0x9e, 0xad, 0xef, 0x64, 0x6d, 0xfd, 0xc8, 0x90, 
+	0xa1, 0xd7, 0xdb, 0x36, 0xd6, 0xd8, 0xe4, 0x5a, 0x9b, 0x5c, 
+	0x67, 0x93, 0xeb, 0x2d, 0x72, 0xde, 0x38, 0x35, 0x80, 0x5a, 
+	0x83, 0xff, 0xba, 0xdd, 00, 0x35, 0xf, 0xd0, 0x54, 0xa0, 
+	0xb5, 0xf8, 0xaf, 0x67, 0xbe, 0xf6, 0x24, 0x5d, 0x97, 0x5b, 
+	0xc2, 0x8d, 0x66, 0x37, 0x58, 0xc7, 0xdd, 0xe0, 0x5a, 0x93, 
+	0x5e, 0xcf, 0xf4, 0x6, 0x93, 0x5e, 0xc3, 0x74, 0x93, 0x49, 
+	0xaf, 0x65, 0x7a, 0xa3, 0xdd, 0x31, 0x6c, 0xb7, 0xcc, 0x7a, 
+	0x7f, 0x13, 0xe9, 0x79, 0xb, 0xe9, 0x79, 0x1b, 0xe9, 0x79, 
+	0x7, 0xe9, 0x79, 0x97, 0x96, 0xd2, 0xfb, 0xb4, 0x9d, 0x7e, 
+	0x89, 0xcb, 0xeb, 0x57, 0x79, 0xae, 0x3e, 0x99, 0x75, 0x75, 
+	0xa9, 0x15, 0xb6, 0xa, 0xdb, 0x93, 0x4d, 0x36, 0xd9, 0x5c, 
+	0x18, 0xb9, 0xdf, 0x60, 0x89, 0xdf, 0x62, 0x89, 0xdf, 0xe5, 
+	0x99, 0x7b, 0xa, 0x99, 0x37, 0xcd, 0xbd, 0x4, 0x19, 0x37, 
+	0x9f, 0x43, 0x9a, 0xe7, 0xbc, 0xb2, 0xc2, 0x5d, 0xe9, 0x76, 
+	0xb8, 0xbb, 0x2a, 0xdd, 0x4e, 0x9f, 0x2b, 0x53, 0xca, 0xe0, 
+	0x5c, 0x7e, 0x4d, 0xf9, 0x58, 0x19, 0x5d, 0x3c, 0x70, 0x18, 
+	0x8c, 0xdb, 0x9f, 0xa1, 0xe4, 0x40, 0x8e, 0x58, 0x9, 0x64, 
+	0x28, 0xcd, 0x5d, 0x95, 0x23, 0xd7, 0xe4, 0xaa, 0x2c, 0xa9, 
+	0xf8, 0x9c, 0xb9, 0x23, 0x45, 0x3e, 0xa7, 0x49, 0xf3, 0xc9, 
+	0xad, 0x74, 0xe7, 0x75, 0xac, 0x25, 0xe8, 0x83, 0x84, 0xde, 
+	0xe7, 0x16, 0xd3, 0xa9, 0x58, 0x54, 0x52, 0xa5, 0x98, 0x41, 
+	0xf3, 0x84, 0x9f, 0xea, 0x44, 0x80, 0x56, 0x8b, 0x2a, 0xda, 
+	0x28, 0x66, 0xd2, 0x56, 0x31, 0x8b, 0x76, 0x8b, 0x20, 0x25, 
+	0xc4, 0x6c, 0xfa, 0xb8, 0x98, 0x43, 0xb7, 0x8b, 0x2b, 0xf3, 
+	0x9c, 0x7c, 0x1a, 0x85, 0x6b, 0x3a, 0x79, 0x11, 0x32, 0x95, 
+	0x5b, 0x81, 0x36, 0xd, 0x4e, 0x16, 0x57, 0x16, 0x3b, 0xe0, 
+	0x56, 0xb1, 0xec, 0xc7, 0x36, 0x8a, 0x95, 00, 0x43, 0x6c, 
+	0xda, 0x76, 0xb8, 0x58, 0x93, 0x7d, 0xce, 0x5c, 0x56, 0xf1, 
+	0xb9, 0xec, 0x8d, 0x17, 0x63, 0xe3, 0xae, 0x2c, 0xed, 0xf1, 
+	0xb9, 0x73, 0x87, 0x8a, 0x7d, 0xee, 0x2c, 0xad, 0xfa, 0xe4, 
+	0xdc, 0xa1, 0x12, 0x9f, 0x9c, 0xa5, 0xa7, 0xf8, 0x14, 0x3, 
+	0x97, 0xfa, 0x8a, 0xc, 0xac, 0xf9, 0x3c, 0x56, 0x18, 0x8a, 
+	0xf3, 0xc2, 0xd0, 0x44, 0x65, 0x20, 0xaf, 0x42, 0x18, 0xea, 
+	0x11, 0x86, 0xc5, 0xb8, 0xcd, 0xaf, 0xa1, 0xa, 0xb1, 0x84, 
+	0xe6, 0x8a, 0xa5, 0xb4, 0x58, 0x2c, 0xa3, 0x46, 0x7c, 0x69, 
+	0xb6, 0xe3, 0xdb, 0xf5, 0x66, 0xb1, 0x92, 0xf6, 0xe0, 0x83, 
+	0x73, 0x3f, 0xbe, 0x32, 0xf, 0xe1, 0x2b, 0xf1, 0x4e, 0xb1, 
+	0x96, 0x8e, 0x88, 0x75, 0x74, 0x4c, 0x34, 0xd0, 0x83, 0xa2, 
+	0x31, 0x2f, 0x2c, 0xcf, 0xe0, 0x94, 0x9b, 0x61, 0x79, 0x11, 
+	0x32, 0x17, 0xf0, 0xe7, 0x64, 0x39, 0xd0, 0xbf, 0x1b, 0x8d, 
+	0xa5, 0xd6, 0xe1, 0xea, 0xaa, 0x75, 0xd9, 0x69, 0xad, 0x75, 
+	0x5b, 0x59, 0x75, 0x2c, 0x41, 0x2c, 0xb6, 0xd6, 0xca, 0x88, 
+	0xb, 0xae, 0x30, 0x9f, 0x73, 0xa1, 0x36, 0x3d, 0xa3, 0xa2, 
+	0xd8, 0x32, 0x2d, 0x23, 0xd3, 0xdc, 0xb6, 0x30, 0x6b, 0x4b, 
+	0xb3, 0x67, 0x9b, 0x92, 0xdb, 0x9d, 0xc2, 0xe7, 0xc, 0x9c, 
+	0xb8, 0xf8, 0x30, 0x3b, 0x5e, 0x9b, 0xe7, 0xf7, 0xd5, 0x9c, 
+	0x2e, 0x11, 0x23, 0x45, 0xec, 0x25, 0x55, 0xe0, 0x55, 0x2a, 
+	0x6, 0x69, 0xb6, 0x48, 0xd0, 0x7c, 0x31, 0x44, 0x2b, 0xc5, 
+	0xad, 0xf0, 0x39, 0x49, 0x51, 0x91, 0xa2, 0x11, 0xc8, 0xe, 
+	0x8a, 0x11, 0xfa, 0xac, 0x18, 0xcd, 0xf3, 0xf1, 0x59, 0x74, 
+	0x30, 0xb3, 0xc3, 0xdf, 0xd, 0xf, 0x71, 0xe, 0x44, 0x50, 
+	0x43, 0x3b, 0x6d, 0xd, 0x9f, 0xa1, 0xeb, 0xca, 0xc4, 0x47, 
+	0x63, 0x54, 0xcd, 0xed, 0xd2, 0x9, 0x76, 0xb3, 0xa6, 0x1c, 
+	0x38, 0x8a, 0xde, 0xe5, 0xb2, 0x58, 0x19, 0xdc, 0x8c, 0x90, 
+	0xc, 0xee, 0x14, 0x6e, 0x51, 0x43, 0xfd, 0xd7, 0x63, 0x18, 
+	0xe7, 0xe7, 0x5a, 0x78, 0x7, 0xeb, 0x7f, 0x78, 0x60, 0x9c, 
+	0x36, 0x33, 0xdf, 0x12, 0xe2, 0x9, 0x13, 0xc4, 0x56, 0xdb, 
+	0xee, 0x23, 0x25, 0xc, 0x59, 0x1b, 0xe8, 0x76, 0x8b, 0x6e, 
+	0x87, 0x5f, 0x8e, 0x10, 0xe6, 0xb4, 0xec, 0x74, 0xe2, 0xbe, 
+	0x6f, 0x51, 0xba, 0xa, 0x4, 0x60, 0x9d, 0x87, 0xb, 0x85, 
+	0x6c, 0x2c, 0x1b, 0xb4, 0x49, 0xc6, 0x2e, 0x37, 0xd0, 0xfe, 
+	0x47, 0x26, 0xb5, 0x67, 0x7, 0x9c, 0xf7, 0xb2, 0x2f, 0xd8, 
+	0x33, 0xc7, 0x9c, 0x15, 0x1d, 00, 0x2d, 0x13, 0xb4, 0xc5, 
+	0x8e, 0x7d, 0x37, 0xde, 0xf8, 0x24, 0x4e, 0x92, 0x4b, 0x3c, 
+	0x48, 0xa5, 0xe2, 0x14, 0x4d, 0x13, 0xf, 0xd1, 0x4c, 0x71, 
+	0x9a, 0xe6, 0x88, 0x47, 0xa9, 0x46, 0x7c, 0xb, 0x75, 0x87, 
+	0x26, 0x27, 0xc6, 0x51, 0x7b, 0x8f, 0x53, 0x9b, 0x78, 0x82, 
+	0x3a, 0xc5, 0x79, 0xda, 0x25, 0x9e, 0xa4, 0x3e, 0xf1, 0x14, 
+	0xa5, 0xc4, 0xd3, 0x38, 0x86, 0xdf, 0xa5, 0xa3, 0xe2, 0x19, 
+	0x1a, 0x17, 0xdf, 0xa3, 0x97, 0xc5, 0xb3, 0xf4, 0xb6, 0xf8, 
+	0xbe, 0x70, 0x88, 0x17, 0x85, 0x47, 0xbc, 0x24, 0x4a, 0xc5, 
+	0xf, 0xc4, 0x2c, 0xf1, 0xc3, 0xbc, 0x5c, 0x3d, 0x97, 0xcd, 
+	0xd5, 0xf3, 0x90, 0xe1, 0x36, 0x16, 0xb5, 0xd8, 0xf2, 0xf5, 
+	0xab, 0x1d, 0x6b, 0xcc, 0xf0, 0x1f, 0x3e, 0x4e, 0x25, 0x26, 
+	0x75, 0xd7, 0x18, 0xb9, 0x9c, 0x96, 0xf4, 0xae, 0xac, 0xf4, 
+	0xee, 0x31, 0xba, 0x3e, 0x60, 0xbc, 0x52, 0x5a, 0x88, 0x1c, 
+	0x6f, 0xe2, 0xff, 0x81, 0xf1, 0xe, 0x36, 0xf8, 0xec, 0x7f, 
+	0x85, 0x71, 0x9a, 0xf8, 0xd6, 0xc1, 0xc3, 0xc5, 0xdb, 0xb1, 
+	0xfa, 0x14, 0x1d, 0xf3, 0x76, 0x2, 0xde, 0xe3, 0xed, 0x2, 
+	0x3c, 0xec, 0xdd, 0xa, 0x78, 0x87, 0x77, 0x1b, 0xe0, 0xa1, 
+	0xc7, 0x2, 0x5a, 0xf0, 0x7e, 0xba, 0x99, 0x93, 0xeb, 0x42, 
+	0x35, 0x78, 0x6f, 0x97, 0x76, 0x7, 0xb4, 0x83, 0x63, 0x34, 
+	0xa0, 0xdd, 0x82, 0xe1, 0xde, 0xc0, 0xc3, 0xbc, 0xd6, 0x5a, 
+	0xc3, 0x3, 0x32, 0xda, 0x78, 0x88, 0x9f, 0x1f, 0xf8, 0xd7, 
+	0x19, 0x6f, 0xe, 0x6e, 0x5e, 0xe6, 0x23, 0x69, 0x95, 0x77, 
+	0x3b, 0x26, 0x78, 0xbd, 0x37, 00, 0xaa, 0xde, 0x1d, 0x80, 
+	0x6e, 0xef, 0x4e, 0xc0, 0x39, 0x81, 0x32, 0x81, 0xcf, 0x8f, 
+	0x52, 0xc3, 0x6a, 0xb9, 0x77, 0x17, 0x44, 0x5a, 0xc0, 0x7b, 
+	0xe3, 0x9, 0x2a, 0xa, 0x78, 0x77, 0x9d, 0x24, 0xe7, 0x63, 
+	0x79, 0xd5, 0x15, 0xa, 0xe0, 0xb5, 0x74, 0x53, 0xd5, 0x9f, 
+	0x4e, 0xdc, 0x17, 0x70, 0xab, 0x90, 0xf8, 0x29, 0x12, 0xf7, 
+	0x33, 0x92, 0xc5, 0xab, 0xe4, 0x17, 0xaf, 0x51, 0x95, 0x78, 
+	0x9d, 0xae, 0x12, 0x6f, 0xa3, 0x4f, 0xbe, 0x43, 0xbd, 0xe2, 
+	0x5d, 0x1a, 0x10, 0xef, 0x51, 0x52, 0xbc, 0x4f, 0xfb, 0xc4, 
+	0x7, 0x74, 00, 0xaf, 0xa3, 0x83, 0x92, 0x4a, 0x87, 0xa4, 
+	0x12, 0xfa, 0xa2, 0x34, 0x85, 0xe, 0x4b, 0xa5, 0x74, 0x8f, 
+	0xa4, 0xd1, 0x31, 0xc9, 0x4b, 0x17, 0xa4, 0xa9, 0xf4, 0xb2, 
+	0x34, 0x8d, 0x5e, 0x91, 0x7c, 0xf4, 0x13, 0xa9, 0x9c, 0x5e, 
+	0x95, 0x66, 0xd0, 0x1b, 0xd2, 0x4c, 0x7a, 0x4f, 0x9a, 0x45, 
+	0x1f, 0x4a, 0xf3, 0xe9, 0xa2, 0x54, 0x8d, 0x2f, 0x84, 0x1a, 
+	0xe1, 0x92, 0x16, 0x8a, 0x12, 0xa9, 0x4e, 0x4c, 0x95, 0x96, 
+	0x88, 0xa, 0x69, 0xa9, 0x8, 0x48, 0x2b, 0x44, 0x8d, 0xb4, 
+	0xb2, 0x20, 0xc1, 0x17, 0xac, 0x86, 0xf3, 0xb, 0xf3, 0x30, 
+	0xd2, 0xa3, 0x5, 0x25, 0x2a, 0x17, 0xd6, 0x6c, 0x20, 0xdb, 
+	0x7d, 0xb, 0x6, 0xfe, 0xb4, 0xc0, 0x9f, 0x6d, 0x4d, 0x97, 
+	0xc, 0x68, 0x97, 0x1b, 0xb8, 0xcc, 0xc9, 0xb1, 0x6e, 0x3a, 
+	0x3b, 0xc2, 0xf3, 0x38, 0xcd, 0xd2, 0x6, 0x2a, 0x93, 0x9a, 
+	0x28, 0x24, 0x6d, 0xa4, 0x95, 0xd2, 0x26, 0x6a, 0x91, 0x9a, 
+	0x49, 0x97, 0xae, 0x43, 0x34, 0x37, 0x23, 0x7a, 0x2d, 0xf4, 
+	0x88, 0xd4, 0x9a, 0xe7, 0xfd, 0xf3, 0xf4, 0x82, 0xe5, 0xfd, 
+	0xb7, 0xcd, 0xcf, 0x21, 0xba, 0xcd, 0xef, 0x3a, 0x80, 0x95, 
+	0x6e, 0x76, 0x1d, 0x38, 0x8e, 0xc7, 0x8f, 0xf7, 0x16, 0x3f, 
+	0x57, 0x99, 0xe9, 0x2e, 0x12, 0xed, 0x77, 0x1a, 0x83, 0x4e, 
+	0x73, 0x70, 0x37, 0xd8, 0xdc, 0x41, 0xd9, 0x18, 0x94, 0xcd, 
+	0xc1, 0x88, 0x5f, 0xce, 0x1b, 0x44, 0x2b, 0xe3, 0x51, 0xa0, 
+	0xe3, 0xe4, 0xb, 0x79, 0xbb, 0xfd, 0x46, 0x6f, 0xcb, 0x8e, 
+	0x87, 0xfc, 0xe3, 0x74, 0xb3, 0xed, 0x4c, 0x88, 0x6b, 0x55, 
+	0xda, 0x41, 0xaa, 0xb4, 0x93, 0xaa, 0xa4, 0x1b, 0x69, 0x81, 
+	0x74, 0x13, 0xad, 0x90, 0x6e, 0xa1, 0x26, 0x69, 0x37, 0x6d, 
+	0x97, 0xba, 0xe1, 0x54, 0xf, 0x8d, 0x4a, 0x3a, 0x7d, 0x42, 
+	0xea, 0xcd, 0x71, 0x48, 0xe0, 0x2d, 0xc8, 0x9f, 0x1, 0x2f, 
+	0xfe, 0x1, 0x50, 0x4b, 0x3, 0x4, 0xa, 00, 00, 00, 
+	0x8, 00, 0x55, 0x58, 0xda, 0x2c, 0x7a, 0x44, 0x1b, 0x63, 
+	0x14, 0x5, 00, 00, 0xb8, 0x8, 00, 00, 0x19, 00, 
+	00, 00, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 
+	0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x6e, 0x65, 
+	0x6c, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x7d, 0x55, 0x4d, 
+	0x74, 0x13, 0x55, 0x14, 0xfe, 0x5e, 0x93, 0x74, 0x92, 0xe9, 
+	0x10, 0x42, 0x28, 0xfd, 0xe1, 0xcf, 0x42, 0x29, 0xa4, 0x69, 
+	0x68, 0x51, 0xea, 0x1f, 0x41, 0xa0, 0xd, 0x2d, 0x94, 0x6, 
+	0x5a, 0x6c, 0x5, 0x83, 0x80, 0x4e, 0x93, 0x69, 0x32, 0x6d, 
+	0x98, 0x29, 0x93, 0x49, 0x4b, 0x15, 0xc5, 0x1f, 0xfc, 0x41, 
+	0x14, 0x7f, 0xf0, 0x9f, 0x8d, 0x1b, 0x5c, 0x71, 0x3c, 0x47, 
+	0xf, 0x49, 0xce, 0xb1, 0x1e, 0x77, 0x6e, 0x5c, 0xb8, 0x71, 
+	0xe3, 0xc2, 0x8d, 0x5b, 0xb7, 0x6e, 0x3d, 0x1e, 0xef, 0x9d, 
+	0x49, 0xdb, 0xb4, 0xf4, 0x98, 0x73, 0xf2, 0xe6, 0xbd, 0x7b, 
+	0xef, 0x77, 0xef, 0x7d, 0xf7, 0xbb, 0xef, 0xbd, 0x5f, 0xfe, 
+	0xfd, 0xe1, 0x27, 0x78, 0xb0, 0x17, 0x77, 0x64, 0xec, 0x43, 
+	0x9f, 0x84, 0x7e, 0x3f, 0x12, 0x32, 0xea, 0x70, 0x34, 0x80, 
+	0x1e, 0xc, 0x48, 0x18, 0xf4, 0xe3, 0x98, 0x8c, 0x7a, 0x1c, 
+	0x97, 0x31, 0x84, 0x13, 0x7e, 0xc, 0xb3, 0x3c, 0x29, 0xe1, 
+	0xa4, 0xc, 0x5, 0xa7, 0x78, 0x31, 0x12, 0xc0, 0x28, 0x4e, 
+	0xb3, 0xfa, 0x69, 0x9e, 0x8d, 0xc9, 0x18, 0xc7, 0x33, 0xac, 
+	0x3d, 0x23, 0xe1, 0xac, 0x1f, 0xcf, 0xca, 0x68, 0x44, 0x8a, 
+	0xd, 0xcf, 0xf9, 0xf1, 0x1c, 0x7f, 0xcf, 0xfb, 0x71, 0x41, 
+	0xc2, 0x45, 0x19, 0x5b, 0x38, 0xe0, 0xf3, 0x32, 0xb6, 0xa1, 
+	0x4f, 0xc6, 0xb, 0x50, 0x3, 0x34, 0x9b, 0x60, 0x71, 0x9a, 
+	0x97, 0x19, 0x5e, 0x6a, 0x3c, 0x4c, 0x4a, 0xc8, 0xca, 0xe8, 
+	0x40, 0x8e, 0x17, 0x3a, 0xf, 0x53, 0x1c, 0x6e, 0x3a, 0x80, 
+	0x3c, 0x2e, 0xc9, 0x30, 0x60, 0xfa, 0x31, 0xc3, 0x49, 0x5f, 
+	0xe6, 0xb0, 0x97, 0x25, 0x58, 0x12, 0xa, 0x2, 0x3e, 0x5b, 
+	0xb7, 0xf3, 0x9a, 0x40, 0x28, 0x39, 0xa5, 0xce, 0xaa, 0x3d, 
+	0xea, 0x9c, 0xdd, 0x93, 0x54, 0x27, 0xb4, 0x7c, 0x9c, 0x54, 
+	0x96, 0x66, 0x5b, 0xf3, 0x2, 0xf5, 0x33, 0x96, 0x79, 0x69, 
+	0xc6, 0x16, 0xf0, 0xcf, 0xa8, 0x85, 0xc2, 0x9c, 0x69, 0x65, 
+	0x4, 0x1a, 0x97, 0xcd, 0xc7, 0xb5, 0x2b, 0xf6, 0xa0, 0xae, 
+	0xe5, 0x33, 0x4, 0xa9, 0x33, 0xa7, 0x5, 0x36, 0x2c, 0xeb, 
+	0xfa, 0x8b, 0xb6, 0x6d, 0x1a, 0xa4, 0xa8, 0x3f, 0xa8, 0x1b, 
+	0xba, 0x7d, 0x48, 0xc0, 0x13, 0xe9, 0x3c, 0x23, 0xe0, 0x4d, 
+	0x98, 0x19, 0xa, 0xba, 0x3e, 0xa9, 0x1b, 0xda, 0xa9, 0xe2, 
+	0xa5, 0x9, 0xcd, 0x1a, 0x57, 0x27, 0x38, 0x8d, 0x7a, 0x35, 
+	0x6d, 0xeb, 0xa6, 0x21, 0xd0, 0x11, 0x59, 0xf6, 0x32, 0x30, 
+	0xab, 0x19, 0x76, 0xdc, 0x5d, 0xe7, 0x55, 0x23, 0xdb, 0x33, 
+	0x32, 0x31, 0xa5, 0xa5, 0xed, 0x78, 0xe7, 0x39, 0x1, 0x79, 
+	0xcc, 0x2c, 0x5a, 0x69, 0x6d, 0x50, 0x67, 0x74, 0x8b, 0x5a, 
+	0xb4, 0x73, 0x64, 0xab, 0xa7, 0x55, 0xf6, 0x32, 0xaa, 0x1a, 
+	0x5a, 0xbe, 0x9b, 0x61, 0xa, 0x9e, 0xc4, 0x1, 0x81, 0xe0, 
+	0xca, 0x3d, 0xa, 0x84, 0xcf, 0x9c, 0x4a, 0xb4, 0xf5, 0xad, 
+	00, 0xb1, 0xa9, 0xad, 0xe0, 0x61, 0x3c, 0x22, 0xb0, 0x6e, 
+	0xc9, 0x7e, 0xd0, 0x34, 0xa8, 00, 0x81, 0xe3, 0x5a, 0x7e, 
+	0x56, 0x63, 0x4b, 0xb6, 0x2a, 0x4a, 0x98, 0x55, 0x30, 0x87, 
+	0x2b, 0xa4, 0x18, 0xad, 0x56, 0xe6, 0x80, 0x82, 0x5e, 0x46, 
+	0x86, 0x1f, 0x2c, 0xf, 0x43, 0xe6, 0x15, 0x3c, 0x8a, 0xc7, 
+	0x24, 0xbc, 0xa8, 0xe0, 0x25, 0x5c, 0x55, 0xf0, 0x32, 0x5e, 
+	0x51, 0x70, 0xd, 0x57, 0x25, 0xbc, 0xaa, 0xe0, 0x35, 0x5e, 
+	0xbc, 0x8e, 0x37, 0xa8, 0x2e, 0xab, 0xa, 0x48, 0x85, 0x1d, 
+	0x19, 0x66, 0xfc, 0x75, 0x5, 0x8f, 0xe3, 0x9, 0x1, 0x62, 
+	0x70, 0x3f, 0x87, 0x91, 0x12, 0xb4, 0x7b, 0x5d, 0xb3, 0x4, 
+	0x9a, 0x96, 0x20, 0xc7, 0x2c, 0x3d, 0xd3, 0xaf, 0x66, 0x93, 
+	0xea, 0xbc, 0x59, 0xa4, 0x9c, 0xb7, 0xac, 0x56, 0x24, 0x4c, 
+	0xa3, 0x60, 0x5b, 0xaa, 0x6e, 0xd8, 0x5, 0x9, 0x6f, 0x2a, 
+	0x78, 0xb, 0x6f, 0x2b, 0x78, 0x7, 0x37, 0x14, 0xbc, 0x8b, 
+	0x9b, 0xa, 0xde, 0xc3, 0xfb, 0xa, 0x6e, 0xf1, 0xf2, 0x3, 
+	0xdc, 0xa8, 0x4d, 0x65, 0xc8, 0x28, 0x68, 0x76, 0x81, 0xb3, 
+	0xf8, 0x50, 0xc1, 0x47, 0xf8, 0x58, 0xc1, 0x6d, 0xb6, 0xfa, 
+	0x4, 0x7, 0x24, 0x7c, 0xaa, 0xe0, 0x33, 0x7c, 0x2e, 0xe1, 
+	0xb, 0x5, 0x5f, 0x72, 0xa1, 0x37, 0x8c, 0x99, 0x96, 0x35, 
+	0xdf, 0xdd, 0x36, 0x6e, 0xcd, 0xb7, 0xa9, 0x59, 0x8a, 0xd5, 
+	0xad, 0xe0, 0x2b, 0x5c, 0x17, 0xd8, 0xb8, 0x6, 0x43, 0xb5, 
+	0xbc, 0x54, 0x5, 0x4d, 0x91, 0x1a, 0xb6, 0xc7, 0x6c, 0x4b, 
+	0x37, 0xb2, 0xf1, 0x21, 0x6e, 0x9c, 0xe6, 0xb5, 0x14, 0x8e, 
+	0x66, 0xb9, 0xe2, 0x9, 0xea, 0x56, 0xd3, 0xd0, 0x98, 0x30, 
+	0x89, 0x52, 0x76, 0xa9, 0xb, 0xd7, 0xf4, 0x13, 0x4b, 0xe2, 
+	0x4e, 0x1b, 0x46, 0x1c, 0x68, 0xb0, 0x6, 0x9a, 0x37, 0xa9, 
+	0x98, 0xbe, 0x89, 0xbc, 0x9a, 0x9e, 0x5e, 0x71, 0x28, 0x1c, 
+	0xd, 0x35, 0xf2, 0x3a, 0xc7, 0xa3, 0xa5, 0x65, 0x2d, 0xb3, 
+	0x68, 0xd0, 0x41, 0xd8, 0x18, 0x59, 0x6d, 0xc3, 0x1e, 0x7d, 
+	0x73, 0x39, 0xdd, 0xd6, 0x6a, 0x59, 0xe1, 0x36, 0xa8, 0x49, 
+	0x8c, 0xdd, 0xf4, 0x53, 0x8c, 0x45, 0x37, 0x21, 0x5a, 0xf, 
+	0xa4, 0x73, 0x66, 0x22, 0xa7, 0x5a, 0x74, 0x4, 0x98, 0x51, 
+	0x6f, 0x24, 0xc1, 0xae, 0x36, 0xad, 0xb1, 0xe3, 0xd5, 0xfb, 
+	0x35, 0x6c, 0x2a, 0x31, 0x63, 0x2, 0xe4, 0x66, 0x89, 0xf8, 
+	0x48, 0xed, 0x91, 0x66, 0xd9, 0x49, 0xd5, 0x50, 0xb3, 0x9a, 
+	0x9b, 0x61, 0x20, 0x4b, 0xdd, 0x30, 0xa7, 0x67, 0xec, 0x9c, 
+	0x80, 0x18, 0xa2, 0x1a, 0x10, 0xb2, 0xa6, 0x33, 0x4, 0x7a, 
+	0x57, 0x6c, 0xac, 0x9a, 0x78, 0x3c, 0xf9, 0x3f, 0xdd, 0xe4, 
+	0xf8, 0xf5, 0xa8, 0x19, 0xda, 0x4e, 0x74, 0x4d, 0x70, 0xe7, 
+	0x5a, 0x42, 0xda, 0xe8, 0xa4, 0x9e, 0x27, 0xce, 0x7d, 0xfa, 
+	0x8c, 0x9a, 0xa1, 0xeb, 0x46, 0x8a, 0xc, 0xd, 0xb9, 0x94, 
+	0xd6, 0xeb, 0x4e, 0xcb, 0xad, 0xb8, 0x51, 0xdc, 0x2e, 0x8c, 
+	0x57, 0xcd, 0xe9, 0xe8, 0x29, 0x96, 0x76, 0xb9, 0xa8, 0x15, 
+	0x88, 0x94, 0x74, 0xb1, 0x50, 0xcb, 0xa5, 0x73, 0x6b, 0x90, 
+	0x13, 0x5b, 0xb5, 0xb2, 0x1a, 0x77, 0xc0, 0x83, 0x17, 0x8, 
+	0xd5, 0x7d, 0xb5, 0x8c, 00, 0x86, 0x69, 0xeb, 0x93, 0xf3, 
+	0x6e, 0xf3, 0x30, 0x6d, 0x68, 0xa3, 0xfb, 0x78, 0x1f, 00, 
+	0x1f, 0xfd, 0xe9, 0x5e, 00, 0xff, 0xf6, 0x57, 0xbf, 0xbd, 
+	0xd5, 0x2f, 0x1d, 0x6b, 0xe7, 0x4b, 0xc7, 0x93, 0x46, 0xf, 
+	0x4, 0xdf, 0x38, 0x34, 0xc6, 0x1, 0xf1, 0x7, 0x24, 0x92, 
+	0x40, 0x1c, 0x8c, 0x56, 0x20, 0xa2, 0xb, 0xa8, 0x4b, 0x85, 
+	0x3d, 0xde, 0xa, 0xbc, 0x25, 0xf8, 0xa2, 0xf7, 0xe1, 0x5b, 
+	0x40, 0x7d, 0x2a, 0x2c, 0x79, 0x43, 0xe1, 0xa, 0xfc, 0x65, 
+	0x4, 0x5c, 0x3, 0xd9, 0x35, 0x68, 0xa0, 0x95, 0x92, 0xa, 
+	0xc9, 0x15, 0xac, 0x2b, 0x21, 0x48, 0xd6, 0xc1, 0xef, 0xb1, 
+	0xbe, 0x8c, 0x90, 0x3b, 0xdb, 0x50, 0x46, 0x98, 0x67, 0xa1, 
+	0x68, 0x19, 0x1b, 0xc9, 0xb2, 0x31, 0x15, 0xde, 0x54, 0x41, 
+	0x53, 0x9, 0xcd, 0xae, 0x93, 0x16, 0xd7, 0x49, 0x2b, 0xd9, 
+	0xb4, 0x3a, 0x51, 0x36, 0x7b, 0x43, 0x21, 0x37, 0xca, 0x2, 
+	0xb6, 0xa4, 0x2a, 0xd8, 0x9a, 0x5c, 0xc0, 0x36, 0xfa, 0x6e, 
+	0x3f, 0x19, 0xed, 0x2a, 0xe3, 0xa1, 0x98, 0xa7, 0x84, 0xb6, 
+	0x2e, 0xce, 0x29, 0x56, 0xc6, 0x8e, 0x28, 0x4f, 0xca, 0xd8, 
+	0x79, 0x36, 0xe6, 0x2b, 0xa1, 0x9d, 0xc5, 0xad, 0x8b, 0xe2, 
+	0x56, 0x47, 0x4c, 0xd6, 0xed, 0x31, 0x6f, 0x15, 0xd2, 0xb0, 
+	0xa8, 0x6b, 0x60, 0x1d, 0x4b, 0x82, 0x8b, 0x92, 0xa0, 0x63, 
+	0x1d, 0x92, 0x4b, 0xd8, 0xe5, 0x44, 0x60, 0x4c, 0x7b, 0x6c, 
+	0x1, 0x1d, 0x29, 0x4f, 0xa8, 0xd1, 0xe3, 0xa9, 0x60, 0x77, 
+	0x9, 0x7b, 0x62, 0xa1, 0x48, 0x9, 0x11, 0xc6, 0x35, 0x2f, 
+	0xe2, 0x9a, 0x19, 0xe7, 0xe2, 0x3b, 0xbf, 0xa3, 0xaa, 0xa, 
+	0x1c, 0xa4, 0xf1, 0x16, 0xda, 0x69, 0xdc, 0x5, 0x2f, 0x76, 
+	0x23, 0x8c, 0x3d, 0xf4, 0xe4, 0x75, 0x12, 0x1b, 0x5d, 0x38, 
+	0x82, 0x18, 0x4e, 0xd0, 0x23, 0x3d, 0x8e, 0x6e, 0x5c, 0x20, 
+	0xbe, 0xa6, 0x88, 0x99, 0x2b, 0xa4, 0xb9, 0x49, 0xcc, 0xdc, 
+	0x26, 0x5e, 0xee, 0x10, 0x23, 0x5f, 0x13, 0x1f, 0x77, 0xc9, 
+	0xcb, 0xb7, 0x78, 0xa, 0x15, 0x1c, 0xc6, 0x8f, 0x84, 0xfa, 
+	0x19, 0x7d, 0xf8, 0x15, 0x9, 0xfc, 0x86, 0xa3, 0xf8, 0x1d, 
+	0x3, 0xf8, 0x13, 0x83, 0xf8, 0xb, 0xc7, 0xf1, 0x37, 0xbd, 
+	0x9e, 0xff, 0x60, 0x58, 0xd4, 0x21, 0x29, 0xe8, 0x29, 0x17, 
+	0xf4, 0x92, 0x8b, 0xad, 0x18, 0x11, 0x3b, 0x31, 0x2a, 0xba, 
+	0x70, 0x5a, 0xf4, 0x62, 0x4c, 0xc4, 0x29, 0xda, 0xe, 0xf2, 
+	0x75, 0xc8, 0x65, 0x1a, 0xfd, 0xf4, 0xbe, 0x12, 0xd3, 0xd8, 
+	0xde, 0x75, 0x1f, 0xce, 0xce, 0xef, 0x22, 0x58, 0x9d, 0x36, 
+	0x7f, 0x43, 0xd4, 0x96, 0xd1, 0xe5, 0xbd, 0xe7, 0xb9, 0xb7, 
+	0xb4, 0x97, 0x30, 0xed, 0x2, 0x38, 0x8f, 0x26, 0xca, 0x78, 
+	0x33, 0x2e, 0x62, 0x2b, 0x3d, 0xe9, 0x82, 0x72, 0xae, 0x76, 
+	0xe, 0xcd, 0xea, 0x68, 0x6, 0x22, 0x97, 0x6a, 0x1e, 0xa6, 
+	0xba, 0xec, 0x65, 0xa7, 0xe1, 0x96, 0x32, 0xba, 0x97, 0xb, 
+	0x12, 0x74, 0x42, 0xe6, 0x10, 0x80, 0x4e, 0xe, 0xa7, 0x48, 
+	0x7a, 0x98, 0xd6, 0x75, 0x38, 0xf2, 0x1f, 0x50, 0x4b, 0x3, 
+	0x4, 0xa, 00, 00, 00, 0x8, 00, 0x55, 0x58, 0xda, 
+	0x2c, 0xe7, 0x52, 0x7f, 0x83, 0x46, 0xb, 00, 00, 0xe7, 
+	0x14, 00, 00, 0xf, 00, 00, 00, 0x76, 0x6e, 0x63, 
+	0x43, 0x61, 0x6e, 0x76, 0x61, 0x73, 0x2e, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x9d, 0x57, 0x79, 0x7c, 0x54, 0xf5, 0x11, 0xff, 
+	0xce, 0xdb, 0x4d, 0xde, 0xee, 0xe6, 0x5, 0x92, 0xc0, 0x62, 
+	0x62, 0x2, 0x4, 0x45, 0x5d, 0x2, 0x8, 0x42, 0x5, 0x91, 
+	0xc3, 0x92, 0x10, 0x60, 0x2b, 0xc1, 0x48, 0x82, 0x18, 0x50, 
+	0xcb, 0xb2, 0xfb, 0x92, 0x2c, 0xec, 0xe5, 0xdb, 0xdd, 0x84, 
+	0x58, 0xb5, 0x45, 0x53, 0xad, 0xe2, 0x51, 0x6f, 0xc1, 0x13, 
+	0xf, 0xd6, 0x8a, 0x17, 0x96, 0x6c, 0x54, 0x44, 0xad, 0xb6, 
+	0x5a, 0xad, 0x3d, 0xbc, 0xad, 0xb5, 0xf6, 0xb2, 0xb6, 0xf6, 
+	0xd0, 0x6a, 0x45, 0x5b, 0x5b, 0xa4, 0x33, 0xef, 0xbd, 0x64, 
+	0x77, 0x93, 0xe0, 0x1f, 0xcd, 0x27, 0x6f, 0xe6, 0xf7, 0x9b, 
+	0xdf, 0xfc, 0xe6, 0xfa, 0xcd, 0x6f, 0xe6, 0xb7, 0x2f, 0x7c, 
+	0xf1, 0xd8, 0x13, 0x70, 0x60, 0x3a, 0x4d, 0xf3, 0xa0, 0x15, 
+	0xe7, 0xbb, 0xd1, 0x82, 0x6f, 0xba, 0xf1, 0x2d, 0x6c, 0x91, 
+	0xd1, 0x16, 0x15, 0x17, 0x78, 0x50, 0x84, 0xb, 0x65, 0xd2, 
+	0xeb, 0xc1, 0xb7, 0x71, 0x91, 0x8a, 0x8b, 0x65, 0xf2, 0x1d, 
+	0xf, 0x2e, 0xc1, 0xa5, 0x1e, 0xb8, 0xb1, 0xd5, 0xcd, 0xe4, 
+	0xcb, 0x4, 0x5c, 0x2e, 0xb, 0x57, 0xa8, 0xb8, 0xd2, 0x83, 
+	0x32, 0x7c, 0x57, 0x26, 0x57, 0x79, 0x70, 0x35, 0xae, 0x91, 
+	0xd1, 0xb5, 0x32, 0xba, 0x4e, 0x46, 0xd7, 0x7b, 0x70, 0x3, 
+	0x6e, 0x94, 0xd1, 0x36, 0x15, 0xdb, 0x3d, 0xa8, 0xc2, 0x4d, 
+	0x1e, 0xdc, 0x8c, 0x5b, 0x44, 0xfa, 0xad, 0xc2, 0x65, 0xae, 
+	0xdd, 0x26, 0xe0, 0x76, 0xa1, 0xed, 0x10, 0x70, 0x87, 0x80, 
+	0x3b, 0x45, 0xc9, 0x5d, 0xc2, 0x7c, 0xb7, 0x8a, 0x9d, 0x32, 
+	0xc9, 0x8, 0xb8, 0x47, 0xc0, 0xf7, 0x4, 0xdc, 0xeb, 0xe1, 
+	0x4d, 0xbb, 0x84, 0xf5, 0x3e, 0x99, 0xde, 0x2f, 0xe0, 0x1, 
+	0xe1, 0x7f, 0x50, 0x46, 0xf, 0x79, 0xb0, 0x1b, 0xf, 0x7b, 
+	0xf0, 0x7d, 0xec, 0x11, 0x5a, 0x9f, 0x80, 0xac, 0x80, 0x7e, 
+	0x59, 0x78, 0x44, 0xc5, 0xa3, 0x2a, 0x1e, 0xf3, 0x60, 0x2e, 
+	0xce, 0x77, 0x61, 0xaf, 0xe0, 0xc7, 0x5, 0xec, 0x13, 0xf0, 
+	0x84, 0x7, 0x73, 0xf0, 0xa4, 0x8, 0x79, 0xca, 0x85, 0x1f, 
+	0xb8, 0xf1, 0x34, 0x9e, 0xf1, 0xe0, 0x87, 0xf8, 0x91, 0xa8, 
+	0x7a, 0xd6, 0x85, 0xe7, 0x44, 0xc0, 0x8f, 0xc5, 0xeb, 0xe7, 
+	0x45, 0xde, 0xb, 0x62, 0xfb, 0x4f, 0x64, 0xf4, 0xa2, 0x8c, 
+	0x7e, 0x2a, 0xa3, 0x9f, 0xc9, 0xe6, 0x9f, 0xbb, 0xf1, 0xb, 
+	0xbc, 0x24, 0xd1, 0x7d, 0x59, 0x1c, 0x7d, 0x45, 0xb6, 0xbf, 
+	0x2a, 0xe0, 0x35, 0x15, 0xaf, 0x7b, 0xf0, 0x6, 0xde, 0x54, 
+	0xf1, 0x4b, 0x15, 0x6f, 0x11, 0xa8, 0x8b, 0x50, 0xb2, 0xa2, 
+	0x2b, 0x16, 0xec, 0xa, 0xeb, 0xdd, 0xba, 0x31, 0x9f, 0xe0, 
+	0x30, 0xda, 0x37, 0x10, 0x3c, 0x2b, 0x18, 0x35, 0x1b, 0xf1, 
+	0x54, 0x9c, 0x49, 0x4a, 0x30, 0x4a, 0xa8, 0x5e, 0xb1, 0x31, 
+	0xd0, 0x15, 0x98, 0x11, 0xe8, 0x4e, 0xcd, 0x8, 0x47, 0x3, 
+	0x1d, 0xfa, 0x8c, 0x86, 0x78, 0x24, 0x6e, 0x34, 0xc5, 0x43, 
+	0x7a, 0x84, 0x59, 0x8a, 0x83, 0x32, 0x4b, 0x12, 0xca, 0xd7, 
+	0xe5, 0xf8, 0x4c, 0xe, 0x5e, 0x1c, 0x65, 0x4, 0xba, 0x9b, 
+	0xc3, 0x9b, 0xf5, 0x48, 0xd2, 0x2f, 0x3b, 0x9, 0x65, 0x39, 
+	0x1e, 0x93, 0xc2, 0x3c, 0xce, 0x40, 0x34, 0x9c, 0x14, 0x2d, 
+	0x81, 0x18, 0x8b, 0x4f, 0xe9, 0xa1, 0x26, 0x3d, 0x1a, 0x37, 
+	0x7a, 0xcc, 0xe5, 0x96, 0x78, 0xda, 0x8, 0xa, 0x53, 0x71, 
+	0xc2, 0x94, 0xc2, 0x16, 0xad, 0xab, 0x67, 0x90, 0xec, 0x20, 
+	0x8c, 0xc9, 0x89, 0x5a, 0x66, 0x4, 0x12, 0x9d, 0xe1, 0x60, 
+	0x52, 0x9c, 0x48, 0x76, 0xcc, 0x62, 0x27, 0x12, 0x81, 0x70, 
+	0x2c, 0x65, 0xeb, 0x74, 0x24, 0xc2, 0xcc, 0xee, 0x64, 0xc8, 
+	0x2b, 0xa3, 0x63, 0xba, 0x1e, 0x6a, 0x8d, 0xaf, 0xd2, 0x93, 
+	0x7a, 0xaa, 0x21, 0x12, 0x4e, 0x70, 0x20, 0xd6, 0xb2, 0xf8, 
+	0x5, 0xe1, 0x58, 0x38, 0xb5, 0x88, 0xd, 0xf6, 0xe5, 0x85, 
+	0x64, 0xca, 0x69, 0xbc, 0xad, 0x81, 0xfd, 0xe4, 0x6d, 0x2b, 
+	0xc2, 0x31, 0x7d, 0x65, 0x3a, 0xba, 0x41, 0x37, 0x5a, 0x3, 
+	0x1b, 0x22, 0x4c, 0xf1, 0x34, 0x6e, 0xe, 0xea, 0x89, 0x54, 
+	0x38, 0x1e, 0x63, 0xab, 0x4a, 0x13, 0x86, 0xde, 0xae, 0x1b, 
+	0x86, 0x1e, 0x6a, 0x9, 0x9f, 0xc3, 0x8b, 0xe3, 0x7c, 0x53, 
+	0x72, 0xd6, 0x2d, 0x9, 0x47, 0xf5, 0x58, 0x92, 0x19, 0xd9, 
+	0xbc, 0x92, 0x28, 0x2b, 0x8a, 0xa6, 0xa3, 0x16, 0x5b, 0x71, 
+	0x3a, 0x11, 0x62, 0x8f, 0x85, 0x7f, 0x4, 0x67, 0x44, 0x7d, 
+	0x91, 0xe9, 0x8, 0xc1, 0x9b, 0x30, 0xe2, 0x41, 0x3d, 0x99, 
+	0x5c, 0x19, 0x37, 0xa2, 0x81, 0x88, 0x79, 0x3c, 0x1c, 0x77, 
+	0xf6, 0xcd, 0x27, 0x5c, 0x25, 0x21, 0x8e, 0xf3, 0x2a, 0xfe, 
+	0xd7, 0x83, 0xcc, 0xab, 0xfa, 0xfc, 0xfc, 0x67, 0xd2, 0x3b, 
+	0x3, 0xb1, 0x50, 0x44, 0x6f, 0xec, 0xd2, 0x45, 0xc6, 0x98, 
+	0x3c, 0x25, 0x26, 0x69, 0xfe, 0x14, 0x76, 0xdd, 0x63, 0xc5, 
+	0x78, 0x69, 0x58, 0x9c, 0x1a, 0xc5, 0xce, 0x37, 0x4, 0x62, 
+	0x5d, 0x81, 0xe4, 0xb1, 0xc2, 0xaa, 0x61, 0x13, 0xba, 0x35, 
+	0xac, 0xc6, 0x69, 0x2a, 0x7e, 0xa5, 0x61, 0xd, 0x4e, 0x27, 
+	0x4c, 0x1c, 0x92, 0xc, 0x4b, 0xc2, 0x6, 0x6b, 0xcd, 0xa5, 
+	0x84, 0xec, 0xe9, 0xd1, 0xd0, 0x86, 0xb5, 0x2a, 0xde, 0xd6, 
+	0xf0, 0x6b, 0xbc, 0xc3, 0x62, 0xb, 0x13, 0x43, 0xc3, 0x3a, 
+	0x9c, 0xa1, 0xe2, 0x37, 0x1a, 0x7e, 0x8b, 0xdf, 0x9, 0xff, 
+	0xef, 0x35, 0xfc, 0x1, 0xef, 0x6a, 0xf8, 0xa3, 0x80, 00, 
+	0x38, 0xb, 0xab, 0xe, 0x99, 0xc, 0xc2, 0xff, 0x9e, 0x86, 
+	0xaf, 0x63, 0xbd, 0x8a, 0x3f, 0x69, 0xf8, 0x33, 0xde, 0xd7, 
+	0x70, 0x26, 0xce, 0x92, 0xd1, 0x5f, 0x34, 0xb4, 0xe3, 0x2c, 
+	0x15, 0x7f, 0xd5, 0xf0, 0x37, 0xfc, 0x5d, 0x43, 0x7, 0x42, 
+	0x84, 0x8a, 0xe1, 0xe7, 0x20, 0x22, 0x3e, 0x50, 0xf1, 0xa1, 
+	0x86, 0x7f, 0xe0, 0x23, 0xd, 0x1f, 0xe3, 0x9f, 0x1a, 0x82, 
+	0x8, 0x69, 0x8, 0x63, 0xa3, 0x86, 0x4f, 0xb0, 0x5f, 0xc3, 
+	0xa7, 0xe2, 0xf7, 0x67, 0x2, 0xfe, 0x25, 0x36, 0xfd, 0x1b, 
+	0x3d, 0x9c, 0xa1, 0xa6, 0xa4, 0x48, 0x20, 0xd6, 0x31, 0x63, 
+	0x65, 0xbc, 0x25, 0x1d, 0xec, 0x6c, 0xd2, 0x53, 0x9d, 0xf1, 
+	0x50, 0xa3, 0x61, 0x88, 0x4b, 0x9f, 0xb, 0xdf, 0x7f, 0x4, 
+	0xfc, 0x57, 0xc0, 0x1, 0x1, 0x9b, 0x25, 0x12, 0x5f, 0x88, 
+	0x94, 0x83, 0x3c, 0x25, 0x8, 0x20, 0x52, 0x34, 0x72, 0x90, 
+	0x53, 0xa5, 0x22, 0x8d, 0x8a, 0xb1, 0x5f, 0x25, 0x55, 0x23, 
+	0x17, 0xeb, 0x24, 0x37, 0x3e, 0xd0, 0xc8, 0x43, 0x25, 0x1a, 
+	0x69, 0xbc, 0x8f, 0x4a, 0xb1, 0x9f, 0xcf, 0xcc, 0xd4, 0x19, 
+	0x8e, 0xcf, 0xf0, 0x9f, 0x32, 0x98, 0x6f, 0x9c, 0x2e, 0x39, 
+	0x4b, 0x5a, 0x52, 0x46, 0x38, 0xd6, 0x51, 0x9f, 0x6e, 0xe7, 
+	0xf4, 0xe3, 0xc3, 0x59, 0x1d, 0xdb, 0x14, 0x8b, 0x77, 0xc7, 
+	0x6a, 0x57, 0x2d, 0xad, 0xaf, 0x95, 0x73, 0x61, 0x96, 0x88, 
+	0x5e, 0xab, 0xc7, 0x82, 0xf1, 0x10, 0xb3, 0xd5, 0x6a, 0x34, 
+	0x8a, 0x46, 0xb, 0x28, 0xd3, 0xa8, 0x9c, 0x2a, 0x38, 0x10, 
+	0x34, 0x46, 0xa3, 0xb1, 0x78, 0x97, 0xe0, 0xe3, 0x73, 0x3f, 
+	0x26, 0x55, 0x6b, 0x65, 0x4c, 0x6d, 0x8b, 0x6e, 0x1e, 0x69, 
+	0xda, 0x68, 0xa, 0x24, 0x1a, 0x63, 0xac, 0x43, 0x4f, 0xd6, 
+	0x46, 0x39, 0xff, 0xf8, 0x18, 0x54, 0xf2, 0x6a, 0x34, 0x8e, 
+	0xe, 0x53, 0xa9, 0x52, 0xa3, 0x2a, 0x3a, 0x5c, 0xa3, 0x6a, 
+	0xaa, 0xe0, 0x13, 0xcb, 0x57, 0x6d, 0xb3, 0xd6, 0xa6, 0x7a, 
+	0x12, 0x3a, 0x2b, 0xad, 0xa1, 0xf1, 0x1a, 0x4d, 0x10, 0xa7, 
+	0x26, 0xca, 0xb9, 0xe8, 0x1c, 0x6b, 0xaa, 0x95, 0xd8, 0x74, 
+	0xca, 0x68, 0x12, 0x7, 0x88, 0x8e, 0xc0, 0x46, 0x95, 0x8e, 
+	0xd4, 0x68, 0xb2, 0xc4, 0xe8, 0x28, 0x3e, 0x7, 0x3a, 0x5a, 
+	0xc8, 0xc7, 0x90, 0x4f, 0xa3, 0x29, 0xe4, 0x1b, 0x88, 0x84, 
+	0xe9, 0xf3, 0x60, 0x24, 0x54, 0xaa, 0xd3, 0x68, 0x2a, 0xba, 
+	0x9, 0xee, 0xc1, 0xc4, 0xe5, 0xbb, 0x9a, 0xcb, 0x36, 0x9b, 
+	0xe2, 0x1e, 0xbc, 0xd3, 0x4, 0xd7, 0x40, 0x79, 0x63, 0x91, 
+	0xdd, 0x46, 0x38, 0xa5, 0xb3, 0xab, 0x66, 0x89, 0x5a, 0x2a, 
+	0x57, 0x8b, 0xaf, 0x49, 0x29, 0x5f, 0x9f, 0xb5, 0x6b, 0xfd, 
+	0xfe, 0x81, 0x4b, 0x54, 0x75, 0xc8, 0xea, 0xc7, 0x17, 0xb8, 
+	0x43, 0x4f, 0xad, 0x5a, 0xc6, 0x15, 0xc9, 0xe9, 0xf3, 0x4f, 
+	0xf1, 0x5b, 0x88, 0xb7, 0x94, 0xb5, 0x1b, 0x81, 0xa8, 0xbe, 
+	0xc1, 0x3c, 0x94, 0x35, 0xe1, 0x50, 0xaa, 0x93, 0xab, 0xc, 
+	0xaf, 0x96, 0xe7, 0x91, 0x97, 0xeb, 0xe1, 0x8e, 0x4e, 0xd6, 
+	0x76, 0x4, 0x6b, 0xfb, 0x92, 0xfa, 0xba, 0xae, 0x5e, 0xe4, 
+	0x55, 0xe4, 0xdd, 0x9f, 0x68, 0x22, 0x1e, 0x33, 0xaf, 0x73, 
+	0x49, 0xd0, 0xd0, 0xf9, 0x86, 0xd8, 0x45, 0x6e, 0xa6, 0x6f, 
+	0xa8, 0x14, 0x73, 0x81, 0x3d, 0xd, 0xa5, 0x83, 0x52, 0xcb, 
+	0x86, 0x17, 0xde, 0xb1, 0xac, 0x7a, 0x4, 0xf2, 0xa8, 0x42, 
+	0xa, 0x2b, 0x62, 0x27, 0x7, 0x8a, 0x12, 0x57, 0xa2, 0xfc, 
+	0xd2, 0x96, 0x57, 0x78, 0x8b, 0x7c, 0x56, 0xb8, 0xca, 0x87, 
+	0x2d, 0x72, 0xfc, 0xa5, 0x3e, 0xd9, 0xd2, 0x66, 0xfb, 0x86, 
+	0xaa, 0x1c, 0x1e, 00, 0x93, 0x7e, 0xca, 0x86, 0xa4, 0x6e, 
+	0x74, 0x89, 0xe9, 0x5c, 0xa5, 0xc6, 0x9b, 0x47, 0xb5, 0x34, 
+	0x17, 0xbf, 0xd5, 0x66, 0xe5, 0x5c, 0xa5, 0x9f, 0x9d, 0xd6, 
+	0x93, 0x1c, 0xc, 0x97, 0x59, 0xf3, 0xd6, 0x8a, 0x1, 0x5e, 
+	0xe, 0x4b, 0xa8, 0xc5, 0xdc, 0xda, 0x64, 0xa5, 0x61, 0x2b, 
+	0x67, 0xa1, 0x59, 0x2a, 0xfd, 0xf6, 0xea, 0x30, 0x39, 0x84, 
+	0x9a, 0x11, 0xe9, 0x52, 0x50, 0x97, 0x87, 0x38, 0x6b, 0x2a, 
+	0xd2, 0x83, 0xf3, 0x46, 0xfb, 0x32, 0x71, 0xa1, 0x1d, 0xec, 
+	0x21, 0x25, 0xb9, 0xe5, 0xd3, 0xb, 0x66, 0x6d, 0x5, 0xb3, 
+	0x35, 0x5, 0xb3, 0xe5, 0x4, 0x4d, 0xb4, 0x36, 0xc4, 0x13, 
+	0x3d, 0x56, 0xe5, 0xd6, 0x82, 0xf6, 0xb0, 0xc5, 0x8, 0x9e, 
+	0x5e, 0x38, 0x65, 0x41, 0x2e, 0x99, 0x2e, 0xe6, 0x1d, 0x1c, 
+	0x50, 0x5f, 0x2e, 0x3f, 0x15, 0xe9, 0x9e, 0x55, 0x2b, 0x6, 
+	0xa, 0xc5, 0x92, 0x40, 0x2a, 0xe0, 0x8f, 0x25, 0xd2, 0x29, 
+	0xae, 0xc, 0x7a, 0x20, 0xca, 0x27, 0x73, 0xd8, 0x21, 0x96, 
+	0xd8, 0x1, 0x51, 0xef, 0x97, 0x64, 0xaa, 0x1a, 0xe0, 0xe1, 
+	0x3e, 0x90, 0xd2, 0x8d, 0x2, 0x2e, 0xa7, 0x70, 0xb1, 0xce, 
+	0x94, 0x11, 0x88, 0x25, 0x23, 0x66, 0xb4, 0x5c, 0x49, 0xab, 
+	0x3e, 0x18, 0x85, 0x5d, 0xc5, 0x6a, 0xfb, 0x62, 0x94, 0xab, 
+	0x3d, 0x1c, 0x89, 0x58, 0x4e, 0x95, 0xcb, 0xf6, 0xd5, 0x5c, 
+	0x78, 0x3b, 0x62, 0xdc, 0x1e, 0x3b, 0xe3, 0x6, 0xd3, 0x8a, 
+	0x3, 0x89, 0x84, 0x1e, 0x63, 0xa1, 0xd3, 0xec, 0xdd, 0x79, 
+	0xb5, 0x6c, 0x20, 0x55, 0x87, 0x95, 0x37, 0x76, 0xa5, 0xda, 
+	0xe7, 0xff, 0x92, 0x55, 0x57, 0x2a, 0x6e, 0x51, 0x24, 0xb7, 
+	0x87, 0xf3, 0xcd, 0x97, 0xe4, 0x1d, 0x41, 0x1d, 0x9b, 0xab, 
+	0x59, 0xa7, 0xb2, 0x52, 0x2c, 0xe6, 0x68, 0x96, 0xe5, 0x31, 
+	0xf5, 0x24, 0x53, 0x3a, 0x7, 0xc1, 0x11, 0x4f, 0x4b, 0x1b, 
+	0x1e, 0xc, 0x73, 0x33, 0xef, 0xcd, 0x85, 0x78, 0xcc, 0x8, 
+	0x64, 0x69, 0xde, 0x86, 0xd9, 0xbc, 0x9d, 0xbe, 0x6, 0xf3, 
+	0x66, 0xe4, 0x12, 0xb3, 0x21, 0x9d, 0x6a, 0xd5, 0x37, 0xf3, 
+	0x92, 0xdb, 0x4c, 0xbb, 0x74, 0x24, 0xd2, 0x23, 0x7d, 0x7b, 
+	0x5d, 0xbd, 0x75, 0xa4, 0xee, 0x98, 0x6e, 0x3f, 0x9b, 0xe4, 
+	0x7d, 0x65, 0x5e, 0x73, 0x39, 0x7e, 0x4e, 0x35, 0xbb, 0xc3, 
+	0x87, 0xc2, 0xc9, 0x44, 0x3c, 0x29, 0xef, 0xa9, 0x70, 0x6c, 
+	0xe8, 0x93, 0x20, 0x77, 0x7f, 0xed, 0xbe, 0xaf, 0x84, 0x39, 
+	0xd0, 0xae, 0x8e, 0x78, 0x6a, 0x69, 0x3c, 0x98, 0x4e, 0x9a, 
+	0x49, 0x67, 0xde, 0x1a, 0x7b, 0x5a, 0x6e, 0x5e, 0xad, 0xe6, 
+	0x38, 0x9b, 0xaa, 0x1b, 0x87, 0x7e, 0x2a, 0xb0, 0x59, 0xa5, 
+	0x26, 0xe7, 0xc9, 0x7a, 0xcf, 00, 0x57, 0x2e, 0x4c, 0xad, 
+	0x9d, 0x46, 0xbc, 0xdb, 0x7a, 0x18, 0x8d, 0x4e, 0x58, 0x31, 
+	0x8, 0x4, 0x37, 0xb5, 0x1a, 0x81, 0xa0, 0x8e, 0x5a, 0x7e, 
+	0xa1, 0xb6, 0x2, 0x28, 0xe5, 0x8f, 0x9f, 0x12, 0x90, 0x3f, 
+	0x7e, 0x4a, 0x98, 0x98, 0x9f, 0x9, 0x26, 0xe6, 0x7, 0x81, 
+	0x89, 0xb9, 0x93, 0x9b, 0x98, 0xdb, 0xbb, 0x89, 0xf9, 0x31, 
+	0x60, 0x62, 0x6e, 0xcf, 0x26, 0xd6, 0x6d, 0xdc, 0x6e, 0xf3, 
+	0x75, 0xd8, 0xf3, 0x4e, 0x1b, 0x73, 0x7, 0x67, 0xe8, 0xe2, 
+	0x6f, 0x13, 0x22, 0x50, 0x10, 0x5, 0xe8, 0x48, 0x94, 0xf0, 
+	0xcf, 0xf, 0xe0, 0x95, 0xba, 0x7e, 0x50, 0xdd, 0xd4, 0x3e, 
+	0x28, 0x75, 0x75, 0x7b, 0xa0, 0xec, 0x81, 0xa3, 0xf, 0xce, 
+	0xba, 0xbd, 0x28, 0x6a, 0x2b, 0x73, 0x95, 0xa9, 0x65, 0x27, 
+	0x94, 0xe3, 0xa9, 0x7e, 0x14, 0xf7, 0x41, 0xe5, 0x55, 0x27, 
+	0x93, 0x5c, 0xe, 0x27, 0x93, 0xd5, 0x62, 0x47, 0x71, 0x59, 
+	0x71, 0x16, 0xae, 0xba, 0x72, 0xc2, 0x3e, 0xb8, 0xfb, 0xe0, 
+	0x71, 0x2c, 0xcc, 0xa0, 0x9a, 0x99, 0x3c, 0x35, 0x7b, 0xe1, 
+	0x6e, 0xe3, 0x81, 0x5a, 0x93, 0x45, 0x49, 0x3f, 0xb4, 0x96, 
+	0x5e, 0x85, 0x6a, 0x98, 0x6d, 0xc7, 0xc1, 0x77, 0x45, 0x85, 
+	0x73, 0xf, 0x4a, 0x2d, 0x34, 0xaa, 0xf3, 0x71, 0x57, 0x1f, 
+	0x46, 0xb3, 0xb2, 0xb2, 0xb6, 0xc2, 0x5, 0xd9, 0xcd, 0xdf, 
+	0xe8, 0x7e, 0x94, 0xf7, 0xa1, 0xa2, 0x4e, 0xb6, 0x55, 0x64, 
+	0x31, 0xa6, 0xf, 0x63, 0x4d, 0x23, 0xb, 0x99, 0xb3, 0xf0, 
+	0xf6, 0x61, 0x9c, 0x2c, 0x8c, 0xcb, 0xe2, 0xb0, 0x3e, 0x54, 
+	0xee, 0x66, 0xb7, 0x8, 0x31, 0x86, 0x8b, 0x30, 0x9a, 0xe1, 
+	0x54, 0x38, 0x31, 0x8d, 0x7f, 0x31, 0x4d, 0xc7, 0x58, 0xcc, 
+	0x80, 0xf, 0xc7, 0x31, 0x7d, 0x36, 0x96, 0xe3, 0x78, 0x34, 
+	0xf1, 0xcf, 0x8b, 0xd, 0x8c, 0x23, 0x98, 0x87, 0x2d, 0x98, 
+	0x8f, 0x3b, 0xb0, 0x10, 0xf, 0xe0, 0x24, 0x3c, 0x87, 0xc5, 
+	0x78, 0x19, 0xf5, 0x88, 0xf3, 0x6e, 0x27, 0xcb, 0x9a, 0xc3, 
+	0x5f, 0x2, 0x67, 0x33, 0xe4, 0xd0, 0xe1, 0x58, 0x93, 0x6, 
+	0x8c, 0xdb, 0x8b, 0xaa, 0x21, 0x86, 0xf7, 0xe3, 0xf0, 0x87, 
+	0x6, 0xb5, 0x17, 0x9b, 0x5c, 0x8d, 0xc, 0x8d, 0xff, 0x73, 
+	0xaf, 0x9f, 0x61, 0x12, 0x29, 0x7b, 0x6f, 0x15, 0x7f, 0x8a, 
+	0x70, 0xec, 0x1e, 0xc2, 0xd6, 0xc4, 0x30, 0x3d, 0xc8, 0x36, 
+	0x85, 0x7f, 0x38, 0xa, 0x5b, 0xe9, 0x54, 0x9, 0x89, 0xc3, 
+	0x51, 0x97, 0x45, 0xf5, 0x9a, 0xdc, 0x16, 0x8f, 0xb9, 0xd8, 
+	0xc, 0xd, 0xa7, 0x32, 0xa5, 0xb, 0xdd, 0x56, 0x42, 0x38, 
+	0xe, 0x72, 0x82, 0x94, 0x30, 0x1e, 0x2d, 0xe6, 0xf0, 0xae, 
+	0x2, 0xdb, 0x1c, 0x59, 0xd4, 0xd4, 0xb1, 0xa0, 0xf1, 0x7d, 
+	0x98, 0x50, 0xc7, 0x19, 0x32, 0x31, 0x3, 0x93, 0x23, 0x8b, 
+	0xda, 0x5, 0xd5, 0xf7, 0x4a, 0x8e, 0x29, 0xcf, 0xc0, 0xfa, 
+	0x93, 0xa4, 0x9a, 0xc8, 0xf3, 0x3b, 0xf9, 0xbb, 0x9f, 0xbf, 
+	0x47, 0x2c, 0xbe, 0x49, 0x9c, 0x1f, 0xca, 0x6a, 0x6b, 0x7c, 
+	0x4, 0xa3, 0x89, 0xdb, 0xb0, 0xc4, 0x12, 0x7e, 0xe4, 0x36, 
+	0x9c, 0xc8, 0xa3, 0x9, 0x43, 0x75, 0x66, 0x31, 0x99, 0x47, 
+	0x95, 0x23, 0x90, 0x33, 0x70, 0xae, 0x34, 0xad, 0xb0, 0x5, 
+	0x88, 0x1, 0xf4, 0xa6, 0xad, 0x5f, 0xbc, 0x3b, 0x9c, 0xbf, 
+	0x85, 0xfc, 0xdd, 0x60, 0x27, 0xdc, 0xd1, 0x16, 0x3a, 0xc6, 
+	0x42, 0x3e, 0xb, 0x4d, 0xc9, 0xa2, 0x2e, 0x43, 0x4f, 0x5a, 
+	0x26, 0x49, 0xac, 0x2a, 0x2d, 0xfa, 0x34, 0xb, 0x4d, 0x2f, 
+	0x64, 0x2e, 0x10, 0x34, 0x2d, 0x54, 0x20, 0x70, 0x7a, 0x28, 
+	0x8b, 0x63, 0xc5, 0x85, 0xbc, 0x80, 0x67, 0x48, 0xb7, 0x16, 
+	0x67, 0x64, 0x31, 0x73, 0xd1, 0xe0, 0xf0, 0xb8, 0x39, 0x4e, 
+	0x9b, 0x31, 0xcf, 0xac, 0x2c, 0x66, 0xd9, 0x44, 0x8f, 0xd7, 
+	0x39, 0x2b, 0x8b, 0xd9, 0xf9, 0xe1, 0xc8, 0x59, 0xfb, 0x95, 
+	0x9c, 0x8d, 0x85, 0x3b, 0x2b, 0xb, 0x76, 0x56, 0x8e, 0xb0, 
+	0xd3, 0x31, 0xc7, 0x93, 0xc1, 0xb9, 0x79, 0x56, 0x14, 0xd, 
+	0x8e, 0x8f, 0x9f, 0x53, 0x9c, 0x37, 0x56, 0xf3, 0xc6, 0xae, 
+	0xbc, 0xb1, 0x7b, 0xd0, 0xc0, 0xa2, 0x1, 0x3, 0xbd, 0xc5, 
+	0x5e, 0xd5, 0xeb, 0xf2, 0xba, 0x73, 0x86, 0xe5, 0x16, 0x2b, 
+	0xf3, 0x16, 0x7b, 0x3d, 0xe4, 0xf5, 0x8c, 0xdf, 0x71, 0xb0, 
+	0x37, 0xcf, 0xf1, 0x94, 0x6d, 0x7f, 0x2a, 0xe7, 0xc0, 0x50, 
+	0x72, 0x6, 0x93, 0xf7, 0x62, 0x4e, 0xdb, 0x5e, 0xcc, 0x6d, 
+	0xeb, 0xc7, 0x9, 0x15, 0xf3, 0xb2, 0x66, 0x96, 0xc8, 0x71, 
+	0x67, 0x31, 0x3f, 0x8b, 0x5, 0xfd, 0x58, 0xf8, 0xa4, 0x54, 
+	0x16, 0x8b, 0xb8, 0x68, 0xc7, 0x81, 0x9d, 0x23, 0x25, 0x2e, 
+	0x1f, 0x6d, 0x4d, 0xe6, 0xc0, 0x1a, 0x91, 0x54, 0x71, 0x92, 
+	0x6c, 0x79, 0x18, 0x5f, 0x2d, 0x53, 0xb3, 0x58, 0x9c, 0x39, 
+	0x50, 0x6f, 0x9d, 0x7c, 0xfd, 0xca, 0xcc, 0x81, 0xb9, 0xf9, 
+	0x9a, 0x1a, 0x58, 0x53, 0x75, 0x4e, 0x7, 0x5f, 0x92, 0x14, 
+	0x17, 0x86, 0xbb, 0x71, 0x94, 0x7d, 0x81, 0x5e, 0xe7, 0x82, 
+	0x1, 0xae, 0xd0, 0x95, 0x5c, 0x97, 0x6b, 0xb9, 0x26, 0x1f, 
+	0xc5, 0xf5, 0xd7, 0xc7, 0xb5, 0x77, 0x26, 0xd7, 0xdb, 0x66, 
+	0xae, 0xb4, 0x6b, 0xb8, 0x9c, 0x9c, 0xc1, 0x57, 0x2a, 0xc8, 
+	0xe5, 0x23, 0xc5, 0x57, 0x7f, 0x2b, 0x5f, 0xe1, 0xbb, 0x79, 
+	0xb4, 0x93, 0x2f, 0xdb, 0x2e, 0xf4, 0xe0, 0x45, 0x9c, 0xcb, 
+	0xbf, 0xc4, 0xce, 0xc7, 0x87, 0x5c, 0x72, 0x3e, 0xc5, 0x5, 
+	0x34, 0x17, 0x97, 0xd1, 0x52, 0x5c, 0x41, 0x7e, 0x5c, 0x4d, 
+	0xad, 0xb8, 0x86, 0xd6, 0xe3, 0x3a, 0x4a, 0xe3, 0x7a, 0xba, 
+	0x10, 0x37, 0xd0, 0x76, 0xdc, 0x48, 0xf, 0x62, 0x1b, 0xed, 
+	0xc3, 0x76, 0x7a, 0x15, 0x37, 0xd1, 0x5b, 0xb8, 0x99, 0xde, 
+	0xc3, 0x2d, 0xf4, 0x31, 0x6e, 0xa5, 0x2f, 0x70, 0x9b, 0xe2, 
+	0xc1, 0xed, 0xca, 0x38, 0xec, 0x50, 0x26, 0xe3, 0xe, 0x65, 
+	0x36, 0xee, 0x54, 0x16, 0xe3, 0x2e, 0xa5, 0x19, 0x37, 0x29, 
+	0x6d, 0xd8, 0xa9, 0x24, 0x90, 0x51, 0x2e, 0xc6, 0x3d, 0xca, 
+	0xa5, 0x34, 0x4d, 0xd9, 0x85, 0x88, 0xf2, 0x28, 0xcd, 0x54, 
+	0x5e, 0xa2, 0x59, 0xca, 0xab, 0x74, 0xbc, 0xf2, 0xe, 0x9d, 
+	0xa0, 0xbc, 0x47, 0xf3, 0x94, 0xf7, 0x69, 0x81, 0xf2, 0x11, 
+	0x2d, 0x52, 0x3e, 0xa1, 0xc5, 0x79, 0xc5, 0xe, 0xf2, 0x1b, 
+	0xcd, 0xee, 0x13, 0xcb, 0xb8, 0x9a, 0xa8, 0x4c, 0x79, 0xa3, 
+	0x66, 0x4e, 0x51, 0x6, 0x93, 0xec, 0x94, 0x90, 0xe2, 0xec, 
+	0xb5, 0x73, 0xa8, 0xb4, 0xb3, 0x7a, 0xfd, 0xf8, 0x2c, 0x96, 
+	0xf4, 0x16, 0x91, 0xb7, 0xa8, 0xc6, 0xeb, 0x5c, 0xbf, 0xe3, 
+	0xe0, 0xdb, 0x52, 0xb0, 0xab, 0x6b, 0xc6, 0x7b, 0x39, 0xbe, 
+	0x8d, 0x72, 0xec, 0xf6, 0xd8, 0xbc, 0xd0, 0x83, 0x63, 0xa7, 
+	0x59, 0x47, 0x66, 0x9f, 0x58, 0x2c, 0xb7, 0x74, 0x42, 0x16, 
+	0x4b, 0xfb, 0xb0, 0x2c, 0x8f, 0x79, 0xb9, 0x90, 0x2b, 0x4d, 
+	0xb2, 0x3f, 0x6f, 0xdf, 0x72, 0x3b, 0x8d, 0xc6, 0xda, 0x17, 
+	0xcd, 0x4e, 0x9f, 0xbc, 0xe9, 0xb2, 0x67, 0xcd, 0xeb, 0xcc, 
+	0x12, 0xbf, 0x26, 0x22, 0x96, 0x49, 0xcd, 0x22, 0x4b, 0x76, 
+	0xa5, 0x4d, 0xf3, 0x73, 0x9b, 0x10, 0x9a, 0x7f, 0x37, 0x3b, 
+	0x3c, 0x8f, 0xdb, 0x6f, 0xdb, 0xe0, 0xf1, 0x9e, 0x6, 0x2f, 
+	0xbb, 0xdd, 0x86, 0x62, 0x5a, 0x8b, 0x49, 0x8c, 0xa7, 0xd3, 
+	0x99, 0x98, 0xc7, 0x87, 0xd2, 0x48, 0x1, 0x9c, 0x4a, 0x1b, 
+	0xd0, 0x46, 0x21, 0xb4, 0x93, 0xe, 0x83, 0xda, 0x71, 0x1e, 
+	0x75, 0xe0, 0x12, 0xda, 0xc8, 0x87, 0xb4, 0x9, 0x19, 0x8a, 
+	0xe2, 0x1, 0x8a, 0xa1, 0x8f, 0xe2, 0xd8, 0x47, 0x9, 0x3c, 
+	0x4d, 0x67, 0xe3, 0x79, 0x32, 0xf0, 0x12, 0x25, 0xf1, 0x3a, 
+	0x1f, 0x68, 0x7e, 0x2f, 0x39, 0x7, 0xdf, 0xb0, 0x8b, 0xf5, 
+	0x6b, 0x1c, 0x66, 0xa9, 0x98, 0x97, 0x4b, 0x2c, 0x9f, 0xc5, 
+	0xc5, 0x56, 0x48, 0x4f, 0xde, 0x86, 0xf3, 0xa6, 0xee, 0xc1, 
+	0x8a, 0x5d, 0x66, 0x45, 0x8b, 0x58, 0xcd, 0x9b, 0xae, 0x62, 
+	0xcc, 0xd, 0x9d, 0xae, 0xb6, 0xf1, 0x35, 0x36, 0xbe, 0xd6, 
+	0xc6, 0xfb, 0x19, 0x9f, 0xcc, 0xf8, 0x53, 0x1b, 0x7f, 0x66, 
+	0xe3, 0xcf, 0x5, 0x5b, 0xcd, 0xbd, 0x69, 0x1b, 0x37, 0xd6, 
+	0x2c, 0x56, 0x8a, 0x9a, 0xa9, 0x59, 0x9c, 0x92, 0x41, 0x89, 
+	0x3d, 0x6c, 0xce, 0xc0, 0xd5, 0x34, 0x2d, 0x8b, 0x55, 0xce, 
+	0xfb, 0x1c, 0xf7, 0xb1, 0x71, 0xe5, 0x9c, 0x9d, 0xbd, 0x66, 
+	0x8b, 0x88, 0x99, 0x6d, 0x8b, 0x5b, 0x3, 0xf5, 0xa2, 0x9c, 
+	0x2e, 0xc2, 0x7a, 0xda, 0x8a, 0x8d, 0x74, 0x19, 0x62, 0x74, 
+	0x5, 0xba, 0xe8, 0x4a, 0xf4, 0xb0, 0x1, 0x5b, 0xe8, 0x3a, 
+	0xf4, 0xd2, 0x8d, 0x1c, 0x8c, 0xed, 0xd8, 0x4a, 0x37, 0xf3, 
+	0xae, 0x73, 0xcd, 0x52, 0x7c, 0xde, 0xff, 00, 0x50, 0x4b, 
+	0x3, 0x4, 0xa, 00, 00, 00, 0x8, 00, 0x55, 0x58, 
+	0xda, 0x2c, 0xb6, 0xdd, 0x6b, 0x3d, 0x5, 0x3, 00, 00, 
+	0xbf, 0x5, 00, 00, 0x1f, 00, 00, 00, 0x61, 0x6e, 
+	0x69, 0x6d, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x6f, 
+	0x72, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x53, 0x6f, 0x75, 
+	0x72, 0x63, 0x65, 0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x95, 
+	0x54, 0x5b, 0x4f, 0x13, 0x41, 0x18, 0x3d, 0xd3, 0x6e, 0xaf, 
+	0x6c, 0xab, 0xa2, 0xa8, 0xb5, 0x5c, 0x4, 0x15, 0xcb, 0x96, 
+	0xb6, 0xca, 0xc5, 0xfb, 0x15, 0x10, 0xad, 0x82, 0x1a, 0x24, 
+	0xc6, 0xc8, 0x8b, 0x4b, 0x3b, 0x96, 0x25, 0xed, 0x2e, 0x6c, 
+	0xb7, 0xa2, 0x7f, 0x48, 0x5f, 0x7c, 0xc1, 0x58, 0xd, 0x3e, 
+	0xf8, 0xe8, 0x83, 0x3f, 0xca, 0x78, 0x66, 0x5b, 0x5a, 0x83, 
+	0x48, 0x62, 0x93, 0x39, 0xdf, 0xec, 0xcc, 0x77, 0x39, 0xdf, 
+	0xf9, 0x26, 0xfd, 0xf9, 0xeb, 0xdb, 0x77, 0x4, 0x91, 0xc3, 
+	0x6c, 0x1c, 0x49, 0x64, 0x62, 0x48, 0x60, 0x4c, 0x81, 0xa1, 
+	0x20, 0xab, 0x60, 0x5c, 0x41, 0xae, 0x7, 0x79, 0x14, 0x14, 
+	0x5c, 0x50, 0x70, 0x51, 0xc1, 0x84, 0x82, 0xc9, 0x38, 0x6f, 
+	0xa7, 0x22, 0x98, 0x8e, 0xe0, 0x52, 0x4, 0x97, 0x5, 0x42, 
+	0x5b, 0x56, 0xd9, 0x5b, 0x13, 0x10, 0x45, 0x81, 0xf0, 0x9a, 
+	0xb4, 0x2a, 0x6b, 0x9e, 0x40, 0xa0, 0x54, 0x13, 0x48, 0x2f, 
+	0xac, 0x9b, 0x6f, 0xcc, 0x82, 0xb9, 0xe5, 0x15, 0xac, 0x9a, 
+	0x59, 0x91, 0x85, 0x59, 0xa7, 0xea, 0xb8, 0x8b, 0x4e, 0x59, 
+	0x56, 0xaf, 0xd3, 0x77, 0xc3, 0x7a, 0x2b, 0xab, 0x75, 0xfa, 
+	0xae, 0xcc, 0x10, 0xac, 0x92, 0xc0, 0xe0, 0xde, 0x80, 0xa2, 
+	0xc2, 0x59, 0xc7, 0xae, 0x37, 0x6a, 0xd2, 0x55, 0x31, 0x37, 
+	0x2c, 0xdb, 0xf2, 0x6e, 0x9, 0x8c, 0x64, 0x8a, 0xc5, 0x3, 
+	0xb2, 0xaf, 0xcc, 0x8c, 0x3d, 0x17, 0xd0, 0x66, 0xf9, 0x21, 
+	0x70, 0x68, 0xc1, 0xb2, 0xe5, 0xe3, 0x46, 0x6d, 0x55, 0xba, 
+	0xcb, 0xe6, 0x6a, 0x95, 0x27, 0x3d, 0x66, 0xb9, 0xbc, 0x9b, 
+	0x55, 0x60, 0x38, 0x73, 0x70, 0x59, 0x95, 0x2a, 0x6e, 0xd5, 
+	0xff, 0x23, 0xe0, 0xa5, 0x40, 0xd2, 0x95, 0x35, 0xe7, 0x8d, 
+	0xec, 0x6, 0xd, 0xb8, 0x72, 0xb3, 0x21, 0xeb, 0xde, 0xb2, 
+	0xb3, 0x31, 0xe7, 0x6c, 0xd9, 0xb, 0xf2, 0xb5, 0xb7, 0xa4, 
+	0xb4, 0x5a, 0x92, 0x75, 0x69, 0x97, 0xc9, 0xb2, 0xee, 0x99, 
+	0xae, 0xf7, 0xd4, 0x75, 0xca, 0x8d, 0x92, 0x67, 0x39, 0xb6, 
+	0x40, 0xcc, 0x96, 0x5b, 0x4f, 0xdb, 0x1a, 0x45, 0xd8, 0x6f, 
+	0xb1, 0xe8, 0x33, 0x79, 0xe6, 0x34, 0xdc, 0x92, 0x9c, 0xb7, 
+	0x54, 0x23, 0x83, 0xa6, 0x4d, 0x2, 0x9e, 0x2c, 0x2f, 0xb2, 
+	0x9a, 0xfb, 0xce, 0xa7, 0xd1, 0xba, 0xcf, 0x2b, 0x86, 0x3a, 
+	0x52, 0xb8, 0xa2, 0xe3, 0x30, 0x8e, 0xe8, 0xe8, 0x55, 0x70, 
+	0x14, 0xc7, 0x74, 0xf4, 0xe1, 0xb8, 0x8e, 0x13, 0x38, 0x19, 
+	0xc1, 0x55, 0x1d, 0xd7, 0x70, 0x5d, 0xc7, 0xd, 0xdc, 0xd4, 
+	0x71, 0xb, 0xb7, 0x75, 0xdc, 0x51, 0x9f, 0x77, 0x31, 0xa3, 
+	0x63, 00, 0x83, 0x2, 0xa9, 0x7f, 0xe6, 0x17, 0x38, 0xec, 
+	0x6b, 0x50, 0x35, 0xed, 0x4a, 0xe1, 0xc9, 0xea, 0xba, 0x2c, 
+	0x71, 0xea, 0xfd, 0xfb, 0xc9, 0xd2, 0x6a, 0x49, 0x49, 0x10, 
+	0xcc, 0xa8, 0x6, 0xf6, 0x75, 0xea, 0xea, 0x94, 0xb0, 0x5a, 
+	0xdf, 0xb5, 0x8d, 0xaa, 0xf4, 0x58, 0x46, 0xcb, 0xf8, 0x6d, 
+	0x27, 0xea, 0xd2, 0x9b, 0xb3, 0x6a, 0xd2, 0xae, 0x53, 0x1b, 
+	0xa, 0x12, 0xca, 0x14, 0x3b, 0xe7, 0xdd, 0xc1, 0x53, 0x91, 
+	0xbf, 0x66, 0xf3, 0xc7, 0xb3, 0x50, 0x1, 0x51, 0x6, 0x3c, 
+	0xb0, 0x6c, 0x8f, 0x39, 0x62, 0xdc, 0xee, 0xa, 0x3c, 0xea, 
+	0xb, 0x7c, 0xe0, 0x93, 0x52, 0x5, 0x71, 0x9a, 0xaf, 0x3f, 
+	0x9, 0x8e, 0xb, 0x21, 0x40, 0x29, 0xb, 0xf5, 0xeb, 0x6d, 
+	0x5b, 0xea, 0xeb, 0x5b, 0x4a, 0xec, 0x5b, 0xaa, 0x4c, 0x8c, 
+	0x70, 0xa5, 0x70, 0x8a, 0x51, 0x69, 0xee, 0xe6, 0x11, 0xf0, 
+	0x63, 0x4f, 0x19, 0x5f, 0x21, 0x8c, 0x74, 0x13, 0x1, 0xa3, 
+	0xbf, 0x89, 0xa0, 0x91, 0x6b, 0x42, 0x33, 0x52, 0x5a, 0x13, 
+	0xa1, 0x6d, 0xde, 0x52, 0x27, 0xe5, 0x83, 0x30, 0x71, 0x18, 
+	0x1a, 0x46, 0x10, 0xc3, 0x19, 0x56, 0x3e, 0xcb, 0x1a, 0xe7, 
+	0x98, 0x6d, 0x94, 0x1e, 0x1c, 0x51, 0x3b, 0xe7, 0x27, 0xde, 
+	0x6, 0x68, 0x5d, 0xe3, 0x33, 0xc2, 0xd9, 0xf7, 0xd0, 0xb6, 
+	0xd5, 0xe6, 0x7, 0x12, 0xca, 0x68, 0x3b, 0x88, 0x4, 0x60, 
+	0x64, 0x9b, 0x8, 0xab, 0x4f, 0xae, 00, 0x57, 0x70, 0x7, 
+	0xd1, 0x20, 0xda, 0x7, 0x74, 0x89, 0x5, 0xd0, 0x76, 0x8e, 
+	0xb7, 0x76, 0xc1, 0xe0, 0xae, 0xa7, 0x72, 0xe0, 0xa, 0xf9, 
+	0x7, 0x3b, 0xe8, 0x89, 0xf9, 0xf7, 0x21, 0x3f, 0x6d, 0x97, 
+	0x6b, 0x1e, 0x3d, 0xc4, 0x31, 0x44, 0x61, 0x90, 0xcd, 0x38, 
+	0xb5, 0xc9, 0x91, 0xff, 0x5, 0xc, 0xe1, 0x22, 0x71, 0x2, 
+	0x37, 0x31, 0x89, 0xfb, 0x98, 0x42, 0x5, 0xd3, 0xd8, 0xc4, 
+	0x25, 0x46, 0xd, 0x51, 0xcd, 0x16, 0xff, 0x51, 0xb2, 0x57, 
+	0xfc, 0x93, 0x6d, 0xfe, 0x11, 0xed, 0x3, 0xb4, 0xe0, 0xc7, 
+	0x4e, 0xee, 0x30, 0x2d, 0x70, 0x95, 0x38, 0xdc, 0xe9, 0x39, 
+	0xbf, 0x27, 0x26, 0x6a, 0x8, 0x76, 0xd8, 0xe5, 0x93, 0xe4, 
+	0xbf, 0x1c, 0x58, 0x35, 0xca, 0x97, 0x9d, 0xc0, 0x6d, 0x9e, 
+	0x8e, 0x74, 0x62, 0x53, 0x5c, 0x2a, 0x56, 0x6c, 0xef, 0x29, 
+	0x31, 0x43, 0x3c, 0xd3, 0x71, 0x1b, 0x69, 0x97, 0x8, 0x1b, 
+	0xd9, 0x2f, 0xd0, 0xbb, 0xbe, 0x71, 0xff, 0xf4, 0x1e, 0xc7, 
+	0x38, 0x4f, 0x7b, 0x96, 0x3, 0x69, 0xf9, 0xbf, 0x60, 0xe3, 
+	0x6a, 0xb4, 0x53, 0x2d, 0xf5, 0xb, 0xca, 0xa4, 0xfb, 0x7, 
+	0xfa, 0xb4, 0x5d, 0x5, 0x95, 0x80, 0xfd, 0x6b, 0xe9, 0x57, 
+	0x7, 0xa, 0xd9, 0xcb, 0x71, 0x3, 0x45, 0x3e, 0x9b, 0x87, 
+	0x94, 0xf3, 0x11, 0x65, 0x5b, 0xe4, 0xcd, 0xa8, 0x4f, 0xf9, 
+	0xfc, 0x6f, 0x50, 0x4b, 0x1, 0x2, 0xa, 00, 0xa, 00, 
+	00, 00, 00, 00, 0x16, 0xa9, 0xda, 0x2c, 00, 00, 
+	00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
+	0x9, 00, 00, 00, 00, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 00, 00, 0x4d, 0x45, 
+	0x54, 0x41, 0x2d, 0x49, 0x4e, 0x46, 0x2f, 0x50, 0x4b, 0x1, 
+	0x2, 0xa, 00, 0xa, 00, 00, 00, 00, 00, 0x16, 
+	0xa9, 0xda, 0x2c, 0x1e, 0xb9, 0xd9, 0x17, 0x2d, 00, 00, 
+	00, 0x2d, 00, 00, 00, 0x14, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 00, 00, 00, 0x27, 
+	00, 00, 00, 0x4d, 0x45, 0x54, 0x41, 0x2d, 0x49, 0x4e, 
+	0x46, 0x2f, 0x4d, 0x41, 0x4e, 0x49, 0x46, 0x45, 0x53, 0x54, 
+	0x2e, 0x4d, 0x46, 0x50, 0x4b, 0x1, 0x2, 0xa, 00, 0xa, 
+	00, 00, 00, 0x8, 00, 0xe3, 0xa5, 0xda, 0x2c, 0x5f, 
+	0xeb, 0x71, 0x9a, 0xd7, 0xd, 00, 00, 0x8, 0x19, 00, 
+	00, 0xf, 00, 00, 00, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 0x86, 00, 00, 00, 0x76, 
+	0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x2e, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x50, 0x4b, 0x1, 0x2, 0xa, 00, 
+	0xa, 00, 00, 00, 0x8, 00, 0x16, 0xa9, 0xda, 0x2c, 
+	0xc9, 0xa0, 0xa1, 0x6c, 0x47, 0xf, 00, 00, 0x1f, 0x1e, 
+	00, 00, 0xe, 00, 00, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 0x8a, 0xe, 00, 00, 
+	0x72, 0x66, 0x62, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x50, 0x4b, 0x1, 0x2, 0xa, 00, 
+	0xa, 00, 00, 00, 0x8, 00, 0x55, 0x58, 0xda, 0x2c, 
+	0x7a, 0x44, 0x1b, 0x63, 0x14, 0x5, 00, 00, 0xb8, 0x8, 
+	00, 00, 0x19, 00, 00, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 0xfd, 0x1d, 00, 00, 
+	0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 
+	0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x6e, 0x65, 0x6c, 0x2e, 
+	0x63, 0x6c, 0x61, 0x73, 0x73, 0x50, 0x4b, 0x1, 0x2, 0xa, 
+	00, 0xa, 00, 00, 00, 0x8, 00, 0x55, 0x58, 0xda, 
+	0x2c, 0xe7, 0x52, 0x7f, 0x83, 0x46, 0xb, 00, 00, 0xe7, 
+	0x14, 00, 00, 0xf, 00, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 00, 0x48, 0x23, 00, 
+	00, 0x76, 0x6e, 0x63, 0x43, 0x61, 0x6e, 0x76, 0x61, 0x73, 
+	0x2e, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x50, 0x4b, 0x1, 0x2, 
+	0xa, 00, 0xa, 00, 00, 00, 0x8, 00, 0x55, 0x58, 
+	0xda, 0x2c, 0xb6, 0xdd, 0x6b, 0x3d, 0x5, 0x3, 00, 00, 
+	0xbf, 0x5, 00, 00, 0x1f, 00, 00, 00, 00, 00, 
+	00, 00, 00, 00, 00, 00, 00, 00, 0xbb, 0x2e, 
+	00, 00, 0x61, 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x64, 
+	0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x49, 0x6d, 0x61, 0x67, 
+	0x65, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x50, 0x4b, 0x5, 0x6, 00, 00, 00, 
+	00, 0x7, 00, 0x7, 00, 0xc3, 0x1, 00, 00, 0xfd, 
+	0x31, 00, 00, 00, 00, };
+
+static prog_char data_vncjava_html[] = {
+	/* /vncjava.html */
+	0x2f, 0x76, 0x6e, 0x63, 0x6a, 0x61, 0x76, 0x61, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 
+	0x59, 0x50, 0x45, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 
+	0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 
+	0x57, 0x33, 0x43, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 
+	0x54, 0x4d, 0x4c, 0x20, 0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 
+	0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 
+	0x6c, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x3e, 0xa, 0x3c, 0x68, 
+	0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x68, 0x65, 
+	0x61, 0x64, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 
+	0x69, 0x74, 0x6c, 0x65, 0x3e, 0x56, 0x69, 0x72, 0x74, 0x75, 
+	0x61, 0x6c, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 
+	0x20, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x3c, 0x2f, 0x74, 
+	0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 
+	0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 
+	0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 
+	0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x61, 0x70, 0x70, 0x6c, 
+	0x65, 0x74, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x3d, 0x22, 0x76, 
+	0x6e, 0x63, 0x76, 0x69, 0x65, 0x77, 0x65, 0x72, 0x2e, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x22, 0x20, 0x61, 0x72, 0x63, 0x68, 
+	0x69, 0x76, 0x65, 0x3d, 0x22, 0x76, 0x6e, 0x63, 0x76, 0x69, 
+	0x65, 0x77, 0x65, 0x72, 0x2e, 0x6a, 0x61, 0x72, 0x22, 0xa, 
+	0x9, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3d, 0x22, 0x34, 0x38, 0x30, 0x22, 0x20, 0x68, 
+	0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x22, 0x34, 0x30, 0x30, 
+	0x22, 0x3e, 0xa, 0x9, 0x3c, 0x70, 0x61, 0x72, 0x61, 0x6d, 
+	0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x50, 0x4f, 0x52, 
+	0x54, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 
+	0x35, 0x39, 0x30, 0x30, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 
+	0x4a, 0x61, 0x76, 0x61, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 
+	0x62, 0x65, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 
+	0x20, 0x69, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x77, 
+	0x65, 0x62, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 
+	0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 
+	0x74, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x61, 0x70, 0x70, 
+	0x6c, 0x65, 0x74, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 
+	0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 
+	0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 
+	0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, };
+
+static prog_char data_style_css[] = {
+	/* /style.css */
+	0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 
+	0xa, 0xd, 0xa, 0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 
+	0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 
+	0x7a, 0x65, 0x3a, 0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 
+	0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 
+	0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 
+	0x67, 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 
+	0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 
+	0x31, 0x30, 0x70, 0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 
+	0x62, 0x6f, 0x64, 0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 
+	0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 
+	0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 
+	0x66, 0x66, 0x65, 0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x54, 0x45, 0x58, 0x54, 0x43, 
+	0x4f, 0x4c, 0x4f, 0x52, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38, 
+	0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 
+	0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 
+	0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e, 0x6d, 
+	0x65, 0x6e, 0x75, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 
+	0x6e, 0x3a, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 
+	0x3b, 0xa, 0x20, 0x20, 0x74, 0x6f, 0x70, 0x3a, 0x31, 0x30, 
+	0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6c, 0x65, 0x66, 0x74, 
+	0x3a, 0x30, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3a, 0x31, 0x34, 0x25, 0x3b, 0xa, 0x20, 0x20, 
+	0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 
+	0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 
+	0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x34, 0x70, 
+	0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 
+	0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 
+	0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 
+	0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 
+	0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 
+	0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 
+	0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 
+	0x30, 0x70, 0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e, 0x63, 
+	0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 
+	0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x70, 0x6f, 
+	0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x61, 0x62, 0x73, 
+	0x6f, 0x6c, 0x75, 0x74, 0x65, 0x3b, 0xa, 0x20, 0x20, 0x74, 
+	0x6f, 0x70, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x31, 0x37, 0x25, 0x3b, 
+	0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x35, 
+	0x32, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 
+	0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 
+	0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 
+	0x67, 0x69, 0x6e, 0x3a, 0x34, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 
+	0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x33, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 
+	0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74, 
+	0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 
+	0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 
+	0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 
+	0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 
+	0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x2e, 0x6e, 0x65, 0x77, 
+	0x73, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0xa, 0x7b, 0xa, 0x20, 
+	0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 
+	0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x3b, 0xa, 
+	0x20, 0x20, 0x74, 0x6f, 0x70, 0x3a, 0x31, 0x30, 0x70, 0x78, 
+	0x3b, 0xa, 0x20, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x37, 
+	0x32, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3a, 0x32, 0x34, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 
+	0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 
+	0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x34, 0x70, 0x78, 
+	0x3b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 
+	0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 
+	0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x63, 0x64, 
+	0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 
+	0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65, 0x66, 0x74, 
+	0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0xa, 
+	0x7d, 0xa, 0xa, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e, 0x74, 
+	0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 
+	0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x32, 
+	0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 
+	0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3a, 
+	0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 
+	0x30, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x62, 
+	0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 
+	0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 
+	0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 
+	0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 
+	0x7a, 0x65, 0x3a, 0x31, 0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 
+	0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 
+	0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 
+	0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 
+	0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 
+	0x72, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0xa, 0x7b, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 
+	0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 
+	0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 
+	0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 
+	0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 
+	0x3b, 0xa, 0x7d, 0xa, 0xa, 0xa, 0xa, 0x69, 0x6d, 0x67, 
+	0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa, 0x20, 
+	0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 
+	0x68, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 
+	0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 
+	0xa, 0xa, 0x69, 0x6d, 0x67, 0x2e, 0x6c, 0x65, 0x66, 0x74, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 
+	0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x6d, 
+	0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 
+	0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x66, 0x69, 0x67, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 
+	0x70, 0x78, 0x3b, 0x20, 0xa, 0xa, 0x20, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 
+	0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 
+	0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0xa, 0x7d, 
+	0xa, 0xa, 0x70, 0x2e, 0x72, 0x66, 0x69, 0x67, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 
+	0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 
+	0x3b, 0x20, 0xa, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 
+	0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 
+	0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x31, 0x30, 
+	0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 
+	0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0xa, 0xa, 0x20, 0x20, 
+	0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 
+	0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x6c, 0x66, 
+	0x69, 0x67, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 
+	0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 
+	0x20, 0x31, 0x70, 0x78, 0x3b, 0x20, 0xa, 0xa, 0x20, 0x20, 
+	0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 
+	0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 
+	0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 
+	0x3a, 0x20, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 
+	0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 
+	0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 
+	0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 
+	0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x31, 0x30, 
+	0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x72, 
+	0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 
+	0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 
+	0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20, 0xa, 0x7d, 0xa, 
+	0xa, 0x70, 0x2e, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 
+	0x74, 0x69, 0x74, 0x6c, 0x65, 0xa, 0x7b, 0xa, 0x20, 0x20, 
+	0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 
+	0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x30, 
+	0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 
+	0x69, 0x6e, 0x3a, 0x34, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 
+	0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x62, 0x6f, 0x74, 
+	0x74, 0x6f, 0x6d, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 
+	0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 
+	0x54, 0x49, 0x54, 0x4c, 0x45, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 
+	0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 
+	0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 
+	0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x63, 0x62, 0x61, 0x3b, 
+	0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 
+	0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 
+	0x3b, 0xa, 0xa, 0x7d, 0x20, 0xa, 0xa, 0xa, 0xa, 0xa, 
+};
+
+struct httpd_fsdata_file file_cgi_processes[] = {{NULL, data_cgi_processes, data_cgi_processes + 15, sizeof(data_cgi_processes) - 15}};
+
+struct httpd_fsdata_file file_cgi_files[] = {{file_cgi_processes, data_cgi_files, data_cgi_files + 11, sizeof(data_cgi_files) - 11}};
+
+struct httpd_fsdata_file file_cgi_meminfo[] = {{file_cgi_files, data_cgi_meminfo, data_cgi_meminfo + 13, sizeof(data_cgi_meminfo) - 13}};
+
+struct httpd_fsdata_file file_cgi_tcp[] = {{file_cgi_meminfo, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
+
+struct httpd_fsdata_file file_img_screenshot_png[] = {{file_cgi_tcp, data_img_screenshot_png, data_img_screenshot_png + 20, sizeof(data_img_screenshot_png) - 20}};
+
+struct httpd_fsdata_file file_404_html[] = {{file_img_screenshot_png, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+struct httpd_fsdata_file file_footer_plain[] = {{file_404_html, data_footer_plain, data_footer_plain + 14, sizeof(data_footer_plain) - 14}};
+
+struct httpd_fsdata_file file_header_html[] = {{file_footer_plain, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+struct httpd_fsdata_file file_vnc_html[] = {{file_index_html, data_vnc_html, data_vnc_html + 10, sizeof(data_vnc_html) - 10}};
+
+struct httpd_fsdata_file file_vncviewer_jar[] = {{file_vnc_html, data_vncviewer_jar, data_vncviewer_jar + 15, sizeof(data_vncviewer_jar) - 15}};
+
+struct httpd_fsdata_file file_vncjava_html[] = {{file_vncviewer_jar, data_vncjava_html, data_vncjava_html + 14, sizeof(data_vncjava_html) - 14}};
+
+struct httpd_fsdata_file file_style_css[] = {{file_vncjava_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
+
+#define HTTPD_FS_ROOT file_style_css
+
+#define HTTPD_FS_NUMFILES 13
\ No newline at end of file
diff --git a/contiki-avr/apps/httpd-fsdata.h b/contiki-avr/apps/httpd-fsdata.h
new file mode 100644
index 0000000..61b43ef
--- /dev/null
+++ b/contiki-avr/apps/httpd-fsdata.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Swedish Institute
+ *      of Computer Science and its contributors.
+ * 4. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.h,v 1.1 2003/07/04 10:54:51 adamdunkels Exp $
+ */
+#ifndef __HTTPD_FSDATA_H__
+#define __HTTPD_FSDATA_H__
+
+#include "uipopt.h"
+
+#include <avr/pgmspace.h>
+
+struct httpd_fsdata_file {
+  struct httpd_fsdata_file *next;
+  prog_char *name;
+  prog_char *data;
+  int len;
+};
+
+struct httpd_fsdata_file_noconst {
+  struct httpd_fsdata_file *next;
+  prog_char *name;
+  prog_char *data;
+  int len;
+};
+
+#endif /* __HTTPD_FSDATA_H__ */
diff --git a/contiki-avr/apps/httpd.c b/contiki-avr/apps/httpd.c
new file mode 100644
index 0000000..61d1094
--- /dev/null
+++ b/contiki-avr/apps/httpd.c
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.c,v 1.3 2004/08/09 22:25:06 adamdunkels Exp $
+ *
+ */
+
+
+#include "contiki.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+#include "httpd-cgi.h"
+
+#include "webserver.h"
+
+#include <avr/pgmspace.h>
+
+/* The HTTP server states: */
+#define HTTP_DEALLOCATED  0
+#define HTTP_NOGET        1
+#define HTTP_FILE         2
+#define HTTP_TEXT         3
+#define HTTP_FUNC         4
+#define HTTP_END          5
+
+#ifdef DEBUG
+#include <stdio.h>
+#define PRINT(x) printf("%s", x)
+#define PRINTLN(x) printf("%s\n", x)
+#else /* DEBUG */
+#define PRINT(x)
+#define PRINTLN(x)
+#endif /* DEBUG */
+
+struct httpd_state *hs;
+
+extern const struct httpd_fsdata_file file_index_html;
+extern const struct httpd_fsdata_file file_404_html;
+
+static void next_scriptline(void);
+static void next_scriptstate(void);
+
+#define ISO_G        0x47
+#define ISO_E        0x45
+#define ISO_T        0x54
+#define ISO_slash    0x2f    
+#define ISO_c        0x63
+#define ISO_g        0x67
+#define ISO_i        0x69
+#define ISO_space    0x20
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+#define ISO_a        0x61
+#define ISO_t        0x74
+#define ISO_hash     0x23
+#define ISO_period   0x2e
+
+#define HTTPD_CONF_NUMCONNS UIP_CONNS
+static struct httpd_state conns[HTTPD_CONF_NUMCONNS];
+static u8_t i;
+
+static char tmp[40];
+/*-----------------------------------------------------------------------------------*/
+static struct httpd_state *
+alloc_state(void)
+{
+  
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    if(conns[i].state == HTTP_DEALLOCATED) {
+      return &conns[i];
+    }
+  }
+
+  /* We are overloaded! XXX: we'll just kick all other connections! */
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = HTTP_DEALLOCATED;
+  }
+  
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+dealloc_state(struct httpd_state *s)
+{
+  s->state = HTTP_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+  httpd_fs_init();
+  
+  /* Listen to port 80. */
+  tcp_listen(HTONS(80));
+
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = HTTP_DEALLOCATED;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+  struct httpd_fs_file fsfile;  
+  u8_t i;
+  char c;
+
+  hs = (struct httpd_state *)(state);
+  
+  /* We use the uip_ test functions to deduce why we were
+     called. If uip_connected() is non-zero, we were called
+     because a remote host has connected to us. If
+     uip_newdata() is non-zero, we were called because the
+     remote host has sent us new data, and if uip_acked() is
+     non-zero, the remote host has acknowledged the data we
+     previously sent to it. */
+  if(uip_connected()) {
+
+    /* Since we've just been connected, the state pointer should be
+       NULL and we need to allocate a new state object. If we have run
+       out of memory for state objects, we'll have to abort the
+       connection and return. */
+    if(hs == NULL) {
+      hs = alloc_state();
+      if(hs == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)hs);
+    }
+    /* Since we have just been connected with the remote host, we
+       reset the state for this connection. The ->count variable
+       contains the amount of data that is yet to be sent to the
+       remote host, and the ->state is set to HTTP_NOGET to signal
+       that we haven't received any HTTP GET request for this
+       connection yet. */
+    hs->state = HTTP_NOGET;
+    hs->count = 0;
+    hs->poll = 0;
+  } else if(uip_closed() || uip_aborted()) {
+    if(hs != NULL) {
+      dealloc_state(hs);
+    }
+    return;
+  } else if(uip_poll()) {
+    /* If we are polled ten times, we abort the connection. This is
+       because we don't want connections lingering indefinately in
+       the system. */
+    if(hs != NULL) {
+      if(hs->state == HTTP_DEALLOCATED) {
+	uip_abort();
+      } else if(hs->poll++ >= 100) {
+	uip_abort();
+	dealloc_state(hs);
+      }
+    }
+    return;
+  }
+
+
+  if(uip_newdata() && hs->state == HTTP_NOGET) {
+    hs->poll = 0;
+    /* This is the first data we receive, and it should contain a
+       GET. */
+      
+    /* Check for GET. */
+    if(uip_appdata[0] != ISO_G ||
+       uip_appdata[1] != ISO_E ||
+       uip_appdata[2] != ISO_T ||
+       uip_appdata[3] != ISO_space) {
+      /* If it isn't a GET, we abort the connection. */
+      uip_abort();
+      dealloc_state(hs);
+      return;
+    }
+	       
+    /* Find the file we are looking for. */
+    for(i = 4; i < 40; ++i) {
+      if(uip_appdata[i] == ISO_space ||
+	 uip_appdata[i] == ISO_cr ||
+	 uip_appdata[i] == ISO_nl) {
+	uip_appdata[i] = 0;
+	break;
+      }
+    }
+
+    PRINT("request for file ");
+    PRINTLN(&uip_appdata[4]);
+    webserver_log_file(uip_conn->ripaddr, &uip_appdata[4]);
+    /* Check for a request for "/". */
+    if(uip_appdata[4] == ISO_slash &&
+       uip_appdata[5] == 0) {
+      memcpy_P(tmp, file_index_html.name, sizeof(tmp));
+      httpd_fs_open((const char *)tmp, &fsfile);  
+    } else {
+      if(!httpd_fs_open((const char *)&uip_appdata[4], &fsfile)) {
+	PRINTLN("couldn't open file");
+	memcpy_P(tmp, file_404_html.name, sizeof(tmp));
+	httpd_fs_open((const char *)tmp, &fsfile);  
+      }
+    } 
+    httpd_fs_inc();
+    
+    if(uip_appdata[4] == ISO_slash &&
+       uip_appdata[5] == ISO_c &&
+       uip_appdata[6] == ISO_g &&
+       uip_appdata[7] == ISO_i &&
+       uip_appdata[8] == ISO_slash) {
+      /* If the request is for a file that starts with "/cgi/", we
+	 prepare for invoking a script. */	
+      hs->script = fsfile.data;
+      next_scriptstate();
+    } else {
+      hs->script = NULL;
+      /* The web server is now no longer in the HTTP_NOGET state, but
+	 in the HTTP_FILE state since is has now got the GET from
+	 the client and will start transmitting the file. */
+      hs->state = HTTP_FILE;
+
+      /* Point the file pointers in the connection state to point to
+	 the first byte of the file. */
+      hs->dataptr = fsfile.data;
+      hs->count = fsfile.len;	
+    }     
+  }
+
+    
+  if(hs->state != HTTP_FUNC) {
+    /* Check if the client (remote end) has acknowledged any data that
+       we've previously sent. If so, we move the file pointer further
+       into the file and send back more data. If we are out of data to
+       send, we close the connection. */
+    if(uip_acked()) {
+      hs->poll = 0;	
+      if(hs->count >= uip_mss()) {
+	hs->count -= uip_mss();
+	hs->dataptr += uip_mss();
+      } else {
+	hs->count = 0;
+      }
+	
+      if(hs->count == 0) {
+	if(hs->script != NULL) {
+	  next_scriptline();
+	  next_scriptstate();
+	} else {
+	  uip_close();
+	  dealloc_state(hs);
+	}
+      }
+    }         
+  }
+    
+  if(hs->state == HTTP_FUNC) {
+    /* Call the CGI function. */
+    memcpy_P(&c, &hs->script[2], 1);
+    if(httpd_cgitab[c - ISO_a]()) {
+      /* If the function returns non-zero, we jump to the next line
+	 in the script. */
+      next_scriptline();
+      next_scriptstate();
+    }
+  }
+
+  if(hs->state != HTTP_FUNC && !uip_poll()) {
+    hs->poll = 0;
+    /* Send a piece of data, but not more than the MSS of the
+       connection. */
+    memcpy_P(uip_appdata, hs->dataptr, uip_mss());
+    uip_send(uip_appdata,
+	     hs->count > uip_mss()? uip_mss(): hs->count);
+  }
+
+  /* Finally, return to uIP. Our outgoing packet will soon be on its
+     way... */
+}
+/*-----------------------------------------------------------------------------------*/
+/* next_scriptline():
+ *
+ * Reads the script until it finds a newline. */
+static void
+next_scriptline(void)
+{
+  char c;
+  /* Loop until we find a newline character. */
+  do {
+    ++(hs->script);
+    memcpy_P(&c, hs->script, 1);
+  } while(c != ISO_nl);
+
+  /* Eat up the newline as well. */
+  ++(hs->script);
+}
+/*-----------------------------------------------------------------------------------*/
+/* next_sciptstate:
+ *
+ * Reads one line of script and decides what to do next.
+ */
+static void
+next_scriptstate(void)
+{
+  struct httpd_fs_file fsfile;
+  u8_t i;
+  char c;
+
+ again:
+  memcpy_P(&c, hs->script, 1);
+  switch(c) {
+  case ISO_t:
+    /* Send a text string. */
+    hs->state = HTTP_TEXT;
+    hs->dataptr = hs->script + 2;
+
+    /* Calculate length of string. */
+    i = 0;
+    do {
+      memcpy_P(&c, &hs->dataptr[i], 1);
+      ++i;
+    } while(c != ISO_nl);
+    hs->count = i;    
+    break;
+  case ISO_c:
+    /* Call a function. */
+    hs->state = HTTP_FUNC;
+    hs->dataptr = NULL;
+    hs->count = 0;
+    /*    uip_reset_acked();*/
+    uip_flags &= ~UIP_ACKDATA;
+    break;
+  case ISO_i:   
+    /* Include a file. */
+    hs->state = HTTP_FILE;
+    memcpy_P(tmp, &hs->script[2], sizeof(tmp));
+    if(!httpd_fs_open(tmp, &fsfile)) {
+      uip_abort();
+      dealloc_state(hs);
+    }
+    hs->dataptr = fsfile.data;
+    hs->count = fsfile.len;
+    break;
+  case ISO_hash:
+    /* Comment line. */
+    next_scriptline();
+    goto again;
+    break;
+  case ISO_period:
+    /* End of script. */
+    hs->state = HTTP_END;
+    uip_close();
+    dealloc_state(hs);
+    break;
+  default:
+    uip_abort();
+    dealloc_state(hs);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/httpd.h b/contiki-avr/apps/httpd.h
new file mode 100644
index 0000000..9f4c94f
--- /dev/null
+++ b/contiki-avr/apps/httpd.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.2 2004/08/09 22:25:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "contiki.h"
+#include <avr/pgmspace.h>
+
+void httpd_init(void);
+void httpd_appcall(void *state);
+
+struct httpd_state {
+  u8_t state; 
+  u16_t count;
+  u8_t poll;
+  prog_char *dataptr;
+  prog_char *script;
+};
+
+extern struct httpd_state *hs;
+#endif /* __HTTPD_H__ */
diff --git a/contiki-avr/apps/makefsdata b/contiki-avr/apps/makefsdata
new file mode 100755
index 0000000..eee8989
--- /dev/null
+++ b/contiki-avr/apps/makefsdata
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+open(FILES, "find . -type f |");
+
+
+while($file = <FILES>) {
+
+    # Do not include files in CVS directories nor backup files.
+    if($file =~ /(CVS|~)/) {
+    	next;
+    }
+    
+    chop($file);
+    
+    open(HEADER, "> /tmp/header") || die $!;
+    print(HEADER "HTTP/1.0 200 OK\r\n");
+    print(HEADER "Server: Contiki/pre-1.1 (http://dunkels.com/adam/contiki/)\r\n");
+    if($file =~ /\.html$/) {
+	print(HEADER "Content-type: text/html\r\n");
+    } elsif($file =~ /\.gif$/) {
+	print(HEADER "Content-type: image/gif\r\n");
+    } elsif($file =~ /\.png$/) {
+	print(HEADER "Content-type: image/png\r\n");
+    } elsif($file =~ /\.jpg$/) {
+	print(HEADER "Content-type: image/jpeg\r\n");
+    } elsif($file =~ /\.css$/) {
+	print(HEADER "Content-type: text/css\r\n");
+    } else {
+	print(HEADER "Content-type: text/plain\r\n");
+    }
+    print(HEADER "\r\n");
+    close(HEADER);
+
+    unless($file =~ /\.plain$/ || $file =~ /cgi/) {
+	system("cat /tmp/header $file > /tmp/file");
+    } else {
+	system("cp $file /tmp/file");
+    }
+    
+    open(FILE, "/tmp/file");
+    unlink("/tmp/file");
+    unlink("/tmp/header");
+
+    $file =~ s/\.//;
+    $fvar = $file;
+    $fvar =~ s-/-_-g;
+    $fvar =~ s-\.-_-g;
+    print(OUTPUT "static prog_char data".$fvar."[] = {\n");
+    print(OUTPUT "\t/* $file */\n\t");
+    for($j = 0; $j < length($file); $j++) {
+	printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+    }
+    printf(OUTPUT "0,\n");
+    
+    
+    $i = 0;        
+    while(read(FILE, $data, 1)) {
+        if($i == 0) {
+            print(OUTPUT "\t");
+        }
+        printf(OUTPUT "%#02x, ", unpack("C", $data));
+        $i++;
+        if($i == 10) {
+            print(OUTPUT "\n");
+            $i = 0;
+        }
+    }
+    print(OUTPUT "};\n\n");
+    close(FILE);
+    push(@fvars, $fvar);
+    push(@files, $file);
+}
+
+for($i = 0; $i < @fvars; $i++) {
+    $file = $files[$i];
+    $fvar = $fvars[$i];
+
+    if($i == 0) {
+        $prevfile = "NULL";
+    } else {
+        $prevfile = "file" . $fvars[$i - 1];
+    }
+    print(OUTPUT "struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i");
diff --git a/contiki-avr/apps/makestrings b/contiki-avr/apps/makestrings
new file mode 100755
index 0000000..e6e8470
--- /dev/null
+++ b/contiki-avr/apps/makestrings
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+  my $name = shift(@_);
+  open(OUTPUTC, "> $name.c");
+  open(OUTPUTH, "> $name.h");
+  
+  open(FILE, "$name");
+  
+  while(<FILE>) {
+    if(/(.+) "(.+)"/) {
+      $var = $1;
+      $data = $2;
+      
+      $datan = $data;
+      $datan =~ s/\\r/\r/g;
+      $datan =~ s/\\n/\n/g;
+      $datan =~ s/\\0/\0/g;
+      
+      printf(OUTPUTC "char $var\[%d] = \n", length($datan) + 1);
+      printf(OUTPUTC "/* \"$data\" */\n");
+      printf(OUTPUTC "{");
+      for($j = 0; $j < length($datan); $j++) {
+	printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+      }
+      printf(OUTPUTC "};\n");
+      
+      printf(OUTPUTH "extern char $var\[%d];\n", length($datan) + 1);
+      
+    }
+  }
+  close(OUTPUTC);
+  close(OUTPUTH);
+}
+stringify("http-user-agent-string");
+
+exit 0;
+
diff --git a/contiki-avr/apps/shell.c b/contiki-avr/apps/shell.c
new file mode 100644
index 0000000..8869650
--- /dev/null
+++ b/contiki-avr/apps/shell.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.c,v 1.1 2004/07/04 20:17:38 adamdunkels Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include <string.h>
+
+
+struct ptentry {
+  char c;
+  void (* pfunc)(char *str);
+};
+
+extern char *shell_prompt_text;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+parse(register char *str, struct ptentry *t)
+{
+  register struct ptentry *p;
+  char *sstr;
+
+  sstr = str;
+  
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      p->pfunc(str);
+      return;
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+inttostr(register char *str, unsigned int i)
+{
+  str[0] = '0' + i / 100;
+  if(str[0] == '0') {
+    str[0] = ' ';
+  }
+  str[1] = '0' + (i / 10) % 10;
+  if(str[1] == '0') {
+    str[1] = ' ';
+  }
+  str[2] = '0' + i % 10;
+  str[3] = ' ';
+  str[4] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes(char *str)
+{
+  static char idstr[5];
+  struct ek_proc *p;
+
+  shell_output("Processes:", "");
+  /* Step through each possible process ID and see if there is a
+     matching process. */
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    inttostr(idstr, p->id);
+    shell_output(idstr, p->name);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(char *str)
+{
+  char procnum, j, c;
+  char procstr[5];
+
+  nullterminate(str);
+  
+  procnum = 0;
+  
+  for(j = 0; j < 4; ++j) {
+    c = str[(int)j];
+    if(c >= '0' && c <= '9') {
+      procnum = procnum * 10 + (str[(int)j] - '0');
+    } else {
+      break;
+    }
+  }
+  if(procnum != 0) {
+    inttostr(procstr, procnum);
+    shell_output("Killing process ", procstr);
+    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+  } else {
+    shell_output("Could not parse process number", "");
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+  shell_output("Available commands:", "");
+  shell_output("ps   - show processes", "");
+  shell_output("kill - kill process", "");
+  shell_output("quit - quit shell", "");
+  shell_output("?    - show this help", "");      
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+none(char *str)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+  {{'k', killproc},   
+   {'p', processes},
+   {'q', shell_quit},
+   {'?', help},
+
+   /* Default action */
+   {0, none}};
+/*-----------------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+  shell_output("Contiki command shell", "");
+  shell_output("Type '?' for help", "");  
+  shell_prompt(shell_prompt_text); 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+  parse(cmd, configparsetab);
+  shell_prompt(shell_prompt_text); 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_idle(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/webclient.c b/contiki-avr/apps/webclient.c
new file mode 100644
index 0000000..a6cd445
--- /dev/null
+++ b/contiki-avr/apps/webclient.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "contiki" web browser.
+ *
+ * $Id: webclient.c,v 1.5 2004/08/09 22:25:36 adamdunkels Exp $
+ *
+ */
+
+#include "ek.h"
+#include "tcpip.h"
+#include "uip.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "uiplib.h"
+
+#include "www-conf.h"
+
+#include <string.h>
+
+#define WEBCLIENT_TIMEOUT 100
+
+#define WEBCLIENT_STATE_STATUSLINE 0
+#define WEBCLIENT_STATE_HEADERS    1
+#define WEBCLIENT_STATE_DATA       2
+#define WEBCLIENT_STATE_CLOSE      3
+
+#define HTTPFLAG_NONE   0
+#define HTTPFLAG_OK     1
+#define HTTPFLAG_MOVED  2
+#define HTTPFLAG_ERROR  3
+
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+#define ISO_space    0x20
+
+struct webclient_state {
+  u8_t timer;
+  u8_t state;
+  u8_t httpflag;
+
+  u16_t port;
+  char host[40];
+  char file[WWW_CONF_MAX_URLLEN];  
+  u16_t getrequestptr;
+  u16_t getrequestleft;
+  
+  char httpheaderline[200];
+  u16_t httpheaderlineptr;
+
+  char mimetype[32];
+};
+
+static struct webclient_state s;
+
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_mimetype(void)
+{
+  return s.mimetype;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_filename(void)
+{
+  return s.file;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_hostname(void)
+{
+  return s.host;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+webclient_port(void)
+{
+  return s.port;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_init(void)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+init_connection(void)
+{
+  s.state = WEBCLIENT_STATE_STATUSLINE;
+
+  s.getrequestleft = sizeof(http_get) - 1 + 1 +
+    sizeof(http_10) - 1 +
+    sizeof(http_crnl) - 1 +
+    sizeof(http_host) - 1 +
+    sizeof(http_crnl) - 1 +
+    strlen(http_user_agent_fields) +
+    strlen(s.file) + strlen(s.host);
+  s.getrequestptr = 0;
+
+  s.httpheaderlineptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_close(void)
+{
+  s.state = WEBCLIENT_STATE_CLOSE;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+webclient_get(char *host, u16_t port, char *file)
+{
+  struct uip_conn *conn;
+  u16_t *ipaddr; 
+  static u16_t addr[2];
+  
+  /* First check if the host is an IP address. */
+  ipaddr = &addr[0];
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    ipaddr = resolv_lookup(host);
+    
+    if(ipaddr == NULL) {
+      return 0;
+    }
+  }
+
+  /* XXX: here we check so that the server does not try to access any
+     hosts on the SICS networks. */
+  if(!(ipaddr[0] == HTONS((193 << 8) | 10) &&
+       ipaddr[1] == HTONS((64 << 8) | 99)) &&
+     (ipaddr[0] == HTONS((193 << 8) | 10) &&
+      ((htons(ipaddr[1]) >> 8) == 66 ||
+       (htons(ipaddr[1]) >> 8) == 67))) {
+    return 0;
+  } else {
+    conn = tcp_connect(ipaddr, htons(port), NULL);
+  }
+  
+  if(conn == NULL) {
+    return 0;
+  }
+  
+  s.port = port;
+  strncpy(s.file, file, sizeof(s.file));
+  strncpy(s.host, host, sizeof(s.host));
+  
+  init_connection();
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char * CC_FASTCALL
+copy_string(unsigned char *dest,
+	    const unsigned char *src, unsigned char len)
+{
+  return strcpy(dest, src) + len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)
+{
+  u16_t len;
+  char *getrequest;
+  char *cptr;
+  
+  if(s.getrequestleft > 0) {
+    cptr = getrequest = (char *)uip_appdata;
+
+    cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
+    cptr = copy_string(cptr, s.file, strlen(s.file));
+    *cptr++ = ISO_space;
+    cptr = copy_string(cptr, http_10, sizeof(http_10) - 1);
+
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+    
+    cptr = copy_string(cptr, http_host, sizeof(http_host) - 1);
+    cptr = copy_string(cptr, s.host, strlen(s.host));
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+
+    cptr = copy_string(cptr, http_user_agent_fields,
+		       strlen(http_user_agent_fields));
+    
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    uip_send(&(getrequest[s.getrequestptr]), len);
+  }
+}  
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)
+{
+  u16_t len;
+  
+  if(s.getrequestleft > 0) {
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    s.getrequestleft -= len;
+    s.getrequestptr += len;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_statusline(u16_t len)
+{
+  char *cptr;
+  
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
+    ++uip_appdata;
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+
+      if((strncmp(s.httpheaderline, http_10,
+		  sizeof(http_10) - 1) == 0) ||
+	 (strncmp(s.httpheaderline, http_11,
+		  sizeof(http_11) - 1) == 0)) {
+	cptr = &(s.httpheaderline[9]);
+	s.httpflag = HTTPFLAG_NONE;
+	if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) {
+	  /* 200 OK */
+	  s.httpflag = HTTPFLAG_OK;
+	} else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
+		  strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) {
+	  /* 301 Moved permanently or 302 Found. Location: header line
+	     will contain thw new location. */
+	  s.httpflag = HTTPFLAG_MOVED;
+	} else {
+	  s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+	}
+      } else {
+	uip_abort();
+	webclient_aborted();
+	return 0;
+      }
+      
+      /* We're done parsing the status line, so we reset the pointer
+	 and start parsing the HTTP headers.*/
+      s.httpheaderlineptr = 0;
+      s.state = WEBCLIENT_STATE_HEADERS;
+      break;
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static char
+casecmp(char *str1, const char *str2, char len)
+{
+  static char c;
+  
+  while(len > 0) {
+    c = *str1;
+    /* Force lower-case characters. */
+    if(c & 0x40) {
+      c |= 0x20;
+    }
+    if(*str2 != c) {
+      return 1;
+    }
+    ++str1;
+    ++str2;
+    --len;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_headers(u16_t len)
+{
+  char *cptr;
+  static unsigned char i;
+  
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
+    ++uip_appdata;
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+      /* We have an entire HTTP header line in s.httpheaderline, so
+	 we parse it. */
+      if(s.httpheaderline[0] == ISO_cr) {
+	/* This was the last header line (i.e., and empty "\r\n"), so
+	   we are done with the headers and proceed with the actual
+	   data. */
+	s.state = WEBCLIENT_STATE_DATA;
+	return len;
+      }
+
+      s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+      /* Check for specific HTTP header fields. */      
+      if(casecmp(s.httpheaderline, http_content_type,
+		     sizeof(http_content_type) - 1) == 0) {
+	/* Found Content-type field. */
+	cptr = strchr(s.httpheaderline, ';');
+	if(cptr != NULL) {
+	  *cptr = 0;
+	}
+	strncpy(s.mimetype, s.httpheaderline +
+		sizeof(http_content_type) - 1, sizeof(s.mimetype));
+      } else if(casecmp(s.httpheaderline, http_location,
+			    sizeof(http_location) - 1) == 0) {
+	cptr = s.httpheaderline +
+	  sizeof(http_location) - 1;
+	
+	if(strncmp(cptr, http_http, 7) == 0) {
+	  cptr += 7; 
+	  for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
+	    if(*cptr == 0 ||
+	       *cptr == '/' ||
+	       *cptr == ' ' ||
+	       *cptr == ':') {
+	      s.host[i] = 0;
+	      break;
+	    }
+	    s.host[i] = *cptr;
+	    ++cptr;
+	  }
+	}
+	strncpy(s.file, cptr, sizeof(s.file));
+	/*	s.file[s.httpheaderlineptr - i] = 0;*/
+      }
+
+
+      /* We're done parsing, so we reset the pointer and start the
+	 next line. */
+      s.httpheaderlineptr = 0;      
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  u16_t len;
+
+  len = uip_datalen();
+
+  if(s.state == WEBCLIENT_STATE_STATUSLINE) {
+    len = parse_statusline(len);
+  }
+  
+  if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) {
+    len = parse_headers(len);
+  }
+
+  if(len > 0 && s.state == WEBCLIENT_STATE_DATA &&
+     s.httpflag != HTTPFLAG_MOVED) {
+    webclient_datahandler((char *)uip_appdata, len);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_appcall(void *state)
+{
+  if(uip_connected()) {
+    s.timer = 0;
+    s.state = WEBCLIENT_STATE_STATUSLINE;
+    senddata();
+    webclient_connected();
+    tcp_markconn(uip_conn, &s);
+    return;
+  }
+
+  if(uip_timedout()) {
+    webclient_timedout();
+  }
+  
+  if(state == NULL) {
+    uip_abort();
+    return;
+  }
+
+  if(s.state == WEBCLIENT_STATE_CLOSE) {
+    webclient_closed();
+    uip_abort();
+    return;
+  }        
+
+  if(uip_aborted()) {
+    webclient_aborted();
+  }
+  
+  
+  if(uip_acked()) {
+    s.timer = 0;
+    acked();
+  }
+  if(uip_newdata()) {
+    s.timer = 0;
+    newdata();
+  }
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata();
+  } else if(uip_poll()) {
+    ++s.timer;
+    if(s.timer == WEBCLIENT_TIMEOUT) {
+      webclient_timedout();
+      uip_abort();
+      return;
+    }
+        /*    senddata();*/
+  }
+
+  if(uip_closed()) {
+    tcp_markconn(uip_conn, NULL);
+    if(s.httpflag != HTTPFLAG_MOVED) {
+      /* Send NULL data to signal EOF. */
+      webclient_datahandler(NULL, 0);
+    } else {
+      /*      conn = uip_connect(uip_conn->ripaddr, s.port);
+      if(conn != NULL) {
+	dispatcher_markconn(conn, NULL);
+	init_connection();
+	}*/
+      if(resolv_lookup(s.host) == NULL) {
+	resolv_query(s.host);
+      }
+      webclient_get(s.host, s.port, s.file);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/weblinks-dsc.c b/contiki-avr/apps/weblinks-dsc.c
new file mode 100644
index 0000000..9a99440
--- /dev/null
+++ b/contiki-avr/apps/weblinks-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: weblinks-dsc.c,v 1.3 2005/03/18 00:50:50 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon weblinks_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(weblinks_dsc,
+    "Web links",
+    "weblinks.prg",
+    weblinks_init,
+    &weblinks_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char weblinksicon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char weblinksicon_textmap[9] = {
+  '+', '-', '+',
+  '|', 'o', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon weblinks_icon =
+  {CTK_ICON("Web links", weblinksicon_bitmap, weblinksicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/weblinks-dsc.h b/contiki-avr/apps/weblinks-dsc.h
new file mode 100644
index 0000000..c3075a1
--- /dev/null
+++ b/contiki-avr/apps/weblinks-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: weblinks-dsc.h,v 1.1 2003/07/04 10:54:51 adamdunkels Exp $
+ *
+ */
+#ifndef __WEBLINKS_DSC_H__
+#define __WEBLINKS_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(weblinks_dsc);
+
+#endif /* __WEBLINKS_DSC_H__ */
diff --git a/contiki-avr/apps/weblinks.c b/contiki-avr/apps/weblinks.c
new file mode 100644
index 0000000..d588295
--- /dev/null
+++ b/contiki-avr/apps/weblinks.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: weblinks.c,v 1.3 2004/07/04 20:17:38 adamdunkels Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "loader.h"
+
+#include "program-handler.h"
+
+#include "www.h"
+
+#include <string.h>
+
+#define WIDTH 45
+#define HEIGHT 16
+
+#define LINK(name, descr, url) \
+ {CTK_HYPERLINK(1, 0, sizeof(name) - 1, name, url)}, \
+ {CTK_LABEL(1, 20, sizeof(descr) - 1, 1, descr)}
+struct link {
+  struct ctk_hyperlink hyperlink;
+  struct ctk_label description;
+};
+
+static struct link links[] =
+  {
+    {LINK("Contiki",
+	  "The Contiki web site",
+	  "http://dunkels.com/adam/contiki/index-text.html")},
+    {LINK("Contiki AVR",
+	  "The server software",
+	  "http://dunkels.com/adam/contiki/ports/avr-text.html")},
+    {LINK("Ethernut",
+	  "The server hardware",
+	  "http://www.ethernut.de/en/")},
+    {LINK("cc65",
+	  "The 6502 C cross compiler",
+	  "http://www.cc65.org/")},
+    {LINK("Google",
+	  "Google",
+	  "http://www.google.com/")},
+    {LINK("OSNews",
+	  "Exploring the future of computing",
+	  "http://www.osnews.com/")},
+    {LINK("Slashdot",
+	  "News for nerds, stuff that matters",
+	  "http://slashdot.org/")},
+  };
+
+#define NUMLINKS 7
+
+static struct ctk_window window;
+static struct ctk_label hintslabel1 =
+  {CTK_LABEL(1, 1, 39, 1, "Open the web browser in the background,")};
+static struct ctk_label hintslabel2 =
+  {CTK_LABEL(1, 2, 24, 1, "then click on the links.")};
+
+
+/*static DISPATCHER_SIGHANDLER(weblinks_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Web links", NULL, weblinks_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Web links", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(weblinks_init, arg)
+{
+  arg_free(arg);
+		     
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  } else {
+    ctk_window_open(&window);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ctk_window_close(&window);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  unsigned char y, i;    
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+
+    ctk_window_new(&window, WIDTH, HEIGHT, "Web links");
+
+    CTK_WIDGET_ADD(&window, &hintslabel1);
+    CTK_WIDGET_ADD(&window, &hintslabel2);
+    
+    y = 4;
+    for(i = 0; i < NUMLINKS; ++i) {
+      
+      CTK_WIDGET_SET_XPOS(&(links[i].hyperlink), 1);
+      CTK_WIDGET_SET_YPOS(&(links[i].hyperlink), y);
+      CTK_WIDGET_ADD(&window, &(links[i].hyperlink));   
+      
+      CTK_WIDGET_SET_XPOS(&(links[i].description),
+			  strlen(links[i].hyperlink.text) + 2);
+      CTK_WIDGET_SET_YPOS(&(links[i].description), y);
+      CTK_WIDGET_ADD(&window, &(links[i].description));
+      
+      ++y;
+      
+    }
+
+    ctk_window_open(&window);
+
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    (ev == ctk_signal_window_close &&
+	     data == (ek_data_t)&window)) {
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/webserver.c b/contiki-avr/apps/webserver.c
new file mode 100644
index 0000000..a12efa0
--- /dev/null
+++ b/contiki-avr/apps/webserver.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: webserver.c,v 1.4 2004/09/13 23:21:36 adamdunkels Exp $
+ *
+ */
+
+
+#include "contiki.h"
+#include "ctk.h"
+#include "http-strings.h"
+
+#include "petsciiconv.h"
+
+#include "loader.h"
+
+#include "webserver.h"
+#include "httpd.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/* The main window. */
+static struct ctk_window mainwindow;
+
+static struct ctk_label message =
+  {CTK_LABEL(0, 0, 15, 1, "Latest requests")};
+
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Web server", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+#define LOG_WIDTH  30
+#define LOG_HEIGHT 20
+static char log[LOG_WIDTH*LOG_HEIGHT];
+
+static struct ctk_label loglabel =
+{CTK_LABEL(0, 1, LOG_WIDTH, LOG_HEIGHT, log)};
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(webserver_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  } else {
+    ctk_window_open(&mainwindow);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
+    
+    
+    CTK_WIDGET_ADD(&mainwindow, &message);
+    CTK_WIDGET_ADD(&mainwindow, &loglabel);
+    
+    /* Attach listeners to signals. */
+    /*    dispatcher_listen(ctk_signal_button_activate);*/
+    
+    httpd_init();
+    
+    ctk_window_open(&mainwindow);
+  } else if(ev == tcpip_event) {
+    httpd_appcall(data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webserver_log_file(u16_t *requester, char *file)
+{
+  int size;
+  
+  /* Scroll previous entries upwards */
+  memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
+
+  /* Print out IP address of requesting host. */
+  size = sprintf(&log[LOG_WIDTH * (LOG_HEIGHT - 1)],
+		 "%d.%d.%d.%d: ",
+		 htons(requester[0]) >> 8,
+		 htons(requester[0]) & 0xff,
+		 htons(requester[1]) >> 8,
+		 htons(requester[1]) & 0xff);
+  
+  /* Copy filename into last line. */		 
+  strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1) + size], file, LOG_WIDTH - size);
+	   
+  /* Update log display. */
+  CTK_WIDGET_REDRAW(&loglabel);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/apps/webserver.h b/contiki-avr/apps/webserver.h
new file mode 100644
index 0000000..3ef6c22
--- /dev/null
+++ b/contiki-avr/apps/webserver.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: webserver.h,v 1.2 2003/08/25 12:42:41 adamdunkels Exp $
+ *
+ */
+#ifndef __WEBSERVER_H__
+#define __WEBSERVER_H__
+
+void webserver_init(char *arg);
+
+void webserver_log_file(u16_t *requester, char *filename);
+
+#endif /* __WEBSERVER_H__ */
diff --git a/contiki-avr/conf/cc-conf.h b/contiki-avr/conf/cc-conf.h
new file mode 100644
index 0000000..089a09b
--- /dev/null
+++ b/contiki-avr/conf/cc-conf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/07/04 10:54:52 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-avr/conf/clock-conf.h b/contiki-avr/conf/clock-conf.h
new file mode 100644
index 0000000..0f054a6
--- /dev/null
+++ b/contiki-avr/conf/clock-conf.h
@@ -0,0 +1,15 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+#define CLOCK_CONF_SECOND 500
+
+void clock_delay(unsigned int us2);
+
+void clock_wait(int ms10);
+
+void clock_set_seconds(unsigned long s);
+unsigned long clock_seconds(void);
+
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-avr/conf/ctk-conf.h b/contiki-avr/conf/ctk-conf.h
new file mode 100644
index 0000000..508af2b
--- /dev/null
+++ b/contiki-avr/conf/ctk-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.4 2004/08/09 22:29:44 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_ESC
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_TAB
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         1
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        1
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-avr/conf/ctk-term-conf.h b/contiki-avr/conf/ctk-term-conf.h
new file mode 100644
index 0000000..747e975
--- /dev/null
+++ b/contiki-avr/conf/ctk-term-conf.h
@@ -0,0 +1,20 @@
+#ifndef __CTK_TERM_CONF_H__

+#define __CTK_TERM_CONF_H__

+

+/* Maximum number of clients to the telnet server */

+#define CTK_TERM_CONF_MAX_TELNET_CLIENTS 3

+

+/* Telnet server port */

+#define CTK_TERM_CONF_TELNET_PORT 23

+

+/* Serial server output buffer size */

+#define CTK_TERM_CONF_SERIAL_BUFFER_SIZE 300

+

+/* Maximum number of clients to the terminal module.

+   Should be set to CTK_TERM_CONF_MAX_TELNET_CLIENTS or

+   CTK_TERM_CONF_MAX_TELNET_CLIENTS+1 if the serial server is used too

+*/

+#define CTK_TERM_CONF_MAX_CLIENTS (CTK_TERM_CONF_MAX_TELNET_CLIENTS+1)

+

+#endif /* __CTK_TERM_CONF_H__ */

+

diff --git a/contiki-avr/conf/ctk-vncserver-conf.h b/contiki-avr/conf/ctk-vncserver-conf.h
new file mode 100644
index 0000000..f495975
--- /dev/null
+++ b/contiki-avr/conf/ctk-vncserver-conf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: ctk-vncserver-conf.h,v 1.2 2004/07/04 20:17:38 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_VNCSERVER_CONF_H__
+#define __CTK_VNCSERVER_CONF_H__
+
+#define CTK_VNCSERVER_CONF_NUMCONNS 8
+
+#define CTK_VNCSERVER_CONF_MAX_ICONS 8
+
+#endif /* __CTK_VNCSERVER_CONF_H__ */
+
diff --git a/contiki-avr/conf/ek-conf.h b/contiki-avr/conf/ek-conf.h
new file mode 100644
index 0000000..93affa9
--- /dev/null
+++ b/contiki-avr/conf/ek-conf.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * $Id: ek-conf.h,v 1.2 2004/07/04 20:17:38 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+/*#include <time.h>*/
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 16
+#define EK_CONF_NUMEVENTS 16
+
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-avr/conf/irc-conf.h b/contiki-avr/conf/irc-conf.h
new file mode 100644
index 0000000..c9c0e23
--- /dev/null
+++ b/contiki-avr/conf/irc-conf.h
@@ -0,0 +1,4 @@
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-avr/conf/libconio-conf.h b/contiki-avr/conf/libconio-conf.h
new file mode 100644
index 0000000..427fb27
--- /dev/null
+++ b/contiki-avr/conf/libconio-conf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: libconio-conf.h,v 1.1 2003/07/04 10:54:52 adamdunkels Exp $
+ *
+ */
+#ifndef __LIBCONIO_CONF_H__
+#define __LIBCONIO_CONF_H__
+
+#define LIBCONIO_CONF_SCREEN_WIDTH  70
+#define LIBCONIO_CONF_SCREEN_HEIGHT 40
+
+#endif /* __LIBCONIO_CONF_H__ */
+
diff --git a/contiki-avr/conf/log-conf.h b/contiki-avr/conf/log-conf.h
new file mode 100644
index 0000000..9ff4810
--- /dev/null
+++ b/contiki-avr/conf/log-conf.h
@@ -0,0 +1,6 @@
+#ifndef __LOG_CONF_H__
+#define __LOG_CONF_H__
+
+#define LOG_CONF_ENABLED 0
+
+#endif /* __LOG_CONF__H__ */
diff --git a/contiki-avr/conf/program-handler-conf.h b/contiki-avr/conf/program-handler-conf.h
new file mode 100644
index 0000000..1f9c743
--- /dev/null
+++ b/contiki-avr/conf/program-handler-conf.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.1 2005/02/15 14:56:37 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-avr/conf/telnetd-conf.h b/contiki-avr/conf/telnetd-conf.h
new file mode 100644
index 0000000..6c0ba6f
--- /dev/null
+++ b/contiki-avr/conf/telnetd-conf.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h,v 1.2 2004/08/09 22:29:31 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 32
+#define TELNETD_CONF_NUMLINES 16
+
+#endif /* __TELNETD_CONF_H__ */
+
+
+
+
+
+
+
+
diff --git a/contiki-avr/conf/uip-conf.h b/contiki-avr/conf/uip-conf.h
new file mode 100644
index 0000000..26566ad
--- /dev/null
+++ b/contiki-avr/conf/uip-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.2 2004/08/09 22:28:01 adamdunkels Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 40
+#define UIP_CONF_MAX_LISTENPORTS 40
+#define UIP_CONF_BUFFER_SIZE     1500
+
+#define UIP_CONF_TCP_SPLIT       1
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-avr/conf/vnc-conf.h b/contiki-avr/conf/vnc-conf.h
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/contiki-avr/conf/vnc-conf.h
@@ -0,0 +1 @@
+
diff --git a/contiki-avr/conf/www-conf.h b/contiki-avr/conf/www-conf.h
new file mode 100644
index 0000000..38dc9c8
--- /dev/null
+++ b/contiki-avr/conf/www-conf.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.4 2004/08/09 22:28:40 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 46
+#define WWW_CONF_WEBPAGE_HEIGHT 25
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 8
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 160
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 30
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  80
+#define WWW_CONF_MAX_FORMNAMELEN    40
+#define WWW_CONF_MAX_INPUTNAMELEN   40
+#define WWW_CONF_MAX_INPUTVALUELEN  40
+
+#define WWW_CONF_PAGEVIEW 1
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-avr/contiki-main.c b/contiki-avr/contiki-main.c
new file mode 100644
index 0000000..f1c81f9
--- /dev/null
+++ b/contiki-avr/contiki-main.c
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: contiki-main.c,v 1.6 2004/09/13 23:23:16 adamdunkels Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-vncserver.h"
+#include "ctk-termtelnet.h"
+#include "ek.h"
+
+#include "uiplib.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "rtl8019-drv.h"
+#include "resolv.h"
+
+#include "clock.h"
+
+#include "webserver.h"
+#include "program-handler.h"
+#include "about-dsc.h"
+#include "irc-dsc.h"
+#include "netconf-dsc.h"
+#include "processes-dsc.h"
+#include "calc-dsc.h"
+#include "www-dsc.h"
+#include "webserver-dsc.h"
+/*#include "directory-dsc.h"*/
+#include "weblinks-dsc.h"
+
+#include "telnetd-dsc.h"
+
+#include "debug.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "compiler.h"
+#include "rtl8019dev.h"
+
+
+#include "avr/pgmspace.h"
+
+
+static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x29}};
+
+
+static u16_t addr[2];
+
+/*-----------------------------------------------------------------------------------*/
+static void setup_xram(void) __attribute__ ((naked)) \
+     __attribute__ ((section (".init1")));
+
+static void
+setup_xram(void)
+{
+  outp(BV(SRE) | BV(SRW), MCUCR);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short count;
+
+static void init_timer(void)
+{
+  /* timer overflows every 32.8ms (with 8MHz clock) */
+  /* timer0 prescale 1/1024 (5) */
+  outp(5, TCCR0);  
+
+  /* interrupt on overflow */
+  sbi(TIMSK, TOIE0);
+        
+  count = 0;
+}
+
+SIGNAL(SIG_OVERFLOW0)
+{
+  ++count;
+}
+
+clock_time_t
+clock_time(void)
+{
+  return count;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+main(int argc, char **argv)
+{
+  
+  /* Setup stack pointer so that it does not interfere with the rest
+     of the RAM. */
+  /*  asm("ldi     r28,lo8(0x00807fff)");
+      asm("ldi     r29,hi8(0x00807fff)");
+      asm("out     0x3e, r29");
+      asm("out     0x3d, r28");*/
+
+  /* Fiddle with RS232 settings of the AVR: */
+  /* Enable transmit. */
+  UCSR0B = _BV(TXEN);
+  /* Set baud rate (23 =~ 38400) */
+  UBRR0H = 0;
+  UBRR0L = 23;
+  UDR0 = '\n';
+
+  
+  outp(BV(SRE) | BV(SRW), MCUCR);
+
+    
+  /* end RS232 fiddling. */
+
+  init_timer();
+  sei();
+
+  ek_init();
+
+  uip_init();
+  tcpip_init(NULL);
+  
+  resolv_init(NULL);
+  
+
+  debug_print8(1);
+  
+  
+  uip_setethaddr(ethaddr);
+
+ 
+    
+#if 1
+  uip_ipaddr(addr, 193,10,67,152);
+  uip_sethostaddr(addr);
+ 
+  uip_ipaddr(addr, 193,10,64,1);
+  uip_setdraddr(addr);
+ 
+  uip_ipaddr(addr, 255,255,252,0);
+  uip_setnetmask(addr);
+
+  uip_ipaddr(addr, 193,10,66,195);
+  resolv_conf(addr);
+
+#else
+
+  uip_ipaddr(addr, 192,168,27,2);
+  uip_sethostaddr(addr);
+ 
+  uip_ipaddr(addr, 192,168,27,1);
+  uip_setdraddr(addr);
+ 
+  uip_ipaddr(addr, 255,255,255,0);
+  uip_setnetmask(addr);
+
+  uip_ipaddr(addr, 195,54,122,204);
+  resolv_conf(addr);
+#endif
+
+   
+  
+  ctk_init();
+
+  rtl8019_drv_init();
+
+  ctk_vncserver_init(NULL);  
+  /*  ctk_termtelnet_init(NULL);*/
+
+  program_handler_init();
+
+  webserver_init(NULL);
+
+  /*  program_handler_add(&netconf_dsc, "Network config", 1);*/
+
+  
+  /*program_handler_add(&irc_dsc, "IRC client", 1);*/
+ 
+  
+
+  program_handler_add(&calc_dsc, "Calculator", 0);
+  program_handler_add(&weblinks_dsc, "Web links", 1);
+
+  program_handler_add(&www_dsc, "Web browser", 1);
+  program_handler_add(&webserver_dsc, "Web server", 1);
+  program_handler_add(&processes_dsc, "Processes", 1);
+  program_handler_add(&about_dsc, "About", 1);
+
+
+
+
+
+  debug_print8(64);
+
+  while(1) {
+    ek_run();
+  }
+
+  
+  return 0;
+
+  argv = argv;
+  argc = argc;
+}
+/*-----------------------------------------------------------------------------------*/
+char *shell_prompt_text = "contiki-ethernut> ";
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  
+}
diff --git a/contiki-avr/ctk/ctk-arch.h b/contiki-avr/ctk/ctk-arch.h
new file mode 100644
index 0000000..5ec7759
--- /dev/null
+++ b/contiki-avr/ctk/ctk-arch.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.2 2004/06/06 06:36:27 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+
+#include "ctk-vncarch.h"
+
+#define ctk_arch_isprint(x) isprint(x)
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-avr/lib/lc.h b/contiki-avr/lib/lc.h
new file mode 100644
index 0000000..7231892
--- /dev/null
+++ b/contiki-avr/lib/lc.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc.h,v 1.1 2004/09/13 10:33:46 adamdunkels Exp $
+ */
+
+#ifndef __LC_H__
+#define __LC_H__
+
+typedef void * lc_t;
+
+#define LC_CONCAT2(s1, s2) s1##s2
+#define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2)
+
+#define LC_SET(s)				\
+  do {						\
+    LC_CONCAT(LC_LABEL, __LINE__):   	        \
+    (s) = &&LC_CONCAT(LC_LABEL, __LINE__);	\
+  } while(0)
+
+#define LC_RESUME(s)				\
+  do {						\
+    if(s != NULL) {				\
+      goto *s;					\
+    }						\
+  } while(0)
+
+#define LC_END(s)
+
+#define LC_INIT(s) s = NULL
+
+#endif /* __LC_H__ */
diff --git a/contiki-avr/uip/compiler.h b/contiki-avr/uip/compiler.h
new file mode 100644
index 0000000..b1f4918
--- /dev/null
+++ b/contiki-avr/uip/compiler.h
@@ -0,0 +1,40 @@
+#ifndef __COMPILER_H__
+#define __COMPILER_H__
+
+#ifdef __IMAGECRAFT__
+
+
+// choose your AVR device here
+#include <iom161.h>
+
+#include <macros.h>
+
+#define outp(val, reg)  (reg = val)
+#define inp(reg)        (reg)
+
+#define cli()           CLI()
+#define sei()           SEI()
+#define cbi(reg, bit)   (reg &= ~BIT(bit))
+#define sbi(reg, bit)   (reg |= BIT(bit))
+
+#define SIGNAL(x)       void x(void)  
+
+#define nop() NOP()
+
+
+#else /* --- GCC --- */
+#ifndef __AVR_ATmega128__
+#define __AVR_ATmega128__
+#endif
+#include <avr/signal.h>
+#include <avr/interrupt.h>
+#include <avr/io.h>
+
+#define nop() asm volatile("nop\n\t"::);
+
+#endif /* Compiler Used */
+
+
+
+#endif /* __COMPILER_H__ */
+
diff --git a/contiki-avr/uip/debug.c b/contiki-avr/uip/debug.c
new file mode 100644
index 0000000..fdd25a3
--- /dev/null
+++ b/contiki-avr/uip/debug.c
@@ -0,0 +1,72 @@
+
+#include "compiler.h"
+#include "delay.h"
+
+#include "avr/pgmspace.h"
+
+/*-----------------------------------------------------------------------------------*/
+static void
+delay(void)
+{
+  unsigned char i;
+  for(i = 0; i < 1; ++i) {
+    Delay_10ms(1);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char buffer[40];
+static prog_char hextab[] =
+  {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+/*-----------------------------------------------------------------------------------*/
+static void
+print_buffer(unsigned char len)
+{
+  unsigned char i;
+
+  for(i = 0; i < len; ++i) {
+    delay();
+    UDR0 = buffer[i];
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+debug_print8(unsigned char v)
+{
+  buffer[0] = v / 100 + '0';
+  buffer[1] = (v / 10) % 10 + '0';
+  buffer[2] = v % 10 + '0';
+  buffer[3] = ' ';
+  buffer[4] = PRG_RDB(hextab + (v >> 4));
+  buffer[5] = PRG_RDB(hextab + (v & 0x0f));    
+  buffer[6] = '\n';
+  print_buffer(7);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+debug_print16(unsigned short v)
+{
+  buffer[0] = v / 10000 + '0';
+  buffer[1] = (v / 1000) % 10 + '0';
+  buffer[2] = (v / 100) % 10 + '0';
+  buffer[3] = (v / 10) % 10 + '0';
+  buffer[4] = v % 10 + '0';
+  buffer[5] = ' ';
+  buffer[6] = PRG_RDB(hextab + ((v & 0xf000) >> 12));
+  buffer[7] = PRG_RDB(hextab + ((v & 0x0f00) >> 8));
+  buffer[8] = PRG_RDB(hextab + ((v & 0xf0) >> 4));
+  buffer[9] = PRG_RDB(hextab + (v & 0x0f));    
+  buffer[10] = '\n';
+  print_buffer(11);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+debug_print(prog_char *str)
+{
+  unsigned char i;
+
+  for(i = 0; PRG_RDB(str + i) != 0; ++i) {
+    buffer[i] = PRG_RDB(str + i);
+  }
+  print_buffer(i);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/uip/debug.h b/contiki-avr/uip/debug.h
new file mode 100644
index 0000000..ec38942
--- /dev/null
+++ b/contiki-avr/uip/debug.h
@@ -0,0 +1,20 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+#if 0
+#define debug_print(x)
+#define debug_print8(x) 
+
+#else
+
+#include "avr/pgmspace.h"
+
+void debug_print(char *str);
+
+void debug_print8(unsigned char v);
+void debug_print16(unsigned short v);
+#endif
+
+
+
+#endif /* __DEBUG_H__ */
diff --git a/contiki-avr/uip/delay.c b/contiki-avr/uip/delay.c
new file mode 100644
index 0000000..01cc3e4
--- /dev/null
+++ b/contiki-avr/uip/delay.c
@@ -0,0 +1,29 @@
+#include "delay.h"
+ 
+//----------------------------------------------------------------------------
+// Wait for a specific time in 100 uSec
+// (15 + t*( ((K_DELAY_100us-1)*6)+5 ))
+//----------------------------------------------------------------------------
+void Delay_100us(unsigned char t) {
+  unsigned int i;
+  if (t==0) return;
+  while (t--) for(i=0;i<K_DELAY_100us; i++);
+}
+//----------------------------------------------------------------------------
+// Wait for a specific time in 1 mSec
+// (15 + t*( ((K_DELAY_1ms-1)*6)+5 ))
+//----------------------------------------------------------------------------
+void Delay_1ms(unsigned char t) {
+  unsigned int i;
+  if (t==0) return;
+  while (t--) for(i=0;i<K_DELAY_1ms; i++);
+}
+//----------------------------------------------------------------------------
+// Wait for a specific time in 10 mSec
+// (15 + t*( ((K_DELAY_10ms-1)*6)+5 ))
+//----------------------------------------------------------------------------
+void Delay_10ms(unsigned char t) {
+  unsigned int i;
+  if (t==0) return;
+  while (t--) for(i=0;i<K_DELAY_10ms; i++);
+}
diff --git a/contiki-avr/uip/delay.h b/contiki-avr/uip/delay.h
new file mode 100644
index 0000000..6e44906
--- /dev/null
+++ b/contiki-avr/uip/delay.h
@@ -0,0 +1,9 @@
+#define F_CPU 15000000
+ 
+#define K_DELAY_100us	F_CPU/61349
+#define K_DELAY_1ms		F_CPU/6013
+#define K_DELAY_10ms	F_CPU/600
+
+void Delay_100us(unsigned char t);
+void Delay_1ms(unsigned char t);
+void Delay_10ms(unsigned char t);
diff --git a/contiki-avr/uip/rtl8019-drv.c b/contiki-avr/uip/rtl8019-drv.c
new file mode 100644
index 0000000..b309db2
--- /dev/null
+++ b/contiki-avr/uip/rtl8019-drv.c
@@ -0,0 +1,114 @@
+/*-----------------------------------------------------------------------------------*/
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rtl8019-drv.c,v 1.4 2004/08/09 22:23:29 adamdunkels Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "rtl8019dev.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RTL8019as", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rtl8019_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  RTL8019dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    RTL8019dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    /*    ek_exit();
+	  LOADER_UNLOAD();*/
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = RTL8019dev_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+	RTL8019dev_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-avr/uip/rtl8019-drv.h b/contiki-avr/uip/rtl8019-drv.h
new file mode 100644
index 0000000..7687098
--- /dev/null
+++ b/contiki-avr/uip/rtl8019-drv.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rtl8019-drv.h,v 1.1 2003/07/04 10:54:52 adamdunkels Exp $
+ *
+ */
+#ifndef __RTL8019_DRV_H__
+#define __RTL8019_DRV_H__
+
+void rtl8019_drv_init(void);
+
+#endif /* __RTL8019_DRV_H__ */
diff --git a/contiki-avr/uip/rtl8019.c b/contiki-avr/uip/rtl8019.c
new file mode 100644
index 0000000..651efaa
--- /dev/null
+++ b/contiki-avr/uip/rtl8019.c
@@ -0,0 +1,931 @@
+#include "rtl8019.h"
+#include "delay.h"
+#include "debug.h"
+#include "avr/pgmspace.h"
+#include "rtlregs.h"
+
+
+/*****************************************************************************
+*  Module Name:       Realtek 8019AS Driver
+*  
+*  Created By:        Louis Beaudoin (www.embedded-creations.com)
+*
+*  Original Release:  September 21, 2002 
+*
+*  Module Description:  
+*  Provides functions to initialize the Realtek 8019AS, and send and retreive
+*  packets
+*
+*  November 15, 2002 - Louis Beaudoin
+*    processRTL8019Interrupt() - bit mask mistake fixed
+*
+*  September 30, 2002 - Louis Beaudoin
+*    Receive functions modified to handle errors encountered when receiving a
+*      fast data stream.  Functions now manually retreive data instead of
+*      using the send packet command.  Interface improved by checking for
+*      overruns and data in the buffer internally.
+*    Corrected the overrun function - overrun flag was not reset after overrun
+*    Added support for the Imagecraft Compiler
+*    Added support to communicate with the NIC using general I/O ports
+*
+*****************************************************************************/
+
+
+/*****************************************************************************
+*  writeRTL( RTL_ADDRESS, RTL_DATA )
+*  Args:        1. unsigned char RTL_ADDRESS - register offset of RTL register
+*               2. unsigned char RTL_DATA - data to write to register
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Writes byte to RTL8019 register.
+*
+*  Notes - If using the External SRAM Interface, performs a write to
+*            address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
+*            The address is sent in the non-multiplxed upper address port so
+*            no latch is required.
+*
+*          If using general I/O ports, the data port is left in the input
+*            state with pullups enabled
+*
+*****************************************************************************/
+#if MEMORY_MAPPED_NIC == 1
+/*#define writeRTL(RTL_ADDRESS,RTL_DATA) do{ *(volatile unsigned char *) \
+                             (MEMORY_MAPPED_RTL8019_OFFSET \
+                             + (((unsigned char)(RTL_ADDRESS)) << 8)) = \
+                             (unsigned char)(RTL_DATA); } while(0)*/
+#define writeRTL nic_write
+#else
+
+
+void writeRTL(unsigned char address, unsigned char data)
+{
+    // put the address and data in the port registers - data port is output
+    outp( address, RTL8019_ADDRESS_PORT );
+    outp( 0xFF, RTL8019_DATA_DDR );
+    outp( data, RTL8019_DATA_PORT );
+    
+	// toggle write pin
+    RTL8019_CLEAR_WRITE;
+    RTL8019_SET_WRITE;
+    
+	// set data port back to input with pullups enabled
+    outp( 0x00, RTL8019_DATA_DDR );
+    outp( 0xFF, RTL8019_DATA_PORT );
+}
+
+
+
+#endif
+
+/*****************************************************************************
+*  readRTL(RTL_ADDRESS)
+*  Args:        unsigned char RTL_ADDRESS - register offset of RTL register
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Reads byte from RTL8019 register
+*
+*  Notes - If using the External SRAM Interface, performs a read from
+*            address MEMORY_MAPPED_RTL8019_OFFSET + (RTL_ADDRESS<<8)
+*            The address is sent in the non-multiplxed upper address port so
+*            no latch is required.
+*
+*          If using general I/O ports, the data port is assumed to already be
+*            an input, and is left as an input port when done
+*
+*****************************************************************************/
+#if MEMORY_MAPPED_NIC == 1
+/*#define readRTL(RTL_ADDRESS) (*(volatile unsigned char *) \
+                       (MEMORY_MAPPED_RTL8019_OFFSET \
+                       + (((unsigned char)(RTL_ADDRESS)) << 8)) )*/
+#define readRTL nic_read
+#else
+
+unsigned char readRTL(unsigned char address)
+{
+   unsigned char byte;
+   
+   // drive the read address
+   outp( address, RTL8019_ADDRESS_PORT );
+    
+   //nop();
+   
+   // assert read
+   RTL8019_CLEAR_READ;
+   nop();
+   
+   // read in the data
+   byte = inp( RTL8019_DATA_PIN );
+
+   // negate read
+   RTL8019_SET_READ;
+
+   return byte;
+}
+
+#endif                       
+
+
+
+/*****************************************************************************
+*  RTL8019setupPorts(void);
+*
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Sets up the ports used for communication with the RTL8019 NIC
+*                 (data bus, address bus, read, write, and reset)
+*****************************************************************************/
+void RTL8019setupPorts(void)
+{
+volatile unsigned char *base = (unsigned char *)0x8300;
+
+#if MEMORY_MAPPED_NIC == 1
+  	// enable external SRAM interface - no wait states
+  	outp(inp(MCUCR) | (1<<SRE), MCUCR);
+
+#else
+
+    // make the address port output
+    outp( 0xFF, RTL8019_ADDRESS_DDR );
+    
+    // make the data port input with pull-ups
+    outp( 0xFF, RTL8019_DATA_PORT );
+
+	// make the control port read and write pins outputs and asserted
+	//outp( inp(RTL8019_CONTROL_DDR) | (1<<RTL8019_CONTROL_READPIN) |
+	//          (1<<RTL8019_CONTROL_WRITEPIN), RTL8019_CONTROL_DDR );
+	sbi( RTL8019_CONTROL_DDR, RTL8019_CONTROL_READPIN );
+	sbi( RTL8019_CONTROL_DDR, RTL8019_CONTROL_WRITEPIN );
+	          
+	//outp( inp(RTL8019_CONTROL_PORT) | (1<<RTL8019_CONTROL_READPIN) |
+	//          (1<<RTL8019_CONTROL_WRITEPIN), RTL8019_CONTROL_PORT );
+	sbi( RTL8019_CONTROL_PORT, RTL8019_CONTROL_READPIN );
+	sbi( RTL8019_CONTROL_PORT, RTL8019_CONTROL_WRITEPIN );
+
+#endif
+
+	// enable output pin for Resetting the RTL8019
+	sbi( RTL8019_RESET_DDR, RTL8019_RESET_PIN );
+	
+	
+	
+
+
+}
+
+
+
+/*****************************************************************************
+*  HARD_RESET_RTL8019()
+*
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Simply toggles the pin that resets the NIC
+*****************************************************************************/
+/*#define HARD_RESET_RTL8019() do{ sbi(RTL8019_RESET_PORT, RTL8019_RESET_PIN); \
+                                Delay_10ms(1); \
+                                cbi(RTL8019_RESET_PORT, RTL8019_RESET_PIN);} \
+                                while(0)*/
+
+
+
+/*****************************************************************************
+*  overrun(void);
+*
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: "Canned" receive buffer overrun function originally from
+*                 a National Semiconductor appnote
+*  Notes:       This function must be called before retreiving packets from
+*                 the NIC if there is a buffer overrun
+*****************************************************************************/
+void overrun(void);
+
+
+
+
+//******************************************************************
+//*	REALTEK CONTROL REGISTER OFFSETS
+//*   All offsets in Page 0 unless otherwise specified
+//*	  All functions accessing CR must leave CR in page 0 upon exit
+//******************************************************************
+#define CR		 	0x00
+#define PSTART		0x01
+#define PAR0      	0x01    // Page 1
+#define CR9346    	0x01    // Page 3
+#define PSTOP		0x02
+#define BNRY		0x03
+#define TSR			0x04
+#define TPSR		0x04
+#define TBCR0		0x05
+#define NCR			0x05
+#define TBCR1		0x06
+#define ISR			0x07
+#define CURR		0x07   // Page 1
+#define RSAR0		0x08
+#define CRDA0		0x08
+#define RSAR1		0x09
+#define CRDA1		0x09
+#define RBCR0		0x0A
+#define RBCR1		0x0B
+#define RSR			0x0C
+#define RCR			0x0C
+#define TCR			0x0D
+#define CNTR0		0x0D
+#define DCR			0x0E
+#define CNTR1		0x0E
+#define IMR			0x0F
+#define CNTR2		0x0F
+#define RDMAPORT  	0x10
+#define RSTPORT   	0x18
+
+
+/*****************************************************************************
+*
+* RTL ISR Register Bits
+*
+*****************************************************************************/
+#define ISR_RST	7
+#define ISR_OVW 4
+#define ISR_PRX 0
+#define ISR_RDC 6
+#define ISR_PTX 1
+
+
+/*****************************************************************************
+*
+*  RTL Register Initialization Values
+*
+*****************************************************************************/
+// RCR : accept broadcast packets and packets destined to this MAC
+//         drop short frames and receive errors
+#define RCR_INIT		0x04
+
+// TCR : default transmit operation - CRC is generated 
+#define TCR_INIT		0x00
+
+// DCR : allows send packet to be used for packet retreival
+//         FIFO threshold: 8-bits (works)
+//         8-bit transfer mode
+#define DCR_INIT		0x58
+
+// IMR : interrupt enabled for receive and overrun events
+#define IMR_INIT		0x11
+
+// buffer boundaries - transmit has 6 256-byte pages
+//   receive has 26 256-byte pages
+//   entire available packet buffer space is allocated
+#define TXSTART_INIT   	0x40
+#define RXSTART_INIT   	0x46
+#define RXSTOP_INIT    	0x60
+
+
+
+void RTL8019beginPacketSend(unsigned int packetLength)
+{
+
+  volatile unsigned char *base = (unsigned char *)0x8300;
+	unsigned int sendPacketLength;
+	sendPacketLength = (packetLength>=ETHERNET_MIN_PACKET_LENGTH) ?
+	                 packetLength : ETHERNET_MIN_PACKET_LENGTH ;
+	
+	//start the NIC
+	writeRTL(CR,0x22);
+	
+	// still transmitting a packet - wait for it to finish
+	while( readRTL(CR) & 0x04 );
+
+	//load beginning page for transmit buffer
+	writeRTL(TPSR,TXSTART_INIT);
+	
+	//set start address for remote DMA operation
+	writeRTL(RSAR0,0x00);
+	writeRTL(RSAR1,0x40);
+	
+	//clear the packet stored interrupt
+	writeRTL(ISR,(1<<ISR_PTX));
+
+	//load data byte count for remote DMA
+	writeRTL(RBCR0, (unsigned char)(packetLength));
+	writeRTL(RBCR1, (unsigned char)(packetLength>>8));
+
+	writeRTL(TBCR0, (unsigned char)(sendPacketLength));
+	writeRTL(TBCR1, (unsigned char)((sendPacketLength)>>8));
+	
+	//do remote write operation
+	writeRTL(CR,0x12);
+}
+
+
+
+void RTL8019sendPacketData(unsigned char * localBuffer, unsigned int length)
+{
+	unsigned int i;
+	volatile unsigned char *base = (unsigned char *)0x8300;
+	for(i=0;i<length;i++)
+		writeRTL(RDMAPORT, localBuffer[i]);
+}
+
+
+
+void RTL8019endPacketSend(void)
+{
+  volatile unsigned char *base = (unsigned char *)0x8300;
+	//send the contents of the transmit buffer onto the network
+	writeRTL(CR,0x24);
+	
+	// clear the remote DMA interrupt
+	writeRTL(ISR, (1<<ISR_RDC));
+}
+
+
+
+
+// pointers to locations in the RTL8019 receive buffer
+static unsigned char nextPage;
+static unsigned int currentRetreiveAddress;
+
+// location of items in the RTL8019's page header
+#define  enetpacketstatus     0x00
+#define  nextblock_ptr        0x01
+#define	 enetpacketLenL		  0x02
+#define	 enetpacketLenH		  0x03
+
+
+
+unsigned int RTL8019beginPacketRetreive(void)
+{
+  volatile unsigned char *base = (unsigned char *)0x8300;
+	unsigned char i;
+	unsigned char bnry;
+	
+	unsigned char pageheader[4];
+	unsigned int rxlen;
+	
+	// check for and handle an overflow
+	processRTL8019Interrupt();
+	
+	// read CURR from page 1
+	writeRTL(CR,0x62);
+	i = readRTL(CURR);
+	
+	// return to page 0
+	writeRTL(CR,0x22);
+	
+	// read the boundary register - pointing to the beginning of the packet
+	bnry = readRTL(BNRY) ;
+
+	/*	debug_print(PSTR("bnry: "));
+		debug_print8(bnry);*/
+
+	/*	debug_print(PSTR("RXSTOP_INIT: "));
+	debug_print8(RXSTOP_INIT);
+	debug_print(PSTR("RXSTART_INIT: "));
+	debug_print8(RXSTART_INIT);*/
+	// return if there is no packet in the buffer
+	if( bnry == i ) {
+	  return 0;
+	}
+	
+
+	// clear the packet received interrupt flag
+	writeRTL(ISR, (1<<ISR_PRX));
+	
+	
+	// the boundary pointer is invalid, reset the contents of the buffer and exit
+	if( (bnry >= RXSTOP_INIT) || (bnry < RXSTART_INIT) )
+	{
+		writeRTL(BNRY, RXSTART_INIT);
+		writeRTL(CR, 0x62);
+		writeRTL(CURR, RXSTART_INIT);
+		writeRTL(CR, 0x22);
+		return 0;
+	}
+
+	// initiate DMA to transfer the RTL8019 packet header
+    writeRTL(RBCR0, 4);
+    writeRTL(RBCR1, 0);
+    writeRTL(RSAR0, 0);
+    writeRTL(RSAR1, bnry);
+    writeRTL(CR, 0x0A);
+    /*    	debug_print(PSTR("Page header: "));*/
+
+	for(i=0;i<4;i++) {
+	  pageheader[i] = readRTL(RDMAPORT);
+	  /*	  debug_print8(pageheader[i]);*/
+	}
+	
+	// end the DMA operation
+    writeRTL(CR, 0x22);
+    for(i = 0; i <= 20; i++) {
+      if(readRTL(ISR) & 1<<6) {
+	break;
+      }
+    }
+    writeRTL(ISR, 1<<6);
+
+	
+	
+	rxlen = (pageheader[enetpacketLenH]<<8) + pageheader[enetpacketLenL];
+	nextPage = pageheader[nextblock_ptr] ;
+	
+	currentRetreiveAddress = (bnry<<8) + 4;
+
+	/*	debug_print(PSTR("nextPage: "));
+		debug_print8(nextPage);*/
+	
+	// if the nextPage pointer is invalid, the packet is not ready yet - exit
+	if( (nextPage >= RXSTOP_INIT) || (nextPage < RXSTART_INIT) ) {
+	  /*	  UDR0 = '0';*/
+	  return 0;
+	}
+    
+    return rxlen-4;
+}
+
+
+void RTL8019retreivePacketData(unsigned char * localBuffer, unsigned int length)
+{
+	unsigned int i;
+	volatile unsigned char *base = (unsigned char *)0x8300;
+	// initiate DMA to transfer the data
+    writeRTL(RBCR0, (unsigned char)length);
+    writeRTL(RBCR1, (unsigned char)(length>>8));
+    writeRTL(RSAR0, (unsigned char)currentRetreiveAddress);
+    writeRTL(RSAR1, (unsigned char)(currentRetreiveAddress>>8));
+    writeRTL(CR, 0x0A);
+	for(i=0;i<length;i++)
+		localBuffer[i] = readRTL(RDMAPORT);
+
+	// end the DMA operation
+    writeRTL(CR, 0x22);
+    for(i = 0; i <= 20; i++)
+        if(readRTL(ISR) & 1<<6)
+            break;
+    writeRTL(ISR, 1<<6);
+    
+    currentRetreiveAddress += length;
+    if( currentRetreiveAddress >= 0x6000 )
+    	currentRetreiveAddress = currentRetreiveAddress - (0x6000-0x4600) ;
+}
+
+
+
+void RTL8019endPacketRetreive(void)
+{
+  volatile unsigned char *base = (unsigned char *)0x8300;
+	unsigned char i;
+
+	// end the DMA operation
+    writeRTL(CR, 0x22);
+    for(i = 0; i <= 20; i++)
+        if(readRTL(ISR) & 1<<6)
+            break;
+    writeRTL(ISR, 1<<6);
+
+	// set the boundary register to point to the start of the next packet
+    writeRTL(BNRY, nextPage);
+}
+
+
+void overrun(void)
+{
+  volatile unsigned char *base = (unsigned char *)0x8300;
+	unsigned char data_L, resend;	
+
+	data_L = readRTL(CR);
+	writeRTL(CR, 0x21);
+	Delay_1ms(2);
+	writeRTL(RBCR0, 0x00);
+	writeRTL(RBCR1, 0x00);
+	if(!(data_L & 0x04))
+		resend = 0;
+	else if(data_L & 0x04)
+	{
+		data_L = readRTL(ISR);
+		if((data_L & 0x02) || (data_L & 0x08))
+	    	resend = 0;
+	    else
+	    	resend = 1;
+	}
+	
+	writeRTL(TCR, 0x02);
+	writeRTL(CR, 0x22);
+	writeRTL(BNRY, RXSTART_INIT);
+	writeRTL(CR, 0x62);
+	writeRTL(CURR, RXSTART_INIT);
+	writeRTL(CR, 0x22);
+	writeRTL(ISR, 0x10);
+	writeRTL(TCR, TCR_INIT);
+	
+	writeRTL(ISR, 0xFF);
+}
+
+
+
+
+/*!
+ * \brief Size of a single ring buffer page.
+ */
+#define NIC_PAGE_SIZE   0x100
+
+/*!
+ * \brief First ring buffer page address.
+ */
+#define NIC_START_PAGE  0x40
+
+/*!
+ * \brief Last ring buffer page address plus 1.
+ */
+#define NIC_STOP_PAGE   0x60
+
+/*!
+ * \brief Number of pages in a single transmit buffer.
+ *
+ * This should be at least the MTU size.
+ */
+#define NIC_TX_PAGES    6
+
+/*!
+ * \brief Number of transmit buffers.
+ */
+#define NIC_TX_BUFFERS  2
+
+/*!
+ * \brief Controller memory layout:
+ *
+ * 0x4000 - 0x4bff  3k bytes transmit buffer
+ * 0x4c00 - 0x5fff  5k bytes receive buffer
+ */
+#define NIC_FIRST_TX_PAGE   NIC_START_PAGE
+#define NIC_FIRST_RX_PAGE   (NIC_FIRST_TX_PAGE + NIC_TX_PAGES * NIC_TX_BUFFERS)
+
+/*!
+ * \brief Standard sizing information
+ */
+#define TX_PAGES 12         /* Allow for 2 back-to-back frames */
+
+static unsigned char mac[6] = {0x00,0x06,0x98,0x01,0x02,0x29};
+void Delay(long nops)
+{
+    volatile long i;
+
+    for(i = 0; i < nops; i++) 
+#ifdef __IMAGECRAFT__
+        asm("nop\n");
+#else
+        asm volatile("nop\n\t"::);
+#endif
+}
+
+static int NicReset(void)
+{
+volatile unsigned char *base = (unsigned char *)0x8300;
+    unsigned char i;
+    unsigned char j;
+
+    for(j = 0; j < 20; j++) {
+        debug_print(PSTR("SW-Reset..."));
+        i = nic_read(NIC_RESET);
+        Delay(500);
+        nic_write(NIC_RESET, i);
+        for(i = 0; i < 20; i++) {
+            Delay(5000);
+
+            /*
+             * ID detection added for version 1.1 boards.
+             */
+            if((nic_read(NIC_PG0_ISR) & NIC_ISR_RST) != 0 &&
+               nic_read(NIC_PG0_RBCR0) == 0x50 && 
+               nic_read(NIC_PG0_RBCR1) == 0x70) {
+                debug_print(PSTR("OK\r\n"));
+                return 0;
+            }
+        }
+        debug_print(PSTR("failed\r\n\x07"));
+
+        /*
+         * Toggle the hardware reset line. Since Ethernut version 1.3 the 
+         * hardware reset pin of the nic is no longer connected to bit 4 
+         * on port E, but wired to the board reset line.
+         */
+        if(j == 10) {
+            debug_print(PSTR("Ethernut 1.1 HW-Reset\r\n"));
+            sbi(DDRE, 4);
+            sbi(PORTE, 4);
+            Delay(100000);
+            cbi(PORTE, 4);
+            Delay(250000);
+        }
+    }
+    return -1;
+}
+
+void initRTL8019(void)
+{
+  unsigned char i, rb;
+  volatile unsigned char *base = (unsigned char *)0x8300;
+  
+  RTL8019setupPorts();
+
+  /*#define nic_write writeRTL
+    #define nic_read readRTL*/
+      /*
+     * Disable NIC interrupts.
+     */
+    cbi(EIMSK, INT5);
+
+    /*    if(NicReset(base))
+	  return -1;*/
+#if 0
+    /*
+     * Mask all interrupts and clear any interrupt status flag to set the 
+     * INT pin back to low.
+     */
+    nic_write(NIC_PG0_IMR, 0);
+    nic_write(NIC_PG0_ISR, 0xff);
+
+    /*
+     * During reset the nic loaded its initial configuration from an 
+     * external eeprom. On the ethernut board we do not have any 
+     * configuration eeprom, but simply tied the eeprom data line to 
+     * high level. So we have to clear some bits in the configuration 
+     * register. Switch to register page 3.
+     */
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2 | NIC_CR_PS0 | NIC_CR_PS1);
+
+    /*
+     * The nic configuration registers are write protected unless both 
+     * EEM bits are set to 1.
+     */
+    nic_write(NIC_PG3_EECR, NIC_EECR_EEM0 | NIC_EECR_EEM1);
+
+    /*
+     * Disable sleep and power down.
+     */
+    nic_write(NIC_PG3_CONFIG3, 0);
+
+    /*
+     * Network media had been set to 10Base2 by the virtual EEPROM and
+     * will be set now to auto detect. This will initiate a link test.
+     * We don't force 10BaseT, because this would disable the link test.
+     */
+    nic_write(NIC_PG3_CONFIG2, NIC_CONFIG2_BSELB);
+
+    /*
+     * Reenable write protection of the nic configuration registers
+     * and wait for link test to complete.
+     */
+    nic_write(NIC_PG3_EECR, 0);
+    /*    NutSleep(WAIT500);*/
+    Delay_10ms(50);
+
+    /*
+     * Switch to register page 0 and set data configuration register
+     * to byte-wide DMA transfers, normal operation (no loopback),
+     * send command not executed and 8 byte fifo threshold.
+     */
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2);
+    nic_write(NIC_PG0_DCR, NIC_DCR_LS | NIC_DCR_FT1);
+
+    /*
+     * Clear remote dma byte count register.
+     */
+    nic_write(NIC_PG0_RBCR0, 0);
+    nic_write(NIC_PG0_RBCR1, 0);
+
+    /*
+     * Temporarily set receiver to monitor mode and transmitter to 
+     * internal loopback mode. Incoming packets will not be stored 
+     * in the nic ring buffer and no data will be send to the network.
+     */
+    nic_write(NIC_PG0_RCR, NIC_RCR_MON);
+    nic_write(NIC_PG0_TCR, NIC_TCR_LB0);
+
+    /*
+     * Configure the nic's ring buffer page layout.
+     * NIC_PG0_BNRY: Last page read.
+     * NIC_PG0_PSTART: First page of receiver buffer.
+     * NIC_PG0_PSTOP: Last page of receiver buffer.
+     */
+    nic_write(NIC_PG0_TPSR, NIC_FIRST_TX_PAGE);
+    nic_write(NIC_PG0_BNRY, NIC_STOP_PAGE - 1);
+    nic_write(NIC_PG0_PSTART, NIC_FIRST_RX_PAGE);
+    nic_write(NIC_PG0_PSTOP, NIC_STOP_PAGE);
+
+    /*
+     * Once again clear interrupt status register.
+     */
+    nic_write(NIC_PG0_ISR, 0xff);
+
+    /*
+     * Switch to register page 1 and copy our MAC address into the nic. 
+     * We are still in stop mode.
+     */
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2 | NIC_CR_PS0);
+    for(i = 0; i < 6; i++)
+        nic_write(NIC_PG1_PAR0 + i, mac[i]);
+
+    /*
+     * Clear multicast filter bits to disable all packets.
+     */
+    for(i = 0; i < 8; i++)
+        nic_write(NIC_PG1_MAR0 + i, 0);
+
+    /*
+     * Set current page pointer to one page after the boundary pointer.
+     */
+    nic_write(NIC_PG1_CURR, NIC_START_PAGE + TX_PAGES);
+
+    /*
+     * Switch back to register page 0, remaining in stop mode.
+     */
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2);
+
+    /*
+     * Take receiver out of monitor mode and enable it for accepting 
+     * broadcasts.
+     */
+    nic_write(NIC_PG0_RCR, NIC_RCR_AB);
+
+    /*
+     * Clear all interrupt status flags and enable interrupts.
+     */
+    nic_write(NIC_PG0_ISR, 0xff);
+    nic_write(NIC_PG0_IMR, NIC_IMR_PRXE | NIC_IMR_PTXE | NIC_IMR_RXEE | 
+                           NIC_IMR_TXEE | NIC_IMR_OVWE);
+
+    /*
+     * Fire up the nic by clearing the stop bit and setting the start bit. 
+     * To activate the local receive dma we must also take the nic out of
+     * the local loopback mode.
+     */
+    nic_write(NIC_CR, NIC_CR_STA | NIC_CR_RD2);
+    nic_write(NIC_PG0_TCR, 0);
+
+    /*    NutSleep(WAIT500);*/
+    Delay_10ms(50);
+
+
+#endif /* 0 */
+
+    NicReset();
+    
+    debug_print(PSTR("Init controller..."));
+    nic_write(NIC_PG0_IMR, 0);
+    nic_write(NIC_PG0_ISR, 0xff);
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2 | NIC_CR_PS0 | NIC_CR_PS1);
+    nic_write(NIC_PG3_EECR, NIC_EECR_EEM0 | NIC_EECR_EEM1);
+    nic_write(NIC_PG3_CONFIG3, 0);
+    nic_write(NIC_PG3_CONFIG2, NIC_CONFIG2_BSELB);
+    nic_write(NIC_PG3_EECR, 0);
+    /*    Delay(50000);*/
+    Delay_10ms(200);
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2);
+    nic_write(NIC_PG0_DCR, NIC_DCR_LS | NIC_DCR_FT1);
+    nic_write(NIC_PG0_RBCR0, 0);
+    nic_write(NIC_PG0_RBCR1, 0);
+    nic_write(NIC_PG0_RCR, NIC_RCR_MON);
+    nic_write(NIC_PG0_TCR, NIC_TCR_LB0);
+    nic_write(NIC_PG0_TPSR, NIC_FIRST_TX_PAGE);
+    nic_write(NIC_PG0_BNRY, NIC_STOP_PAGE - 1);
+    nic_write(NIC_PG0_PSTART, NIC_FIRST_RX_PAGE);
+    nic_write(NIC_PG0_PSTOP, NIC_STOP_PAGE);
+    nic_write(NIC_PG0_ISR, 0xff);
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2 | NIC_CR_PS0);
+    for(i = 0; i < 6; i++)
+        nic_write(NIC_PG1_PAR0 + i, mac[i]);
+    for(i = 0; i < 8; i++)
+        nic_write(NIC_PG1_MAR0 + i, 0);
+    nic_write(NIC_PG1_CURR, NIC_START_PAGE + TX_PAGES);
+    nic_write(NIC_CR, NIC_CR_STP | NIC_CR_RD2);
+    nic_write(NIC_PG0_RCR, NIC_RCR_AB);
+    nic_write(NIC_PG0_ISR, 0xff);
+    nic_write(NIC_PG0_IMR, 0);
+    nic_write(NIC_CR, NIC_CR_STA | NIC_CR_RD2);
+    nic_write(NIC_PG0_TCR, 0);
+    /*    Delay(1000000)*/
+    Delay_10ms(200);
+
+
+        nic_write(NIC_CR, NIC_CR_STA | NIC_CR_RD2 | NIC_CR_PS0 | NIC_CR_PS1);
+    rb = nic_read(NIC_PG3_CONFIG0);
+    debug_print8(rb);
+    switch(rb & 0xC0) {
+    case 0x00:
+        debug_print(PSTR("RTL8019AS "));
+        if(rb & 0x08)
+            debug_print(PSTR("jumper mode: "));
+        if(rb & 0x20)
+            debug_print(PSTR("AUI "));
+        if(rb & 0x10)
+            debug_print(PSTR("PNP "));
+        break;
+    case 0xC0:
+        debug_print(PSTR("RTL8019 "));
+        if(rb & 0x08)
+            debug_print(PSTR("jumper mode: "));
+        break;
+    default:
+        debug_print(PSTR("Unknown chip "));
+	debug_print8(rb);
+        break;
+    }
+    if(rb & 0x04)
+        debug_print(PSTR("BNC\x07 "));
+    if(rb & 0x03)
+        debug_print(PSTR("Failed\x07 "));
+
+    /*    rb = nic_read(NIC_PG3_CONFIG1);
+	  debug_print8(rb);*/
+    /*    NutPrintFormat(0, "IRQ%u ", (rb >> 4) & 7);*/
+    /*    debug_print("IRQ ");
+	  debug_print8((rb >> 4) & 7);*/
+
+    rb = nic_read(NIC_PG3_CONFIG2);
+    debug_print8(rb);
+    switch(rb & 0xC0) {
+    case 0x00:
+        debug_print(PSTR("Auto "));
+        break;
+    case 0x40:
+        debug_print(PSTR("10BaseT "));
+        break;
+    case 0x80:
+        debug_print(PSTR("10Base5 "));
+        break;
+    case 0xC0:
+        debug_print(PSTR("10Base2 "));
+        break;
+    }
+
+
+    return;
+    
+  /*  HARD_RESET_RTL8019();*/
+
+  // do soft reset
+  writeRTL( ISR, readRTL(ISR) ) ;
+  Delay_10ms(5);
+  
+  writeRTL(CR,0x21);       // stop the NIC, abort DMA, page 0
+  Delay_1ms(2);               // make sure nothing is coming in or going out
+  writeRTL(DCR, DCR_INIT);    // 0x58
+  writeRTL(RBCR0,0x00);
+  writeRTL(RBCR1,0x00);
+  writeRTL(RCR,0x04);
+  writeRTL(TPSR, TXSTART_INIT);
+  writeRTL(TCR,0x02);
+  writeRTL(PSTART, RXSTART_INIT);
+  writeRTL(BNRY, RXSTART_INIT);
+  writeRTL(PSTOP, RXSTOP_INIT);
+  writeRTL(CR, 0x61);
+  Delay_1ms(2);
+  writeRTL(CURR, RXSTART_INIT);
+  
+  writeRTL(PAR0+0, MYMAC_0);
+  writeRTL(PAR0+1, MYMAC_1);
+  writeRTL(PAR0+2, MYMAC_2);
+  writeRTL(PAR0+3, MYMAC_3);
+  writeRTL(PAR0+4, MYMAC_4);
+  writeRTL(PAR0+5, MYMAC_5);
+     	  
+  writeRTL(CR,0x21);
+  writeRTL(DCR, DCR_INIT);
+  writeRTL(CR,0x22);
+  writeRTL(ISR,0xFF);
+  writeRTL(IMR, IMR_INIT);
+  writeRTL(TCR, TCR_INIT);
+	
+  writeRTL(CR, 0x22);	// start the NIC
+}
+
+
+void processRTL8019Interrupt(void)
+{
+  volatile unsigned char *base = (unsigned char *)0x8300;
+  unsigned char byte = readRTL(ISR);
+	
+  if( byte & (1<<ISR_OVW) )
+    overrun();
+
+}
+
+/*
+  unsigned char RTL8019ReceiveEmpty(void)
+  {
+  unsigned char temp;
+
+  // read CURR from page 1
+  writeRTL(CR,0x62);
+  temp = readRTL(CURR);
+	
+  // return to page 0
+  writeRTL(CR,0x22);
+	
+  return ( readRTL(BNRY) == temp );
+	
+  }*/
+
+
+
+
diff --git a/contiki-avr/uip/rtl8019.h b/contiki-avr/uip/rtl8019.h
new file mode 100644
index 0000000..240beff
--- /dev/null
+++ b/contiki-avr/uip/rtl8019.h
@@ -0,0 +1,265 @@
+#ifndef __RTL8019_H__
+#define __RTL8019_H__
+
+/*****************************************************************************
+*  Module Name:       Realtek 8019AS Driver
+*  
+*  Created By:        Louis Beaudoin (www.embedded-creations.com)
+*
+*  Original Release:  September 21, 2002 
+*
+*  Module Description:  
+*  Provides functions to initialize the Realtek 8019AS, and send and retreive
+*  packets
+*
+*  September 30, 2002 - Louis Beaudoin
+*    Receive functions modified to handle errors encountered when receiving a
+*      fast data stream.  Functions now manually retreive data instead of
+*      using the send packet command.  Interface improved by checking for
+*      overruns and data in the buffer internally.
+*    Corrected the overrun function - overrun flag was not reset after overrun
+*    Added support for the Imagecraft Compiler
+*    Added support to communicate with the NIC using general I/O ports
+*
+*****************************************************************************/
+
+/*#include "delay.h"*/
+
+#include "compiler.h"
+
+
+/*****************************************************************************
+*  RTL8019beginPacketSend(unsigned int packetLength)
+*  Args:        unsigned int - length of the Ethernet frame (see note)
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Sets up the NIC to send a packet
+*  Notes:       The NIC will not send packets less than 60 bytes long (the min
+*                 Ethernet frame length.  The transmit length is automatically
+*                 increased to 60 bytes if packetLength is < 60
+*****************************************************************************/
+void RTL8019beginPacketSend(unsigned int packetLength);
+
+
+/*****************************************************************************
+*  RTL8019sendPacketData(unsigned char * localBuffer, unsigned int length)
+*  Args:        1. unsigned char * localBuffer - Pointer to the beginning of
+*                    the buffer to load into the NIC
+*               2. unsigned char length - number of bytes to copy to
+*                    the NIC
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Loads length # of bytes from a local buffer to the transmit
+*                 packet buffer
+*  Notes:       RTL8019beginPacketSend() must be called before sending
+*                 any data.
+*               Several calls to RTL8019retreivePacketData() may be made to 
+*                 copy packet data from different buffers
+*****************************************************************************/
+void RTL8019sendPacketData(unsigned char * localBuffer, unsigned int length);
+
+
+/*****************************************************************************
+*  RTL8019endPacketSend()
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Ends a packet send operation and instructs the NIC to transmit
+*                 the frame over the network
+*****************************************************************************/
+void RTL8019endPacketSend(void);
+
+
+/*****************************************************************************
+*  initRTL8019(void);
+*
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Sets up the RTL8019 NIC hardware interface, and initializes
+*                 the buffers and configuration of the NIC
+*****************************************************************************/
+void initRTL8019(void);
+
+
+/*****************************************************************************
+*  processRTL8019Interrupt(void);
+*
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Reads the NIC's ISR register looking for a receive buffer
+*                 overrun - which is then handled.
+*  Notes:       The function does not need to be called in response to an
+*                 interrupt.  The function can be polled and the NIC's INT
+*                 line not used.  This function should be called before
+*                 attempting to retreive a packet from the NIC
+*****************************************************************************/
+void processRTL8019Interrupt(void);
+
+
+/*****************************************************************************
+*  unsigned char RTL8019ReceiveEmpty(void);
+*
+*  Returns:     non-zero (true) if buffer is empty, zero if data in buffer
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Compares the BNRY and CURR receive buffer pointers to see if
+*                 there is a packet in the receive buffer
+*  ** Removed as of version 0.60.1 **
+*****************************************************************************/
+//unsigned char RTL8019ReceiveEmpty(void);
+
+
+/*****************************************************************************
+*  unsigned int RTL8019beginPacketRetreive()
+*  Returns:     unsigned int - length of the Ethernet frame (see note)
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Sets up the NIC to retreive a packet
+*  Notes:       The size returned is the size of all the data in the Ethernet
+*                 frame minus the Ethernet checksum.  This may include unused
+*                 trailer bytes appended if data is less than the minimum
+*                 Ethernet frame length (60 bytes).  A size of zero indicates
+*                 there are no packets available.
+*               A call to RTL8019beginPacketRetreive() must be followed by a
+*                 call to RTL8019endPacketRetreive() regardless if data is
+*                 retreived, unless 0 is returned.
+*****************************************************************************/
+unsigned int RTL8019beginPacketRetreive(void);
+
+
+/*****************************************************************************
+*  RTL8019retreivePacketData(unsigned char * localBuffer, unsigned int length)
+*  Args:        1. unsigned char * localBuffer - Pointer to the beginning of
+*                    the buffer to store the ethernet frame.
+*               2. unsigned char length - number of bytes to copy to
+*                    localBuffer
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Loads length # of bytes from the receive packet buffer to
+*                 a local buffer
+*  Notes:       RTL8019beginPacketRetreive() must be called before retreiving
+*                 any data.
+*               Several calls to RTL8019retreivePacketData() may be made to 
+*                 copy packet data to different buffers
+*****************************************************************************/
+void RTL8019retreivePacketData(unsigned char * localBuffer,
+                               unsigned int length);
+
+/*****************************************************************************
+*  RTL8019endPacketRetreive()
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Ends a packet retreive operation begun by calling
+*                 RTL8019beginPacketRetreive().  The NIC buffer space used by
+*                 the retreived packet is freed
+*  Notes:       A packet may be removed from the buffer without being read
+*                 by calling RTL8019endPacketRetreive() after
+*                 RTL8019beginPacketRetreive().
+*****************************************************************************/
+void RTL8019endPacketRetreive(void);
+
+
+/*****************************************************************************
+*
+*  AVR hardware setup
+*
+*    External SRAM Interface:
+*      The five NIC address lines are taken from A8-A12 (uses the
+*      non-multiplexed address port so no latch is required)
+*
+*    General I/O Interface:
+*      Two full ports are required for the address and data buses.  Two pins
+*        from another port are used to control the read and write lines
+*
+*    One output pin is required for hard resetting the NIC
+*
+*****************************************************************************/
+
+// set to 1 to use the External SRAM Interface - 0 for General I/O
+#define MEMORY_MAPPED_NIC 1
+
+#if MEMORY_MAPPED_NIC /*** NIC Interface through External SRAM Interface ****/
+
+// NIC is mapped from address 0x8000 - 0x9F00
+#define MEMORY_MAPPED_RTL8019_OFFSET 0x8300
+
+#else /************ NIC Interface through General I/O *******************/
+
+// RTL8019 address port
+#define RTL8019_ADDRESS_PORT        PORTC
+#define RTL8019_ADDRESS_DDR         DDRC
+
+// RTL8019 data port
+#define RTL8019_DATA_PORT           PORTA
+#define RTL8019_DATA_DDR            DDRA
+#define RTL8019_DATA_PIN            PINA
+
+// RTL8019 control port
+#define RTL8019_CONTROL_PORT        PORTD
+#define RTL8019_CONTROL_DDR         DDRD
+#define RTL8019_CONTROL_READPIN     PD7
+#define RTL8019_CONTROL_WRITEPIN    PD6
+
+
+// macros to control the read and write pins
+#define RTL8019_CLEAR_READ   cbi(RTL8019_CONTROL_PORT,\
+                                 RTL8019_CONTROL_READPIN)
+#define RTL8019_SET_READ     sbi(RTL8019_CONTROL_PORT,\
+                                 RTL8019_CONTROL_READPIN) 
+#define RTL8019_CLEAR_WRITE  cbi(RTL8019_CONTROL_PORT,\
+                                 RTL8019_CONTROL_WRITEPIN)
+#define RTL8019_SET_WRITE    sbi(RTL8019_CONTROL_PORT,\
+                                 RTL8019_CONTROL_WRITEPIN)
+
+#endif /** NIC Interface **/
+
+
+
+// RTL RESET - Port B pin 0
+#define RTL8019_RESET_PORT 	PORTE
+#define RTL8019_RESET_DDR 	DDRE
+#define RTL8019_RESET_PIN 	PORTE0
+
+
+
+
+
+/*****************************************************************************
+*
+*  Ethernet constants
+*
+*****************************************************************************/
+#define ETHERNET_MIN_PACKET_LENGTH	0x3C
+#define ETHERNET_HEADER_LENGTH		0x0E
+
+
+
+/*****************************************************************************
+*
+* MAC address assigned to the RTL8019
+*
+*****************************************************************************/
+/*#define MYMAC_0 '0'
+#define MYMAC_1 'F'
+#define MYMAC_2 'F'
+#define MYMAC_3 'I'
+#define MYMAC_4 'C'
+#define MYMAC_5 'E'*/
+
+#define MYMAC_0 0x00
+#define MYMAC_1 0x06
+#define MYMAC_2 0x98
+#define MYMAC_3 0x01
+#define MYMAC_4 0x02
+#define MYMAC_5 0x26
+
+
+
+
+
+
+
+
+
+
+
+#endif /* __RTL8019_H__ */
diff --git a/contiki-avr/uip/rtl8019as-drv.c b/contiki-avr/uip/rtl8019as-drv.c
new file mode 100644
index 0000000..5db3159
--- /dev/null
+++ b/contiki-avr/uip/rtl8019as-drv.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rtl8019as-drv.c,v 1.1 2003/07/04 10:54:52 adamdunkels Exp $
+ *
+ */
+
+
+/* uip_main.c: initialization code and main event loop. */
+
+#define NULL (void *)0
+
+
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "uip-signal.h"
+#include "loader.h"
+#include "rtl8019dev.h"
+
+#include "dispatcher.h"
+#include "ek.h"
+
+#include "debug.h"
+
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+static u8_t i, arptimer;
+static u16_t start, current;
+
+static void rtl8019_drv_idle(void);
+static DISPATCHER_SIGHANDLER(rtl8019_drv_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("TCP/IP/RTL8019 driver", rtl8019_drv_idle,
+		   rtl8019_drv_sighandler, NULL)};
+ek_id_t id = EK_ID_NONE;
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+timer(void)
+{
+  for(i = 0; i < UIP_CONNS; ++i) {
+    uip_periodic(i);
+    if(uip_len > 0) {
+      uip_arp_out();
+      rtl8019as_send();
+    }
+  }
+
+  for(i = 0; i < UIP_UDP_CONNS; i++) {
+    uip_udp_periodic(i);
+    /* If the above function invocation resulted in data that
+       should be sent out on the network, the global variable
+       uip_len is set to a value > 0. */
+    if(uip_len > 0) {
+      uip_arp_out();
+      rtl8019as_send();
+    }
+  }   
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+rtl8019_drv_idle(void)
+{
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = rtl8019as_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */ 
+    if(BUF->type == htons(UIP_ETHTYPE_IP)) {
+      /*      debug_print16(uip_len);*/
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      uip_input();
+      /* If the above function invocation resulted in data that
+	 should be sent out on the network, the global variable
+	 uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+	/*	debug_print(PSTR("Sending packet\n"));*/
+	uip_arp_out();
+	rtl8019as_send();
+      }
+    } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+	 should be sent out on the network, the global variable
+	 uip_len is set to a value > 0. */	
+      if(uip_len > 0) {
+	rtl8019as_send();
+      }
+    }
+  }
+  /* Check the clock so see if we should call the periodic uIP
+     processing. */
+  current = ek_clock();
+
+  if((current - start) >= CLK_TCK/2 ||
+     (current - start) < 0) {
+    timer();
+    start = current;
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rtl8019_drv_init)
+{
+  if(id == EK_ID_NONE) {
+    id = dispatcher_start(&p);
+    
+    arptimer = 0;
+    start = ek_clock();
+
+    rtl8019as_init();
+    
+    dispatcher_listen(uip_signal_uninstall);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static
+DISPATCHER_SIGHANDLER(rtl8019_drv_sighandler, s, data)
+{
+  DISPATCHER_SIGHANDLER_ARGS(s, data);
+
+  if(s == uip_signal_uninstall) {
+    dispatcher_exit(&p);
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();   
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/uip/rtl8019dev.c b/contiki-avr/uip/rtl8019dev.c
new file mode 100644
index 0000000..3ca828b
--- /dev/null
+++ b/contiki-avr/uip/rtl8019dev.c
@@ -0,0 +1,77 @@
+#include "uip.h"
+#include "rtl8019dev.h"
+
+/*****************************************************************************
+*  Module Name:       Realtek 8019AS Driver Interface for uIP-AVR Port
+*  
+*  Created By:        Louis Beaudoin (www.embedded-creations.com)
+*
+*  Original Release:  September 21, 2002 
+*
+*  Module Description:  
+*  Provides three functions to interface with the Realtek 8019AS driver
+*  These functions can be called directly from the main uIP control loop
+*  to send packets from uip_buf and uip_appbuf, and store incoming packets to
+*  uip_buf
+*
+*  September 30, 2002 - Louis Beaudoin
+*    Modifications required to handle the packet receive function changes in
+*      rtl8019.c.  There is no longer a need to poll for an empty buffer or
+*      an overflow.
+*    Added support for the Imagecraft Compiler
+*
+*****************************************************************************/
+
+
+#define IP_TCP_HEADER_LENGTH 40
+#define TOTAL_HEADER_LENGTH (IP_TCP_HEADER_LENGTH+ETHERNET_HEADER_LENGTH)
+
+
+
+void RTL8019dev_init(void)
+{
+	initRTL8019();
+}
+
+
+void RTL8019dev_send(void)
+{
+  RTL8019beginPacketSend(uip_len);
+  
+  // send packet, using data in uip_appdata if over the IP+TCP header size
+  if( uip_len <= TOTAL_HEADER_LENGTH ) {
+    RTL8019sendPacketData(uip_buf, uip_len);
+  } else {
+    uip_len -= TOTAL_HEADER_LENGTH;
+    RTL8019sendPacketData(uip_buf, TOTAL_HEADER_LENGTH);
+    RTL8019sendPacketData((unsigned char *)uip_appdata, uip_len);
+  }
+  
+  RTL8019endPacketSend();
+}
+
+
+
+unsigned int RTL8019dev_poll(void)
+{
+	unsigned int packetLength;
+	
+	packetLength = RTL8019beginPacketRetreive();
+
+	// if there's no packet or an error - exit without ending the operation
+	if( !packetLength )
+	  return 0;
+
+	// drop anything too big for the buffer
+	if( packetLength > UIP_BUFSIZE )
+	{
+	  RTL8019endPacketRetreive();
+      return 0;
+	}
+	
+	// copy the packet data into the uIP packet buffer
+	RTL8019retreivePacketData( uip_buf, packetLength );
+	RTL8019endPacketRetreive();
+		
+	return packetLength;
+}
diff --git a/contiki-avr/uip/rtl8019dev.h b/contiki-avr/uip/rtl8019dev.h
new file mode 100644
index 0000000..677614d
--- /dev/null
+++ b/contiki-avr/uip/rtl8019dev.h
@@ -0,0 +1,60 @@
+#ifndef __RTL8019DEV_H__
+#define __RTL8019DEV_H__
+
+/*****************************************************************************
+*  Module Name:       Realtek 8019AS Driver Interface for uIP-AVR Port
+*  
+*  Created By:        Louis Beaudoin (www.embedded-creations.com)
+*
+*  Original Release:  September 21, 2002 
+*
+*  Module Description:  
+*  Provides three functions to interface with the Realtek 8019AS driver
+*  These functions can be called directly from the main uIP control loop
+*  to send packets from uip_buf and uip_appbuf, and store incoming packets to
+*  uip_buf
+*
+*  September 30, 2002 - Louis Beaudoin
+*    Modifications required to handle the packet receive function changes in
+*      rtl8019.c.  There is no longer a need to poll for an empty buffer or
+*      an overflow.
+*    Added support for the Imagecraft Compiler
+*
+*****************************************************************************/
+
+#include "uip.h"
+#include "rtl8019.h"
+
+/*****************************************************************************
+*  RTL8019dev_init()
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Power-up initialization of the RTL8019
+*****************************************************************************/
+void RTL8019dev_init(void);
+
+
+/*****************************************************************************
+*  RTL8019dev_send()
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Sends the packet contained in uip_buf and uip_appdata over
+*                 the network
+*****************************************************************************/
+void RTL8019dev_send(void);
+
+
+/*****************************************************************************
+*  unsigned char/int RTL8019dev_poll()
+*  Returns:     Length of the packet retreived, or zero if no packet retreived
+*  Created By:  Louis Beaudoin
+*  Date:        September 21, 2002
+*  Description: Polls the RTL8019 looking for an overflow condition or a new
+*                 packet in the receive buffer.  If a new packet exists and
+*                 will fit in uip_buf, it is retreived, and the length is
+*                 returned.  A packet bigger than the buffer is discarded
+*****************************************************************************/
+unsigned int RTL8019dev_poll(void);
+
+
+#endif /* __RTL8019DEV_H__ */
diff --git a/contiki-avr/uip/rtlregs.h b/contiki-avr/uip/rtlregs.h
new file mode 100644
index 0000000..fcaaebd
--- /dev/null
+++ b/contiki-avr/uip/rtlregs.h
@@ -0,0 +1,345 @@
+#ifndef _DEV_RTLREGS_H_

+#define _DEV_RTLREGS_H_

+

+/*

+ * Copyright (C) 2001-2002 by egnite Software GmbH. All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions

+ * are met:

+ *

+ * 1. Redistributions of source code must retain the above copyright

+ *    notice, this list of conditions and the following disclaimer.

+ * 2. Redistributions in binary form must reproduce the above copyright

+ *    notice, this list of conditions and the following disclaimer in the

+ *    documentation and/or other materials provided with the distribution.

+ * 3. All advertising materials mentioning features or use of this

+ *    software must display the following acknowledgement:

+ *

+ *    This product includes software developed by egnite Software GmbH

+ *    and its contributors.

+ *

+ * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS

+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS

+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE

+ * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,

+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,

+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS

+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED

+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,

+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF

+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF

+ * SUCH DAMAGE.

+ *

+ * For additional information see http://www.ethernut.de/

+ *

+ * -

+ * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>

+ *

+ * This file is distributed in the hope that it will be useful, but WITHOUT

+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or

+ * FITNESS FOR A PARTICULAR PURPOSE.

+ *

+ * You can redistribute this file and/or modify it under the terms of the GNU

+ * General Public License (GPL) as published by the Free Software Foundation;

+ * either version 2 of the License, or (at your discretion) any later version.

+ * See the accompanying file "copying-gpl.txt" for more details.

+ *

+ * As a special exception to the GPL, permission is granted for additional

+ * uses of the text contained in this file.  See the accompanying file

+ * "copying-liquorice.txt" for details.

+ * -

+ * Portions Copyright (c) 1983, 1993 by

+ *  The Regents of the University of California.  All rights reserved.

+ *

+ * Redistribution and use in source and binary forms, with or without

+ * modification, are permitted provided that the following conditions

+ * are met:

+ * 1. Redistributions of source code must retain the above copyright

+ *    notice, this list of conditions and the following disclaimer.

+ * 2. Redistributions in binary form must reproduce the above copyright

+ *    notice, this list of conditions and the following disclaimer in the

+ *    documentation and/or other materials provided with the distribution.

+ * 3. All advertising materials mentioning features or use of this software

+ *    must display the following acknowledgement:

+ *  This product includes software developed by the University of

+ *  California, Berkeley and its contributors.

+ * 4. Neither the name of the University nor the names of its contributors

+ *    may be used to endorse or promote products derived from this software

+ *    without specific prior written permission.

+ *

+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND

+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE

+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL

+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS

+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)

+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT

+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY

+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF

+ * SUCH DAMAGE.

+ */

+

+/*

+ * $Log: rtlregs.h,v $
+ * Revision 1.1  2003/07/04 10:54:52  adamdunkels
+ * First version of the AVR port
+ *
+ * Revision 1.1  2003/02/05 20:49:07  adam
+ * *** empty log message ***
+ *

+ * Revision 1.6  2002/10/29 15:27:36  harald

+ * *** empty log message ***

+ *

+ * Revision 1.5  2002/06/26 17:29:08  harald

+ * First pre-release with 2.4 stack

+ *

+ */

+

+/*!

+ * \brief Realtek 8019AS register definitions.

+ */

+/*@{*/

+

+/*

+ * Register offset applicable to all register pages.

+ */

+#define NIC_CR 0x00        /*!< \brief Command register */

+#define NIC_IOPORT 0x10    /*!< \brief I/O data port */

+#define NIC_RESET 0x1f     /*!< \brief Reset port */

+

+/*

+ * Page 0 register offsets.

+ */

+#define NIC_PG0_CLDA0 0x01    /*!< \brief Current local DMA address 0 */

+#define NIC_PG0_PSTART 0x01   /*!< \brief Page start register */

+#define NIC_PG0_CLDA1 0x02    /*!< \brief Current local DMA address 1 */

+#define NIC_PG0_PSTOP 0x02    /*!< \brief Page stop register */

+#define NIC_PG0_BNRY 0x03     /*!< \brief Boundary pointer */

+#define NIC_PG0_TSR 0x04      /*!< \brief Transmit status register */

+#define NIC_PG0_TPSR 0x04     /*!< \brief Transmit page start address */

+#define NIC_PG0_NCR 0x05      /*!< \brief Number of collisions register */

+#define NIC_PG0_TBCR0 0x05    /*!< \brief Transmit byte count register 0 */

+#define NIC_PG0_FIFO 0x06     /*!< \brief FIFO */

+#define NIC_PG0_TBCR1 0x06    /*!< \brief Transmit byte count register 1 */

+#define NIC_PG0_ISR 0x07      /*!< \brief Interrupt status register */

+#define NIC_PG0_CRDA0 0x08    /*!< \brief Current remote DMA address 0 */

+#define NIC_PG0_RSAR0 0x08    /*!< \brief Remote start address register 0 

+                                   Low byte address to read from the buffer. */

+#define NIC_PG0_CRDA1 0x09    /*!< \brief Current remote DMA address 1 */

+#define NIC_PG0_RSAR1 0x09    /*!< \brief Remote start address register 1 

+                                   High byte address to read from the buffer. */

+#define NIC_PG0_RBCR0 0x0a    /*!< \brief Remote byte count register 0 

+                                   Low byte of the number of bytes to read

+                                   from the buffer. */

+#define NIC_PG0_RBCR1 0x0b    /*!< \brief Remote byte count register 1

+                                   High byte of the number of bytes to read

+                                   from the buffer. */

+#define NIC_PG0_RSR 0x0c      /*!< \brief Receive status register */

+#define NIC_PG0_RCR 0x0c      /*!< \brief Receive configuration register */

+#define NIC_PG0_CNTR0 0x0d    /*!< \brief Tally counter 0 (frame alignment errors) */

+#define NIC_PG0_TCR 0x0d      /*!< \brief Transmit configuration register */

+#define NIC_PG0_CNTR1 0x0e    /*!< \brief Tally counter 1 (CRC errors) */

+#define NIC_PG0_DCR 0x0e      /*!< \brief Data configuration register */

+#define NIC_PG0_CNTR2 0x0f    /*!< \brief Tally counter 2 (Missed packet errors) */

+#define NIC_PG0_IMR 0x0f      /*!< \brief Interrupt mask register */

+

+/*

+ * Page 1 register offsets.

+ */

+#define NIC_PG1_PAR0 0x01     /*!< \brief Physical address register 0 */

+#define NIC_PG1_PAR1 0x02     /*!< \brief Physical address register 1 */

+#define NIC_PG1_PAR2 0x03     /*!< \brief Physical address register 2 */

+#define NIC_PG1_PAR3 0x04     /*!< \brief Physical address register 3 */

+#define NIC_PG1_PAR4 0x05     /*!< \brief Physical address register 4 */

+#define NIC_PG1_PAR5 0x06     /*!< \brief Physical address register 5 */

+#define NIC_PG1_CURR 0x07     /*!< \brief Current page register

+                                   The next incoming packet will be stored

+                                   at this page address. */

+#define NIC_PG1_MAR0 0x08     /*!< \brief Multicast address register 0 */

+#define NIC_PG1_MAR1 0x09     /*!< \brief Multicast address register 1 */

+#define NIC_PG1_MAR2 0x0a     /*!< \brief Multicast address register 2 */

+#define NIC_PG1_MAR3 0x0b     /*!< \brief Multicast address register 3 */

+#define NIC_PG1_MAR4 0x0c     /*!< \brief Multicast address register 4 */

+#define NIC_PG1_MAR5 0x0d     /*!< \brief Multicast address register 5 */

+#define NIC_PG1_MAR6 0x0e     /*!< \brief Multicast address register 6 */

+#define NIC_PG1_MAR7 0x0f     /*!< \brief Multicast address register 7 */

+

+/*

+ * Page 2 register offsets.

+ */

+#define NIC_PG2_PSTART 0x01   /*!< \brief Page start register */

+#define NIC_PG2_CLDA0 0x01    /*!< \brief Current local DMA address 0 */

+#define NIC_PG2_PSTOP 0x02    /*!< \brief Page stop register */

+#define NIC_PG2_CLDA1 0x02    /*!< \brief Current local DMA address 1 */

+#define NIC_PG2_RNP 0x03      /*!< \brief Remote next packet pointer */

+#define NIC_PG2_TSPR 0x04     /*!< \brief Transmit page start register */

+#define NIC_PG2_LNP 0x05      /*!< \brief Local next packet pointer */

+#define NIC_PG2_ACU 0x06      /*!< \brief Address counter (upper) */

+#define NIC_PG2_ACL 0x07      /*!< \brief Address counter (lower) */

+#define NIC_PG2_RCR 0x0c      /*!< \brief Receive configuration register */

+#define NIC_PG2_TCR 0x0d      /*!< \brief Transmit configuration register */

+#define NIC_PG2_DCR 0x0e      /*!< \brief Data configuration register */

+#define NIC_PG2_IMR 0x0f      /*!< \brief Interrupt mask register */

+

+/*

+ * Page 3 register offsets.

+ */

+#define NIC_PG3_EECR     0x01    /*!< \brief EEPROM command register */

+#define NIC_PG3_BPAGE    0x02    /*!< \brief Boot-ROM page register */

+#define NIC_PG3_CONFIG0  0x03    /*!< \brief Configuration register 0 (r/o) */

+#define NIC_PG3_CONFIG1  0x04    /*!< \brief Configuration register 1 */

+#define NIC_PG3_CONFIG2  0x05    /*!< \brief Configuration register 2 */

+#define NIC_PG3_CONFIG3  0x06    /*!< \brief Configuration register 3 */

+#define NIC_PG3_CSNSAV   0x08    /*!< \brief CSN save register (r/o) */

+#define NIC_PG3_HLTCLK   0x09    /*!< \brief Halt clock */

+#define NIC_PG3_INTR     0x0b    /*!< \brief Interrupt pins (r/o) */

+

+/*

+ * Command register bits.

+ */

+#define NIC_CR_STP 0x01    /*!< \brief Stop */

+#define NIC_CR_STA 0x02    /*!< \brief Start */

+#define NIC_CR_TXP 0x04    /*!< \brief Transmit packet */

+#define NIC_CR_RD0 0x08    /*!< \brief Remote DMA command bit 0 */

+#define NIC_CR_RD1 0x10    /*!< \brief Remote DMA command bit 1 */

+#define NIC_CR_RD2 0x20    /*!< \brief Remote DMA command bit 2 */

+#define NIC_CR_PS0 0x40    /*!< \brief Page select bit 0 */

+#define NIC_CR_PS1 0x80    /*!< \brief Page select bit 1 */

+

+/*

+ * Interrupt status register bits.

+ */

+#define NIC_ISR_PRX 0x01      /*!< \brief Packet received */

+#define NIC_ISR_PTX 0x02      /*!< \brief Packet transmitted */

+#define NIC_ISR_RXE 0x04      /*!< \brief Receive error */

+#define NIC_ISR_TXE 0x08      /*!< \brief Transmit error */

+#define NIC_ISR_OVW 0x10      /*!< \brief Overwrite warning */

+#define NIC_ISR_CNT 0x20      /*!< \brief Counter overflow */

+#define NIC_ISR_RDC 0x40      /*!< \brief Remote DMA complete */

+#define NIC_ISR_RST 0x80      /*!< \brief Reset status */

+

+/*

+ * Interrupt mask register bits.

+ */

+#define NIC_IMR_PRXE 0x01     /*!< \brief Packet received interrupt enable */

+#define NIC_IMR_PTXE 0x02     /*!< \brief Packet transmitted interrupt enable */

+#define NIC_IMR_RXEE 0x04     /*!< \brief Receive error interrupt enable */

+#define NIC_IMR_TXEE 0x08     /*!< \brief Transmit error interrupt enable */

+#define NIC_IMR_OVWE 0x10     /*!< \brief Overwrite warning interrupt enable */

+#define NIC_IMR_CNTE 0x20     /*!< \brief Counter overflow interrupt enable */

+#define NIC_IMR_RCDE 0x40     /*!< \brief Remote DMA complete interrupt enable */

+

+/*

+ * Data configuration register bits.

+ */

+#define NIC_DCR_WTS 0x01      /*!< \brief Word transfer select */

+#define NIC_DCR_BOS 0x02      /*!< \brief Byte order select */

+#define NIC_DCR_LAS 0x04      /*!< \brief Long address select */

+#define NIC_DCR_LS 0x08       /*!< \brief Loopback select */

+#define NIC_DCR_AR 0x10       /*!< \brief Auto-initialize remote */

+#define NIC_DCR_FT0 0x20      /*!< \brief FIFO threshold select bit 0 */

+#define NIC_DCR_FT1 0x40      /*!< \brief FIFO threshold select bit 1 */

+

+/*

+ * Transmit configuration register bits.

+ */

+#define NIC_TCR_CRC 0x01      /*!< \brief Inhibit CRC */

+#define NIC_TCR_LB0 0x02      /*!< \brief Encoded loopback control bit 0 */

+#define NIC_TCR_LB1 0x04      /*!< \brief Encoded loopback control bit 1 */

+#define NIC_TCR_ATD 0x08      /*!< \brief Auto transmit disable */

+#define NIC_TCR_OFST 0x10     /*!< \brief Collision offset enable */

+

+/*

+ * Transmit status register bits.

+ */

+#define NIC_TSR_PTX 0x01      /*!< \brief Packet transmitted */

+#define NIC_TSR_COL 0x04      /*!< \brief Transmit collided */

+#define NIC_TSR_ABT 0x08      /*!< \brief Transmit aborted */

+#define NIC_TSR_CRS 0x10      /*!< \brief Carrier sense lost */

+#define NIC_TSR_FU 0x20       /*!< \brief FIFO underrun */

+#define NIC_TSR_CDH 0x40      /*!< \brief CD heartbeat */

+#define NIC_TSR_OWC 0x80      /*!< \brief Out of window collision */

+

+/*

+ * Receive configuration register bits.

+ */

+#define NIC_RCR_SEP 0x01      /*!< \brief Save errored packets */

+#define NIC_RCR_AR 0x02       /*!< \brief Accept runt packets */

+#define NIC_RCR_AB 0x04       /*!< \brief Accept broadcast */

+#define NIC_RCR_AM 0x08       /*!< \brief Accept multicast */

+#define NIC_RCR_PRO 0x10      /*!< \brief Promiscuous physical */

+#define NIC_RCR_MON 0x20      /*!< \brief Monitor mode */

+

+/*

+ * Receive status register bits.

+ */

+#define NIC_RSR_PRX 0x01      /*!< \brief Packet received intact */

+#define NIC_RSR_CRC 0x02      /*!< \brief CRC error */

+#define NIC_RSR_FAE 0x04      /*!< \brief Frame alignment error */

+#define NIC_RSR_FO 0x08       /*!< \brief FIFO overrun */

+#define NIC_RSR_MPA 0x10      /*!< \brief Missed packet */

+#define NIC_RSR_PHY 0x20      /*!< \brief Physical/multicast address */

+#define NIC_RSR_DIS 0x40      /*!< \brief Receiver disabled */

+#define NIC_RSR_DFR 0x80      /*!< \brief Deferring */

+

+/*

+ * EEPROM command register bits.

+ */

+#define NIC_EECR_EEM1  0x80    /*!< \brief EEPROM Operating Mode */

+#define NIC_EECR_EEM0  0x40    /*!< \brief  EEPROM Operating Mode

+                                    - 0 0 Normal operation

+                                    - 0 1 Auto-load 

+                                    - 1 0 9346 programming 

+                                    - 1 1 Config register write enab */

+#define NIC_EECR_EECS  0x08    /*!< \brief EEPROM Chip Select */

+#define NIC_EECR_EESK  0x04    /*!< \brief EEPROM Clock */

+#define NIC_EECR_EEDI  0x02    /*!< \brief EEPROM Data In */

+#define NIC_EECR_EEDO  0x01    /*!< \brief EEPROM Data Out */

+

+/*

+ * Configuration register 2 bits.

+ */

+#define NIC_CONFIG2_PL1   0x80 /*!< \brief Network media type */

+#define NIC_CONFIG2_PL0   0x40 /*!< \brief Network media type

+                                    - 0 0 TP/CX auto-detect 

+                                    - 0 1 10baseT 

+                                    - 1 0 10base5 

+                                    - 1 1 10base2 */

+#define NIC_CONFIG2_BSELB 0x20 /*!< \brief BROM disable */

+#define NIC_CONFIG2_BS4   0x10 /*!< \brief BROM size/base */

+#define NIC_CONFIG2_BS3   0x08

+#define NIC_CONFIG2_BS2   0x04

+#define NIC_CONFIG2_BS1   0x02

+#define NIC_CONFIG2_BS0   0x01

+

+/*

+ * Configuration register 3 bits

+ */

+#define NIC_CONFIG3_PNP     0x80 /*!< \brief PnP Mode */

+#define NIC_CONFIG3_FUDUP   0x40 /*!< \brief Full duplex */

+#define NIC_CONFIG3_LEDS1   0x20 /*!< \brief LED1/2 pin configuration 

+                                        - 0 LED1 == LED_RX, LED2 == LED_TX 

+                                        - 1 LED1 == LED_CRS, LED2 == MCSB */

+#define NIC_CONFIG3_LEDS0   0x10 /*!< \brief LED0 pin configration

+                                        - 0 LED0 pin == LED_COL 

+                                        - 1 LED0 pin == LED_LINK */

+#define NIC_CONFIG3_SLEEP   0x04 /*!< \brief Sleep mode */

+#define NIC_CONFIG3_PWRDN   0x02 /*!< \brief Power Down */

+#define NIC_CONFIG3_ACTIVEB 0x01 /*!< \brief inverse of bit 0 in PnP Act Reg */

+

+/*@}*/

+

+/*!

+ * \brief Read byte from controller register.

+ */

+#define nic_read(reg) *(base + (reg))

+

+/*!

+ * \brief Write byte to controller register.

+ */

+#define nic_write(reg, data) *(base + (reg)) = data

+

+#endif

diff --git a/contiki-avr/uip/uip_arch.c b/contiki-avr/uip/uip_arch.c
new file mode 100644
index 0000000..9a0ce7d
--- /dev/null
+++ b/contiki-avr/uip/uip_arch.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.3 2005/02/24 22:04:19 oliverschmidt Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add_rcv_nxt(u16_t n)
+{
+  uip_conn->rcv_nxt[3] += (n & 0xff);
+  uip_conn->rcv_nxt[2] += (n >> 8);
+
+  if(uip_conn->rcv_nxt[2] < (n >> 8)) {
+    ++uip_conn->rcv_nxt[1];    
+    if(uip_conn->rcv_nxt[1] == 0) {
+      ++uip_conn->rcv_nxt[0];
+    }
+  }
+  
+  
+  if(uip_conn->rcv_nxt[3] < (n & 0xff)) {
+    ++uip_conn->rcv_nxt[2];  
+    if(uip_conn->rcv_nxt[2] == 0) {
+      ++uip_conn->rcv_nxt[1];    
+      if(uip_conn->rcv_nxt[1] == 0) {
+	++uip_conn->rcv_nxt[0];
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  
+  uip_acc32[3] = op32[3] + (op16 & 0xff);
+  uip_acc32[2] = op32[2] + (op16 >> 8);
+  uip_acc32[1] = op32[1];
+  uip_acc32[0] = op32[0];
+  
+  if(uip_acc32[2] < (op16 >> 8)) {
+    ++uip_acc32[1];    
+    if(uip_acc32[1] == 0) {
+      ++uip_acc32[0];
+    }
+  }
+  
+  
+  if(uip_acc32[3] < (op16 & 0xff)) {
+    ++uip_acc32[2];  
+    if(uip_acc32[2] == 0) {
+      ++uip_acc32[1];    
+      if(uip_acc32[1] == 0) {
+	++uip_acc32[0];
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
+static u16_t
+chksum(u16_t *sdata, u16_t len)
+{ 
+  u16_t acc;
+  for(acc = 0; len > 1; len -= 2) {
+    acc += *sdata;
+    if(acc < *sdata) {
+      /* Overflow, so we add the carry to acc (i.e., increase by
+         one). */
+      ++acc;
+    }
+    ++sdata;
+  }
+
+  /* add up any odd byte */
+  if(len == 1) {
+    acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
+    if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
+      ++acc;
+    }
+  }
+
+  return acc;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{
+  return chksum((u16_t *)&uip_buf[UIP_LLH_LEN], UIP_IPH_LEN);
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  u16_t hsum, sum;
+
+  
+  /* Compute the checksum of the TCP header. */
+  hsum = uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN], UIP_TCPH_LEN);
+
+  /* Compute the checksum of the data in the TCP packet and add it to
+     the TCP header checksum. */
+  sum = uip_chksum((u16_t *)uip_appdata,
+		   (u16_t)(((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) -
+		   UIP_IPTCPH_LEN)));
+
+  if((sum += hsum) < hsum) {
+    ++sum;
+  }
+  
+  if((sum += BUF->srcipaddr[0]) < BUF->srcipaddr[0]) {
+    ++sum;
+  }
+  if((sum += BUF->srcipaddr[1]) < BUF->srcipaddr[1]) {
+    ++sum;
+  }
+  if((sum += BUF->destipaddr[0]) < BUF->destipaddr[0]) {
+    ++sum;
+  }
+  if((sum += BUF->destipaddr[1]) < BUF->destipaddr[1]) {
+    ++sum;
+  }
+  if((sum += (u16_t)htons((u16_t)IP_PROTO_TCP)) < (u16_t)htons((u16_t)IP_PROTO_TCP)) {
+    ++sum;
+  }
+
+  hsum = (u16_t)HTONS((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN);
+  
+  if((sum += hsum) < hsum) {
+    ++sum;
+  }
+  
+  return sum;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-avr/uip/uip_arch.h b/contiki-avr/uip/uip_arch.h
new file mode 100644
index 0000000..1d393c5
--- /dev/null
+++ b/contiki-avr/uip/uip_arch.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.2 2005/01/26 23:36:23 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki-c128/Makefile b/contiki-c128/Makefile
new file mode 100644
index 0000000..b46ffec
--- /dev/null
+++ b/contiki-c128/Makefile
@@ -0,0 +1,51 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.9 2005/05/07 13:29:39 oliverschmidt Exp $
+#
+
+all: contiki loader-arch-module.o loader-arch-module-dsc.o contiki-labels.o \
+     about.prg about.dsc processes.prg processes.dsc \
+     netconf.prg netconf.dsc memstat.prg memstat.dsc 
+
+CONTIKI=../contiki
+CONTIKICC65=../contiki-cc65
+SYS=c128
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+CFLAGS=$(CFLAGSCC65) -DWITH_LOADER_ARCH
+
+contiki: contiki-main.o strncasecmp.o petsciiconv.o \
+ ctk-conio.o ctk.o arg.o ek.o timer.o \
+ program-handler.o loader-arch.o \
+ about-dsc.o netconf-dsc.o processes-dsc.o memstat-dsc.o
+	$(CL) $(CLFLAGS) -o contiki -t $(SYS) $^
+
diff --git a/contiki-c128/conf/cc-conf.h b/contiki-c128/conf/cc-conf.h
new file mode 100644
index 0000000..31afc18
--- /dev/null
+++ b/contiki-c128/conf/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/08 18:08:28 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-c128/conf/clock-conf.h b/contiki-c128/conf/clock-conf.h
new file mode 100644
index 0000000..a690e15
--- /dev/null
+++ b/contiki-c128/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-c128/conf/ctk-conf.h b/contiki-c128/conf/ctk-conf.h
new file mode 100644
index 0000000..6317da6
--- /dev/null
+++ b/contiki-c128/conf/ctk-conf.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.3 2004/06/27 12:42:20 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          1
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-c128/conf/ek-conf.h b/contiki-c128/conf/ek-conf.h
new file mode 100644
index 0000000..eb9ade7
--- /dev/null
+++ b/contiki-c128/conf/ek-conf.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.2 2004/07/04 19:51:19 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_NUMEVENTS   32    /* Must be 2^n */
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 16
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-c128/conf/program-handler-conf.h b/contiki-c128/conf/program-handler-conf.h
new file mode 100644
index 0000000..022d72e
--- /dev/null
+++ b/contiki-c128/conf/program-handler-conf.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.1 2005/02/15 14:57:09 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-c128/conf/uip-conf.h b/contiki-c128/conf/uip-conf.h
new file mode 100644
index 0000000..30b6f66
--- /dev/null
+++ b/contiki-c128/conf/uip-conf.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.2 2004/07/04 19:51:19 adamdunkels Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE     310
+
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+#define UIP_CONF_UDP             1
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-c128/conf/www-conf.h b/contiki-c128/conf/www-conf.h
new file mode 100644
index 0000000..b63629e
--- /dev/null
+++ b/contiki-c128/conf/www-conf.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2003/04/08 18:08:30 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 100
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+#define WWW_CONF_MAX_INPUTVALUELEN  34
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-c128/contiki-main.c b/contiki-c128/contiki-main.c
new file mode 100644
index 0000000..7c443f9
--- /dev/null
+++ b/contiki-c128/contiki-main.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: contiki-main.c,v 1.4 2004/07/04 19:51:19 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+#include "processes-dsc.h"
+#include "about-dsc.h"
+#include "netconf-dsc.h"
+#include "memstat-dsc.h"
+
+#include "uiplib.h"
+#include "uip.h"
+#include "uip_arp.h"
+#if WITH_TFE
+#include "cs8900a.h"
+#endif /* WITH_TFE */
+#include "resolv.h"
+
+
+
+/*-----------------------------------------------------------------------------------*/
+int
+main(void)
+{
+  /*  toggle_videomode(); */ /* Turn on 80 column mode */
+
+  ek_init();
+  
+#ifdef WITH_UIP
+  uip_init();
+  tcpip_init();
+  resolv_init();
+
+#ifdef WITH_TFE
+  cs8900a_init();
+#endif /* WITH_TFE */
+
+  
+#ifdef WITH_RS232
+  rs232dev_init();
+#endif /* WITH_RS232 */
+  
+#ifdef WITH_TAPDEV
+  tapdev_init();
+#endif /* WITH_TAPDEV */
+
+
+#endif /* WITH_UIP */
+	    
+  ctk_init();
+     
+  program_handler_init();
+  program_handler_add(&about_dsc, "About", 1);
+  program_handler_add(&netconf_dsc, "Netconf", 1);  
+  program_handler_add(&processes_dsc, "Processes", 1);
+  program_handler_add(&memstat_dsc, "Memory stats", 1);  
+
+
+  while(1) {
+    ek_run();
+  }
+
+  clrscr();
+  
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
diff --git a/contiki-c128/ctk/ctk-arch.h b/contiki-c128/ctk/ctk-arch.h
new file mode 100644
index 0000000..42c2c7e
--- /dev/null
+++ b/contiki-c128/ctk/ctk-arch.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.3 2004/07/04 19:51:19 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include <ctype.h>
+#include "ctk-conio.h"
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-c128/ctk/ctk-conio-conf.h b/contiki-c128/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..a88dbe1
--- /dev/null
+++ b/contiki-c128/ctk/ctk-conio-conf.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.3 2004/08/12 21:54:12 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 1
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+#define BACKGROUNDCOLOR     COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+#define BACKGROUNDCOLOR     COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-c64/Makefile b/contiki-c64/Makefile
new file mode 100644
index 0000000..3d73033
--- /dev/null
+++ b/contiki-c64/Makefile
@@ -0,0 +1,74 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.12 2005/04/24 23:09:31 oliverschmidt Exp $
+#
+
+CONTIKI=../contiki
+CONTIKICC65=../contiki-cc65
+
+usage:
+	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+	@echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+	@echo 'is one of the following:'
+	@echo all
+	@echo c64
+	@echo programs
+	@echo d64
+	@echo programs
+	@echo '(Also check the Makefile for more targets to try...)'
+
+all: clean c64 programs
+
+programs:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs
+c64:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64
+
+c64-exo:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64 contiki-exo
+
+wget:
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64-wget
+
+
+CCDEPFLAGS=-D__CBM__ -D__C64__ -DCTK_HIRES -DWITH_UIP -DWITH_LOADER_ARCH -I/usr/local/lib/cc65/include
+
+include $(CONTIKICC65)/Makefile.cc65
+
+d64:	
+	c1541 -format contiki,00 d64 contiki.d64
+	c1541 -attach contiki.d64 -write contiki
+	c1541 -attach contiki.d64 -write config.cfg
+	c1541 -attach contiki.d64 $(foreach dsc, $(wildcard *.dsc), -write $(dsc))
+	c1541 -attach contiki.d64 $(foreach prg, $(wildcard *.prg), -write $(prg))
+	c1541 -attach contiki.d64 $(foreach sav, $(wildcard *.sav), -write $(sav))
+	c1541 -attach contiki.d64 $(foreach drv, $(wildcard *.drv), -write $(drv))
+	c1541 -attach contiki.d64 $(foreach ser, $(wildcard *.ser), -write $(ser))
+	c1541 -attach contiki.d64 -list
diff --git a/contiki-c64/Makefile.c64 b/contiki-c64/Makefile.c64
new file mode 100644
index 0000000..bfdae9f
--- /dev/null
+++ b/contiki-c64/Makefile.c64
@@ -0,0 +1,56 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64,v 1.17 2005/04/24 23:24:24 oliverschmidt Exp $
+#
+
+all: contiki contiki-labels.o
+
+SYS=c64
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+CFLAGS:=$(CFLAGSCC65) \
+        -DCTK_HIRES -DWITH_UIP -DWITH_LOADER_ARCH -DWITH_ETHERNET
+
+contiki:  main.o save-driveunit.o petsciiconv.o \
+ ctk.o ek.o ek-service.o loader-arch.o arg.o timer.o \
+ configedit-dsc.o processes-dsc.o directory-dsc.o \
+ cfs.o cfs-init.o \
+ $(UIP) \
+ program-handler.o \
+ ctk-draw.o
+# ctk-hires.o ctk-hires-asm.o ctk-hires-theme-default.o \
+# ctk-mouse-arch.o ctk-mouse-joy.o ctk-mouse-asm.o 
+	cl65 -C c64.cfg -Ln contiki-labels -o contiki -t $(SYS) $^
+
+contiki-exo: contiki
+	exomizer -s sys -o contiki-exo contiki
+	mv contiki-exo contiki
diff --git a/contiki-c64/Makefile.c64-wget b/contiki-c64/Makefile.c64-wget
new file mode 100644
index 0000000..fd85247
--- /dev/null
+++ b/contiki-c64/Makefile.c64-wget
@@ -0,0 +1,60 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64-wget,v 1.5 2005/04/24 23:24:24 oliverschmidt Exp $
+#
+
+all: contiki-exo
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+SYS=c64
+
+CFLAGS:=$(CFLAGSCC65) -t $(SYS) \
+        -DCTK_HIRES \
+	-DWITH_UIP -DWITH_RRNET -DWITH_ETHERNET \
+        -DCONTIKI_VERSION_STRING='"Contiki 1.2-devel1 IRC/DHCP edition"'
+
+contiki:  main-rrnet.o petsciiconv.o \
+ ctk.o ek.o ek.o ek-service.o arg.o timer.o \
+ program-handler.o \
+ $(UIP) uip_arp.o cs8900a.o rrnet-drv.o rrnet-drv-asm.o \
+ ctk-80col.o ctk-80col-asm.o ctk-draw.o \
+ netconf.o netconf-dsc.o \
+ dhcp-dsc.o dhcp.o dhcpc.o lc-asm.o \
+ irc.o ircc.o ircc-strings.o socket.o uipbuf.o  irc-dsc.o \
+# $(WGET) wget-dsc.o c64-dio.o c64-dio-asm.o
+	cl65 -Ln labels -o contiki -t $(SYS) $^
+
+contiki-exo: contiki
+	exomizer -s sys -o contiki-exo contiki
+	
\ No newline at end of file
diff --git a/contiki-c64/Makefile.programs b/contiki-c64/Makefile.programs
new file mode 100644
index 0000000..2924143
--- /dev/null
+++ b/contiki-c64/Makefile.programs
@@ -0,0 +1,171 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.42 2005/05/07 14:36:47 oliverschmidt Exp $
+#
+
+all: loader-arch-module.o loader-arch-module-dsc.o contiki-labels.o \
+     welcome.prg \
+     about.prg about.dsc \
+     netconf.prg netconf.dsc \
+     processes.prg processes.dsc \
+     www.prg www.dsc \
+     telnet.prg telnet.dsc \
+     memstat.prg memstat.dsc \
+     webserver.prg webserver.dsc \
+     wget.prg wget.dsc \
+     directory.prg directory.dsc \
+     ssfire.sav ssfire.dsc \
+     plasma.sav plasma.dsc \
+     rrnet.drv rrnet.dsc rrnet-dump.drv \
+     tfe.drv tfe.dsc \
+     eth64.drv eth64.dsc eth64-dump.drv \
+     config.prg configedit.prg configedit.dsc config.cfg \
+     shell.prg shell.dsc \
+     telnetd.prg telnetd.dsc \
+     ftp.prg ftp.dsc \
+     editor.prg editor.dsc \
+     cfs-cbm.drv \
+     email.prg \
+     ctk-text.drv ctk-default.drv ctk-80col.drv \
+     irc.prg irc.dsc \
+     slip.drv slip.dsc \
+     cgterm.prg cgterm.dsc \
+     dhcp.prg dhcp.dsc
+#     vnc.prg  \
+#     mtest.prg warmboot.prg lc-test
+#     blueround.prg blueround.dsc \
+#     enabler.prg enabler.dsc \
+#     springlight.prg springlight.dsc \
+#     default.prg default.dsc \
+#     ravenpine.prg ravenpine.dsc \
+#     slip-ss.drv \
+#     calc.prg \
+#     ssconfig.prg \
+
+SYS=c64
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+CFLAGS:=$(CFLAGSCC65) \
+        -DCTK_HIRES \
+	-DWITH_LOADER_ARCH \
+        -DWITH_UIP -DWITH_ETHERNET
+
+config.cfg:
+	echo C CFS-CBM.DRV > config.cfg
+	echo T CTK-80COL.DRV >> config.cfg
+	echo . >> config.cfg
+
+directory.prg: $(DIRECTORY)
+
+shell.prg: $(SHELL_)
+
+telnetd.prg: $(TELNETD)
+
+configedit.prg: configedit.o #c64-fs-write.o
+
+email.prg: $(EMAIL) lc-asm.o
+
+www.prg: $(WWW)
+
+irc.prg: $(IRC) lc-asm.o
+
+cgterm.prg: cgterm.o psock.o uipbuf.o lc-asm.o
+
+dhcp.prg: $(DHCP) lc-asm.o
+
+webserver.prg: $(WEBSERVER) lc-asm.o #c64-fs-raw.o
+
+telnet.prg: $(TELNET)
+
+tfe.drv: tfe-drv.o cs8900a.o tfe-drv-asm.o uip_arp.o
+
+rrnet.drv: rrnet-drv.o cs8900a.o rrnet-drv-asm.o uip_arp.o
+
+rrnet-dump.drv: rrnet-dump-drv.o cs8900a.o rrnet-drv-asm.o uip_arp.o tcpdump.o
+
+eth64.drv: eth64-drv.o lan91c96.o uip_arp.o
+
+eth64-dump.drv: eth64-dump-drv.o lan91c96.o uip_arp.o tcpdump.o
+
+slip.drv: slip-drv.o rs232dev.o
+
+slip-dump.drv: tcpdump.o slip-dump-drv.o rs232dev.o
+
+slip-ss.drv: slip-drv.o rs232dev-ss.o rs232silversurfer.o contiki-labels.o
+	cl65 --module -t $(SYS) -o $@ loader-arch-module.o $^
+
+
+wget.prg: wget.o webclient.o http-strings.o http-user-agent-string.o c64-dio.o c64-dio-asm.o
+
+ftp.prg: $(FTP)
+
+ftp.dsc: ftp-dsc.o
+
+editor.prg: $(EDITOR)
+
+VNC=vnc.o vnc-viewer.o vnc-draw.o vnc-draw-asm.o
+vnc.prg: $(VNC)
+
+ctk-vnc.drv: ctk-vncserver-service.o libconio.o vnc-server.o vnc-out.o ctk-vncfont.o contiki-labels.o
+	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+ctk-text.drv: ctk-conio-service.o contiki-labels.o
+	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+ctk-80col.drv: ctk-80col.o ctk-80col-asm.o contiki-labels.o
+	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+ctk-default.drv: ctk-hires-service.o ctk-hires-asm.o ctk-hires-theme-default.o contiki-labels.o
+	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+memstat.prg: memstat.o
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
+	cl65 -o lc-test -t c64 $^
\ No newline at end of file
diff --git a/contiki-c64/README b/contiki-c64/README
new file mode 100644
index 0000000..e574af6
--- /dev/null
+++ b/contiki-c64/README
@@ -0,0 +1,2 @@
+This is the Commodore 64 port of Contiki. See the Contiki homepage for
+more information: http://www.sics.se/~adam/contiki/
diff --git a/contiki-c64/apps/blueround-dsc.c b/contiki-c64/apps/blueround-dsc.c
new file mode 100644
index 0000000..221f293
--- /dev/null
+++ b/contiki-c64/apps/blueround-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: blueround-dsc.c,v 1.4 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon blueround_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(blueround_dsc,
+    "Blueround CTK theme",
+    "blueround.prg",
+    blueround_init,
+    &blueround_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char blueroundicon_bitmap[3*3*8] = {
+  0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00,
+  0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00,
+  0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char blueroundicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon blueround_icon =
+  {CTK_ICON("Blueround", blueroundicon_bitmap, blueroundicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/cgterm-dsc.c b/contiki-c64/apps/cgterm-dsc.c
new file mode 100644
index 0000000..aae1a33
--- /dev/null
+++ b/contiki-c64/apps/cgterm-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: cgterm-dsc.c,v 1.3 2005/04/19 22:01:53 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon cgterm_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(cgterm_dsc,
+    "Program for connecting to C64 Telnet BBSes",
+    "cgterm.prg",
+    cgterm_init,
+    &cgterm_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char cgtermicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char cgtermicon_textmap[9] = {
+  'T', 'e', 'l',
+  'n', 'e', 't',
+  'B', 'B', 'S'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon cgterm_icon =
+  {CTK_ICON("C/G terminal", cgtermicon_bitmap, cgtermicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/cgterm.c b/contiki-c64/apps/cgterm.c
new file mode 100644
index 0000000..2bcb491
--- /dev/null
+++ b/contiki-c64/apps/cgterm.c
@@ -0,0 +1,243 @@
+#include "contiki.h"
+#include "psock.h"
+#include "ctk-draw.h"
+
+#include <cbm.h>
+#include <c64.h>
+#include <string.h>
+
+static struct {
+  struct psock sout, sin;
+  struct pt inpt, outpt;
+  char outputbuf[200];
+  char inputbuf[200];
+  unsigned short len;
+} s;
+
+#define CURSOR_ON()  *(char *)0xcc = 0
+#define CURSOR_OFF() *(char *)0xcc = 1
+static void ctkmode(void);
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send(void))
+{
+  PSOCK_BEGIN(&s.sout);
+  
+  PSOCK_SEND(&s.sout, s.outputbuf, s.len);
+  PSOCK_END(&s.sout);    
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(void))
+{
+  ctk_arch_key_t c;
+  char *ptr;
+  
+  PT_BEGIN(&s.outpt);
+  
+  while(1) {
+    PT_WAIT_UNTIL(&s.outpt, (ctk_mode_get() == CTK_MODE_EXTERNAL) &&
+		  kbhit());
+
+
+    ptr = s.outputbuf;
+    s.len = 0;    
+    while(kbhit() && s.len < sizeof(s.outputbuf)) {
+      c = cgetc();
+      *ptr = c;
+      ++ptr;
+      ++s.len;   
+    }
+
+    PT_WAIT_THREAD(&s.outpt, send());
+  }
+  PT_END(&s.outpt);      
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(void))
+{
+  unsigned short i;
+  char *ptr;
+  char next;
+  
+  next = 1; 
+  PT_BEGIN(&s.inpt);
+  
+  while(1) {
+    /* Wait until data arrives. */
+    next = 0;
+    PT_WAIT_UNTIL(&s.inpt, next && uip_newdata());
+
+    CURSOR_OFF();
+    /* Print it out on the screen. */
+    ptr = (char *)uip_appdata;
+    for(i = 0; i < uip_len; ++i) {
+      cbm_k_bsout(*ptr);
+      ++ptr;
+    }
+    CURSOR_ON();
+  }  
+  PT_END(&s.inpt);
+}
+/*---------------------------------------------------------------------------*/
+static void
+appcall(void *state)
+{
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    ctkmode();
+  } else if(uip_connected()) {
+  } else {
+    handle_input();
+    handle_output();   
+  }
+}
+/*---------------------------------------------------------------------------*/
+static struct uip_conn *
+connect(u16_t *host, u16_t port)
+{
+  PSOCK_INIT(&s.sin, s.inputbuf, sizeof(s.inputbuf));
+  PSOCK_INIT(&s.sout, s.inputbuf, sizeof(s.inputbuf));
+  PT_INIT(&s.inpt);
+  PT_INIT(&s.outpt);
+  return tcp_connect(host, htons(port), NULL);
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler);
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "C/G terminal", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+static struct uip_conn *conn;
+static u16_t serveraddr[2];
+static u16_t serverport;
+/*---------------------------------------------------------------------------*/
+static struct ctk_window window;
+static struct ctk_label hostlabel =
+  {CTK_LABEL(0, 0, 4, 1, "Host")};
+static char host[32];
+static struct ctk_textentry hostentry =
+  {CTK_TEXTENTRY(5, 0, 20, 1, host, sizeof(host) - 1)};
+static struct ctk_label portlabel =
+  {CTK_LABEL(27, 0, 4, 1, "Port")};
+static char port[7];
+static struct ctk_textentry portentry =
+  {CTK_TEXTENTRY(32, 0, 4, 1, port, sizeof(port) - 1)};
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(0, 2, 7, "Connect")};
+static struct ctk_button switchbutton =
+  {CTK_BUTTON(30, 2, 6, "Switch")};
+static struct ctk_label helplabel =
+  {CTK_LABEL(0, 4, 37, 1, "RUN/STOP to return from terminal view")};
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cgterm_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+ctkmode(void)
+{
+  ctk_mode_set(CTK_MODE_NORMAL);
+  ctk_draw_init();
+  ctk_desktop_redraw(NULL);
+}
+/*---------------------------------------------------------------------------*/
+static void
+textmode(void)
+{
+  ctk_mode_set(CTK_MODE_EXTERNAL);
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+  
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */
+
+  CURSOR_ON();
+}     
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t *ipaddr;
+  char *cptr;
+    
+  if(ev == tcpip_event) {
+    appcall(data);
+  } else if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 38, 5, "C/G term");
+    CTK_WIDGET_ADD(&window, &hostlabel);
+    CTK_WIDGET_ADD(&window, &hostentry);
+    CTK_WIDGET_ADD(&window, &portlabel);
+    CTK_WIDGET_ADD(&window, &portentry);
+    CTK_WIDGET_ADD(&window, &connectbutton);
+    CTK_WIDGET_ADD(&window, &switchbutton);
+    CTK_WIDGET_ADD(&window, &helplabel);
+    ctk_window_open(&window);
+  } else if(ev == ctk_signal_widget_activate) {
+
+    if(data == (ek_data_t)&switchbutton) {
+      textmode();
+    } else if(data == (ek_data_t)&connectbutton) {
+      serverport = 0;
+      for(cptr = port; *cptr != ' ' && *cptr != 0; ++cptr) {
+	if(*cptr < '0' || *cptr > '9') {
+	  return;
+	}
+	serverport = 10 * serverport + *cptr - '0';
+      }
+
+      ipaddr = serveraddr;
+      if(uiplib_ipaddrconv(host, (u8_t *)serveraddr) == 0) {
+	ipaddr = resolv_lookup(host);
+	if(ipaddr == NULL) {
+	  resolv_query(host);
+	} else {
+	  uip_ipaddr_copy(serveraddr, ipaddr);
+	}
+      }
+      if(ipaddr != NULL) {      
+	conn = connect(serveraddr, serverport);
+	if(conn != NULL) {
+	  memset((char *)0x0400, 0x20, 40*25);
+	  memset((char *)0xd800, 0x01, 40*25);
+	  textmode();
+	}
+      }
+    }
+  } else if(ev == resolv_event_found) {
+    ipaddr = resolv_lookup(host);
+    if(ipaddr != NULL) {
+      uip_ipaddr_copy(serveraddr, ipaddr);
+      
+      conn = connect(serveraddr, serverport);
+      if(conn != NULL) {
+	memset((char *)0x0400, 0x20, 40*25);
+	memset((char *)0xd800, 0x01, 40*25);
+	textmode();
+      }
+    }
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_window_close) {
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+  } 
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  if(ctk_mode_get() == CTK_MODE_EXTERNAL) {
+    if(CIA1.prb == 0x7f) {
+      ctkmode();
+    } else if(kbhit() && conn != NULL) {
+      tcpip_poll_tcp(conn);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/config.c b/contiki-c64/apps/config.c
new file mode 100644
index 0000000..8fe2814
--- /dev/null
+++ b/contiki-c64/apps/config.c
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: config.c,v 1.11 2005/05/12 21:26:46 oliverschmidt Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadfile(char *str)
+{
+  char *nt;
+
+  nt = nullterminate(str);
+  
+  /* Call loader function. */
+  program_handler_load(str, NULL);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+screensaverconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  program_handler_setscreensaver(str);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t addr[2];
+static char *
+ipaddrconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+    uip_sethostaddr(addr);
+  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+    uip_setnetmask(addr);
+  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+    uip_setdraddr(addr);
+  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+    resolv_conf(addr);
+  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+  {{'n', loadfile},
+   {'t', loadfile},
+   {'c', loadfile},   
+   {'s', screensaverconf},   
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+configscript(void)
+{
+  static char line[40], *lineptr;
+  /*  static struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, configparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+  arg_free(arg);
+  program_handler_setscreensaver(NULL);  
+  configscript();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/configedit-dsc.c b/contiki-c64/apps/configedit-dsc.c
new file mode 100644
index 0000000..ddeb5a9
--- /dev/null
+++ b/contiki-c64/apps/configedit-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.5 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+    "Edit Contiki configuration",
+    "configedit.prg",
+    configedit_init,
+    &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+  'C', 'F', 'G',
+  ' ', ' ', ' ',
+  'C', 'F', 'G'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon configedit_icon =
+  {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/configedit-dsc.h b/contiki-c64/apps/configedit-dsc.h
new file mode 100644
index 0000000..4dcd8a5
--- /dev/null
+++ b/contiki-c64/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2003/08/06 22:57:05 adamdunkels Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-c64/apps/configedit.c b/contiki-c64/apps/configedit.c
new file mode 100644
index 0000000..688bd7f
--- /dev/null
+++ b/contiki-c64/apps/configedit.c
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.14 2004/09/14 07:35:23 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk-draw-service.h"
+#include "packet-service.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "program-handler.h"
+
+#include "cfs.h"
+
+#include "loader.h"
+
+#include <stdio.h>
+
+#include <string.h>
+
+/* TCP/IP configuration window. */
+static struct ctk_window window;
+
+#define LABELMAXWIDTH 12
+
+static struct ctk_label cfslabel =
+  {CTK_LABEL(0, 1, LABELMAXWIDTH, 1, "Disk driver")};
+static char cfs[25];
+static struct ctk_textentry cfstextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 1, 16, 1, cfs, 24)};
+
+static struct ctk_label themelabel =
+  {CTK_LABEL(0, 3, LABELMAXWIDTH, 1, "CTK theme")};
+static char theme[25];
+static struct ctk_textentry themetextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 3, 16, 1, theme, 24)};
+
+static struct ctk_label driverlabel =
+  {CTK_LABEL(0, 5, LABELMAXWIDTH, 1, "Net driver")};
+static char driver[25];
+static struct ctk_textentry drivertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 5, 16, 1, driver, 24)};
+
+static struct ctk_label screensaverlabel =
+  {CTK_LABEL(0, 7, LABELMAXWIDTH, 1, "Screensaver")};
+static char screensaver[25];
+static struct ctk_textentry screensavertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 7, 16, 1, screensaver, 24)};
+
+
+static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 9, LABELMAXWIDTH, 1, "IP address")};
+static char ipaddr[25];
+static struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 9, 16, 1, ipaddr, 24)};
+static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 11, LABELMAXWIDTH, 1, "Netmask")};
+static char netmask[25];
+static struct ctk_textentry netmasktextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 11, 16, 1, netmask, 24)};
+static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 13, LABELMAXWIDTH, 1, "Gateway")};
+static char gateway[25];
+static struct ctk_textentry gatewaytextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 13, 16, 1, gateway, 24)};
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 15, LABELMAXWIDTH, 1, "DNS server")};
+static char dnsserver[25];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 15, 16, 1, dnsserver, 24)};
+
+static struct ctk_button savebutton =
+  {CTK_BUTTON(0, 17, 12, "Save & close")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(24, 17, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(configedit_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Config editor", NULL, configedit_sighandler, NULL)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Config editor", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+/*-----------------------------------------------------------------------------------*/
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+    
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char * __fastcall__
+copystr(char *dst, char *src, int len)
+{
+  char *nt = nullterminate(src);
+  strncpy(dst, src, len);
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loaddriver(char *str)
+{
+  return copystr(driver, str, sizeof(driver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadtheme(char *str)
+{
+  return copystr(theme, str, sizeof(theme));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadcfs(char *str)
+{
+  return copystr(cfs, str, sizeof(cfs));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadscreensaver(char *str)
+{
+  return copystr(screensaver, str, sizeof(screensaver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+ipaddrconf(char *str)
+{
+  return copystr(ipaddr, str, sizeof(ipaddr));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  return copystr(netmask, str, sizeof(netmask));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  return copystr(gateway, str, sizeof(gateway));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  return copystr(dnsserver, str, sizeof(dnsserver));
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry initparsetab[] =
+  {{'n', loaddriver},
+   {'t', loadtheme},
+   {'c', loadcfs},
+   {'s', loadscreensaver},
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+initscript(void)
+{
+  char line[40], *lineptr;
+  /*  struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, initparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+static int
+makeline(char *line, char c, char *str)
+{
+  int len;
+
+  len = strlen(str);
+  
+  line[0] = c;
+  line[1] = ' ';
+  strcpy(&line[2], str);
+  line[2 + len] = '\n';
+  line[3 + len] = 0;
+  return len + 3;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+savescript(void)
+{
+  char line[40];
+  /*  struct c64_fs_file f;*/
+  int f;
+  
+  f = cfs_open("@:config.cfg", CFS_WRITE);
+  if(f == -1) {
+    log_message("Could not open config.cfg", "");
+    return;
+  }
+  if(cfs[0] != 0) {
+    cfs_write(f, line, makeline(line, 'c', cfs));
+  }
+  if(theme[0] != 0) {
+    cfs_write(f, line, makeline(line, 't', theme));
+  }
+  if(driver[0] != 0) {
+    cfs_write(f, line, makeline(line, 'n', driver));
+  }
+  if(ipaddr[0] != 0) {
+    cfs_write(f, line, makeline(line, 'i', ipaddr));
+  }
+  if(netmask[0] != 0) {
+    cfs_write(f, line, makeline(line, 'm', netmask));
+  }
+  if(gateway[0] != 0) {
+    cfs_write(f, line, makeline(line, 'r', gateway));
+  }
+  if(dnsserver[0] != 0) {
+    cfs_write(f, line, makeline(line, 'd', dnsserver));
+  }
+  
+  if(screensaver[0] != 0) {
+    cfs_write(f, line, makeline(line, 's', screensaver));
+  }
+  
+  strcpy(line, ".\n\0\n\n\n");
+  cfs_write(f, line, strlen(line));
+  
+  cfs_close(f);
+  
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(configedit_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------------*/
+static void
+configedit_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit_services(void)
+{
+  cfs_init_init(NULL);
+  ctk_draw_quit();  
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create window. */
+    ctk_window_new(&window, 32, 18, "Config editor");
+
+    CTK_WIDGET_ADD(&window, &cfslabel);  
+    CTK_WIDGET_ADD(&window, &cfstextentry);
+
+    CTK_WIDGET_ADD(&window, &themelabel);  
+    CTK_WIDGET_ADD(&window, &themetextentry);
+    
+    CTK_WIDGET_ADD(&window, &driverlabel);  
+    CTK_WIDGET_ADD(&window, &drivertextentry);
+
+    CTK_WIDGET_ADD(&window, &screensaverlabel);  
+    CTK_WIDGET_ADD(&window, &screensavertextentry);
+
+    CTK_WIDGET_ADD(&window, &ipaddrlabel);  
+    CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+    CTK_WIDGET_ADD(&window, &netmasklabel);
+    CTK_WIDGET_ADD(&window, &netmasktextentry);
+    CTK_WIDGET_ADD(&window, &gatewaylabel);
+    CTK_WIDGET_ADD(&window, &gatewaytextentry);
+    CTK_WIDGET_ADD(&window, &dnsserverlabel);
+    CTK_WIDGET_ADD(&window, &dnsservertextentry);
+
+    CTK_WIDGET_ADD(&window, &savebutton);
+    CTK_WIDGET_ADD(&window, &cancelbutton);    
+    
+    CTK_WIDGET_FOCUS(&window, &cfstextentry);  
+
+    /* Fill the configuration strings with values from the current
+       configuration */
+    initscript();
+    
+    ctk_window_open(&window);
+
+  } else if(ev == ctk_signal_button_activate) {   
+    if(data == (ek_data_t)&savebutton) {
+      savescript();
+      quit_services();
+      ctk_window_close(&window);
+      configedit_quit();
+      program_handler_load("config.prg", NULL);
+    } else if(data == (ek_data_t)&cancelbutton) {
+      ctk_window_close(&window);
+      configedit_quit();
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&window);
+    configedit_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/default-dsc.c b/contiki-c64/apps/default-dsc.c
new file mode 100644
index 0000000..60eb33b
--- /dev/null
+++ b/contiki-c64/apps/default-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: default-dsc.c,v 1.4 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon default_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(default_dsc,
+    "Default CTK theme",
+    "default.prg",
+    default_init,
+    &default_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char defaulticon_bitmap[3*3*8] = {
+  0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0,
+  0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00,
+  0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00,
+  0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,
+  0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff  
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char defaulticon_textmap[9] = {
+  '+', '=', '+',
+  '|', 'D', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon default_icon =
+  {CTK_ICON("Default", defaulticon_bitmap, defaulticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/enabler-dsc.c b/contiki-c64/apps/enabler-dsc.c
new file mode 100644
index 0000000..d9b5522
--- /dev/null
+++ b/contiki-c64/apps/enabler-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: enabler-dsc.c,v 1.3 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon enabler_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(enabler_dsc,
+    "Colorless grayish CTK theme",
+    "enabler.prg",
+    enabler_init,
+    &enabler_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char enablericon_bitmap[3*3*8] = {
+  0xff,0xff,0xff,0xfc,0xf0,0xf0,0xe0,0xe0,
+  0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+  0xff,0xff,0xff,0x3f,0x0f,0x0f,0x07,0x07,
+
+  0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
+
+  0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff,
+  0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+  0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char enablericon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon enabler_icon =
+  {CTK_ICON("Enabler", enablericon_bitmap, enablericon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/http-user-agent-string b/contiki-c64/apps/http-user-agent-string
new file mode 100644
index 0000000..1b3104c
--- /dev/null
+++ b/contiki-c64/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n"
diff --git a/contiki-c64/apps/http-user-agent-string.c b/contiki-c64/apps/http-user-agent-string.c
new file mode 100644
index 0000000..56e6e2a
--- /dev/null
+++ b/contiki-c64/apps/http-user-agent-string.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.c,v 1.3 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+char http_user_agent_fields[100] = 
+/* "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x31, 0x2d, 0x72, 0x63, 0x30, 0x20, 0x28, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x20, 0x36, 0x34, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki-c64/apps/http-user-agent-string.h b/contiki-c64/apps/http-user-agent-string.h
new file mode 100644
index 0000000..a42afad
--- /dev/null
+++ b/contiki-c64/apps/http-user-agent-string.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.h,v 1.3 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+extern char http_user_agent_fields[100];
diff --git a/contiki-c64/apps/httpd-cgi.c b/contiki-c64/apps/httpd-cgi.c
new file mode 100644
index 0000000..7b830a0
--- /dev/null
+++ b/contiki-c64/apps/httpd-cgi.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#ifdef __CBM__
+#include <cbm.h>
+#include <c64.h>
+#endif /* __CBM__ */
+
+#include <stdio.h>
+#include <string.h>
+
+static u8_t file_stats(void);
+static u8_t tcp_stats(void);
+static u8_t processes(void);
+
+static u8_t d64output(void);
+static u8_t diroutput(void);
+
+httpd_cgifunction httpd_cgitab[] = {
+  NULL,
+  tcp_stats,     /* CGI function "b" */
+  processes,     /* CGI function "c" */
+
+  d64output,     /* CGI function "d" */
+};
+
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49, 
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+/*-----------------------------------------------------------------------------------*/
+#if 0
+static u8_t
+file_stats(void)
+{
+  /* We use sprintf() to print the number of file accesses to a
+     particular file (given as an argument to the function in the
+     script). We then use uip_send() to actually send the data. */
+  if(uip_acked()) {
+    return 1;
+  }
+  uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", httpd_fs_count(&hs->script[4])));
+  return 0;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+tcp_stats(void)
+{
+  register struct uip_conn *conn;  
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  conn = &uip_conns[hs->count];
+  while((conn->tcpstateflags & TS_MASK) == CLOSED) {
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+    conn = &uip_conns[hs->count];
+  }
+
+  uip_send(uip_appdata, sprintf((char *)uip_appdata,
+				"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+				htons(conn->lport),
+				htons(conn->ripaddr[0]) >> 8,
+				htons(conn->ripaddr[0]) & 0xff,
+				htons(conn->ripaddr[1]) >> 8,
+				htons(conn->ripaddr[1]) & 0xff,
+				htons(conn->rport),
+				states[conn->tcpstateflags & TS_MASK],
+				conn->nrtx,
+				conn->timer,
+				(uip_outstanding(conn))? '*':' ',
+				(uip_stopped(conn))? '!':' '));
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+processes(void)
+{
+  u8_t i;
+  register struct dispatcher_proc *p;
+  char name[40];
+
+  p = DISPATCHER_PROCS();
+  for(i = 0; i < hs->count; ++i) {
+    if(p != NULL) {
+      p = p->next;
+    }
+  }
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    ++hs->count;
+    if(p != NULL) {
+      p = p->next;
+    }
+    if(p == NULL) {
+      /* If all processes have been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  strncpy(name, p->name, 40);
+  petsciiconv_toascii(name, 40);
+  uip_send(uip_appdata,
+	   sprintf((char *)uip_appdata,
+		   "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%04x</td><td>0x%04x</td><td>0x%04x</td></tr>\r\n",
+		   p->id, name,
+		   p->idle, p->signalhandler, p->uiphandler));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+
+#include "c64-dio.h"
+
+static void
+read_sector(void)
+{
+  c64_dio_read_block(ds.track, ds.sect, uip_appdata);
+}
+
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+
+static u8_t
+d64output(void)
+{
+  if(hs->count == 0) {
+    ds.track = 1;
+    ds.sect = 0;
+    /*    c64_dio_init(8);*/
+  }
+  
+  if(uip_acked()) {
+    ++hs->count;
+    if(next_sector()) {
+      return 1;
+    }
+  }
+
+  read_sector();
+  uip_send(uip_appdata, 256);
+  return 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/httpd-fs.h b/contiki-c64/apps/httpd-fs.h
new file mode 100644
index 0000000..ae76886
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 0
+
+struct httpd_fs_file {
+  char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1  
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki-c64/apps/httpd-fs/404.html b/contiki-c64/apps/httpd-fs/404.html
new file mode 100644
index 0000000..47a4412
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/404.html
@@ -0,0 +1 @@
+<html><body bgcolor="white"><center><table width="600" border="0"><tr><td><h1>404 - file not found</h1></tr></td></table></center></body></html>
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/binaryheader.plain b/contiki-c64/apps/httpd-fs/binaryheader.plain
new file mode 100644
index 0000000..d4c85c1
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/binaryheader.plain
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK

+Content-type: application/octet-stream

+

diff --git a/contiki-c64/apps/httpd-fs/cgi/d64 b/contiki-c64/apps/httpd-fs/cgi/d64
new file mode 100644
index 0000000..60251eb
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/cgi/d64
@@ -0,0 +1,3 @@
+i /binaryheader.plain
+c d
+.
diff --git a/contiki-c64/apps/httpd-fs/cgi/processes b/contiki-c64/apps/httpd-fs/cgi/processes
new file mode 100644
index 0000000..8f76c57
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/cgi/processes
@@ -0,0 +1,7 @@
+i /header.html
+t <h1>System processes</h1><br><table width="100%">
+t <tr><th>ID</th><th>Name</th><th>Idle handler</th><th>Signal handler</th><th>TCP/IP handler</th></tr>
+c c
+t </table>
+i /footer.plain
+.
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/cgi/tcp b/contiki-c64/apps/httpd-fs/cgi/tcp
new file mode 100644
index 0000000..14681aa
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/cgi/tcp
@@ -0,0 +1,7 @@
+i /header.html
+t <h1>Current connections</h1><br><table width="100%">
+t <tr><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
+c b
+t </table>
+i /footer.plain
+.
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/contiki.png b/contiki-c64/apps/httpd-fs/contiki.png
new file mode 100644
index 0000000..e8724dd
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/contiki.png
Binary files differ
diff --git a/contiki-c64/apps/httpd-fs/d64header.plain b/contiki-c64/apps/httpd-fs/d64header.plain
new file mode 100644
index 0000000..d4c85c1
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/d64header.plain
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK

+Content-type: application/octet-stream

+

diff --git a/contiki-c64/apps/httpd-fs/dirfooter.plain b/contiki-c64/apps/httpd-fs/dirfooter.plain
new file mode 100644
index 0000000..d40603e
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/dirfooter.plain
@@ -0,0 +1 @@
+</table></center>The Contiki homepage: <a href="http://dunkels.com/adam/contiki/"><tt>http://dunkels.com/adam/contiki/</tt></a>.</body></html>
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/dirheader.html b/contiki-c64/apps/httpd-fs/dirheader.html
new file mode 100644
index 0000000..632174b
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/dirheader.html
@@ -0,0 +1,4 @@
+<html><head><title>The Contiki web server!</title></head>
+<body bgcolor="white">
+<center><h1>Files on disk</h1>
+<table width="100%" border="0"><th>File</th><th>Size (blocks)</th>
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/footer.plain b/contiki-c64/apps/httpd-fs/footer.plain
new file mode 100644
index 0000000..a1b69f1
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/footer.plain
@@ -0,0 +1 @@
+The Contiki homepage: <a href="http://dunkels.com/adam/contiki/"><tt>http://dunkels.com/adam/contiki/</tt></a>.</body></html>
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/header.html b/contiki-c64/apps/httpd-fs/header.html
new file mode 100644
index 0000000..8d128d0
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/header.html
@@ -0,0 +1 @@
+<html><head><title>The Contiki web server!</title></head><body bgcolor="white">
diff --git a/contiki-c64/apps/httpd-fs/index.html b/contiki-c64/apps/httpd-fs/index.html
new file mode 100644
index 0000000..8d47e2c
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/index.html
@@ -0,0 +1,14 @@
+<html><head><title>The Contiki web server!</title></head>
+<body bgcolor="white">
+<table width="100%" border="0">
+<tr><td><img src="contiki.png"></td>
+<td align="center"><h1>Welcome to the Contiki web server!</h1></td>
+<td><img src="webserver.png"></td></tr></table><br>
+<b><center>These web pages are served from your C64!</center></b>
+<ul><li><a href="/8/">Disk directory</a><br>
+<li><a href="/cgi/d64">Download entire disk in as a D64 file</a>.<br>
+<li><a href="/cgi/tcp">Current network connections</a><br>
+<li><a href="/cgi/processes">System processes</a><br>
+</ul>
+The Contiki homepage: <a href="http://dunkels.com/adam/contiki/"><tt>http://dunkels.com/adam/contiki/</tt></a>.
+</body></html>
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd-fs/webserver.png b/contiki-c64/apps/httpd-fs/webserver.png
new file mode 100644
index 0000000..81db410
--- /dev/null
+++ b/contiki-c64/apps/httpd-fs/webserver.png
Binary files differ
diff --git a/contiki-c64/apps/httpd-fsdata.c b/contiki-c64/apps/httpd-fsdata.c
new file mode 100644
index 0000000..dd153b9
--- /dev/null
+++ b/contiki-c64/apps/httpd-fsdata.c
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.c,v 1.3 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+static const char data_cgi_processes[] = {
+	/* /cgi/processes */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x74, 0x20, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 
+	0x6d, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x49, 0x64, 0x6c, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64, 
+	0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 
+	0x68, 0x3e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x68, 
+	0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x43, 0x50, 0x2f, 0x49, 
+	0x50, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 
+	0x63, 0x20, 0x63, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61, 
+	0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 
+	0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 
+	0xa, 0x2e, };
+
+static const char data_cgi_tcp[] = {
+	/* /cgi/tcp */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x74, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 
+	0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52, 
+	0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 
+	0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 0x6c, 0x61, 
+	0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0xa, 0x63, 0x20, 0x62, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 
+	0x61, 0x69, 0x6e, 0xa, 0x2e, };
+
+static const char data_cgi_d64[] = {
+	/* /cgi/d64 */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0,
+	0x69, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 
+	0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 
+	0x6e, 0xa, 0x63, 0x20, 0x64, 0xa, 0x2e, 0xa, };
+
+static const char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 
+	0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 
+	0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 
+	0x73, 0x72, 0x63, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x20, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3d, 0x22, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x22, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x57, 0x65, 0x6c, 
+	0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 
+	0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 
+	0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 
+	0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x77, 0x65, 0x62, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0x22, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x62, 0x3e, 0x3c, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 0x73, 0x65, 
+	0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 
+	0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 
+	0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x79, 0x6f, 0x75, 
+	0x72, 0x20, 0x43, 0x36, 0x34, 0x21, 0x3c, 0x2f, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x3e, 0xa, 
+	0x3c, 0x75, 0x6c, 0x3e, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x38, 0x2f, 
+	0x22, 0x3e, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x64, 0x69, 0x72, 
+	0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0x22, 0x3e, 0x44, 0x6f, 
+	0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x65, 0x6e, 0x74, 
+	0x69, 0x72, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x20, 0x69, 
+	0x6e, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x44, 0x36, 0x34, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e, 0x43, 0x75, 
+	0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 
+	0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 
+	0x73, 0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 
+	0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 
+	0x75, 0x6c, 0x3e, 0xa, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 
+	0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 
+	0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 
+	0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 
+	0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 
+	0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 
+	0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+};
+
+static const char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 
+	0x22, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 
+	0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20, 0x62, 
+	0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x68, 
+	0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 
+	0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 
+	0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 
+	0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 
+	0x65, 0x22, 0x3e, 0xa, };
+
+static const char data_footer_plain[] = {
+	/* /footer.plain */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 
+	0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 
+	0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 
+	0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 
+	0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 
+	0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 
+	0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 
+	0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 
+	0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 
+	0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x2e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 
+	0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_webserver_png[] = {
+	/* /webserver.png */
+	0x2f, 0x77, 0x65, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x1, 00, 
+	00, 00, 00, 0xc8, 0xc, 00, 0x55, 00, 00, 00, 
+	0x2, 0x62, 0x4b, 0x47, 0x44, 00, 0x1, 0xdd, 0x8a, 0x13, 
+	0xa4, 00, 00, 00, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x78, 
+	0xda, 0x1d, 0xc8, 0x21, 0xa, 0x80, 0x30, 00, 0x46, 0xe1, 
+	0xa7, 0xc7, 0x34, 0x78, 0x93, 0x89, 0xb, 0x1e, 0x43, 0x96, 
+	0x8c, 0x62, 0x14, 0x19, 0x6e, 0xc1, 0xe8, 0x19, 0x96, 0x97, 
+	0x8c, 0x6, 0xc3, 0xf8, 0x45, 0xc3, 0x83, 0x8f, 0x87, 0x24, 
+	0x7a, 0x2a, 0xe2, 0x54, 0x8, 0x32, 0x78, 0x25, 0x56, 0x5d, 
+	0xc4, 0xa3, 0xb0, 0x74, 0xf7, 0xff, 0x9c, 0x1e, 0x76, 0xed, 
+	0x8c, 0x79, 0xfb, 0xfb, 0xec, 0xf2, 0x43, 0xc8, 0x86, 0xa5, 
+	0xb9, 0x89, 0x67, 0x61, 0x3d, 0x2e, 0xfc, 0x9c, 0x8, 0x83, 
+	0x21, 0xda, 0x82, 0x6d, 0x2d, 0xaa, 0xf5, 0x2, 0x33, 0x91, 
+	0x35, 0x61, 0x3a, 0xe8, 0xa4, 0x34, 00, 00, 00, 00, 
+	0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
+
+static const char data_contiki_png[] = {
+	/* /contiki.png */
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x8, 0x2, 
+	00, 00, 00, 0x6f, 0x15, 0xaa, 0xaf, 00, 00, 00, 
+	0x9, 0x70, 0x48, 0x59, 0x73, 00, 00, 0x1c, 0x1f, 00, 
+	00, 0x1c, 0x1f, 0x1, 0x60, 0xfd, 0x4, 0xda, 00, 00, 
+	00, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xd3, 0x3, 0x9, 
+	0x16, 0x4, 0xd, 0x60, 0xa0, 0x97, 00, 00, 00, 00, 
+	0xad, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xad, 0x94, 0x41, 
+	0xe, 0xc5, 0x20, 0x8, 0x44, 0x9d, 0x1f, 0xee, 0x7f, 0xe5, 
+	0xf9, 0xb, 0x13, 0x6a, 0x1, 0x29, 0xa5, 0xb2, 0x53, 0xca, 
+	0xf0, 0x9c, 0x40, 0x41, 0x72, 0x1c, 0x89, 0x23, 0x42, 0x24, 
+	0xc5, 0xcb, 0x1, 0x48, 0x1a, 0xf8, 0xec, 0xbc, 0x91, 0xe4, 
+	0xa3, 0x79, 0x34, 0x9d, 0x67, 0xd6, 0xcb, 0x5d, 0x42, 0x3e, 
+	0x97, 0xbc, 0x9a, 0x24, 00, 00, 0xfa, 0x8d, 0x98, 0x74, 
+	0x8, 0x12, 0xa, 0x4d, 0xad, 0x8b, 0x43, 0xcf, 0x3d, 0xd7, 
+	0xb5, 0x36, 0xf0, 0xa8, 0x1e, 0x81, 0x47, 0xf3, 0xaa, 0x1, 
+	0xa5, 0xf, 0xb2, 0x66, 0x37, 0x84, 0x6e, 0x44, 0x3d, 0x9c, 
+	0x35, 0x3a, 0x44, 0x61, 0xcb, 0x26, 0x91, 0xef, 0xfa, 0x82, 
+	0x28, 0x9f, 0xb2, 0x77, 0x44, 0x49, 0xb3, 0xd2, 0x1c, 0x55, 
+	0x26, 0x5e, 0x54, 0x42, 0x17, 0xf2, 0x91, 0x25, 0xdc, 0x6a, 
+	0x49, 0xa, 0x4c, 0x99, 0x3f, 0xae, 0xeb, 0x26, 0xeb, 0xd5, 
+	0xe, 0xaa, 0x32, 0x19, 0xd6, 0x23, 0x6f, 0x47, 0x71, 0x2c, 
+	0x7e, 0xa6, 0x40, 0xb7, 0x59, 0x23, 0xa1, 0xdb, 0x7a, 0xb4, 
+	0xfb, 0xfb, 0x25, 0x5a, 0xb6, 0xf8, 0x63, 0x90, 0xc4, 0x11, 
+	0xa1, 0x31, 0xc6, 0x1f, 0x2c, 0x64, 0x9c, 0x21, 0xc5, 0x1a, 
+	0x66, 0x5d, 00, 00, 00, 00, 0x49, 0x45, 0x4e, 0x44, 
+	0xae, 0x42, 0x60, 0x82, };
+
+static const char data_binaryheader_plain[] = {
+	/* /binaryheader.plain */
+	0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 
+	0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 
+	0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+
+static const char data_dirheader_html[] = {
+	/* /dirheader.html */
+	0x2f, 0x64, 0x69, 0x72, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x46, 0x69, 0x6c, 
+	0x65, 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x64, 0x69, 0x73, 0x6b, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 
+	0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 
+	0x3c, 0x74, 0x68, 0x3e, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x28, 
+	0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x29, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, };
+
+static const char data_dirfooter_plain[] = {
+	/* /dirfooter.plain */
+	0x2f, 0x64, 0x69, 0x72, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 
+	0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 
+	0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 
+	0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 
+	0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 
+	0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 
+	0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 
+	0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 
+	0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x3c, 0x2f, 
+	0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 
+	0x6c, 0x3e, };
+
+const struct httpd_fsdata_file file_cgi_processes[] = {{NULL, data_cgi_processes, data_cgi_processes + 15, sizeof(data_cgi_processes) - 15}};
+
+const struct httpd_fsdata_file file_cgi_tcp[] = {{file_cgi_processes, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
+
+const struct httpd_fsdata_file file_cgi_d64[] = {{file_cgi_tcp, data_cgi_d64, data_cgi_d64 + 9, sizeof(data_cgi_d64) - 9}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_cgi_d64, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_index_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_404_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_footer_plain[] = {{file_header_html, data_footer_plain, data_footer_plain + 14, sizeof(data_footer_plain) - 14}};
+
+const struct httpd_fsdata_file file_webserver_png[] = {{file_footer_plain, data_webserver_png, data_webserver_png + 15, sizeof(data_webserver_png) - 15}};
+
+const struct httpd_fsdata_file file_contiki_png[] = {{file_webserver_png, data_contiki_png, data_contiki_png + 13, sizeof(data_contiki_png) - 13}};
+
+const struct httpd_fsdata_file file_binaryheader_plain[] = {{file_contiki_png, data_binaryheader_plain, data_binaryheader_plain + 20, sizeof(data_binaryheader_plain) - 20}};
+
+const struct httpd_fsdata_file file_dirheader_html[] = {{file_binaryheader_plain, data_dirheader_html, data_dirheader_html + 16, sizeof(data_dirheader_html) - 16}};
+
+const struct httpd_fsdata_file file_dirfooter_plain[] = {{file_dirheader_html, data_dirfooter_plain, data_dirfooter_plain + 17, sizeof(data_dirfooter_plain) - 17}};
+
+#define HTTPD_FS_ROOT file_dirfooter_plain
+
+#define HTTPD_FS_NUMFILES 12
\ No newline at end of file
diff --git a/contiki-c64/apps/httpd.c b/contiki-c64/apps/httpd.c
new file mode 100644
index 0000000..affbbd8
--- /dev/null
+++ b/contiki-c64/apps/httpd.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.c,v 1.5 2004/07/04 18:33:07 adamdunkels Exp $
+ *
+ */
+
+
+#include "uip.h"
+
+#include "http-strings.h"
+
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+#include "httpd-cgi.h"
+
+#include "tcpip.h"
+
+#include <stdio.h>
+
+/* The HTTP server states: */
+#define STATE_DEALLOCATED       0
+#define STATE_INITIAL           1
+#define STATE_GET               2
+#define STATE_HEADERS           3
+#define STATE_SEND_HEADERS      4
+#define STATE_SEND_CONTENT_TYPE 5
+#define STATE_SEND_DATA         6
+
+#define ISO_nl                  0x0a
+#define ISO_space               0x20
+#define ISO_slash               0x2f
+
+#ifdef DEBUG
+#include <stdio.h>
+#define PRINT(x) printf("%s", x)
+#define PRINTLN(x) printf("%s\n", x)
+#else /* DEBUG */
+#define PRINT(x)
+#define PRINTLN(x)
+#endif /* DEBUG */
+
+
+#define HTTPD_CONF_NUMCONNS 4
+static struct httpd_state conns[HTTPD_CONF_NUMCONNS];
+u8_t i;
+
+struct http_filetype {
+  const char *ext;
+  unsigned char extlen;
+  const char *type;
+  unsigned char typelen;
+};
+
+static struct http_filetype filetypes[] = {
+  {http_html, sizeof(http_html) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_htm, sizeof(http_htm) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_css, sizeof(http_css) - 1,
+   http_content_type_css, sizeof(http_content_type_css) - 1},
+  {http_png, sizeof(http_png) - 1,
+   http_content_type_png, sizeof(http_content_type_png) - 1},
+  {http_gif, sizeof(http_gif) - 1,
+   http_content_type_gif, sizeof(http_content_type_gif) - 1},
+  {http_jpg, sizeof(http_jpg) - 1,
+   http_content_type_jpg, sizeof(http_content_type_jpg) - 1},
+  {http_txt, sizeof(http_txt) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},
+  {http_text, sizeof(http_text) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},  
+  {NULL, 0, NULL, 0}
+};
+#define NUMFILETYPES (sizeof(filetypes) / sizeof(struct http_filetype))
+/*-----------------------------------------------------------------------------*/
+static struct httpd_state *
+alloc_state(void)
+{
+  
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    if(conns[i].state == STATE_DEALLOCATED) {
+      return &conns[i];
+    }
+  }
+
+  /* We are overloaded! XXX: we'll just kick all other connections! */
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+  
+  return NULL;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+dealloc_state(struct httpd_state *s)
+{
+  s->state = STATE_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+  httpd_fs_init();
+  
+  /* Listen to port 80. */
+  tcp_listen(HTONS(80));
+
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Buffer an amount of data from the incoming uIP data.
+ *
+ * \param buf A pointer to the buffer.
+ * \param len The length of data to buffer.
+ *
+ * \return Zero if the function wasn't able to buffer to buffer all
+ * data, non-zero otherwise.
+ */
+/*-----------------------------------------------------------------------------*/
+static unsigned char
+buffer(CC_REGISTER_ARG struct httpd_buffer *buf, int len, u8_t c)
+{
+  while(buf->ptr < len &&
+	uip_len > 0) {
+    buf->buf[buf->ptr] = *uip_appdata;
+    ++uip_appdata;
+    --uip_len;
+
+    if(buf->buf[buf->ptr] == c) {
+      return 1;
+    }
+    ++buf->ptr;
+  }
+  return (buf->ptr == len);
+}
+/*-----------------------------------------------------------------------------*/
+static void
+buffer_reset(struct httpd_buffer *buf)
+{
+  buf->ptr = 0;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+newdata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  int i;
+  struct http_filetype *filetype;
+    
+  while(uip_len > 0) {
+    switch(hs->state) {
+      
+    case STATE_INITIAL:
+      /* This is the first data that we receive, so we check if we can
+	 identify the "GET" request. We call the buffer() function to
+	 try to buffer 4 bytes of data from the incoming data stream. If
+	 the function isn't able to buffer enough data, we return and
+	 will try again next time around. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), 4, ISO_space)) {
+	if(strncmp(http_get, hs->buf.buf, 4) == 0) {
+	  hs->state = STATE_GET;
+	  buffer_reset(&(hs->buf));
+	} else {
+	  uip_abort();
+	  return;
+	}
+      }
+      break;
+    
+    case STATE_GET:
+      /* We will read one byte at a time from the GET request until we
+	 find a en end of the line (\n\r). The GET request is remembered
+	 in the httpd state since we might need to look at it later. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->getbuffer), ISO_nl)) {
+	hs->state = STATE_HEADERS;
+	hs->getlen = hs->buf.ptr - 1;
+	/* Null-terminate GET request string. */
+	hs->getbuffer[hs->getlen] = 0;
+
+	/* If there is a space character in the get request, we find
+	   it and null terminate the string there. */
+	for(i = 0; i < hs->getlen; ++i) {
+	  if(hs->getbuffer[i] == ISO_space) {
+	    hs->getbuffer[i] = 0;
+	    hs->getlen = i;
+	    break;
+	  }
+	}
+	buffer_reset(&(hs->buf));	
+      }
+      break;
+
+    case STATE_HEADERS:
+      hs->buf.buf = hs->hdrbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->hdrbuffer), '\n')) {
+	if(hs->buf.ptr == 1) {
+	  hs->state = STATE_SEND_HEADERS;
+	  if(httpd_fs_open(hs->getbuffer, &hs->file)) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_binary;
+	    hs->contentlen = sizeof(http_content_type_binary) - 1;
+	    for(filetype = filetypes;
+		filetype->ext != NULL;
+		++filetype) {
+	      if(strncmp(filetype->ext,
+			 hs->getbuffer + (hs->getlen - filetype->extlen),
+			 filetype->extlen) == 0) {
+		hs->contenttype = filetype->type;
+		hs->contentlen = filetype->typelen;
+		break;
+	      }
+	    }
+
+	  } else if(hs->getbuffer[0] == ISO_slash &&
+	      hs->getbuffer[1] == 0) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_index_html, &hs->file);
+	  } else {
+	    hs->count = sizeof(http_header_404) - 1;
+	    hs->dataptr = (char *)http_header_404;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_404_html, &hs->file);
+	  }
+	} else {
+	  buffer_reset(&(hs->buf));
+	}
+      }
+      break;
+
+    default:
+      uip_len = 0;
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+acked(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  hs->poll = 0;
+
+  
+  switch(hs->state) {
+
+  case STATE_SEND_HEADERS:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_CONTENT_TYPE;
+      hs->count = hs->contentlen;
+      hs->dataptr = (char *)hs->contenttype;
+    }
+    break;
+    
+  case STATE_SEND_CONTENT_TYPE:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_DATA;
+      hs->count = hs->file.len;
+      hs->dataptr = hs->file.data;
+    }
+    break;
+    
+  case STATE_SEND_DATA:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      uip_close();
+      dealloc_state(hs);
+    }
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+senddata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  if(hs->state == STATE_SEND_HEADERS ||
+     hs->state == STATE_SEND_CONTENT_TYPE ||
+     hs->state == STATE_SEND_DATA) {
+    uip_send(hs->dataptr,
+	     hs->count > uip_mss()? uip_mss(): hs->count);
+  }
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+  register struct httpd_state *hs;
+
+  hs = (struct httpd_state *)(state);
+
+
+  if(uip_connected()) {
+    /* Since we've just been connected, the state pointer should be
+       NULL and we need to allocate a new state object. If we have run
+       out of memory for state objects, we'll have to abort the
+       connection and return. */
+    if(hs == NULL) {
+      hs = alloc_state();
+      if(hs == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)hs);
+    }
+    /* Since we have just been connected with the remote host, we
+       reset the state for this connection. The ->count variable
+       contains the amount of data that is yet to be sent to the
+       remote host, and the ->state is set to HTTP_NOGET to signal
+       that we haven't received any HTTP GET request for this
+       connection yet. */
+    hs->state = STATE_INITIAL;
+    hs->count = 0;
+    hs->poll = 0;
+    buffer_reset(&(hs->buf));
+    return;
+  }
+
+  if(uip_closed() ||
+     uip_aborted() ||
+     uip_timedout()) {
+    if(hs != NULL) {
+      dealloc_state(hs);
+    }
+    return;
+  } else if(uip_poll()) {
+    /* If we are polled ten times, we abort the connection. This is
+       because we don't want connections lingering indefinately in
+       the system. */
+    if(hs != NULL) {
+      if(hs->state == STATE_DEALLOCATED) {
+	uip_abort();
+      } else if(hs->poll++ >= 100) {
+	uip_abort();
+	dealloc_state(hs);
+      }
+    }
+    return;
+  }
+  
+  if(uip_acked()) {
+    acked(hs);
+  }
+  
+  if(uip_newdata()) {
+    newdata(hs);
+  }
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata(hs);
+  } else if(uip_poll()) {    
+    senddata(hs);
+  }
+
+
+}
+/*-----------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/httpd.h b/contiki-c64/apps/httpd.h
new file mode 100644
index 0000000..bfdd83d
--- /dev/null
+++ b/contiki-c64/apps/httpd.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.4 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "ek.h"
+
+#include "httpd-fs.h"
+
+void httpd_init(void);
+/*DISPATCHER_UIPCALL(httpd_appcall, state);*/
+void httpd_appcall(void *state);
+
+struct httpd_buffer {
+  u8_t *buf;
+  int ptr;
+};
+
+struct httpd_state {
+  u8_t state; 
+  u16_t count;
+  u8_t poll;
+  char *dataptr;
+  struct httpd_fs_file file;
+
+  const char *contenttype;
+  int contentlen;
+  
+  char *script;
+
+  struct httpd_buffer buf;
+
+  int getlen;
+  u8_t getbuffer[100];
+  u8_t hdrbuffer[100];
+  
+  /*
+  union {
+    struct c64_fs_dir d;
+    struct c64_fs_file f;
+    } f;*/
+};
+
+extern struct httpd_state *hs;
+
+void webserver_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff --git a/contiki-c64/apps/makefsdata b/contiki-c64/apps/makefsdata
new file mode 100755
index 0000000..83bbc5b
--- /dev/null
+++ b/contiki-c64/apps/makefsdata
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+open(FILES, "find . -type f |");
+
+
+while($file = <FILES>) {
+
+    # Do not include files in CVS directories nor backup files.
+    if($file =~ /(CVS|~)/) {
+    	next;
+    }
+    
+    chop($file);
+    
+    open(HEADER, "> /tmp/header") || die $!;
+    print(HEADER "HTTP/1.0 200 OK\r\n");
+    print(HEADER "Server: Contiki/pre-1.1 (http://dunkels.com/adam/contiki/)\r\n");
+    if($file =~ /\.html$/) {
+	print(HEADER "Content-type: text/html\r\n");
+    } elsif($file =~ /\.gif$/) {
+	print(HEADER "Content-type: image/gif\r\n");
+    } elsif($file =~ /\.png$/) {
+	print(HEADER "Content-type: image/png\r\n");
+    } elsif($file =~ /\.jpg$/) {
+	print(HEADER "Content-type: image/jpeg\r\n");
+    } elsif($file =~ /\.css$/) {
+	print(HEADER "Content-type: text/css\r\n");
+    } else {
+	print(HEADER "Content-type: text/plain\r\n");
+    }
+    print(HEADER "\r\n");
+    close(HEADER);
+
+    unless($file =~ /\.plain$/ || $file =~ /cgi/) {
+	system("cat /tmp/header $file > /tmp/file");
+    } else {
+	system("cp $file /tmp/file");
+    }
+    
+    open(FILE, "/tmp/file");
+    unlink("/tmp/file");
+    unlink("/tmp/header");
+
+    $file =~ s/\.//;
+    $fvar = $file;
+    $fvar =~ s-/-_-g;
+    $fvar =~ s-\.-_-g;
+    print(OUTPUT "static const char data".$fvar."[] = {\n");
+    print(OUTPUT "\t/* $file */\n\t");
+    for($j = 0; $j < length($file); $j++) {
+	printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+    }
+    printf(OUTPUT "0,\n");
+    
+    
+    $i = 0;        
+    while(read(FILE, $data, 1)) {
+        if($i == 0) {
+            print(OUTPUT "\t");
+        }
+        printf(OUTPUT "%#02x, ", unpack("C", $data));
+        $i++;
+        if($i == 10) {
+            print(OUTPUT "\n");
+            $i = 0;
+        }
+    }
+    print(OUTPUT "};\n\n");
+    close(FILE);
+    push(@fvars, $fvar);
+    push(@files, $file);
+}
+
+for($i = 0; $i < @fvars; $i++) {
+    $file = $files[$i];
+    $fvar = $fvars[$i];
+
+    if($i == 0) {
+        $prevfile = "NULL";
+    } else {
+        $prevfile = "file" . $fvars[$i - 1];
+    }
+    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i");
diff --git a/contiki-c64/apps/makestrings b/contiki-c64/apps/makestrings
new file mode 100755
index 0000000..e6e8470
--- /dev/null
+++ b/contiki-c64/apps/makestrings
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+  my $name = shift(@_);
+  open(OUTPUTC, "> $name.c");
+  open(OUTPUTH, "> $name.h");
+  
+  open(FILE, "$name");
+  
+  while(<FILE>) {
+    if(/(.+) "(.+)"/) {
+      $var = $1;
+      $data = $2;
+      
+      $datan = $data;
+      $datan =~ s/\\r/\r/g;
+      $datan =~ s/\\n/\n/g;
+      $datan =~ s/\\0/\0/g;
+      
+      printf(OUTPUTC "char $var\[%d] = \n", length($datan) + 1);
+      printf(OUTPUTC "/* \"$data\" */\n");
+      printf(OUTPUTC "{");
+      for($j = 0; $j < length($datan); $j++) {
+	printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+      }
+      printf(OUTPUTC "};\n");
+      
+      printf(OUTPUTH "extern char $var\[%d];\n", length($datan) + 1);
+      
+    }
+  }
+  close(OUTPUTC);
+  close(OUTPUTH);
+}
+stringify("http-user-agent-string");
+
+exit 0;
+
diff --git a/contiki-c64/apps/memstat-dsc.c b/contiki-c64/apps/memstat-dsc.c
new file mode 100644
index 0000000..d049912
--- /dev/null
+++ b/contiki-c64/apps/memstat-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.c,v 1.4 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon memstat_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(memstat_dsc,
+    "Memory statistics",
+    "memstat.prg",
+    memstat_init,
+    &memstat_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char memstaticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char memstaticon_textmap[9] = {
+  '0', '0', '1',
+  '0', '1', '0',
+  '1', '0', '1'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon memstat_icon =
+  {CTK_ICON("Memory stats", memstaticon_bitmap, memstaticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/mtest.c b/contiki-c64/apps/mtest.c
new file mode 100644
index 0000000..a887f6e
--- /dev/null
+++ b/contiki-c64/apps/mtest.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtest.c,v 1.3 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#include "mt.h"
+
+MTP(t, p, "Test thread");
+/*--------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+test(void *data)
+{
+  while(1) {
+    asm("inc $d020");
+  }
+}
+#pragma optimize(pop)
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(mtest_init, arg)
+{
+  arg_free(arg);
+  mtp_start(&t, test, NULL);
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/plasma-dsc.c b/contiki-c64/apps/plasma-dsc.c
new file mode 100644
index 0000000..c74771e
--- /dev/null
+++ b/contiki-c64/apps/plasma-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.4 2005/05/12 21:08:26 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+    "Screensaver with a plasma",
+    "plasma.sav",
+    plasma_init,
+    &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+  '.', ' ', '.',
+  ' ', 'O', ' ',
+  '.', ' ', '.'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon plasma_icon =
+  {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/plasma.c b/contiki-c64/apps/plasma.c
new file mode 100644
index 0000000..c4834e9
--- /dev/null
+++ b/contiki-c64/apps/plasma.c
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.4 2005/05/12 21:07:22 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+  128, 131, 134, 137, 140, 143, 146, 149, 
+  152, 156, 159, 162, 165, 168, 171, 174, 
+  176, 179, 182, 185, 188, 191, 193, 196, 
+  199, 201, 204, 206, 209, 211, 213, 216, 
+  218, 220, 222, 224, 226, 228, 230, 232, 
+  234, 236, 237, 239, 240, 242, 243, 245, 
+  246, 247, 248, 249, 250, 251, 252, 252, 
+  253, 254, 254, 255, 255, 255, 255, 255, 
+  255, 255, 255, 255, 255, 255, 254, 254, 
+  253, 252, 252, 251, 250, 249, 248, 247, 
+  246, 245, 243, 242, 240, 239, 237, 236, 
+  234, 232, 230, 228, 226, 224, 222, 220, 
+  218, 216, 213, 211, 209, 206, 204, 201, 
+  199, 196, 193, 191, 188, 185, 182, 179, 
+  176, 174, 171, 168, 165, 162, 159, 156, 
+  152, 149, 146, 143, 140, 137, 134, 131, 
+  128, 124, 121, 118, 115, 112, 109, 106, 
+  103,  99,  96,  93,  90,  87,  84,  81, 
+   79,  76,  73,  70,  67,  64,  62,  59, 
+   56,  54,  51,  49,  46,  44,  42,  39, 
+   37,  35,  33,  31,  29,  27,  25,  23, 
+   21,  19,  18,  16,  15,  13,  12,  10, 
+    9,   8,   7,   6,   5,   4,   3,   3, 
+    2,   1,   1,   0,   0,   0,   0,   0, 
+    0,   0,   0,   0,   0,   0,   1,   1, 
+    2,   3,   3,   4,   5,   6,   7,   8, 
+    9,  10,  12,  13,  15,  16,  18,  19, 
+   21,  23,  25,  27,  29,  31,  33,  35, 
+   37,  39,  42,  44,  46,  49,  51,  54, 
+   56,  59,  62,  64,  67,  70,  73,  76, 
+   78,  81,  84,  87,  90,  93,  96,  99, 
+  103, 106, 109, 112, 115, 118, 121, 124, 
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+  {
+    0x00, 0x06, 0x0b, 0x04,
+    0x0a, 0x0f, 0x07, 0x01,
+    0x07, 0x0f, 0x0a, 0x08,
+    0x02, 0x09, 0x00, 0x00,
+  };
+
+#define XSIZE 25
+#define YSIZE 25
+
+#define XADD01 0xfe
+#define YADD01 0x05
+
+#define XADD1 0x04
+#define YADD1 0x02
+#define XADD2 0xfc
+#define YADD2 0xf9
+
+#define XADD 0x03
+#define YADD 0xfe
+
+#define MOVADD 0xfb
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char movcnt;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Plasma screensaver", idle,
+		   sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+  unsigned char *ptr, *cptr;
+  static int i;
+  
+  /* Make sine tables */
+  for(i = 0; i < 256; ++i) {
+    sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+    sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;    
+  }
+    
+  /* Make color table */
+  for(i = 0; i < 256; ++i) {
+    colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+  }
+    
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  static unsigned char i, x, y;
+  register unsigned char *cptr;
+  
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+
+    xcnt1 = xcnt01;
+    xcnt2 = xcnt02;
+    
+    for(i = 0; i < XSIZE; ++i) {
+      xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+      xcnt1 += XADD1;
+      xcnt2 += XADD2;
+    }
+
+    ycnt1 = ycnt01;
+    ycnt2 = ycnt02;
+    
+    for(i = 0; i < YSIZE; ++i) {
+      yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+      ycnt1 += YADD1;
+      ycnt2 += YADD2;
+    }
+
+    xcnt01 += XADD01;
+    xcnt02 += xadd02;
+    ycnt01 += YADD01;
+    ycnt02 += yadd02;
+
+    
+    yadd02 = sinetab3[ycnt] / 4;
+    xadd02 = sinetab3[xcnt] / 4;
+
+    ycnt += YADD;
+    xcnt += XADD;
+
+    movcnt += MOVADD;
+    cptr = (unsigned char *)(COLOR_RAM + sinetab1[movcnt]/16);
+    for(y = 0; y < YSIZE; ++y) {
+      for(x = 0; x < XSIZE; ++x) {
+	*cptr = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+	++cptr;
+      }
+      cptr += 40 - XSIZE;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+   
+    scrninit();
+
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+    /*    ctk_mode_set(CTK_MODE_NORMAL);*/
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+ 
diff --git a/contiki-c64/apps/ravenpine-dsc.c b/contiki-c64/apps/ravenpine-dsc.c
new file mode 100644
index 0000000..5e27df6
--- /dev/null
+++ b/contiki-c64/apps/ravenpine-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ravenpine-dsc.c,v 1.3 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ravenpine_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ravenpine_dsc,
+    "Terminal green CTK theme",
+    "ravenpine.prg",
+    ravenpine_init,
+    &ravenpine_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ravenpineicon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ravenpineicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon ravenpine_icon =
+  {CTK_ICON("Ravenpine", ravenpineicon_bitmap, ravenpineicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/springlight-dsc.c b/contiki-c64/apps/springlight-dsc.c
new file mode 100644
index 0000000..011067e
--- /dev/null
+++ b/contiki-c64/apps/springlight-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: springlight-dsc.c,v 1.3 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon springlight_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(springlight_dsc,
+    "Spring green CTK theme",
+    "springlight.prg",
+    springlight_init,
+    &springlight_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char springlighticon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char springlighticon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon springlight_icon =
+  {CTK_ICON("Springlight", springlighticon_bitmap, springlighticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/ssfire-dsc.c b/contiki-c64/apps/ssfire-dsc.c
new file mode 100644
index 0000000..7dc5683
--- /dev/null
+++ b/contiki-c64/apps/ssfire-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.4 2005/03/18 00:51:17 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+    "Screensaver with two fires",
+    "ssfire.sav",
+    ssfire_init,
+    &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon ssfire_icon =
+  {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/ssfire.c b/contiki-c64/apps/ssfire.c
new file mode 100644
index 0000000..ec3b2bf
--- /dev/null
+++ b/contiki-c64/apps/ssfire.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.7 2005/05/11 22:23:08 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+		   ssfire_sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+	   ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+
+static const unsigned char flamecolors[16] =
+  {COLOR_BLACK,    COLOR_BLACK,  COLOR_BLACK, COLOR_RED,
+   COLOR_LIGHTRED, COLOR_YELLOW, COLOR_WHITE, COLOR_WHITE,
+   COLOR_WHITE,    COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,
+   COLOR_WHITE,    COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE};
+   
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+  unsigned char *ptr, *cptr;
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+
+  SID.v3.freq = 0xffff;
+  SID.v3.ctrl = 0x80;
+  SID.amp = 0;  
+
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+    fire_init();
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    fire_quit();
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+fire_burn(void)
+{
+  /* Calculate new flames. */
+  asm("ldy #$00");
+loop1:
+  asm("lda %v+7,y", flames);
+  asm("clc");
+  asm("adc %v+8,y", flames);
+  asm("adc %v+9,y", flames);
+  asm("adc %v+16,y", flames);
+  asm("lsr");
+  asm("lsr");
+  asm("sta %v,y", flames);
+  asm("iny");
+  asm("cpy #(8*15)");
+  asm("bne %g", loop1);
+
+  /* Fill last line with pseudo-random data from noise generator on
+     voice 3. */
+  asm("ldy #$05");
+loop2:
+  asm("ldx #$20");
+delay:
+  asm("dex");
+  asm("bne %g", delay);
+  asm("lda $D41B");
+  asm("and #$0F");
+  asm("sta %v+8*15+1,y", flames);
+  asm("dey");
+  asm("bpl %g", loop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *flameptr, *colorptr1, *colorptr2;
+static unsigned char x, y;
+
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+  
+    fire_burn();
+  
+    /* Display flames on screen. */  
+    flameptr = flames;
+    colorptr1 = COLOR_RAM + 40*10;
+    colorptr2 = colorptr1 + 0x20;
+    for(y = 0; y < 15; ++y) {
+      for(x = 0; x < 8; ++x) {
+	colorptr1[x] = colorptr2[x] = flamecolors[flameptr[x]];
+      }
+      colorptr1 += 0x28;
+      colorptr2 += 0x28;
+      flameptr += 8;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/themeloader.c b/contiki-c64/apps/themeloader.c
new file mode 100644
index 0000000..680cf19
--- /dev/null
+++ b/contiki-c64/apps/themeloader.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: themeloader.c,v 1.2 2003/08/24 22:35:23 adamdunkels Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "loader.h"
+#include "ctk-draw.h"
+#include "ctk-hires-theme.h"
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(themeloader_init, arg)
+{
+  arg_free(arg);
+  
+  memcpy(ctk_hires_theme_ptr, &ctk_hires_theme,
+	 sizeof(struct ctk_hires_theme));
+  ctk_draw_init();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/vnc-draw-asm.S b/contiki-c64/apps/vnc-draw-asm.S
new file mode 100644
index 0000000..7522a43
--- /dev/null
+++ b/contiki-c64/apps/vnc-draw-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		_vnc_draw_datalen
+	.import		_vnc_draw_dataptr
+	.import		_vnc_draw_bitmapptr	
+	.import		_vnc_draw_x
+	.import		_vnc_draw_y
+;---------------------------------------------------------------------
+.bss
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
diff --git a/contiki-c64/apps/vnc-draw-asm.h b/contiki-c64/apps/vnc-draw-asm.h
new file mode 100644
index 0000000..f5bf9f1
--- /dev/null
+++ b/contiki-c64/apps/vnc-draw-asm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw-asm.h,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+#ifndef __VNC_DRAW_ASM_H__
+#define __VNC_DRAW_ASM_H__
+
+#include "vnc-draw.h"
+
+void vnc_draw_asm_pixelline(void);
+
+#endif /* __VNC_DRAW_ASM_H__ */
diff --git a/contiki-c64/apps/vnc-draw.c b/contiki-c64/apps/vnc-draw.c
new file mode 100644
index 0000000..67d6538
--- /dev/null
+++ b/contiki-c64/apps/vnc-draw.c
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw.c,v 1.3 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+
+
+#include "vnc-draw.h"
+#include "vnc-draw-asm.h"
+
+#include "vnc-conf.h"
+
+
+static unsigned char conv[256];
+
+static unsigned char oratab[8] =
+  { 0x80, 0x40, 0x20, 0x10,
+    0x08, 0x04, 0x02, 0x01 };
+static unsigned char andtab[8] =
+  { 0x7f, 0xbf, 0xdf, 0xef,
+    0xf7, 0xfb, 0xfd, 0xfe };
+
+static u8_t *bitmapptrtab[VNC_CONF_VIEWPORT_HEIGHT];
+
+static unsigned short viewport_x,
+  viewport_y, viewport_w, viewport_h;
+
+u8_t vnc_draw_bitmap[(VNC_CONF_VIEWPORT_WIDTH / 8) *
+		     VNC_CONF_VIEWPORT_HEIGHT];
+
+
+
+u16_t vnc_draw_x;
+u16_t vnc_draw_y;
+u8_t *vnc_draw_dataptr;
+u8_t *vnc_draw_bitmapptr;
+u16_t vnc_draw_datalen;
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixel(u16_t x, u8_t y, u8_t c)
+{
+  u8_t o, a;
+  
+  vnc_draw_bitmapptr = bitmapptrtab[y] + (x & 0x1f8);  
+  
+  if(c) {
+    o = oratab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr | o;
+  } else {
+    a = andtab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr & a;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixelline(u16_t x, u16_t y, u8_t *data, u16_t datalen)
+{
+  u8_t o, a;
+  register u8_t *bitmapptr;
+  
+  vnc_draw_x = x - viewport_x;
+  vnc_draw_y = y - viewport_y;
+
+  /*  if(vnc_draw_y & 1) {
+    return;
+  } else {
+    vnc_draw_y /= 2;
+    }*/
+
+  
+  
+  if(vnc_draw_y >= VNC_CONF_VIEWPORT_HEIGHT ||
+     vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    return;
+  }
+
+  vnc_draw_datalen = datalen;
+  
+  if(vnc_draw_datalen + vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    vnc_draw_datalen = VNC_CONF_VIEWPORT_WIDTH - vnc_draw_x;
+    if(vnc_draw_datalen == 0) {
+      return;
+    }
+  }
+  
+  vnc_draw_dataptr = data;
+
+  /*  vnc_draw_bitmapptr = bitmaptab[vnc_draw_y] +
+      (vnc_draw_x & 0x1f8);*/
+
+  for(; vnc_draw_datalen > 0; --vnc_draw_datalen) {
+    /*    vnc_draw_pixel(vnc_draw_x, vnc_draw_y,
+	  conv[*vnc_draw_dataptr]);*/
+
+    bitmapptr = bitmapptrtab[vnc_draw_y] + (vnc_draw_x & 0x1f8);  
+    
+    if(conv[*vnc_draw_dataptr]) {
+      o = oratab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr | o;
+    } else {
+      a = andtab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr & a;
+    }
+    ++vnc_draw_dataptr;
+    ++vnc_draw_x;
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_init(void)
+{
+  unsigned int tmp;
+  unsigned int i;
+  unsigned short ptr;
+
+
+  /* Create color conversion table. */
+  for(i = 0; i < 256; ++i) {
+    if(((i & 0xc0) > 0xc0) ||
+       ((i & 0x38) > 0x18) ||
+       ((i & 0x07) > 0x03)) {
+      conv[i] = 0;
+    } else {
+      conv[i] = 1;
+    }
+  }
+
+  memset(vnc_draw_bitmap, 0, sizeof(vnc_draw_bitmap));
+  
+  for(i = 0; i < VNC_CONF_VIEWPORT_HEIGHT; ++i) {
+    bitmapptrtab[i] = (u8_t *)((u16_t)vnc_draw_bitmap +
+			       ((i & 0xfff8)/8) * VNC_CONF_VIEWPORT_WIDTH +
+			       (i & 7));
+  }
+
+  viewport_x = 0;
+  viewport_y = 0;
+
+  viewport_w = VNC_CONF_VIEWPORT_WIDTH;
+  viewport_h = VNC_CONF_VIEWPORT_HEIGHT;
+  
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_x(void)
+{
+  return viewport_x;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_y(void)
+{
+  return viewport_y;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_w(void)
+{
+  return viewport_w;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_h(void)
+{
+  return viewport_h;
+}
+/*-----------------------------------------------------------------------------------*/
+#if 0
+signed short
+c64_mouse_x(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+signed short
+c64_mouse_y(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+u8_t
+c64_mouse_buttons(void)
+{
+  return firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_x(unsigned short x)
+{
+  joyx = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_y(unsigned short y)
+{
+  joyy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_x(unsigned short x)
+{
+  viewport_x = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_y(unsigned short y)
+{
+  viewport_y = y;
+}
+/*-----------------------------------------------------------------------------------*/
+
+#endif /* 0 */
+#if 0
+#pragma optimize(push, off)
+void
+c64_scroll_up(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$80");
+  asm("sta $f7");
+  asm("lda #$a2");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$80");
+  asm("sta $fb");
+  asm("lda #$e2");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("lda $fc");
+  asm("cmp #$00");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $fe00,y");
+  asm("sta $be00,y");
+  asm("sta $fcc0,y");
+  asm("sta $bcc0,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $ff00,y");
+  asm("sta $bf00,y");
+  asm("sta $fdc0,y");
+  asm("sta $bdc0,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_down(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$c0");
+  asm("sta $fb");
+  asm("lda #$fb");
+  asm("sta $fc");
+  asm("lda #$40");
+  asm("sta $fd");
+  asm("lda #$fe");
+  asm("sta $fe");
+
+  asm("lda #$c0");
+  asm("sta $f7");
+  asm("lda #$bb");
+  asm("sta $f8");
+  asm("lda #$40");
+  asm("sta $f9");
+  asm("lda #$be");
+  asm("sta $fa");
+
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("dec $f8");
+  asm("dec $fa");
+  asm("dec $fc");
+  asm("dec $fe");
+
+
+  asm("lda $fe");
+  asm("cmp #$df");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $e000,y");
+  asm("sta $a000,y");
+  asm("sta $e140,y");
+  asm("sta $a140,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $e100,y");
+  asm("sta $a100,y");
+  asm("sta $e240,y");
+  asm("sta $a240,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_right(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$00");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$10");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$00");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$10");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  
+  asm("loop3:");
+  
+  asm("ldy #$ff");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #$30");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_left(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$10");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$10");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  asm("loop3:");
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #0");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("cpy #$30");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
+
+
+#endif /* 0 */
diff --git a/contiki-c64/apps/welcome.c b/contiki-c64/apps/welcome.c
new file mode 100644
index 0000000..1e77cf8
--- /dev/null
+++ b/contiki-c64/apps/welcome.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.1 2004/09/12 13:11:51 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+static struct ctk_label welcomelabel1 =
+  {CTK_LABEL(1, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING "!")};
+static struct ctk_label welcomelabel2 =
+  {CTK_LABEL(2, 4, 28, 1, "F1     - open menus")};
+static struct ctk_label welcomelabel3 =
+  {CTK_LABEL(2, 6, 28, 1, "F3     - cycle windows")};
+static struct ctk_label welcomelabel4 =
+  {CTK_LABEL(2, 8, 28, 1, "F5     - select up")};
+static struct ctk_label welcomelabel5 =
+  {CTK_LABEL(2, 10, 28, 1, "F7     - select down")};
+static struct ctk_label welcomelabel6 =
+  {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
+static struct ctk_label welcomelabel7 =
+  {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+  ctk_dialog_close();
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+  unsigned char width;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    width = ctk_desktop_width(NULL);
+    
+    if(width > 34) {
+      ctk_dialog_new(&welcomedialog, 32, 17);
+    } else {
+      ctk_dialog_new(&welcomedialog, width - 2, 17);
+    }
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);    
+    
+    ctk_dialog_open(&welcomedialog);
+    
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_keypress) {
+    welcome_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/wget-dsc.c b/contiki-c64/apps/wget-dsc.c
new file mode 100644
index 0000000..0717c26
--- /dev/null
+++ b/contiki-c64/apps/wget-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.4 2005/04/19 22:01:54 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon wget_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+    "Downloads files or D64 disks from the web",
+    "wget.prg",
+    wget_init,
+    &wget_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char wgeticon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char wgeticon_textmap[9] = {
+  'w', 'e', 'b',
+  'p', 'r', 'g',
+  'd', '6', '4'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon wget_icon =
+  {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/wget-dsc.h b/contiki-c64/apps/wget-dsc.h
new file mode 100644
index 0000000..36d4142
--- /dev/null
+++ b/contiki-c64/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2003/07/30 23:10:49 adamdunkels Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-c64/apps/wget.c b/contiki-c64/apps/wget.c
new file mode 100644
index 0000000..568f8fa
--- /dev/null
+++ b/contiki-c64/apps/wget.c
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.14 2005/05/12 21:26:46 oliverschmidt Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "loader.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <c64.h>
+#include <cbm.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "c64-dio.h"
+
+#define USE_KERNAL 0
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+  {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+  {CTK_TEXTENTRY(5, 1, 29, 1, urledit, 78)};
+
+
+static struct ctk_label savefilenamelabel =
+  {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+  {CTK_TEXTENTRY(15, 3, 19, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+  {CTK_BUTTON(0, 5, 13, "Download file")};
+
+static struct ctk_button d64button =
+  {CTK_BUTTON(17, 5, 18, "Download D64 disk")};
+
+static struct ctk_label statustext =
+  {CTK_LABEL(0, 7, 36, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window d64dialog;
+static struct ctk_label overwritelabel =
+  {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+  {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+  {CTK_LABEL(6, 4, 24, 1, "right disk in the drive!")};
+static struct ctk_button overwritebutton =
+  {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(wget_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Web downloader", NULL, wget_sighandler, webclient_appcall)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+	   wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_D64  2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+
+
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+static char buffer[256];
+static u16_t bufferptr;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+  if(arg != NULL) {
+    strncpy(url, arg, sizeof(url));
+    strncpy(urledit, arg, sizeof(urledit));
+    petsciiconv_topetscii(urledit, sizeof(urledit));
+  } else {
+#ifdef WGET_CONF_URL
+    strncpy(url, WGET_CONF_URL, sizeof(url));
+    strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL  */
+  }
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&statustext, text);
+  CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+  u16_t addr[2];
+  unsigned char i;
+  static char host[32];
+  char *file;
+  register char *urlptr;
+  unsigned short port;
+
+  /* Trim off any spaces in the end of the url. */
+  urlptr = url + strlen(url) - 1;
+  while(*urlptr == ' ' && urlptr > url) {
+    *urlptr = 0;
+    --urlptr;
+  }
+
+  /* Don't even try to go further if the URL is empty. */
+  if(urlptr == url) {
+    return;
+  }
+
+  /* See if the URL starts with http://, otherwise prepend it. */
+  if(strncmp(url, http_http, 7) != 0) {
+    while(urlptr >= url) {
+      *(urlptr + 7) = *urlptr;
+      --urlptr;
+    }
+    strncpy(url, http_http, 7);
+  } 
+
+  /* Find host part of the URL. */
+  urlptr = &url[7];  
+  for(i = 0; i < sizeof(host); ++i) {
+    if(*urlptr == 0 ||
+       *urlptr == '/' ||
+       *urlptr == ' ' ||
+       *urlptr == ':') {
+      host[i] = 0;
+      break;
+    }
+    host[i] = *urlptr;
+    ++urlptr;
+  }
+
+  /* XXX: Here we should find the port part of the URL, but this isn't
+     currently done because of laziness from the programmer's side
+     :-) */
+  
+  /* Find file part of the URL. */
+  while(*urlptr != '/' && *urlptr != 0) {
+    ++urlptr;
+  }
+  if(*urlptr == '/') {
+    file = urlptr;
+  } else {
+    file = "/";
+  }
+      
+  
+  /* First check if the host is an IP address. */
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    
+    /* Try to lookup the hostname. If it fails, we initiate a hostname
+       lookup and print out an informative message on the
+       statusbar. */
+    if(resolv_lookup(host) == NULL) {
+      resolv_query(host);
+      show_statustext("Resolving host...");
+      return;
+    }
+  }
+
+  /* The hostname we present in the hostname table, so we send out the
+     initial GET request. */
+  if(webclient_get(host, 80, file) == 0) {
+    show_statustext("Out of memory error.");
+  } else {
+    show_statustext("Connecting...");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+  int ret;
+  static unsigned char i;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create the main window. */
+    ctk_window_new(&window, 36, 8, "Web downloader");
+
+    
+    CTK_WIDGET_ADD(&window, &urllabel);
+    CTK_WIDGET_ADD(&window, &urltextentry);
+    
+    CTK_WIDGET_ADD(&window, &savefilenamelabel);
+    CTK_WIDGET_ADD(&window, &savefilenametextentry);
+
+    /*    CTK_WIDGET_ADD(&window, &filebutton);*/
+
+    CTK_WIDGET_ADD(&window, &d64button);
+
+    CTK_WIDGET_ADD(&window, &statustext);
+
+    dload_state = DLOAD_NONE;
+      
+    memset(savefilename, 0, sizeof(savefilename));
+    memset(url, 0, sizeof(url));
+
+    ctk_dialog_new(&d64dialog, 36, 8);
+    CTK_WIDGET_ADD(&d64dialog, &overwritelabel);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel1);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel2);
+    CTK_WIDGET_ADD(&d64dialog, &overwritebutton);
+    CTK_WIDGET_ADD(&d64dialog, &cancelbutton);
+    
+    
+    ctk_window_open(&window);
+  } else if(ev == tcpip_event) {
+    webclient_appcall(data);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (void *)&filebutton) {
+      /*      ret = cbm_open(2, 8, 2, savefilename);
+	      if(ret == -1) {*/
+	sprintf(statusmsg, "Open error with '%s'", savefilename);
+	show_statustext(statusmsg);
+	/*      } else {
+	strncpy(url, urledit, sizeof(url));
+	petsciiconv_toascii(url, sizeof(url));
+	start_get();
+	dload_bytes = 0;
+	dload_state = DLOAD_FILE;
+	}*/
+    } else if(data == (void *)&d64button) {
+      ctk_dialog_open(&d64dialog);
+    } else if(data == (void *)&cancelbutton) {
+      ctk_dialog_close();
+    } else if(data == (void *)&overwritebutton) {
+      ctk_dialog_close();
+
+      /* Turn of screensaver. */
+      program_handler_setscreensaver(NULL);
+      
+      strncpy(url, urledit, sizeof(url));
+      petsciiconv_toascii(url, sizeof(url));
+      start_get();
+      dload_bytes = 0;
+      dload_state = DLOAD_D64;
+      ds.track = 1;
+      ds.sect = 0;
+      bufferptr = 0;
+#if USE_KERNAL
+#else
+      c64_dio_init(_curunit);
+#endif
+      
+      /*      c64_dio_init(8);*/
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    if(dload_state == DLOAD_NONE) {
+      /*      open_link(w->widget.hyperlink.url);*/
+      strncpy(urledit,
+	      ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+      petsciiconv_topetscii(urledit, sizeof(urledit));
+      CTK_WIDGET_REDRAW(&urltextentry);
+      CTK_WIDGET_FOCUS(&window, &urltextentry);
+    }
+  } else if(ev == resolv_event_found) {
+    /* Either found a hostname, or not. */
+    if((char *)data != NULL &&
+       resolv_lookup((char *)data) != NULL) {
+      start_get();
+    } else {
+      show_statustext("Host not found.");
+    }
+  } else if(ev == ctk_signal_window_close) {
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+  show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+  show_statustext("Connection timed out");
+  if(dload_state == DLOAD_FILE) {
+    cbm_close(2);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{  
+  show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{    
+  show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+x_open(u8_t f, u8_t d, u8_t cmd, u8_t *fname)
+{
+  u8_t ret;
+  
+  ret = cbm_open(f, d, cmd, fname);
+  if(ret != 0) {
+    /*    printf("open: error %d\n", ret);*/
+    /*    ctk_label_set_text(&statuslabel, "Open err");
+	  CTK_WIDGET_REDRAW(&statuslabel);*/
+    show_statustext("Open error");
+  }
+  
+}
+static void
+write_sector(u8_t device, u8_t track, u8_t sect, void *mem)
+{
+  u16_t ret;
+  static u8_t cmd[32];
+  
+  x_open(15, device, 15, NULL);
+  x_open(2, device, 2, "#");
+
+  ret = cbm_write(2, mem, 256);
+  
+  sprintf(cmd, "u2: 2 0 %d %d", track, sect);  
+  cbm_write(15, cmd, strlen(cmd));
+  /*  printf("%s\n", cmd);*/
+    
+
+  /*  ret = 0;*/
+  if(ret == -1) {
+    sprintf(statusmsg, "Write error at %d:%d", track, sect);
+    show_statustext(statusmsg);
+  } else {
+    sprintf(statusmsg, "Wrote %d bytes to %d:%d", ret, track, sect);
+    show_statustext(statusmsg);
+  }
+  /*  printf("write: wrote %d bytes\n", ret);*/
+
+  cbm_close(2);
+  cbm_close(15);
+}
+
+static void
+write_buffer(void)
+{
+#if USE_KERNAL
+  write_sector(8, ds.track, ds.sect, buffer);
+#else
+  c64_dio_write_block(ds.track, ds.sect, buffer);
+#endif
+  if(next_sector() != 0) {
+    dload_state = DLOAD_NONE;
+  }
+}
+static void
+handle_d64_data(char *data, u16_t len)
+{
+  u16_t bufferlen;
+
+  while(dload_state == DLOAD_D64 &&
+	len > 0) {
+    bufferlen = sizeof(buffer) - bufferptr;
+    if(len < bufferlen) {
+      bufferlen = len;
+    }
+    
+    memcpy(&buffer[bufferptr], data, bufferlen);
+
+    data += bufferlen;
+    bufferptr += bufferlen;
+    len -= bufferlen;
+    
+    if(bufferptr == sizeof(buffer)) {
+      write_buffer();
+      bufferptr = 0;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():   
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+  int ret;
+  
+  if(len > 0) {
+    dload_bytes += len;    
+    sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+    show_statustext(statusmsg);
+    if(dload_state == DLOAD_D64) {
+      handle_d64_data(data, len);
+    } else if(dload_state == DLOAD_FILE) {      
+      ret = cbm_write(2, data, len);       
+      if(ret != len) {
+	sprintf(statusmsg, "Wrote only %d bytes", ret);
+	  show_statustext(statusmsg);	  
+      }
+    }
+  }
+  
+  if(data == NULL) {
+    if(dload_state == DLOAD_FILE) {
+      cbm_close(2);
+    }
+    dload_state = DLOAD_NONE;
+    sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+    show_statustext(statusmsg);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/c64.cfg b/contiki-c64/c64.cfg
new file mode 100644
index 0000000..76efb17
--- /dev/null
+++ b/contiki-c64/c64.cfg
@@ -0,0 +1,30 @@
+MEMORY {
+ ZP: start = $02, size = $1A, type = rw, define = yes;
+ RAM: start = $7FF, size = $c801, define = yes, file = %O;
+}
+SEGMENTS {
+ STARTUP: load = RAM, type = ro;
+ INIT: load = RAM, type = ro;
+ CODE: load = RAM, type = ro;
+ RODATA: load = RAM, type = ro;
+ DATA: load = RAM, type = rw;
+ BSS: load = RAM, type = bss, define = yes;
+ ZEROPAGE: load = ZP, type = zp;
+}
+FEATURES {
+ CONDES: segment = RODATA,
+	   type = constructor,
+	   label = __CONSTRUCTOR_TABLE__,
+	   count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+	   type = destructor,
+	   label = __DESTRUCTOR_TABLE__,
+	   count = __DESTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+	   type = interruptor,
+	   label = __INTERRUPTOR_TABLE__,
+	   count = __INTERRUPTOR_COUNT__;
+}
+SYMBOLS {
+  __STACKSIZE__ = $100;
+}
diff --git a/contiki-c64/conf/cc-conf.h b/contiki-c64/conf/cc-conf.h
new file mode 100644
index 0000000..cc3a1a2
--- /dev/null
+++ b/contiki-c64/conf/cc-conf.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.3 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-c64/conf/clock-conf.h b/contiki-c64/conf/clock-conf.h
new file mode 100644
index 0000000..a29d9ff
--- /dev/null
+++ b/contiki-c64/conf/clock-conf.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock-conf.h,v 1.4 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+#include <time.h>
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-c64/conf/ctk-conf.h b/contiki-c64/conf/ctk-conf.h
new file mode 100644
index 0000000..e80b626
--- /dev/null
+++ b/contiki-c64/conf/ctk-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.8 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          1
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-c64/conf/ctk-conio-conf.h b/contiki-c64/conf/ctk-conio-conf.h
new file mode 100644
index 0000000..c6f2591
--- /dev/null
+++ b/contiki-c64/conf/ctk-conio-conf.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.3 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+#define BACKGROUNDCOLOR     COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+#define BACKGROUNDCOLOR     COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 1
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+#define BACKGROUNDCOLOR     COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+#define BACKGROUNDCOLOR     COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-c64/conf/ek-conf.h b/contiki-c64/conf/ek-conf.h
new file mode 100644
index 0000000..62ff25d
--- /dev/null
+++ b/contiki-c64/conf/ek-conf.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.5 2004/09/01 20:48:55 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_num_events_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_MAXPROCS 32
+#define EK_CONF_NUMEVENTS 16
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-c64/conf/email-conf.h b/contiki-c64/conf/email-conf.h
new file mode 100644
index 0000000..28bb100
--- /dev/null
+++ b/contiki-c64/conf/email-conf.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: email-conf.h,v 1.1 2004/12/22 09:40:06 oliverschmidt Exp $
+ */
+#ifndef __EMAIL_CONF_H__
+#define __EMAIL_CONF_H__
+
+#define EMAIL_CONF_WIDTH 36
+#define EMAIL_CONF_HEIGHT 17
+
+#endif /* __EMAIL_CONF_H__ */
diff --git a/contiki-c64/conf/irc-conf.h b/contiki-c64/conf/irc-conf.h
new file mode 100644
index 0000000..1d953a2
--- /dev/null
+++ b/contiki-c64/conf/irc-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.3 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#define IRC_CONF_WIDTH 78
+#define IRC_CONF_HEIGHT 21
+
+#define IRC_CONF_SYSTEM_STRING "c64"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-c64/conf/libconio-conf.h b/contiki-c64/conf/libconio-conf.h
new file mode 100644
index 0000000..2241544
--- /dev/null
+++ b/contiki-c64/conf/libconio-conf.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: libconio-conf.h,v 1.4 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+#ifndef __LIBCONIO_CONF_H__
+#define __LIBCONIO_CONF_H__
+
+#define LIBCONIO_CONF_SCREEN_WIDTH  80
+#define LIBCONIO_CONF_SCREEN_HEIGHT 25
+
+#endif /* __LIBCONIO_CONF_H__ */
+
diff --git a/contiki-c64/conf/log-conf.h b/contiki-c64/conf/log-conf.h
new file mode 100644
index 0000000..ccb8c99
--- /dev/null
+++ b/contiki-c64/conf/log-conf.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: log-conf.h,v 1.2 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#ifndef __LOG_CONF_H__
+#define __LOG_CONF_H__
+
+#define LOG_CONF_ENABLED 1
+
+#endif /* __LOG_CONF__H__ */
diff --git a/contiki-c64/conf/program-handler-conf.h b/contiki-c64/conf/program-handler-conf.h
new file mode 100644
index 0000000..26a7dc6
--- /dev/null
+++ b/contiki-c64/conf/program-handler-conf.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.1 2005/02/15 14:57:49 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 10
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-c64/conf/shell-gui-conf.h b/contiki-c64/conf/shell-gui-conf.h
new file mode 100644
index 0000000..e797b20
--- /dev/null
+++ b/contiki-c64/conf/shell-gui-conf.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: shell-gui-conf.h,v 1.2 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#ifndef __SHELL_GUI_CONF_H__
+#define __SHELL_GUI_CONF_H__
+
+#define SHELL_GUI_CONF_XSIZE 26
+#define SHELL_GUI_CONF_YSIZE 12
+
+
+#endif /* __SHELL_GUI_CONF_H__ */
diff --git a/contiki-c64/conf/telnetd-conf.h b/contiki-c64/conf/telnetd-conf.h
new file mode 100644
index 0000000..bedb8f9
--- /dev/null
+++ b/contiki-c64/conf/telnetd-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h,v 1.1 2004/02/16 21:12:38 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 32
+#define TELNETD_CONF_NUMLINES 12
+
+#define TELNETD_CONF_GUI     1
+
+#endif /* __TELNETD_CONF_H__ */
+
diff --git a/contiki-c64/conf/uip-conf.h b/contiki-c64/conf/uip-conf.h
new file mode 100644
index 0000000..57d1a22
--- /dev/null
+++ b/contiki-c64/conf/uip-conf.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.8 2004/09/19 15:28:49 adamdunkels Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE     400
+#define UIP_CONF_RECEIVE_WINDOW  320
+
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+#define UIP_CONF_ARBTAB_SIZE 4
+
+#define UIP_CONF_RESOLV_ENTRIES  4
+#define UIP_CONF_PINGADDRCONF    0
+
+#define UIP_CONF_LOGGING         0
+#define UIP_CONF_UDP_CONNS       6
+#define UIP_CONF_BROADCAST       0
+
+#define UIP_CONF_UDP_CHECKSUMS   0
+
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-c64/conf/vnc-conf.h b/contiki-c64/conf/vnc-conf.h
new file mode 100644
index 0000000..2812ee9
--- /dev/null
+++ b/contiki-c64/conf/vnc-conf.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH  (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS    8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-c64/conf/www-conf.h b/contiki-c64/conf/www-conf.h
new file mode 100644
index 0000000..b32505d
--- /dev/null
+++ b/contiki-c64/conf/www-conf.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.11 2004/09/19 20:05:40 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 2
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 55
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 8
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 0
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       0
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  30
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-c64/ctk/ctk-80col-asm.S b/contiki-c64/ctk/ctk-80col-asm.S
new file mode 100644
index 0000000..4df6cad
--- /dev/null
+++ b/contiki-c64/ctk/ctk-80col-asm.S
@@ -0,0 +1,986 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		pushax
+	.import		incsp2
+
+	.import		_ctk_80col_screencolors
+	.import		_ctk_80col_screenpattern	
+		
+	.import		_ctk_80col_lefttab
+	.import		_ctk_80col_righttab
+	
+	.import		_ctk_80col_cursx
+	.import		_ctk_80col_cursy
+	.import		_ctk_80col_color
+	.import		_ctk_80col_underline	
+	.import		_ctk_80col_reversed
+
+	.import		_ctk_80col_yscreenaddr
+	.import		_ctk_80col_yhiresaddr
+
+	.import		_ctk_80col_windowparams
+	
+	.import		_ctk_80col_bitmapptr
+
+	.import		_ctk_80col_versionstring
+	.import		_ctk_80col_versionstring_len	
+	
+	.import		_ctk_80col_theme
+			
+	.export		_ctk_80col_cclear
+	.export		_ctk_80col_chline
+	.export		_ctk_80col_cputc
+	.export		_ctk_80col_cputsn
+	
+	.export		_ctk_80col_clear_line
+	.export		_ctk_80col_draw_bitmapline
+	
+	.export		_ctk_80col_draw_windowborders
+
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlecolor:  .res 1
+wptitlecolor = 6
+titlelen:    .res 1
+wptitlelen   = 7
+title:	.res 2
+wptitle      = 8
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_80col_cursx
+	asl
+	rol ptr1+1
+; 	asl	
+; 	rol ptr1+1	
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	and #$f8
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+	;; Find screen address. 
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_cursx
+	lsr
+	clc
+	adc _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+	
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_80col_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	ldy tmpl
+	lda _ctk_80col_color
+:		
+	sta (ptr1),y
+	dey
+	bpl :-
+	
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_80col_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf
+
+		
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_80col_cursx
+
+	dex
+	bpl @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_80col_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_80col_cputc:
+	sta tmpc
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+
+	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_80col_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+        jmp incsp2	
+:		
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:		
+
+	
+	lda #0
+	sta ptr1+1		  	
+
+	ldy tmpc
+	lda (ptr3),y
+	bne :+
+	jmp @end
+:	
+			
+	;; Convert from PETSCII to screen encoding
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp @loopend
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+			
+	inc _ctk_80col_cursx	
+@loopend:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	beq :+
+	jmp @loop1
+:	
+	
+@end:
+	jsr restore01
+	
+        jmp incsp2	
+;---------------------------------------------------------------------
+_ctk_80col_clear_line:
+	sta tmpl
+	asl
+	tax
+	lda _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	sta ptr1+1	
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+	
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+
+	ldy #39
+	ldx tmpl
+	lda _ctk_80col_screencolors,x
+:	
+	sta (ptr1),y
+	dey
+	bpl :-
+
+	lda tmpl
+	asl
+	asl
+	asl
+	tax
+	ldy #0
+:
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	bne :-
+
+	inc ptr2+1
+	
+:	
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	cpy #$40
+	bne :-
+
+	lda tmpl
+	cmp #24
+	bne :+			
+
+	sta _ctk_80col_cursy
+	lda #2
+	sta _ctk_80col_cursx
+
+	jsr restore01
+		
+	lda #<_ctk_80col_versionstring
+	ldx #>_ctk_80col_versionstring
+ 	jsr pushax		
+	lda _ctk_80col_versionstring_len
+	jmp _ctk_80col_cputsn
+:		
+	jmp restore01	
+;---------------------------------------------------------------------	
+_ctk_80col_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_80col_color
+:	
+	sta (ptr1),y	
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_80col_bitmapptr
+	sta ptr1
+	lda _ctk_80col_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_80col_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_80col_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	lda _ctk_80col_windowparams + wpw
+	sta tmpw	
+
+	
+	ldy #0
+	lda _ctk_80col_windowparams + wptitlecolor	
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	dec tmpw
+
+	;; Set color for upper right corner
+	sta (ptr1),y	
+	iny
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_80col_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+
+	
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_80col_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	bpl @titlebarloop
+
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_80col_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_80col_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_80col_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_80col_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_80col_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_80col_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_80col_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_80col_windowparams + wpw
+	lda _ctk_80col_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_80col_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_80col_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_80col_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_80col_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_80col_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_80col_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_80col_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+	
\ No newline at end of file
diff --git a/contiki-c64/ctk/ctk-80col-asm.h b/contiki-c64/ctk/ctk-80col-asm.h
new file mode 100644
index 0000000..2b88e3d
--- /dev/null
+++ b/contiki-c64/ctk/ctk-80col-asm.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-80col-asm.h,v 1.2 2004/09/06 06:33:39 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_80COL_ASM_H__
+#define __CTK_80COL_ASM_H__
+
+void __fastcall__ ctk_80col_cclear(unsigned char len);
+void __fastcall__ ctk_80col_chline(unsigned char len);
+void __fastcall__ ctk_80col_cputc(unsigned char c);
+void __fastcall__ ctk_80col_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_80col_draw_buttonleft(void);
+void ctk_80col_draw_buttonright(void);
+
+struct ctk_80col_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlecolor;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_80col_windowparams ctk_80col_windowparams;
+void ctk_80col_draw_windowborders(void);
+
+extern unsigned char ctk_80col_cursx,
+  ctk_80col_cursy,
+  ctk_80col_color,
+  ctk_80col_reversed,
+  ctk_80col_underline;
+
+
+void __fastcall__ ctk_80col_draw_bitmapline(unsigned char len);
+
+void __fastcall__ ctk_80col_clear_line(unsigned char len);
+
+#endif /* __CTK_80COL_ASM_H__ */
diff --git a/contiki-c64/ctk/ctk-80col-theme.h b/contiki-c64/ctk/ctk-80col-theme.h
new file mode 100644
index 0000000..72d9971
--- /dev/null
+++ b/contiki-c64/ctk/ctk-80col-theme.h
@@ -0,0 +1,83 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-80col-theme.h,v 1.3 2004/09/09 21:45:37 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_80COL_THEME_H__
+#define __CTK_80COL_THEME_H__
+
+struct ctk_80col_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpattern[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+
+};
+
+extern struct ctk_80col_theme ctk_80col_theme;
+extern struct ctk_80col_theme *ctk_80col_theme_ptr;
+
+#endif /* __CTK_80COL_THEME_H__ */
diff --git a/contiki-c64/ctk/ctk-80col.c b/contiki-c64/ctk/ctk-80col.c
new file mode 100644
index 0000000..21f0a28
--- /dev/null
+++ b/contiki-c64/ctk/ctk-80col.c
@@ -0,0 +1,1201 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-80col.c,v 1.16 2006/05/28 20:40:16 oliverschmidt Exp $
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+
+#include "ctk-80col-asm.h"
+
+#include "ctk-80col-theme.h"
+
+#include <string.h>
+
+unsigned char ctk_80col_cursx, ctk_80col_cursy;
+unsigned char ctk_80col_reversed;
+unsigned char ctk_80col_color;
+unsigned char *ctk_80col_bitmapptr;
+unsigned char ctk_80col_underline = 0;
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  80
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+unsigned char ctk_80col_lefttab[256];
+unsigned char ctk_80col_righttab[256];
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define COLOR_DIALOG            0x01
+#define COLOR_FOCUS_WINDOW      0xbf
+#define COLOR_BACKGROUND_WINDOW 0x0c
+
+#define color(c) ctk_80col_color = c
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+unsigned char ctk_80col_screencolors[25] =
+  {COLOR(BGCOLOR4,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,1)};
+
+unsigned char ctk_80col_screenpattern[25*8] =
+  {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+unsigned short ctk_80col_yscreenaddr[25] =
+  {0 * 40 + SCREENADDR, 1 * 40 + SCREENADDR,
+   2 * 40 + SCREENADDR, 3 * 40 + SCREENADDR,
+   4 * 40 + SCREENADDR, 5 * 40 + SCREENADDR,
+   6 * 40 + SCREENADDR, 7 * 40 + SCREENADDR,
+   8 * 40 + SCREENADDR, 9 * 40 + SCREENADDR,
+   10 * 40 + SCREENADDR, 11 * 40 + SCREENADDR,
+   12 * 40 + SCREENADDR, 13 * 40 + SCREENADDR,
+   14 * 40 + SCREENADDR, 15 * 40 + SCREENADDR,
+   16 * 40 + SCREENADDR, 17 * 40 + SCREENADDR,
+   18 * 40 + SCREENADDR, 19 * 40 + SCREENADDR,
+   20 * 40 + SCREENADDR, 21 * 40 + SCREENADDR,
+   22 * 40 + SCREENADDR, 23 * 40 + SCREENADDR,
+   24 * 40 + SCREENADDR};
+
+unsigned short ctk_80col_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+
+
+struct ctk_80col_theme ctk_80col_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xc0,0x80,0xbf,0x80,0xbf,0x80,0x80},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x03,0x01,0xfd,0x01,0xfd,0x01,0x01},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x03,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0x0f,0x3f,0x3f,0x7f,0x7f,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xf0,0xfc,0xfc,0xfe,0xfe,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_WHITE),
+    
+  };
+char ctk_80col_versionstring[] = CONTIKI_VERSION_STRING;
+char ctk_80col_versionstring_len = sizeof(CONTIKI_VERSION_STRING) - 1;
+
+struct ctk_80col_windowparams ctk_80col_windowparams;
+
+/*---------------------------------------------------------------------------*/
+/*void
+ctk_arch_draw_char(char c,
+		   unsigned char xpos,
+		   unsigned char ypos,
+		   unsigned char reversedflag,
+		   unsigned char color)
+{
+  ctk_80col_cursx = xpos;
+  ctk_80col_cursy = ypos;
+  ctk_80col_reversed = reversedflag;
+  ctk_80col_color = color;
+  
+  ctk_80col_cputc(c);
+}*/
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+void reset(void);
+void
+quit(void)
+{
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+  VIC.bordercolor = 0x0e; /* $D020 */
+  VIC.bgcolor0 = 0x06; /* $D021 */
+
+  memset((char *)0xd800, 0x0e, 40*25);
+
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+ctk_80col_init(void)
+{
+  int i;
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = 0x06; /* $D020 */
+  VIC.bgcolor0 = 0x0b; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  memset((char *)0xe000, 0, 8000);
+
+  for(i = 0; i < 256; ++i) {
+#if 0
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x20) << 1) |
+      ((i & 0x08) << 2) |
+      ((i & 0x02) << 3);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x20) >> 3) |
+      ((i & 0x08) >> 2) |
+      ((i & 0x02) >> 1);
+#else
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x10) << 2) |
+      ((i & 0x04) << 3) |
+      ((i & 0x01) << 4);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x10) >> 2) |
+      ((i & 0x04) >> 1) |
+      ((i & 0x01));
+#endif
+  }
+  
+#if 0
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_80col_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+#endif
+  return;
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+/*static unsigned char cursx, cursy;
+  static unsigned char reversed;*/
+
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+cputc(char c) 
+{
+  /*  ctk_arch_draw_char(c, cursx, cursy, reversed, 0);*/
+  ctk_80col_cputc(c);
+  /*  ++cursx;*/
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+  return ctk_80col_cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+  return ctk_80col_cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+/*void
+clrscr(void)
+{
+  unsigned char x, y;
+
+  for(x = 0; x < SCREEN_WIDTH; ++x) {
+    for(y = 0; y < SCREEN_HEIGHT; ++y) {
+      gotoxy(x, y);
+      cputc(' ');
+    }
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+#define revers(c) ctk_80col_reversed = c
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+_cputs(char *str)
+{
+  char *ptr = str;
+  
+  while(*ptr != 0) {
+    cputc(*ptr++);
+  }
+
+  /*  int i;
+  for(i = 0; i < strlen(str); ++i) {
+    cputc(str[i]);
+    }*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+cclear(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc(' ');
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('-');
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('|');
+    --ctk_80col_cursx;
+    ++ctk_80col_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_80col_cursx = x;
+  ctk_80col_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+_cputsxy(unsigned char x, unsigned char y, char *str)
+{
+  gotoxy(x, y);
+  _cputs(str);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cputcxy(unsigned char x, unsigned char y, char c)
+{
+  gotoxy(x, y);
+  cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+/*void CC_FASTCALL
+screensize(unsigned char *x, unsigned char *y)
+{
+  *x = SCREEN_WIDTH;
+  *y = SCREEN_HEIGHT;
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*static unsigned char sizex, sizey;*/
+/*-----------------------------------------------------------------------------------*/
+static void
+_cputsn(char *str, unsigned char len)
+{
+  /*  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+    }*/  
+  ctk_80col_cputsn(str, len);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_init(void)
+{
+  ctk_80col_init();
+
+  /*  screensize(&sizex, &sizey);*/
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else {
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	_cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      cputcxy(xpos, ypos, '[');
+      _cputsn(w->widget.button.text, w->w);
+      cputc(']');
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(0);
+      } else {
+	revers(1);
+      }
+      gotoxy(xpos, ypos);
+      _cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {	    
+	      c = text[i + xscroll];
+	    }
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      revers(1);
+	    } else {
+	      revers(0);
+	    }
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	    revers(0);
+	  }
+	  cputc('<');
+	} else {
+	  if(wfocus != 0 && j == w->widget.textentry.ypos) {
+	    revers(1);
+	  } else {
+	    revers(0);
+	  }
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  _cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      color(ctk_80col_theme.iconcolors[focus]);
+      
+      /*      if(focus & 1) {
+	
+	revers(1);
+      } else {
+	revers(0);
+	}*/
+      /*      gotoxy(xpos, ypos);*/
+      if(xpos >= 73) {
+	xpos = 73;
+      }
+      if(xpos <= 2) {
+	xpos = 2;
+      }
+      if(w->widget.icon.textmap != NULL) {
+	ctk_80col_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    gotoxy(xpos, ypos);
+	    ctk_80col_draw_bitmapline(3);	    
+	  }
+	  ctk_80col_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+      }
+      x = xpos;
+  
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      if(ypos >= clipy1 && ypos < clipy2) {
+	len = strlen(w->widget.icon.title);
+	gotoxy((x & 0xfe) + 1, ypos);
+	ctk_80col_cclear((len - 1)/ 2);
+	gotoxy(x, ypos);
+	ctk_80col_cputsn(w->widget.icon.title, len);
+      }
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		  unsigned char focus,
+		  unsigned char clipy1,
+		  unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = (win->x & 0xfe) + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+  
+  if(focus & CTK_FOCUS_WINDOW) {
+    color(COLOR_FOCUS_WINDOW);
+  } else {
+    color(COLOR_BACKGROUND_WINDOW);
+  }
+    
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      gotoxy((window->x & 0xfe) + 1, i);
+      ctk_80col_cclear((window->w + 1)/2);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		  unsigned char clipy1, unsigned char clipy2,
+		  unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+
+  
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x & 0xfe;
+  y = window->y + 1;
+  
+/*  if(focus & CTK_FOCUS_WINDOW) {
+  } else {
+  }*/
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  /* Draw window frame. */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (window->w-1)/2;
+  ctk_80col_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_80col_windowparams.clipy1 = 0;
+  } else {
+    ctk_80col_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_80col_windowparams.clipy2 = clipy2 - y + 1;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[focus+1];
+  ctk_80col_windowparams.title = window->title;
+  ctk_80col_windowparams.titlelen = window->titlelen/2;
+
+  if(ctk_80col_windowparams.clipy1 < ctk_80col_windowparams.clipy2 &&
+     ctk_80col_windowparams.clipy2 > 0) {
+    ctk_80col_draw_windowborders();
+  }
+  /*  
+  if(y >= clipy1) {
+    cputcxy(x, y, CH_ULCORNER);
+    gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
+    chline(window->w - (wherex() - x) - 2);
+    cputcxy(x2, y, CH_URCORNER);
+  }
+
+  h = window->h;
+  
+  if(clipy1 > y1) {
+    if(clipy1 - y1 < h) {
+      h = clipy1 - y1;
+            y1 = clipy1;
+    } else {
+      h = 0;
+    }
+  }
+
+  if(clipy2 < y1 + h) {
+    if(y1 >= clipy2) {
+      h = 0;
+    } else {
+      h = clipy2 - y1;
+    }
+  }
+
+  cvlinexy(x, y1, h);
+  cvlinexy(x2, y1, h);  
+
+  if(y + window->h >= clipy1 &&
+     y + window->h < clipy2) {
+    cputcxy(x, y2, CH_LLCORNER);
+    chlinexy(x1, y2, window->w);
+    cputcxy(x2, y2, CH_LRCORNER);
+  }
+  */
+  if(ctk_mode_get() != CTK_MODE_WINDOWMOVE) {
+    draw_window_contents(window, focus, clipy1, clipy2,
+			 x1, x2, y + 1, y2);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  
+  x = dialog->x & 0xfe;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  /*  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (dialog->w-1)/2;
+  ctk_80col_windowparams.h = dialog->h;
+  ctk_80col_windowparams.clipy1 = 0;
+  ctk_80col_windowparams.clipy2 = SCREEN_HEIGHT;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[5];
+
+  ctk_80col_draw_windowborders();  
+  
+  /* Clear dialog contents. */
+  color(COLOR_DIALOG);
+  for(i = y1; i < y2; ++i) {
+    gotoxy((x1 & 0xfe) + 2, i);
+    ctk_80col_cclear((dialog->w + 1)/2 - 2);
+    /*    cclearxy(x1, i, dialog->w);*/
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, SCREEN_HEIGHT,
+		       x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+
+  
+  for(i = y1; i < y2; ++i) {
+    
+    ctk_80col_clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  
+  color(ctk_80col_theme.openmenucolor);
+  
+  revers(0);
+  x = wherex();
+  _cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH - 2;
+  }
+    
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      color(ctk_80col_theme.activemenucolor);
+    } else {
+      color(ctk_80col_theme.openmenucolor);
+    }
+    gotoxy(x, y + 1);
+    ctk_80col_cclear(CTK_CONF_MENUWIDTH/2);
+
+    gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      /*      _cputs(m->items[y].title);*/
+      ctk_80col_cputsn(m->items[y].title, m->items[y].titlelen);
+    }
+    /*    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear(x + CTK_CONF_MENUWIDTH - wherex());
+      }*/
+  
+  }
+  gotoxy(x2, 0);
+  revers(1);
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+  
+  memcpy((char *)0xe000, ctk_80col_theme.menuleftpattern, 8);
+  /* Draw menus */
+  gotoxy(2, 0);
+
+  revers(1); 
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    color(ctk_80col_theme.menucolor);
+    if(m != menus->open) {
+      /*      _cputs(m->title);*/
+      ctk_80col_cputsn(m->title, m->titlelen);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+  color(ctk_80col_theme.menucolor);
+    
+  if(wherex() + strlen(menus->desktopmenu->title) + 2 >= SCREEN_WIDTH) {
+    gotoxy(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 2, 0);
+  } else {
+    cclear(SCREEN_WIDTH - wherex() -
+	   strlen(menus->desktopmenu->title) - 2);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    ctk_80col_cputsn(menus->desktopmenu->title, menus->desktopmenu->titlelen);
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  /*  gotoxy(78, 0);
+  color(ctk_80col_screencolors[0]);
+  cputc(' ');
+  cputc(' ');    */
+  
+  revers(0);
+  memcpy((char *)0xe138, ctk_80col_theme.menurightpattern, 8);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 4;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": 80col", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_80col_service_init, arg)
+{ 
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    quit();
+    ek_exit();
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-arch.h b/contiki-c64/ctk/ctk-arch.h
new file mode 100644
index 0000000..ebc8c50
--- /dev/null
+++ b/contiki-c64/ctk/ctk-arch.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.8 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#if CTK_HIRES
+#include "ctk-hires.h"
+#endif 
+
+#if CTK_CONIO
+#include "ctk-conio.h"
+#endif 
+
+#if CTK_VNCSERVER
+#include "ctk-vncarch.h"
+#endif
+
+#include <ctype.h>
+
+#define ctk_arch_isprint(c) isprint(c)
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-c64/ctk/ctk-hires-asm.S b/contiki-c64/ctk/ctk-hires-asm.S
new file mode 100644
index 0000000..8d52510
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-asm.S
@@ -0,0 +1,934 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		incsp2
+
+	
+	.import		_ctk_hires_cursx
+	.import		_ctk_hires_cursy
+	.import		_ctk_hires_color
+	.import		_ctk_hires_underline
+	.import		_ctk_hires_reversed
+
+	.import		_ctk_hires_yscreenaddr
+	.import		_ctk_hires_yhiresaddr
+
+	.import		_ctk_hires_windowparams
+	
+	.import		_ctk_hires_bitmapptr
+
+	.import		_ctk_hires_theme
+			
+	.export		_ctk_hires_cclear
+	.export		_ctk_hires_chline
+	.export		_ctk_hires_cputc
+	.export		_ctk_hires_cputsn
+
+	.export		_ctk_hires_draw_buttonleft
+	.export		_ctk_hires_draw_buttonright
+	
+	.export		_ctk_hires_draw_windowborders
+
+	.export		_ctk_hires_draw_bitmapline
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlelen:	.res 1
+wptitlelen   = 6
+title:	.res 2
+wptitle      = 7	
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_hires_cursy
+	asl
+	tax
+	lda _ctk_hires_yhiresaddr,x
+	sta ptr2
+	lda _ctk_hires_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_hires_cursx
+	asl
+	rol ptr1+1
+	asl	
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+
+	;; Find screen address. 
+	lda _ctk_hires_cursy
+	asl
+	tax	
+	lda _ctk_hires_yscreenaddr,x
+	clc
+	adc _ctk_hires_cursx
+	sta ptr1
+	lda _ctk_hires_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_hires_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_hires_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf	
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_cputc:
+	sta tmpc
+
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_hires_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+	
+	jsr setupptrs
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+			
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:	
+	
+	lda #0
+	sta ptr1+1		  
+		
+	ldy tmpc
+	lda (ptr3),y
+	beq @end
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	bne @loop1
+	
+@end:		
+	jsr restore01
+	
+        jmp incsp2
+	
+;---------------------------------------------------------------------
+_ctk_hires_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_hires_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y	
+	dey
+	dey
+	dey
+	sty tmpw	
+
+	ldy _ctk_hires_windowparams + wptitlelen
+	iny
+	iny
+	iny
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	inc tmpw
+
+	;; Set color for upper left corner
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_hires_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	;; Draw first empty char left of the title
+	ldy #8
+	lda #0
+:		
+; 	sta (ptr3),y		
+	iny
+	cpy #$10
+	bne :-
+
+	lda ptr3
+	clc
+	adc #$10
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;;  Draw the title
+	lda _ctk_hires_windowparams + wptitle
+	sta ptr4
+	lda _ctk_hires_windowparams + wptitle+1
+	sta ptr4+1
+	
+
+	lda #0
+	sta tmpc
+@titleloop:
+	lda #0
+	sta ptr5+1
+
+	ldy tmpc
+	lda (ptr4),y
+
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	;; Convert to address in character ROM
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	sta ptr5
+	lda #$d8
+	adc ptr5+1
+	sta ptr5+1
+
+	;; Print on hires screen, character by character, bottom-up.
+	ldy #7
+:
+	lda (ptr5),y
+; 	sta (ptr3),y		
+	dey
+	bpl :-
+	
+	lda ptr3
+	clc
+	adc #8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+	
+	inc tmpc
+	lda tmpc
+	cmp _ctk_hires_windowparams + wptitlelen
+	bne @titleloop
+
+	;; Draw empty char after the title
+	ldy #7
+	lda #0
+:		
+; 	sta (ptr3),y
+	dey	
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_hires_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	lda tmpw
+	cmp #3
+	bcs @titlebarloop
+
+	lda ptr3
+	clc
+	adc #$18
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:		
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_hires_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_hires_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_hires_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_hires_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_hires_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_hires_windowparams + wpw
+	lda _ctk_hires_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_hires_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_hires_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_hires_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_hires_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_hires_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_hires_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_hires_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonleft:
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonleftpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonright:
+	jsr setupptrs
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonrightpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_hires_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_hires_color
+:	
+ 	sta (ptr1),y
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_hires_bitmapptr
+	sta ptr1
+	lda _ctk_hires_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+	
\ No newline at end of file
diff --git a/contiki-c64/ctk/ctk-hires-asm.h b/contiki-c64/ctk/ctk-hires-asm.h
new file mode 100644
index 0000000..f5c6ad2
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-asm.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-asm.h,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_ASM_H__
+#define __CTK_HIRES_ASM_H__
+
+void __fastcall__ ctk_hires_cclear(unsigned char len);
+void __fastcall__ ctk_hires_chline(unsigned char len);
+void __fastcall__ ctk_hires_cputc(unsigned char c);
+void __fastcall__ ctk_hires_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_hires_draw_buttonleft(void);
+void ctk_hires_draw_buttonright(void);
+
+struct ctk_hires_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_hires_windowparams ctk_hires_windowparams;
+void ctk_hires_draw_windowborders(void);
+
+extern unsigned char ctk_hires_cursx,
+  ctk_hires_cursy,
+  ctk_hires_color,
+  ctk_hires_reversed,
+  ctk_hires_underline;
+
+
+void __fastcall__ ctk_hires_draw_bitmapline(unsigned char len);
+
+#endif /* __CTK_HIRES_ASM_H__ */
diff --git a/contiki-c64/ctk/ctk-hires-service.c b/contiki-c64/ctk/ctk-hires-service.c
new file mode 100644
index 0000000..cd94122
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-service.c
@@ -0,0 +1,930 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-service.c,v 1.4 2005/03/15 15:56:08 oliverschmidt Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+/*unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;*/
+
+static void s_ctk_draw_clear(unsigned char y1, unsigned char y2);
+
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+s_ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+  
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  s_ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": hires", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_conio_service_init, arg)
+{
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-hires-theme-blueround.c b/contiki-c64/ctk/ctk-hires-theme-blueround.c
new file mode 100644
index 0000000..dee3f5e
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme-blueround.c
@@ -0,0 +1,313 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-blueround.c,v 1.2 2003/04/24 17:08:15 adamdunkels Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x06
+#define BGCOLOR2 0x00
+#define BGCOLOR3 0x06
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_CYAN)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_CYAN),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_CYAN, COLOR_BLUE),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    /*unsigned char pointermaskcolor,*/
+    3,
+
+    /* Pointer sprite 1 color */
+    /*     pointercolor; */
+    6,
+
+    
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+     
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    },
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+
+      COLOR(BGCOLOR4,BGCOLOR4)},
+      
+    
+
+  };
diff --git a/contiki-c64/ctk/ctk-hires-theme-default.c b/contiki-c64/ctk/ctk-hires-theme-default.c
new file mode 100644
index 0000000..3a7379b
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme-default.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-default.c,v 1.3 2004/08/09 21:27:58 adamdunkels Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_YELLOW),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    6,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-c64/ctk/ctk-hires-theme-enabler.c b/contiki-c64/ctk/ctk-hires-theme-enabler.c
new file mode 100644
index 0000000..c75ebd1
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme-enabler.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-enabler.c,v 1.1 2003/04/24 17:07:40 adamdunkels Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x0f
+#define BGCOLOR2 0x0c
+#define BGCOLOR3 0x0b
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xfc,0xf0,0xf0,0xe0,0xe0,0xe0,0xe0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x3f,0x0f,0x0f,0x07,0x07,0x07,0x07},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},    
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GRAY3, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_GRAY1, COLOR_GRAY3),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-c64/ctk/ctk-hires-theme-ravenpine.c b/contiki-c64/ctk/ctk-hires-theme-ravenpine.c
new file mode 100644
index 0000000..dd5aaed
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme-ravenpine.c
@@ -0,0 +1,288 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-ravenpine.c,v 1.3 2004/07/04 18:33:08 adamdunkels Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x00
+#define BGCOLOR2 0x05
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xfc,0xfc,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0xfc,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x3e,0x30,0x30,0x30,0x30,0x30,0x30,0x3c},
+    
+    /* buttonright[8]; */
+    {0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_GREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+        
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GREEN, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_LIGHTGREEN, COLOR_GREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_LIGHTGREEN,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+    },
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-c64/ctk/ctk-hires-theme-springlight.c b/contiki-c64/ctk/ctk-hires-theme-springlight.c
new file mode 100644
index 0000000..31ed22e
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme-springlight.c
@@ -0,0 +1,284 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-springlight.c,v 1.2 2003/08/09 13:25:56 adamdunkels Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x05
+#define BGCOLOR2 0x0d
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x0f,0x18,0x10,0x10,0x10,0x10,0x10,0x00},    
+    
+    /* buttonright[8]; */
+    {0x00,0x08,0x08,0x08,0x08,0x08,0x18,0xf0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GREEN, COLOR_CYAN),
+     COLOR(COLOR_GREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTGREEN)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_LIGHTGREEN),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    5,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_WHITE,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 223, 255, 255, 247, 255, 255, 191, 247, 255, 255, 219, 255, 255, 187,
+255, 239, 251, 191, 239, 253, 223, 251, 223, 253, 183, 255, 213, 127, 237, 191,
+245, 95, 245, 223, 181, 255, 85, 255, 85, 219, 118, 219, 109, 219, 182, 109, 219, 182, 109, 219, 170, 109, 219, 170, 181, 173, 85, 218, 85, 173, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 146, 85, 146, 170, 82, 138, 50, 74, 164, 73,
+146, 84, 137, 82, 4, 169, 18, 164, 2, 168, 18, 68, 18, 160, 10, 32, 74, 0, 42, 128, 18, 64, 20, 0, 82, 0, 4, 80, 4, 0, 72, 2, 0, 16, 132, 0, 0, 72, 0, 0, 4, 64, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-c64/ctk/ctk-hires-theme.h b/contiki-c64/ctk/ctk-hires-theme.h
new file mode 100644
index 0000000..6ee7b82
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires-theme.h
@@ -0,0 +1,105 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme.h,v 1.1 2003/04/17 15:09:44 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_HIRES_THEME_H__
+#define __CTK_HIRES_THEME_H__
+
+struct ctk_hires_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpatterns[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  
+  /* Button corner colors. */
+  unsigned char buttonleftcolors[6],
+    buttonrightcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+ 
+  /* Border and screen colors. */
+  unsigned char bordercolor,
+    screencolor;
+
+  /* Pointer sprite colors. */
+  unsigned char pointermaskcolor,
+    pointercolor;
+  
+  /* Pointer sprite. */
+  unsigned char pointer[128];
+
+  /* Background pattern fill. */
+  unsigned char backgroundpattern[8*25];
+
+  /* Background colors. */
+  unsigned char backgroundpatterncolors[25];
+
+};
+
+extern struct ctk_hires_theme ctk_hires_theme;
+extern struct ctk_hires_theme *ctk_hires_theme_ptr;
+
+#endif /* __CTK_HIRES_THEME_H__ */
diff --git a/contiki-c64/ctk/ctk-hires.c b/contiki-c64/ctk/ctk-hires.c
new file mode 100644
index 0000000..22ce048
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires.c
@@ -0,0 +1,871 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.c,v 1.15 2005/03/15 15:56:08 oliverschmidt Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+/*unsigned char
+ctk_arch_isprint(char c)
+{
+  return isprint(c);
+}*/
diff --git a/contiki-c64/ctk/ctk-hires.h b/contiki-c64/ctk/ctk-hires.h
new file mode 100644
index 0000000..5ff533a
--- /dev/null
+++ b/contiki-c64/ctk/ctk-hires.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.h,v 1.2 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_H__
+#define __CTK_HIRES_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey   cgetc
+
+#define CH_ENTER '\n'
+
+#endif /* __CTK_HIRES_H__ */
diff --git a/contiki-c64/ctk/ctk-mouse-1351.S b/contiki-c64/ctk/ctk-mouse-1351.S
new file mode 100644
index 0000000..eeef7b5
--- /dev/null
+++ b/contiki-c64/ctk/ctk-mouse-1351.S
@@ -0,0 +1,149 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_1351
+;---------------------------------------------------------------------
+.bss
+OldValue:       .res    1               ; Temp for MoveCheck routine
+NewValue:       .res    1               ; Temp for MoveCheck routine
+YCorr:          .res    1               ; Correction for Y coordinate
+	
+OldPotX:        .res    1               ; Old hw counter values
+OldPotY:        .res    1
+ 
+SID_ADConv1     = $D419
+SID_ADConv2     = $D41A
+CIA1_PRA        = $DC00	
+CIA1_PRB        = $DC01	
+CIA1_DDRB       = $DC03	
+
+
+;---------------------------------------------------------------------
+.data
+XMin:           .word    0               ; X1 value of bounding box
+YMin:           .word    0               ; Y1 value of bounding box
+XMax:           .word    319             ; X2 value of bounding box
+YMax:           .word    199             ; Y2 value of bounding box
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+;---------------------------------------------------------------------
+	;; Most of the mouse code is taken from the CC65 libraries written by
+	;; Ullrich von Bassewitz
+MoveCheck:
+        sty     OldValue
+        sta     NewValue
+        ldx     #$00
+ 
+        sub     OldValue                ; a = mod64 (new - old)
+        and     #%01111111
+        cmp     #%01000000              ; if (a > 0)
+        bcs     @L1                     ;
+        lsr     a                       ;   a /= 2;
+        beq     @L2                     ;   if (a != 0)
+        ldy     NewValue                ;     y = NewValue
+        rts                             ;   return
+ 
+@L1:    ora     #%11000000              ; else or in high order bits
+        cmp     #$FF                    ; if (a != -1)
+        beq     @L2
+        sec
+        ror     a                       ;   a /= 2
+        dex                             ;   high byte = -1 (X = $FF)
+        ldy     NewValue
+        rts
+                                                                               
+@L2:    txa                             ; A = $00
+        rts
+                                                                               
+;---------------------------------------------------------------------	
+_ctk_mouse_1351:
+        lda     SID_ADConv1             ; Get mouse X movement
+        ldy     OldPotX
+        jsr     MoveCheck               ; Calculate movement vector
+        sty     OldPotX
+ 
+; Calculate the new X coordinate (--> a/y)
+ 
+        add     _ctk_mouse_joyx
+        tay                             ; Remember low byte
+        txa
+        adc     _ctk_mouse_joyx+1
+        tax
+ 
+; Limit the X coordinate to the bounding box
+ 
+        cpy     XMin
+        sbc     XMin+1
+        bpl     @L1
+        ldy     XMin
+        ldx     XMin+1
+        jmp     @L2
+@L1:    txa
+ 
+        cpy     XMax
+        sbc     XMax+1
+        bmi     @L2
+        ldy     XMax
+        ldx     XMax+1
+@L2:    sty     _ctk_mouse_joyx
+        stx     _ctk_mouse_joyx+1
+; Calculate the Y movement vector
+ 
+        lda     SID_ADConv2             ; Get mouse Y movement
+        ldy     OldPotY
+        jsr     MoveCheck               ; Calculate movement
+        sty     OldPotY
+ 
+; Calculate the new Y coordinate (--> a/y)
+ 
+        sta     OldValue
+        lda     _ctk_mouse_joyy
+        sub     OldValue
+        tay
+        stx     OldValue
+        lda     _ctk_mouse_joyy+1
+        sbc     OldValue
+        tax
+ 
+        cpy     YMin
+        sbc     YMin+1
+        bpl     @L3
+        ldy     YMin
+        ldx     YMin+1
+        jmp     @L4
+@L3:    txa
+                                                                               
+        cpy     YMax
+        sbc     YMax+1
+        bmi     @L4
+        ldy     YMax
+        ldx     YMax+1
+@L4:    sty     _ctk_mouse_joyy
+        stx     _ctk_mouse_joyy+1
+
+	;; Get mouse button
+        lda     #$7F
+        sta     CIA1_PRA
+        lda     CIA1_PRB                ; Read joystick #0
+        ldx     #0
+        and     #$1F
+        eor     #$1F
+	
+	ora     _ctk_mouse_firebutton
+	sta	_ctk_mouse_firebutton
+	
+	lda	#0
+	sta	CIA1_PRA
+	sta	CIA1_DDRB	
+	rts	
+;---------------------------------------------------------------------			
diff --git a/contiki-c64/ctk/ctk-mouse-asm.S b/contiki-c64/ctk/ctk-mouse-asm.S
new file mode 100644
index 0000000..6aa53b4
--- /dev/null
+++ b/contiki-c64/ctk/ctk-mouse-asm.S
@@ -0,0 +1,48 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton
+	.export		_ctk_mouse_asm_irq
+	.import		_ctk_mouse_joy, _ctk_mouse_1351
+;---------------------------------------------------------------------
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------			
+_ctk_mouse_asm_irq:
+	lda #0
+	sta _ctk_mouse_firebutton
+	
+	jsr _ctk_mouse_joy
+	;; jsr_ctk_mouse_1351
+
+ ; 	lda _ctk_mouse_joybutton
+ ; 	ora _ctk_mouse_1351button
+ ; 	sta _ctk_mouse_firebutton
+	
+	  lda _ctk_mouse_joyy
+	  clc
+	  adc #$32
+	  sta $d001
+	  sta $d003	
+
+	  lda _ctk_mouse_joyx
+	  clc
+	  adc #$18
+	  sta $d000
+	  sta $d002	
+	  lda #0
+	  adc _ctk_mouse_joyx+1
+	  and #1
+	  beq :+
+	  lda #3
+:		
+	  sta $d010                                                                                       
+	  jmp $ea31
diff --git a/contiki-c64/ctk/ctk-mouse-joy.S b/contiki-c64/ctk/ctk-mouse-joy.S
new file mode 100644
index 0000000..963ca36
--- /dev/null
+++ b/contiki-c64/ctk/ctk-mouse-joy.S
@@ -0,0 +1,135 @@
+
+;---------------------------------------------------------------------
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_joy	
+;---------------------------------------------------------------------
+.bss
+lastjoydy:	.res 1
+lastjoydx:	.res 1
+joydycnt:	.res 1
+joydxcnt:	.res 1
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+_ctk_mouse_joy:
+	  ldy $dc02
+	  lda #0
+          sta $dc02
+          lda $dc00
+          sty $dc02
+	  ldy #0
+	  ldx #0
+	  lsr
+	  bcs nodey
+	  dey
+nodey:
+	  lsr
+	  bcs noiny
+	  iny
+noiny:
+	  lsr
+	  bcs nodex
+	  dex
+nodex:
+	  lsr
+	  bcs noinx
+	  inx
+noinx:
+	  and #1
+	  eor #1
+	  ora _ctk_mouse_firebutton
+	  sta _ctk_mouse_firebutton
+
+	  cpy lastjoydy
+	  sty lastjoydy
+	  bne noydy
+	  tya
+	  pha
+	  inc joydycnt
+	  lda joydycnt
+          cmp #$1f
+          bmi nostajoydycnt
+          lda #$20
+	  sta joydycnt
+nostajoydycnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tay
+	  pla
+asldeyloop:
+	  asl
+	  dey
+	  bpl asldeyloop
+	  tay
+	  jmp ydy
+noydy:
+	  lda #0
+	  sta joydycnt
+ydy:
+
+	  tya
+	  clc
+	  adc _ctk_mouse_joyy
+
+	  cmp #240
+	  bcc :+
+	  lda #0
+:	
+		
+ 	  cmp #200
+ 	  bcc :+
+ 	  lda #199		
+:
+	  sta _ctk_mouse_joyy
+	
+	  cpx lastjoydx
+	  stx lastjoydx
+	  bne noxdx
+	  txa
+	  pha
+	  inc joydxcnt
+	  lda joydxcnt
+          cmp #$1f
+          bmi nostajoydxcnt
+          lda #$20
+	  sta joydxcnt
+nostajoydxcnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tax
+	  pla
+asldexloop:
+	  asl
+	  dex
+	  bpl asldexloop
+	  tax
+	  jmp xdx
+noxdx:
+	  lda #0
+	  sta joydxcnt
+xdx:
+	                                                                                       
+	  txa
+	  clc
+	  adc _ctk_mouse_joyx
+	  sta _ctk_mouse_joyx
+	  php
+	  lda #$ff
+	  cpx #0
+	  bmi nolda02
+	  lda #0
+nolda02:
+	  plp
+	  adc _ctk_mouse_joyx+1
+	  sta _ctk_mouse_joyx+1
+	  rts	                                                                                       
diff --git a/contiki-c64/ctk/ctk-mouse.c b/contiki-c64/ctk/ctk-mouse.c
new file mode 100644
index 0000000..f9031d0
--- /dev/null
+++ b/contiki-c64/ctk/ctk-mouse.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.c,v 1.6 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+unsigned short ctk_mouse_joyy, ctk_mouse_joyx;
+unsigned char ctk_mouse_firebutton;
+
+extern void ctk_mouse_asm_irq(void);
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_init(void)
+{
+  /* Place mouse pointer at the middle of the screen. */
+  ctk_mouse_joyx = 160;
+  ctk_mouse_joyy = 100;
+  
+  /* Setup and start IRQ */
+  asm("sei");
+  asm("lda #<%v", ctk_mouse_asm_irq);
+  asm("sta $0314");
+  asm("lda #>%v", ctk_mouse_asm_irq);
+  asm("sta $0315");   
+  asm("cli");
+  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+  if(ctk_mouse_joyx >= 342) {
+    ctk_mouse_joyx = 0;
+  } else if(ctk_mouse_joyx >= 320) {
+    ctk_mouse_joyx = 319;
+  }
+  return ctk_mouse_joyx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+  return ctk_mouse_joyy;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+  return ctk_mouse_firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_hide(void)
+{
+  /* Turn off sprites 0 and 1 */
+  asm("lda #0");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_show(void)
+{  
+  /* Turn on sprites 0 and 1 */
+  asm("lda #3");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki-c64/lib/mtarch-asm.S b/contiki-c64/lib/mtarch-asm.S
new file mode 100644
index 0000000..22ab609
--- /dev/null
+++ b/contiki-c64/lib/mtarch-asm.S
@@ -0,0 +1,245 @@
+;---------------------------------------------------------------------       
+	.importzp       ptr1
+	.importzp	sp
+	.import		__ZP_START__
+
+	
+	.import		_mtarch_asm_threadstack
+	.import		_mtarch_asm_threadsp
+	.import		_mtarch_asm_threadspreg
+	.import		_mtarch_asm_threadzp	
+	
+	.export		_mtarch_asm_exec
+	.export		_mtarch_yield
+	.export		_mtarch_asm_start
+	.export		_mtarch_pstart, _mtarch_pstop
+	
+;---------------------------------------------------------------------
+.bss
+kernelsp:	.res 2
+kernelspreg:	.res 1		
+	
+oldirq:		.res 2
+
+	zpsize = 32
+.code
+;---------------------------------------------------------------------	
+	;; Switch to thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped onto the threadstack, and the
+	;; sp and spreg are saved to the local variables "kernelsp" and
+	;; "kernelspreg". Also, the zeropage variables are saved.
+	
+_mtarch_asm_exec:
+	sei
+	;; Save current stack pointer
+	lda sp
+	sta kernelsp
+	lda sp+1
+	sta kernelsp+1
+	
+	tsx
+	stx kernelspreg
+	
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda _mtarch_asm_threadsp
+	sta sp
+	lda _mtarch_asm_threadsp+1
+	sta sp+1
+	
+	ldx _mtarch_asm_threadspreg
+	txs
+
+; 	jsr _mtarch_pstart	
+
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315
+
+	
+	pla
+	tay
+	pla
+	tax
+	pla
+	
+	rti
+
+	;; Switch from thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped back from the threadstack, and the
+	;; sp and spreg are restored from the local variables "kernelsp" and
+	;; "kernelspreg".
+yield:
+	sei
+	lda sp
+	sta _mtarch_asm_threadsp
+	lda sp+1
+	sta _mtarch_asm_threadsp+1
+
+	tsx
+	stx _mtarch_asm_threadspreg
+
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy #0
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda kernelsp
+	sta sp
+	lda kernelsp+1
+	sta sp+1
+	
+	ldx kernelspreg
+	txs
+
+	cli
+	
+	rts
+;---------------------------------------------------------------------
+	;; Simulate an IRQ by pushing CPU status and CPu registers
+	;; onto the stack. Then call the yield function to yield the
+	;; process.		
+_mtarch_yield:	
+	php
+	pha
+	txa
+	pha
+	tya
+	pha
+
+        tsx
+         
+                                ; the rts adds 1 to the PC
+                                ; saved on the stack. We want
+        lda $0105,x             ; the stack to look like is would
+        clc                     ; do inside of an interrupt.
+        adc #1                  ; (this is what the 'rts' does,
+        sta $0105,x             ;  but not the 'rti')
+        lda $0106,x
+        adc #0
+        sta $0106,x
+ 
+	
+	jmp yield		
+;---------------------------------------------------------------------
+_mtarch_asm_start:
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	rts
+
+;---------------------------------------------------------------------
+irq:
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	jmp yield
+;---------------------------------------------------------------------	
+	;; Setup preemption IRQ
+_mtarch_pstart:
+	sei
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315		
+	cli
+	rts
+;---------------------------------------------------------------------
+_mtarch_pstop:
+	sei
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	cli
+	rts	
+;---------------------------------------------------------------------
+
diff --git a/contiki-c64/lib/mtarch.c b/contiki-c64/lib/mtarch.c
new file mode 100644
index 0000000..46e9b0b
--- /dev/null
+++ b/contiki-c64/lib/mtarch.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.c,v 1.2 2004/09/12 20:30:03 adamdunkels Exp $
+ */
+#include "mtarch.h"
+#include <string.h>
+
+unsigned char  mtarch_asm_threadspreg;
+unsigned char *mtarch_asm_threadsp;
+unsigned char *mtarch_asm_threadzp;
+unsigned char *mtarch_asm_threadstack;
+
+void mtarch_asm_start(void);
+void mtarch_asm_exec(void);
+
+
+/*--------------------------------------------------------------------------*/
+void
+mtarch_start(struct mtarch_thread *thread,
+	     void (* function)(void *data),
+	     void *data)
+{
+  memset(thread->cpustack, 0, sizeof(thread->cpustack));
+  memset(thread->cstack, 0, sizeof(thread->cstack));
+  
+  /* Create a CPU stack frame with the appropriate values... */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((unsigned short)function) >> 8; /* high byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((unsigned short)function) & 0xff; /* low byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21; /* processor flags. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 5] =       /* a register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 6] =     /* x register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0;  /* y register */
+  thread->spreg = MTARCH_CPUSTACKSIZE - 8;
+
+  /* Setup the C stack with the data pointer. */
+  thread->sp = &thread->cstack[MTARCH_CSTACKSIZE - 1];
+  
+  mtarch_asm_threadzp    = &(thread->zp);  
+  mtarch_asm_start();
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_exec(struct mtarch_thread *thread)
+{
+  /* Switch processor stack. The call to mtarch_asm_switch() will not
+     return until the process that we switch to calls yield(). */
+  mtarch_asm_threadspreg = thread->spreg;
+  mtarch_asm_threadsp    = thread->sp;
+
+  mtarch_asm_threadstack = &(thread->cpustack[0]);  
+  mtarch_asm_threadzp    = &(thread->zp[0]);
+  
+  mtarch_asm_exec();
+
+  thread->sp = mtarch_asm_threadsp;
+  thread->spreg = mtarch_asm_threadspreg;  
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_init(void) {
+
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_remove(void)
+{
+
+}
diff --git a/contiki-c64/lib/mtarch.h b/contiki-c64/lib/mtarch.h
new file mode 100644
index 0000000..5967f4e
--- /dev/null
+++ b/contiki-c64/lib/mtarch.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.h,v 1.2 2004/09/12 20:30:04 adamdunkels Exp $
+ */
+#ifndef __MTARCH_H__
+#define __MTARCH_H__
+
+#define MTARCH_CPUSTACKSIZE 256
+#define MTARCH_CSTACKSIZE 256
+#define MTARCH_ZPSIZE 32
+
+struct mtarch_thread {
+  unsigned char  spreg;
+  unsigned char *sp;
+  unsigned char  cpustack[MTARCH_CPUSTACKSIZE];
+  unsigned char  cstack[MTARCH_CSTACKSIZE];
+  unsigned char  zp[MTARCH_ZPSIZE];
+};
+
+#endif /* __MTARCH_H__ */
+	
diff --git a/contiki-c64/lib/save-driveunit.S b/contiki-c64/lib/save-driveunit.S
new file mode 100644
index 0000000..b9a8f16
--- /dev/null
+++ b/contiki-c64/lib/save-driveunit.S
@@ -0,0 +1,7 @@
+	.import __curunit
+       	.constructor    saveunit, 32
+.code
+saveunit:
+     	lda	$ba
+     	sta	__curunit
+     	rts
diff --git a/contiki-c64/loader/c64-dio-asm.S b/contiki-c64/loader/c64-dio-asm.S
new file mode 100644
index 0000000..86b9639
--- /dev/null
+++ b/contiki-c64/loader/c64-dio-asm.S
@@ -0,0 +1,505 @@
+
+	
+	.export _c64_dio_asm_init
+	.export _c64_dio_asm_read_block
+	.export _c64_dio_asm_write_block	
+
+	.export _c64_dio_asm_track, _c64_dio_asm_sector
+
+	.export _c64_dio_asm_ptr
+	
+	.importzp ptr1, ptr2
+		
+	;; job code $80 read, $90 write
+	
+
+ciout    = $ffa8
+listen   = $ffb1
+second   = $ff93
+unlsn    = $ffae
+
+nbytes   = 34
+esc      = $42
+
+blockread = 1
+blockwrite = 2
+
+errok    = 0
+errerr   = 1
+
+.data
+_c64_dio_asm_track: .byte 0
+_c64_dio_asm_sector: .byte 0
+_c64_dio_asm_ptr: .byte 0,0			
+
+.code
+;---------------------------------------
+_c64_dio_asm_read_block:		
+
+  	lda #blockread
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+	 lda _c64_dio_asm_sector
+         jsr send
+
+
+         jsr recv
+         cmp #errok
+         bne readerr
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+readl:	
+         jsr recv
+         sta (ptr1),y
+         iny
+         bne readl
+         clc
+	 lda #0
+         tax	
+         rts
+readerr:	
+	;          sta $07c0	
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_write_block:		
+
+ 	lda #blockwrite
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+         lda _c64_dio_asm_sector
+         jsr send
+
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+writel:
+         lda (ptr1),y	
+         jsr send
+         iny
+         bne writel
+
+         jsr recv
+         cmp #errok
+         bne writeerr
+         lda #0
+	 tax
+         rts
+
+writeerr:	
+	;          sta $07c0
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_init:		
+         sta devnr
+         lda #$00
+         sta drvmem
+         lda #$05
+         sta drvmem+1
+
+         lda #<drive
+         sta ptr1
+         lda #>drive
+         sta ptr1+1
+
+       ; lda devnr
+       ; ldx #<icmd
+       ; ldy #>icmd
+       ; jsr drvcmd
+       ; jsr unlsn
+
+mwl:	
+         lda devnr
+         ldx #<mwcmd
+         ldy #>mwcmd
+         jsr drvcmd
+
+         ldy #0
+         lda (ptr1),y
+         jsr ciout
+         iny
+         cpy #nbytes
+         bne *-8
+
+         jsr unlsn
+
+         lda drvmem
+         clc
+         adc #nbytes
+         sta drvmem
+         lda drvmem+1
+         adc #0
+         sta drvmem+1
+
+         lda ptr1
+         clc
+         adc #nbytes
+         sta ptr1
+         tax
+         lda ptr1+1
+         adc #0
+         sta ptr1+1
+         cpx #<driveend
+         sbc #>driveend
+         bcc mwl
+
+         lda devnr
+         ldx #<mecmd
+         ldy #>mecmd
+         jsr drvcmd
+         jsr unlsn
+
+         rts
+;---------------------------------------
+drvcmd:	
+         stx ptr2
+         sty ptr2+1
+         jsr listen
+         lda #$6f
+         jsr second
+
+         ldy #0
+         lda (ptr2),y
+         sta drvcmdcmp+1
+         inc ptr2
+         bne *+4
+         inc ptr2+1
+
+         ldy #0
+         lda (ptr2),y
+         jsr ciout
+         iny
+drvcmdcmp:	 cpy #0
+         bne *-8
+         rts
+;---------------------------------------
+devnr:	    .byte 8
+mwcmd:	    .byte 6
+	.byte $4d, $2d, $57
+drvmem:	   .word $0500
+         .byte nbytes
+         .byte 0
+mecmd:	    .byte 2
+	 .byte $55, $33
+         .byte 0
+;---------------------------------------
+send:
+
+         sta ptr2
+         ldx #7
+sendl:	
+         lsr ptr2
+
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcc *+4
+         eor #$30
+         sta $dd00
+
+         lda #$c0
+         bit $dd00
+         bne *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         lda $dd00
+         and #$c0
+         eor #$c0
+         bne *-7
+
+         dex
+         bpl sendl
+
+	 ldx $d020
+	 lda #1
+	 sta $d020
+	 stx $d020
+		
+         rts
+;---------------------------------------
+recv:
+	 ldx $d020
+	 lda #0
+	 sta $d020
+	 stx $d020
+	
+         ldx #7
+recvl:	
+         lda $dd00
+         and #$c0
+         eor #$c0
+         beq *-7
+         asl a
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcs *+4
+         eor #$30
+         sta $dd00
+         ror ptr2
+
+         lda #$c0
+         bit $dd00
+         beq *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         dex
+         bpl recvl
+         lda ptr2
+         rts
+;---------------------------------------
+
+;---------------------------------------
+;the code residing in the drive:
+;---------------------------------------
+dtmp     = $46
+dtmp2    = $97
+dbuf     = $0300
+dbufcmd  = $00
+dbuftrack = $06
+dbufsect = $07
+
+retries  = 10
+bretries = 2
+;---------------------------------------
+drive  :		
+	.org $0500
+
+
+
+         cld
+         tsx
+         stx dstack
+         sei
+         jsr ledoff
+
+drivel:	
+         jsr dload
+         jsr ledoff
+         cli
+         jmp drivel
+;---------------------------------------
+ledon:	
+         lda $1c00
+         ora #$08
+         sta $1c00
+         rts
+ledoff:	
+         lda $1c00
+         and #$f7
+         sta $1c00
+         rts
+;---------------------------------------
+drecv:	
+         ldx #7
+drecvl:	
+         lda $1800
+         bmi atn
+         and #5
+         beq *-7
+         lsr a
+         lda #2
+         bcc *+4
+         lda #8
+         sta $1800
+         ror dtmp
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         beq *-9
+         lda #0
+         sta $1800
+         dex
+         bpl drecvl
+         lda dtmp
+         rts
+;---------------------------------------
+atn:	
+         ldx dstack
+         txs
+         cli
+         rts
+;---------------------------------------
+dsend:	
+         sta dtmp
+         ldx #7
+dsendl:	
+         lsr dtmp
+         lda #2
+         bcs *+4
+         lda #8
+         sta $1800
+
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         bne *-9
+
+         sta $1800
+
+         lda #5
+         bit $1800
+         bne *-3
+         dex
+         bpl dsendl
+         rts
+;---------------------------------------
+dload:
+         ldy #0
+
+         jsr drecv
+         sta dcmd
+	
+         jsr ledon
+	
+         jsr drecv
+         sta dbuftrack
+
+         jsr drecv
+         sta dbufsect
+
+	 lda dcmd
+	 cmp #blockwrite
+	 bne dblockread
+dblockwrite:
+         ldy #0
+drecvpl:	
+         jsr drecv
+         sta dbuf,y	
+         iny
+         bne drecvpl
+	
+	 jmp dputsect
+
+dblockread:		
+         jsr dgetsect
+
+dsendpage:	
+         ldy #0
+dsendpl:	
+         lda dbuf,y
+         jsr dsend
+         iny
+         bne dsendpl
+         rts
+;---------------------------------------
+dgetsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dgetsectl:	
+         lda #$80
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dgsnoerr
+
+         cpx #0
+         beq dgsserr
+         dex
+         cpx #bretries
+         bcs dgetsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dgetsectl
+
+dgsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dgsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+dputsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dputsectl:	
+         lda #$90
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dpsnoerr
+
+         cpx #0
+         beq dpsserr
+         dex
+         cpx #bretries
+         bcs dputsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dputsectl
+
+dpsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dpsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+led:	      .byte 0,0
+dstack:	   .byte 0
+dcmd:	     .byte 0
+.RELOC
+driveend:	
+
diff --git a/contiki-c64/loader/c64-dio-asm.h b/contiki-c64/loader/c64-dio-asm.h
new file mode 100644
index 0000000..953908a
--- /dev/null
+++ b/contiki-c64/loader/c64-dio-asm.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio-asm.h,v 1.3 2004/09/12 14:07:31 adamdunkels Exp $
+ *
+ */
+#ifndef __C64_DIO_ASM_H__
+#define __C64_DIO_ASM_H__
+
+extern unsigned char c64_dio_asm_track,
+  c64_dio_asm_sector;
+
+extern unsigned char *c64_dio_asm_ptr;
+
+void __fastcall__ c64_dio_asm_init(unsigned char drive);
+unsigned char c64_dio_asm_read_block(void);
+unsigned char c64_dio_asm_write_block(void);
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-c64/loader/c64-dio.c b/contiki-c64/loader/c64-dio.c
new file mode 100644
index 0000000..b765182
--- /dev/null
+++ b/contiki-c64/loader/c64-dio.c
@@ -0,0 +1,119 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * C64 direct disk I/O.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */ 
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.c,v 1.2 2004/02/16 20:58:54 adamdunkels Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read a block of data (256 bytes) from the disk.
+ *
+ * \param track The track of the disk block to be read.
+ *
+ * \param sector The sector of the disk block to be read.
+ *
+ * \param ptr A pointer to a buffer than must be able to accomodate
+ * 256 bytes of data.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * read.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_read_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_read_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write a block of data (256 bytes) to the disk.
+ *
+ * \param track The track of the disk block to be written.
+ *
+ * \param sector The sector of the disk block to be written.
+ *
+ * \param ptr A pointer to a buffer containing the 256 bytes of data
+ * to be written.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * written.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_write_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_write_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the direct disk I/O routines for a particular disk drive.
+ *
+ * This function must be called before any of the other direct disk
+ * I/O functions can be used.
+ *
+ * \param drive The drive number of the disk drive for which the
+ * direct disk I/O should be enabled.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_dio_init(unsigned char drive)
+{
+  c64_dio_asm_init(drive);
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-c64/loader/c64-dio.h b/contiki-c64/loader/c64-dio.h
new file mode 100644
index 0000000..6eac623
--- /dev/null
+++ b/contiki-c64/loader/c64-dio.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.h,v 1.2 2004/02/16 20:58:54 adamdunkels Exp $
+ *
+ */
+#ifndef __C64_DIO_H__
+#define __C64_DIO_H__
+
+void c64_dio_init(unsigned char drive);
+
+unsigned char c64_dio_read_block(unsigned char track,
+				 unsigned char sector,
+				 unsigned char *buf);
+
+unsigned char c64_dio_write_block(unsigned char track,
+				  unsigned char sector,
+				  unsigned char *buf);
+
+#define C64_DIO_OK 0
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-c64/loader/c64-fs-raw.c b/contiki-c64/loader/c64-fs-raw.c
new file mode 100644
index 0000000..e1ff4b6
--- /dev/null
+++ b/contiki-c64/loader/c64-fs-raw.c
@@ -0,0 +1,205 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * "Raw" C64 file system access.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file provides functions that allow reading data from files
+ * without updating the file descriptor pointer. The functions are not
+ * automatically included in the core Contiki code and therefore
+ * application programs that use tham must manually link with this
+ * file.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.c,v 1.3 2004/02/16 21:00:14 adamdunkels Exp $
+ *
+ */
+
+#include "c64-fs-raw.h"
+
+#include <string.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+
+extern unsigned char _c64_fs_dirbuf[256];
+extern unsigned char _c64_fs_dirbuftrack, _c64_fs_dirbufsect;
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack, _c64_fs_filebufsect;
+
+void _c64_fs_readdirbuf(unsigned char track, unsigned char sect);
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from a file without updating the file descriptor pointer.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller, but does not update the file
+ * description pointer like the c64_fs_read() function does.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_read_raw(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+  unsigned char fptr, ftrack, fsect;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  fptr = f->ptr;
+  ftrack = f->track;
+  fsect = f->sect;
+  
+  for(i = 0; i < len; ++i) {
+    *buf = _c64_fs_filebuf[fptr];
+    
+    ++fptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(fptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(fptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = ftrack = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = fsect = _c64_fs_filebuf[1];
+      fptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the file descriptior pointer forward in the file.
+ *
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param len The number of bytes the pointer should be moved forward.
+ *
+ * \return The number of bytes that the pointer actually was moved, or
+ * 0 if an end of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_read_next(register struct c64_fs_file *f, int len)
+{
+  int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+    
+    ++f->ptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }    
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-c64/loader/c64-fs-raw.h b/contiki-c64/loader/c64-fs-raw.h
new file mode 100644
index 0000000..3c52b60
--- /dev/null
+++ b/contiki-c64/loader/c64-fs-raw.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.h,v 1.3 2004/02/16 21:00:14 adamdunkels Exp $
+ *
+ */
+#ifndef __C64_FS_RAW_H__
+#define __C64_FS_RAW_H__
+
+#include "c64-fs.h"
+
+int __fastcall__ c64_fs_read_raw(struct c64_fs_file *f,
+				 char *buf, int len);
+
+int c64_fs_read_next(struct c64_fs_file *f, int len);
+
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-c64/loader/c64-fs-write.c b/contiki-c64/loader/c64-fs-write.c
new file mode 100644
index 0000000..e67e8dd
--- /dev/null
+++ b/contiki-c64/loader/c64-fs-write.c
@@ -0,0 +1,121 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of C64 file writes.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The functions in this file are not included in the core Contiki
+ * code, but must be explicitly linked by an application that that
+ * wishes to be able to write to files.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-write.c,v 1.3 2004/02/16 21:00:14 adamdunkels Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-fs.h"
+#include <string.h>
+
+/* An *UGLY* implementation of c64_fs_write that only can be used to
+   overwrite a single block file. */
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack,
+  _c64_fs_filebufsect;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write data to an open file.
+ *
+ * \note This function currently does not support writing to other than a single block file (cannot be more than 254 bytes long).
+ *
+ * \param f A pointer to a file descriptor previously opened with c64_fs_open().
+ *
+ * \param buf A pointer to a buffer with data that should be written
+ * to the file.
+ *
+ * \param len The length of the data that should be written.
+ *
+ * \return The number of bytes actually written.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_write(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+
+  if(len <= 0) {
+    return 0;
+  }
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+
+  i = 256 - f->ptr;
+  if(len < i) {
+    i = len;
+  }
+
+  memcpy(&_c64_fs_filebuf[f->ptr], buf, i);
+
+  f->ptr += i;
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr > _c64_fs_filebuf[1]) {
+    _c64_fs_filebuf[1] = f->ptr;    
+  }
+
+  c64_dio_write_block(_c64_fs_filebuftrack,
+		      _c64_fs_filebufsect,
+		      _c64_fs_filebuf);
+  
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-c64/loader/c64-fs.c b/contiki-c64/loader/c64-fs.c
new file mode 100644
index 0000000..a3e36f7
--- /dev/null
+++ b/contiki-c64/loader/c64-fs.c
@@ -0,0 +1,411 @@
+/**
+ * \defgroup c64fs C64 file system and disk functions.
+ * @{
+ *
+ * The C64 file system functions are divided into two categories:
+ * those that deal with C64 files and the C64 disk directory, and
+ * those that allow direct block access to the disk. The former
+ * functions can be used for accessing regular files, whereas the
+ * latter functions are used e.g. to download D64 files onto 1541
+ * disks.
+ *
+ * \note The C64 filesystem functions currently only work with the
+ * 1541/1541-II/1571 and compatible drives, and not with the IDE64
+ * hard disks or the 1581/FD2000 3.5" drives.
+ *
+ * 
+ */
+
+/**
+ * \file
+ * C64 file system operations interface for Contiki.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.c,v 1.10 2004/07/18 13:20:11 oliverschmidt Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+#include "c64-fs.h"
+
+#include <string.h>
+#include <stdio.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+unsigned char _c64_fs_dirbuf[256];
+unsigned char _c64_fs_dirbuftrack = 0, _c64_fs_dirbufsect = 0;
+
+unsigned char _c64_fs_filebuf[256];
+unsigned char _c64_fs_filebuftrack = 0, _c64_fs_filebufsect = 0;
+
+static struct c64_fs_dirent lastdirent;
+
+static struct c64_fs_dir opendir;
+static struct c64_fs_dirent opendirent;
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a file.
+ *
+ * The file description must be allocated by the caller and a pointer
+ * to it is passed to this function.
+ *
+ * \param name A pointer to the name of the file to be opened.
+ * \param f A pointer to the file descriptor struct.
+ *
+ * \retval 0 If the file was successfully opened.
+ * \retval -1 If the file does not exist.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_open(const char *name, register struct c64_fs_file *f)
+{
+  /* First check if we already have the file cached. If so, we don't
+     need to do an expensive directory lookup. */
+  if(strncmp(lastdirent.name, name, 16) == 0) {
+    f->track = lastdirent.track;
+    f->sect = lastdirent.sect;
+    f->ptr = 2;
+    return 0;
+  }
+
+  /* Not in cache, so we walk through directory instead. */
+  c64_fs_opendir(&opendir);
+
+  do {
+    c64_fs_readdir_dirent(&opendir, &opendirent);
+    if(strncmp(opendirent.name, name, 16) == 0) {
+      f->track = opendirent.track;
+      f->sect = opendirent.sect;
+      f->ptr = 2;
+      return 0;
+    }
+  } while(c64_fs_readdir_next(&opendir) == 0);
+
+  /* The file was not found in the directory. We flush the directory
+     buffer cache now in order to prevent a nasty problem from
+     happening: If the first directory block of an empty disk was
+     cached, *all* subsequent file opens would return "file not
+     found". */
+  _c64_fs_dirbuftrack = 0; /* There are no disk blocks on track 0. */
+  return -1;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from an open file.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if !NOASM
+#pragma optimize(push, off)
+#endif /* !NOASM */
+int __fastcall__
+c64_fs_read(register struct c64_fs_file *f, char *buf, int len)
+{
+  static int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+
+#if NOASM
+  if(f->track != _c64_fs_filebuftrack ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack, _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+#else /* NOASM */
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebuftrack);
+  asm("bne doblock");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebufsect);
+  asm("bne doblock");
+
+  asm("jmp noblock");
+
+  asm("doblock:");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebuftrack);
+  asm("sta %v", c64_dio_asm_track);
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebufsect);
+  asm("sta %v", c64_dio_asm_sector);
+
+  asm("lda #<(%v)", _c64_fs_filebuf);
+  asm("sta %v", c64_dio_asm_ptr);
+  asm("lda #>(%v)", _c64_fs_filebuf);
+  asm("sta %v+1", c64_dio_asm_ptr);
+
+  asm("jsr %v", c64_dio_asm_read_block);
+
+  asm("noblock:");
+
+#endif /* NOASM */
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+#if NOASM    
+    *buf = _c64_fs_filebuf[f->ptr];
+    ++f->ptr;
+#else /* NOASM */	
+    asm("ldy #%o+1", buf);
+    asm("jsr ldaxysp");
+    asm("sta ptr2");
+    asm("stx ptr2+1");
+
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("lda (regbank+%b),y", 4);    
+    asm("tax");
+
+    asm("ldy #0");
+    asm("lda %v,x", _c64_fs_filebuf);
+    asm("sta (ptr2),y");
+
+    asm("inx");
+    asm("txa");
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("sta (regbank+%b),y", 4);    
+#endif /* NOASM */
+
+    
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+#if !NOASM    
+#pragma optimize(pop)
+#endif /* !NOASM */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close an open file.
+ *
+ * \param f A pointer to a file descriptor struct that previously has
+ * been opened with c64_fs_open().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_close(struct c64_fs_file *f)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Read a directory buffer into the _c64_fs_dirbuf buffer.
+ *
+ * This function is shared between this and  the c64-fs-raw module.
+ *
+ * \param track The track of the directory block.
+ * \param sect The sector of the directory block.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+_c64_fs_readdirbuf(unsigned char track, unsigned char sect)
+{
+  if(_c64_fs_dirbuftrack == track &&
+     _c64_fs_dirbufsect == sect) {
+    /* Buffer already contains requested block, return. */
+    return;
+  }
+  c64_dio_read_block(track, sect, _c64_fs_dirbuf);
+  _c64_fs_dirbuftrack = track;
+  _c64_fs_dirbufsect = sect;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open the disk directory for reading.
+ *
+ * The caller must supply a pointer to a directory descriptor.
+ *
+ * \param d A pointer to a directory description that must be
+ * allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_opendir(register struct c64_fs_dir *d)
+{
+  d->track = 18;
+  d->sect = 1;
+  d->ptr = 2;
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read the current directory entry.
+ *
+ * This function reads the directory entry to which the directory
+ * descriptor currently points into a struct c64_fs_dirent supplied by
+ * the caller.
+ *
+ * The function c64_fs_readdir_next() is used to move the directory
+ * entry pointer forward in the directory.
+ *
+ * \param d A pointer to a directory descriptor previously opened with c64_fs_opendir().
+ *
+ * \param f A pointer to a directory entry that must have been
+ * previously allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_readdir_dirent(register struct c64_fs_dir *d,
+		      register struct c64_fs_dirent *f)
+{
+  struct directory_entry *de;
+  int i;
+  register char *nameptr;
+  
+  _c64_fs_readdirbuf(d->track, d->sect);
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  nameptr = de->name;
+  for(i = 0; i < 16; ++i) {
+    if(*nameptr == 0xa0) {
+      *nameptr = 0;
+      break;
+    }
+    ++nameptr;
+  }
+  strncpy(f->name, de->name, 16);
+  f->track = de->track;
+  f->sect = de->sect;
+  f->size = de->blockslo + (de->blockshi >> 8);
+  memcpy(&lastdirent, f, sizeof(struct c64_fs_dirent));
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the directory pointer forward.
+ *
+ * This function moves the directory entry pointer in the directory
+ * descriptor forward so that it points to the next file.
+ *
+ * \param d A pointer to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ *
+ * \retval 1 If there are no more directory entried in the directory.
+ * \retval 0 There were more directory entries and the pointer has
+ * been moved to point to the next one.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_readdir_next(struct c64_fs_dir *d)
+{
+  struct directory_entry *de;
+ again:
+  _c64_fs_readdirbuf(d->track, d->sect);
+  if(d->ptr == 226) {
+    if(_c64_fs_dirbuf[0] == 0) {
+      return 1;
+    }
+    d->track = _c64_fs_dirbuf[0];
+    d->sect = _c64_fs_dirbuf[1];
+    d->ptr = 2;
+  } else {
+    d->ptr += 32;
+  }
+
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  if(de->type == 0) {
+    goto again;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close a directory descriptor previously opened by c64_fs_opendir().
+ *
+ * \param d A poitner to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_closedir(struct c64_fs_dir *d)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-c64/loader/c64-fs.h b/contiki-c64/loader/c64-fs.h
new file mode 100644
index 0000000..804c2f2
--- /dev/null
+++ b/contiki-c64/loader/c64-fs.h
@@ -0,0 +1,97 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the C64 filesystem functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.h,v 1.6 2004/02/16 21:00:14 adamdunkels Exp $
+ *
+ */
+#ifndef __C64_FS_H__
+#define __C64_FS_H__
+
+#include "c64-dio.h"
+
+/**
+ * An opaque structure with no user visible elements that represents
+ * an open file.
+ */
+struct c64_fs_file {
+  unsigned char track, sect, ptr;
+};
+
+int c64_fs_open(const char *name, struct c64_fs_file *f);
+void c64_fs_close(struct c64_fs_file *f);
+int __fastcall__ c64_fs_read(struct c64_fs_file *f,
+			     char *buf, int len);
+
+int __fastcall__ c64_fs_write(struct c64_fs_file *f,
+			      char *buf, int len);
+
+/**
+ * An opaque structure with no user visible elements that represents a
+ * directory descriptor.
+ */
+struct c64_fs_dir {
+  unsigned char track, sect, ptr;
+};
+
+/**
+ * A C64 directory entry.
+ */
+struct c64_fs_dirent {
+  char name[17];        /**< The name of the directory entry. */
+  unsigned short size;  /**< The size of the directory entry in 256 byte blocks. */
+  unsigned char track,  
+    sect;
+};
+
+
+unsigned char c64_fs_opendir(struct c64_fs_dir *d);
+
+void c64_fs_readdir_dirent(struct c64_fs_dir *d,
+			   struct c64_fs_dirent *f);
+unsigned char c64_fs_readdir_next(struct c64_fs_dir *d);
+
+void c64_fs_closedir(struct c64_fs_dir *d);
+
+/** @} */
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-c64/loader/cfs-cbm.c b/contiki-c64/loader/cfs-cbm.c
new file mode 100644
index 0000000..aadebe9
--- /dev/null
+++ b/contiki-c64/loader/cfs-cbm.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.c,v 1.3 2004/09/14 07:32:06 adamdunkels Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cfs_cbm_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    log_message("Starting KERNAL CFS", "");
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, f, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+  return cbm_opendir(4, 8);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  struct cbm_dirent ce;
+  int ret;
+  ret = cbm_readdir(4, &ce);
+  strncpy(e->name, ce.name, sizeof(ce.name));
+  e->size = ce.size;
+  return ret;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+  cbm_closedir(4);
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/loader/cfs-cbm.h b/contiki-c64/loader/cfs-cbm.h
new file mode 100644
index 0000000..ea7a870
--- /dev/null
+++ b/contiki-c64/loader/cfs-cbm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.h,v 1.2 2004/09/12 20:30:04 adamdunkels Exp $
+ */
+#ifndef __CFS_CBM_H__
+#define __CFS_CBM_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cbm_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-c64/loader/cfs-init.c b/contiki-c64/loader/cfs-init.c
new file mode 100644
index 0000000..91f762d
--- /dev/null
+++ b/contiki-c64/loader/cfs-init.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.c,v 1.2 2004/09/12 20:30:04 adamdunkels Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l) {return -1;}
+static int  s_opendir(struct cfs_dir *p, const char *n) {return -1;}
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;}
+static int  s_closedir(struct cfs_dir *p) {return -1;}
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": init", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_init_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, CBM_READ, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/loader/cfs-init.h b/contiki-c64/loader/cfs-init.h
new file mode 100644
index 0000000..7f02a24
--- /dev/null
+++ b/contiki-c64/loader/cfs-init.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.h,v 1.2 2004/09/12 20:30:04 adamdunkels Exp $
+ */
+#ifndef __CFS_INIT_H__
+#define __CFS_INIT_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_init_init, arg);
+
+#endif /* __CFS_INIT_H__ */
diff --git a/contiki-c64/loader/loader-arch.c b/contiki-c64/loader/loader-arch.c
new file mode 100644
index 0000000..120c339
--- /dev/null
+++ b/contiki-c64/loader/loader-arch.c
@@ -0,0 +1,140 @@
+/**
+ * \file
+ * File loader implementation.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file implements dynamically loadable files for Contiki using
+ * the cc65 module loading system. The actual file operations are
+ * implemented in other files.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.12 2005/05/07 14:26:11 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <modload.h>
+
+#include "cfs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+static int __fastcall__
+do_read(int f, char *buf, unsigned int len)
+{
+  return cfs_read(f, buf, len);
+}
+  
+struct mod_ctrl ctrl = {
+  (void *)do_read            /* Read from disk */
+};
+
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load a program from disk and execute it.
+ *
+ * Code originally written by Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  
+  /* Now open the file */
+  ctrl.callerdata = cfs_open(name, 0);
+  if(ctrl.callerdata < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+  
+  /* Load the module */
+  res = mod_load(&ctrl);
+  
+  /* Close the input file */
+  cfs_close(ctrl.callerdata);
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load and start a program.
+ *
+ * \param name The name of the program file.
+ * \param arg A pointer that will be passed to the new process.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/main-rrnet.c b/contiki-c64/main-rrnet.c
new file mode 100644
index 0000000..1a67993
--- /dev/null
+++ b/contiki-c64/main-rrnet.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main-rrnet.c,v 1.5 2004/09/18 21:06:47 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "netconf-dsc.h"
+#include "irc-dsc.h"
+#include "dhcp-dsc.h"
+
+#include "cfs-cbm.h"
+
+#include "clock.h"
+
+#include <cbm.h>
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t addr[2];
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+void
+log_message(char *part1, char *part2)
+{
+  while(*part1 != 0) {
+    cbm_k_bsout(*part1++);
+  }
+
+  while(*part2 != 0) {
+    cbm_k_bsout(*part2++);
+  }
+
+  
+  cbm_k_bsout('\n');
+}
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_curunit(void)
+{
+  asm("lda $ba");
+  asm("sta %v", _curunit);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+void
+main(void)
+{
+
+  setup_curunit();
+  
+  log_message("Starting ", CONTIKI_VERSION_STRING);
+  
+  ek_init();
+
+  ek_start(&init);
+    
+  log_message(": TCP/IP", "");
+    
+  tcpip_init(NULL);
+
+  resolv_init(NULL); 
+
+  log_message(": CTK GUI", "");
+  ctk_init();
+
+  /*  log_message(": Initial filesystem", "");
+      cfs_init_init(NULL);*/
+
+  program_handler_init();
+   
+  program_handler_add(&netconf_dsc, "Network config", 1);
+  program_handler_add(&dhcp_dsc, "DHCP", 1);
+  program_handler_add(&irc_dsc, "IRC", 1);
+  
+
+  ctk_80col_service_init(NULL);
+  rrnet_drv_init(NULL);  
+  
+  log_message("Starting process scheduling", "");  
+
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/main.c b/contiki-c64/main.c
new file mode 100644
index 0000000..8b1906c
--- /dev/null
+++ b/contiki-c64/main.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main.c,v 1.17 2004/09/18 20:35:37 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "configedit-dsc.h"
+#include "directory-dsc.h"
+#include "processes-dsc.h"
+
+#include "cfs-cbm.h"
+
+#include "clock.h"
+
+#include <cbm.h>
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    program_handler_load("config.prg", NULL);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+void
+log_message(char *part1, char *part2)
+{
+  while(*part1 != 0) {
+    cbm_k_bsout(*part1++);
+  }
+
+  while(*part2 != 0) {
+    cbm_k_bsout(*part2++);
+  }
+
+  
+  cbm_k_bsout('\n');
+}
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
+/*-----------------------------------------------------------------------------------*/
+void
+main(void)
+{
+  
+  log_message("Starting ", CONTIKI_VERSION_STRING);
+  
+  ek_init();
+
+  ek_start(&init);
+    
+  log_message(": TCP/IP", "");
+    
+  tcpip_init(NULL);
+
+  resolv_init(NULL); 
+
+  log_message(": CTK GUI", "");
+  ctk_init();
+
+  log_message(": Initial filesystem", "");
+  cfs_init_init(NULL);
+
+  program_handler_init();
+   
+  program_handler_add(&directory_dsc, "Directory", 1);
+  program_handler_add(&configedit_dsc, "Configuration", 1);
+  program_handler_add(&processes_dsc, "Processes", 1);  
+  
+  
+  log_message("Starting process scheduling", "");  
+
+  while(1) {
+    if(ek_run() == 0) {
+      program_handler_load("welcome.prg", NULL);
+      break;
+    }
+  }
+    
+  
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+reset(void)
+{
+  asm("lda #$36");
+  asm("sta $01");
+  asm("jmp $fce2");
+}
+
diff --git a/contiki-c64/make-labels b/contiki-c64/make-labels
new file mode 100755
index 0000000..6cf3998
--- /dev/null
+++ b/contiki-c64/make-labels
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+
+egrep -v 'ZP|BSS' contiki-labels | perl -n -e 'if(/^al 0000(.+) \.([^@]+)\n/){if($l{$2} eq ""){$l{$2}=$1;print ".exportzp $2\n$2=\$$1\n";}} elsif(/^al 00(.+) \.([^@]+)\n/){if($l{$2} eq ""){$l{$2}=$1;print ".export $2\n$2=\$$1\n";}}' > contiki-labels.s
+
+echo '.segment        "EXTZP", zeropage' >> contiki-labels.s
\ No newline at end of file
diff --git a/contiki-c64/uip/cs8900a.c b/contiki-c64/uip/cs8900a.c
new file mode 100644
index 0000000..34d8efc
--- /dev/null
+++ b/contiki-c64/uip/cs8900a.c
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.13 2005/03/16 22:39:21 oliverschmidt Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+   written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+extern u8_t *cs8900a_rxtxreg,
+            *cs8900a_txcmd,
+            *cs8900a_txlen,
+            *cs8900a_packetpp,
+            *cs8900a_ppdata;
+
+static u16_t len;
+static u16_t cnt;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+  /* Turn on transmission and reception of frames. */
+  /* PACKETPP = 0x0112;
+     PPDATA   = 0x00c0; */
+  asm("lda #$12");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Accept valid unicast+broadcast frames. */
+  /* PACKETPP = 0x0104;
+     PPDATA   = 0x0d05; */
+  asm("lda #$04");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$05");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$0d");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Set MAC address. */
+  /* PACKETPP = 0x0158;
+     PPDATA   = (ETHADDR1 << 8) | (ETHADDR0); */
+  asm("lda #$58");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015a;
+     PPDATA   = (ETHADDR3 << 8) | (ETHADDR2); */
+  asm("lda #$5a");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015c;
+     PPDATA   = (ETHADDR5 << 8) | (ETHADDR4); */
+  asm("lda #$5c");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+  /* Transmit command. */
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_txcmd);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_txcmd);
+  asm("lda %v", uip_len);
+  asm("sta %v", cs8900a_txlen);
+  asm("lda %v+1", uip_len);
+  asm("sta %v+1", cs8900a_txlen);
+
+  asm("ldy #8");
+tryagain:
+  /* Check for avaliable buffer space. */
+  asm("lda #$38");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #1");
+  asm("bne %g", send);
+
+  /* No space avaliable, skip a received frame and try again. */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+
+  asm("dey");
+  asm("bne %g", tryagain);
+  return;
+
+  /* Send the frame. */
+send:
+
+  /* First, send 14+40=54 bytes of header. */
+  asm("ldy #0");
+sendloop1:
+  asm("lda %v,y", uip_buf);
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda %v,y", uip_buf);
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+  asm("bne %g", sendloop1);
+
+  if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+    return;
+  }
+
+  /* Next, send rest of the packet. */
+  cnt = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+  asm("lda %v", cnt);
+  asm("lsr");
+  asm("bcc %g", noinc);
+  asm("inc %v", cnt);
+  asm("bne %g", noinc);
+  asm("inc %v+1", cnt);
+noinc:
+
+  asm("lda %v", uip_appdata);
+  asm("sta ptr1");
+  asm("lda %v+1", uip_appdata);
+  asm("sta ptr1+1");  
+
+  asm("ldy #0");
+sendloop2:
+  asm("lda (ptr1),y");
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("bne %g", check);
+  asm("inc ptr1+1");
+check:
+  asm("cpy %v", cnt);
+  asm("bne %g", sendloop2);
+  asm("dec %v+1", cnt);
+  asm("bpl %g", sendloop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+  /* PACKETPP = 0x0102;
+     PPDATA   = PPDATA | 0x0040; */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+cs8900a_poll(void)
+{
+  /* Check receiver event register to see if there are any valid
+     unicast frames avaliable.  */
+  /* PACKETPP = 0x0124;
+     if(PPDATA & 0x000d == 0x0000) {
+       return 0;
+     }
+  */
+  asm("lda #$24");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #$0d");
+  asm("cmp #$00");
+  asm("bne %g", noreturn);
+  /* No frame ready. */
+  return 0;
+  
+noreturn:
+  /* Process the incoming frame. */
+  
+  /* Read receiver event and discard it. */
+  /* RXTXREG; */
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("lda %v", cs8900a_rxtxreg);
+  
+  /* Read frame length. */
+  /* cnt = len = RXTXREG; */
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta %v+1", len);
+  asm("sta %v+1", cnt);
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta %v", len);
+  asm("sta %v", cnt);
+
+  asm("lsr");
+  asm("bcc %g", noinc);
+  asm("inc %v", cnt);
+  asm("bne %g", noinc);
+  asm("inc %v+1", cnt);
+noinc:
+
+  if(cnt > UIP_BUFSIZE) {
+    skip_frame();
+    return 0;
+  }
+
+  /* Read bytes into uip_buf. */
+  asm("lda #<%v", uip_buf);
+  asm("sta ptr1");
+  asm("lda #>%v", uip_buf);
+  asm("sta ptr1+1");  
+  
+  asm("ldy #0");
+readloop:
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne %g", check);
+  asm("inc ptr1+1");
+check:
+  asm("cpy %v", cnt);
+  asm("bne %g", readloop);
+  asm("dec %v+1", cnt);
+  asm("bpl %g", readloop);
+  return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-c64/uip/cs8900a.h b/contiki-c64/uip/cs8900a.h
new file mode 100644
index 0000000..4d4e182
--- /dev/null
+++ b/contiki-c64/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.3 2005/05/07 14:22:00 oliverschmidt Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u16_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-c64/uip/eth64-drv.c b/contiki-c64/uip/eth64-drv.c
new file mode 100644
index 0000000..e43459c
--- /dev/null
+++ b/contiki-c64/uip/eth64-drv.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-drv.c,v 1.2 2005/03/17 21:51:23 oliverschmidt Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:80:0F is the OUI of Standard Microsystems, 64:64:64 just means C64 */
+static const struct uip_eth_addr addr =
+  {{0x00,0x80,0x0f,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(eth64_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/eth64-dsc.c b/contiki-c64/uip/eth64-dsc.c
new file mode 100644
index 0000000..aa31932
--- /dev/null
+++ b/contiki-c64/uip/eth64-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: eth64-dsc.c,v 1.2 2005/03/29 23:17:25 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lan91c96_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(lan91c96_dsc,
+    "IDE64/ETH64 driver",
+    "lan91c96.drv",
+    lan91c96_init,
+    &lan91c96_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lan91c96icon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lan91c96icon_textmap[9] = {
+  'I', 'D', 'E',
+  ' ', '6', '4',
+  'E', 'T', 'H'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon lan91c96_icon =
+  {CTK_ICON("ETH64 driver", lan91c96icon_bitmap, lan91c96icon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/eth64-dump-drv.c b/contiki-c64/uip/eth64-dump-drv.c
new file mode 100644
index 0000000..1b629f9
--- /dev/null
+++ b/contiki-c64/uip/eth64-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-dump-drv.c,v 1.1 2004/09/19 18:43:16 adamdunkels Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      dump_packet();
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/lan91c96.c b/contiki-c64/uip/lan91c96.c
new file mode 100644
index 0000000..880998a
--- /dev/null
+++ b/contiki-c64/uip/lan91c96.c
@@ -0,0 +1,454 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Ethernet card for Commodore 64, based on lan91c96 chip
+ * is a device created by IDE64 Project team.
+ * More information: http://ide64.come.to
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.13 2005/03/29 23:14:39 oliverschmidt Exp $
+ *
+ */
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+// #define DEBUG
+
+#define ETHBASE 0xde10
+
+#define ETHBSR     ETHBASE+0x0e	 /* Bank select register             R/W (2B) */
+
+/* Register bank 0 */
+
+#define ETHTCR     ETHBASE       /* Transmition control register     R/W (2B) */
+#define ETHEPHSR   ETHBASE+2     /* EPH status register              R/O (2B) */
+#define ETHRCR     ETHBASE+4     /* Receive control register         R/W (2B) */
+#define ETHECR     ETHBASE+6     /* Counter register                 R/O (2B) */
+#define ETHMIR     ETHBASE+8     /* Memory information register      R/O (2B) */
+#define ETHMCR     ETHBASE+0x0a  /* Memory Config. reg.    +0 R/W +1 R/O (2B) */
+
+/* Register bank 1 */
+
+#define ETHCR      ETHBASE       /* Configuration register           R/W (2B) */
+#define ETHBAR     ETHBASE+2     /* Base address register            R/W (2B) */
+#define ETHIAR     ETHBASE+4     /* Individual address register      R/W (6B) */
+#define ETHGPR     ETHBASE+0x0a  /* General address register         R/W (2B) */
+#define ETHCTR     ETHBASE+0x0c  /* Control register                 R/W (2B) */
+
+/* Register bank 2 */
+
+#define ETHMMUCR   ETHBASE       /* MMU command register             W/O (1B) */
+#define ETHAUTOTX  ETHBASE+1     /* AUTO TX start register           R/W (1B) */
+#define ETHPNR     ETHBASE+2     /* Packet number register           R/W (1B) */
+#define ETHARR     ETHBASE+3     /* Allocation result register       R/O (1B) */
+#define ETHFIFO    ETHBASE+4     /* FIFO ports register              R/O (2B) */
+#define ETHPTR     ETHBASE+6     /* Pointer register                 R/W (2B) */
+#define ETHDATA    ETHBASE+8     /* Data register                    R/W (4B) */
+#define ETHIST     ETHBASE+0x0c  /* Interrupt status register        R/O (1B) */
+#define ETHACK     ETHBASE+0x0c  /* Interrupt acknowledge register   W/O (1B) */
+#define ETHMSK     ETHBASE+0x0d  /* Interrupt mask register          R/W (1B) */
+
+/* Register bank 3 */
+
+#define ETHMT      ETHBASE       /* Multicast table                  R/W (8B) */
+#define ETHMGMT    ETHBASE+8     /* Management interface             R/W (2B) */
+#define ETHREV     ETHBASE+0x0a  /* Revision register                R/W (2B) */
+#define ETHERCV    ETHBASE+0x0c  /* Early RCV register               R/W (2B) */
+
+#define BANK(num) asm("lda #%b", num); asm("sta %w", ETHBSR);
+
+#ifdef DEBUG
+static void print_packet(u8_t *, u16_t);
+#endif
+
+static u8_t packet_status;
+static u16_t packet_length;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+  /* Check if high byte is 0x33 */
+  asm("lda %w", ETHBSR+1);
+  asm("cmp #$33");
+  asm("beq %g", L1);
+
+  asm("inc $d021");              /* Error */
+
+L1:
+  /* Reset ETH card */
+  BANK(0);
+  asm("lda #%%10000000");        /* Software reset */
+  asm("sta %w", ETHRCR+1);
+
+  asm("lda #0");
+  asm("sta %w", ETHRCR);
+  asm("sta %w", ETHRCR+1);
+
+  /* delay */
+  asm("ldy #0");
+L2:
+  asm("cmp ($ff,x)");            /* 6 cycles */
+  asm("cmp ($ff,x)");            /* 6 cycles */
+  asm("dey");                    /* 2 cycles */
+  asm("bne %g", L2);             /* 3 cycles */
+                                 /* 17*256=4352 => 4,4 ms */
+
+  /* Enable transmit and receive */
+  asm("lda #%%10000001");        /* Enable transmit TXENA, PAD_EN */
+  asm("sta %w", ETHTCR);
+  asm("lda #%%00000011");        /* Enable receive, strip CRC ??? */
+  asm("sta %w", ETHRCR+1);
+
+  BANK(1);
+  asm("lda %w", ETHCR+1);
+  asm("ora #%%00010000");        /* No wait (IOCHRDY) */
+  asm("sta %w", ETHCR+1);
+
+  asm("lda #%%00001001");        /* Auto release */
+  asm("sta %w", ETHCTR+1);
+  
+  /* Set MAC address */
+  asm("lda %v", uip_ethaddr);
+  asm("sta %w", ETHIAR);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %w", ETHIAR+1);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %w", ETHIAR+2);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %w", ETHIAR+3);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %w", ETHIAR+4);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %w", ETHIAR+5);
+
+  BANK(2);
+  asm("lda #%%00001111");        /* RCV INT, ALLOC INT, TX INT, TX EMPTY */
+  asm("sta %w", ETHMSK);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t lan91c96_poll(void)
+{
+#ifdef DEBUG
+  BANK(0);
+  printf("RAM: %d ", ((*(unsigned int *)(ETHMIR)) & 0xff00));
+  BANK(2);
+#endif
+
+  asm("lda %w", ETHIST);
+  asm("and #%%00000001");        /* RCV INT */
+  asm("bne %g", L1);
+
+  /* No packet available */
+  return 0;
+
+L1:
+
+#ifdef DEBUG
+  printf("RCV: IRQ\n");
+#endif
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%11100000");        /* RCV,AUTO INCR.,READ */
+  asm("sta %w", ETHPTR+1);
+
+  asm("lda %w", ETHDATA);        /* Status word */
+  asm("lda %w", ETHDATA);
+  asm("sta %v", packet_status);  /* High byte only */
+
+  asm("lda %w", ETHDATA);        /* Total number of bytes */
+  asm("sta %v", packet_length);
+  asm("lda %w", ETHDATA);
+  asm("sta %v+1", packet_length);
+
+  /* Last word contain 'last data byte' and 0x60 */
+  /* or 'fill byte' and 0x40 */
+
+  packet_length -= 6;            /* The packet contains 3 extra words */
+
+  asm("lda %v", packet_status);
+  asm("and #$10");
+  asm("beq %g", L2);
+
+  packet_length++;
+
+#ifdef DEBUG
+  printf("RCV: odd number of bytes\n");
+#endif
+
+L2:
+                    
+#ifdef DEBUG
+  printf("RCV: L:%d ST-HIGH:0x%02x ", packet_length, packet_status);
+#endif
+
+  if(packet_length > UIP_BUFSIZE) {
+
+    /* Remove and release RX packet from FIFO */ 
+    asm("lda #%%10000000");
+    asm("sta %w", ETHMMUCR);
+
+#ifdef DEBUG
+    printf("RCV: UIP_BUFSIZE exceeded - packet dropped!\n");
+#endif
+
+    return 0;
+  }
+
+  asm("lda #<%v", uip_buf);
+  asm("sta ptr1");
+  asm("lda #>%v", uip_buf);
+  asm("sta ptr1+1");
+
+  asm("lda %v+1", packet_length);
+  asm("sta tmp1");
+
+  asm("ldy #0");
+L3:
+  asm("lda %w", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne %g", L4);
+  asm("inc ptr1+1");
+L4:
+  asm("cpy %v", packet_length);
+  asm("bne %g", L3);
+  asm("dec tmp1");
+  asm("bpl %g", L3);
+
+  /* Remove and release RX packet from FIFO */ 
+  asm("lda #%%10000000");
+  asm("sta %w", ETHMMUCR);
+
+#ifdef DEBUG
+  print_packet(uip_buf, packet_length);
+#endif
+
+  return packet_length;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+  /* First 14+40 (IP and TCP header) is send from uip_buf */
+  /* than data from uip_appdata */
+
+#ifdef DEBUG
+  printf("SND: send packet\n");
+#endif
+
+  asm("lda %v+1", uip_len);
+  asm("ora #%%00100000");        /* Allocate memory for TX */
+  asm("sta %w", ETHMMUCR);
+
+  asm("ldy #8");                 /* Wait... */
+L1:                              /* Wait for allocation ready */
+  asm("lda %w", ETHIST);
+  asm("and #%%00001000");        /* ALLOC INT */
+  asm("bne %g", L2);
+  asm("dey");
+  asm("bne %g", L1);
+
+#ifdef DEBUG
+    printf("SND: ERR: memory alloc timeout\n");
+#endif
+
+    return;
+
+L2:
+
+#ifdef DEBUG
+  printf("SND: packet memory allocated\n");
+#endif
+
+  asm("lda #%%00001000");        /* Acknowledge int, is it necessary ??? */
+  asm("sta %w", ETHACK);
+
+  asm("lda %w", ETHARR);
+  asm("sta %w", ETHPNR);         /* Set packet address */
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%01000000");        /* AUTO INCR. */
+  asm("sta %w", ETHPTR+1);
+
+#ifdef DEBUG
+  printf("SND: L:%d ", uip_len);
+#endif
+
+  asm("lda #0");                 /* Status written by CSMA */
+  asm("sta %w", ETHDATA);
+  asm("sta %w", ETHDATA);
+
+  asm("lda %v", uip_len);
+  asm("and #$01");
+  asm("beq %g", L3);
+
+  packet_length = uip_len + 5;
+  asm("jmp %g", L4);
+
+L3:
+  packet_length = uip_len + 6;   /* +6 for status word, length and ctl byte */
+
+L4:
+
+#ifdef DEBUG
+  printf("SND: L:%d ", packet_length);
+#endif
+
+  asm("lda %v", packet_length);
+  asm("sta %w", ETHDATA);
+  asm("lda %v+1", packet_length);
+  asm("sta %w", ETHDATA);
+
+#ifdef DEBUG
+  print_packet(uip_buf, uip_len);
+#endif
+
+  /* Send 14+40=54 bytes of header */
+
+  if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+
+#ifdef DEBUG
+    printf("SND: short packet sent.\n");
+#endif
+
+    asm("ldy #0");
+L5:
+    asm("lda %v,y", uip_buf);
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("cpy %v", uip_len);
+    asm("bne %g", L5);
+
+  } else {
+
+    asm("ldy #0");
+L6:
+    asm("lda %v,y", uip_buf);
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+    asm("bne %g", L6);
+
+    packet_length = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+    asm("lda %v", uip_appdata);  /* uip_appdata is pointer */
+    asm("sta ptr1");
+    asm("lda %v+1", uip_appdata);
+    asm("sta ptr1+1");
+
+    asm("ldy #0");
+L7:
+    asm("lda (ptr1),y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("bne %g", L8);
+    asm("inc ptr1+1");
+L8:
+    asm("cpy %v", packet_length);
+    asm("bne %g", L7);
+    asm("dec %v+1", packet_length);
+    asm("bpl %g", L7);
+  }
+
+  asm("lda %v", packet_length);
+  asm("and #$01");
+  asm("beq %g", L9);
+
+  asm("lda #%%00100000");
+  asm("sta %w", ETHDATA);        /* Control byte */
+
+  asm("lda #%%11000000");        /* ENQUEUE PACKET - transmit packet */
+  asm("sta %w", ETHMMUCR);
+
+#ifdef DEBUG
+  printf("\n## %02x", *(unsigned char *)(ETHIST));
+#endif
+
+  return;
+
+L9:
+  asm("lda #0");
+  asm("sta %w", ETHDATA);        /* Fill byte */
+  asm("sta %w", ETHDATA);        /* Control byte */
+
+  asm("lda #%%11000000");        /* ENQUEUE PACKET - transmit packet */
+  asm("sta %w", ETHMMUCR);
+
+#ifdef DEBUG
+  printf("\n## %02x\n", *(unsigned char *)(ETHIST));
+#endif
+
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#ifdef DEBUG
+static void print_packet(u8_t *buf, u16_t length)
+{
+  int i;
+  int remainder;
+  int lines;
+  u8_t a;
+  int cur;
+  int address=0;
+
+  printf("\nPacket of length %d \n", length);
+
+  lines = length / 8;
+  remainder = length % 8;
+
+  for(i = 0; i < lines; i++) {
+    printf(":%04x ", address=i*8);
+
+    for(cur = 0; cur < 8; cur++) {
+      a = *(buf++);
+      printf("%02x ", a);
+    }
+    printf("\n");
+  }
+
+  printf(":%04x ", address+8);
+
+  for (i = 0; i < remainder; i++) {
+    a = *(buf++);
+    printf("%02x ", a);
+  }
+  printf("\n");
+}
+#endif /* DEBUG */
diff --git a/contiki-c64/uip/lan91c96.h b/contiki-c64/uip/lan91c96.h
new file mode 100644
index 0000000..8e0510c
--- /dev/null
+++ b/contiki-c64/uip/lan91c96.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.5 2005/03/10 00:05:46 oliverschmidt Exp $
+ */
+
+#ifndef __LAN91C96_H__
+#define __LAN91C96_H__
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_send(void);
+u16_t lan91c96_poll(void);
+
+#endif /* __LAN91C96_H__ */
diff --git a/contiki-c64/uip/rrnet-drv-asm.S b/contiki-c64/uip/rrnet-drv-asm.S
new file mode 100644
index 0000000..595c00c
--- /dev/null
+++ b/contiki-c64/uip/rrnet-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de08
+	_cs8900a_txcmd		= $de0c
+	_cs8900a_txlen		= $de0e
+	_cs8900a_packetpp	= $de02
+	_cs8900a_ppdata		= $de04
+
diff --git a/contiki-c64/uip/rrnet-drv.c b/contiki-c64/uip/rrnet-drv.c
new file mode 100644
index 0000000..a1def96
--- /dev/null
+++ b/contiki-c64/uip/rrnet-drv.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-drv.c,v 1.12 2004/09/18 20:51:28 adamdunkels Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/rrnet-dsc.c b/contiki-c64/uip/rrnet-dsc.c
new file mode 100644
index 0000000..b01b49a
--- /dev/null
+++ b/contiki-c64/uip/rrnet-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: rrnet-dsc.c,v 1.4 2005/03/29 23:17:25 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon rrnet_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(rrnet_dsc,
+    "RR-Net driver",
+    "rrnet.drv",
+    rrnet_init,
+    &rrnet_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char rrneticon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char rrneticon_textmap[9] = {
+  'R', 'R', '-',
+  'N', 'e', 't',
+  'D', 'R', 'V'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon rrnet_icon =
+  {CTK_ICON("RR-Net driver", rrneticon_bitmap, rrneticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/rrnet-dump-drv.c b/contiki-c64/uip/rrnet-dump-drv.c
new file mode 100644
index 0000000..3ba9ab3
--- /dev/null
+++ b/contiki-c64/uip/rrnet-dump-drv.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-dump-drv.c,v 1.2 2004/09/18 20:49:13 adamdunkels Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "RR-Net dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/rs232dev-ss.c b/contiki-c64/uip/rs232dev-ss.c
new file mode 100644
index 0000000..b7b0285
--- /dev/null
+++ b/contiki-c64/uip/rs232dev-ss.c
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev-ss.c,v 1.4 2005/02/23 22:43:00 oliverschmidt Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include "rs232silversurfer.h"
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c)  (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c)  while(rs232_put(c) == RS_ERR_OVERFLOW)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == UIP_TCPIP_HLEN) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  while(SIO_POLL(c)) {
+    /*    printf("c %x\n", c);*/
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+      
+      
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  
+  err = rs232_init(0);
+  rs232_err(err);
+  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);
+  rs232_err(err);
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-c64/uip/rs232silversurfer.S b/contiki-c64/uip/rs232silversurfer.S
new file mode 100644
index 0000000..89bbf9d
--- /dev/null
+++ b/contiki-c64/uip/rs232silversurfer.S
@@ -0,0 +1,329 @@
+	;; The following code is written and is copyrighted by
+	;; Groepaz/Hitmen
+
+	;; Small changes by Adam Dunkels (renamed ss232 -> rs232)
+	
+;----------------------------------------------------------------------------------------------
+; silver surfer polling mode driver for cc65
+; - work from here to create a full featured driver with interupts.
+; gpz fixed 20020828: fatal bug fixed in _rs232_params
+;----------------------------------------------------------------------------------------------
+
+rs16550base             = $de08
+
+fifo_rxd     = rs16550base+$00 ;8  (r)
+fifo_txd     = rs16550base+$00 ;8 (w)
+
+fifo_dll     = rs16550base+$00 ;8 (r/w)
+fifo_dlm     = rs16550base+$01 ;9 (r/w)
+
+fifo_ier     = rs16550base+$01 ;9
+
+fifo_fcr     = rs16550base+$02 ;a (w)
+fifo_iir     = rs16550base+$02 ;a (r)
+fifo_lcr     = rs16550base+$03 ;b
+fifo_mcr     = rs16550base+$04 ;c
+fifo_lsr     = rs16550base+$05 ;d
+fifo_msr     = rs16550base+$06 ;e (r)
+fifo_scratch = rs16550base+$07 ;f (r/w)
+	
+
+
+                        .export _rs232_init
+                        .export _rs232_done
+                        .export _rs232_params
+                        .export _rs232_put
+                        .export _rs232_get
+
+                        .importzp ptr1, ptr2
+                        .import   popa, popax
+
+;----------------------------------------------------------------------------------------------
+; Error codes. Beware: The codes must match the codes in the C header file
+
+ErrNotInitialized       = $01
+ErrBaudTooFast    	= $02
+ErrBaudNotAvail   	= $03
+ErrNoData         	= $04
+ErrOverflow       	= $05
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_init (char hacked);
+;/* Initialize the serial port, install the interrupt handler. The parameter
+; * has no effect for now and should be set to 0.
+; */
+;----------------------------------------------------------------------------------------------
+
+         .code
+
+_rs232_init:
+         ; enable ssurfer-port
+         lda $de01
+         ora #$01
+         sta $de01
+
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; activate dtr
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_done (void);
+;/* Close the port, deinstall the interrupt hander. You MUST call this function
+; * before terminating the program, otherwise the machine may crash later. If
+; * in doubt, install an exit handler using atexit(). The function will do
+; * nothing, if it was already called.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_done:
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; deactivate dtr
+         sta fifo_mcr
+
+         ; disable ssurfer-port
+         lda $de01
+         and #$fe
+         sta $de01
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+;/* Set the port parameters. Use a combination of the #defined values above. */
+;----------------------------------------------------------------------------------------------
+
+         .data
+
+_rs232_baudrates:
+
+         .word          (7372800 / (      50 * 16))
+         .word          (7372800 / (     110 * 16))
+         .word          (7372800 / (     269 *  8))
+         .word          (7372800 / (     300 * 16))
+         .word          (7372800 / (     600 * 16))
+         .word          (7372800 / (    1200 * 16))
+         .word          (7372800 / (    2400 * 16))
+         .word          (7372800 / (    4800 * 16))
+         .word          (7372800 / (    9600 * 16))
+         .word          (7372800 / (   19200 * 16))
+         .word          (7372800 / (   38400 * 16))
+         .word          (7372800 / (   57600 * 16))
+         .word          (7372800 / (  115200 * 16))
+         .word          (7372800 / (  230400 * 16))
+
+         .bss
+
+_rs232_tmp1:
+         .res 1
+
+         .code
+
+_rs232_params:
+
+         sta _rs232_tmp1 ; save parity
+
+         ; reset fifo
+         lda #%10000111
+         sta fifo_fcr
+
+   ; that delay thing really needed ?!
+   ; (original datasheet mentions a delay here)
+   ;      ldy #$00
+   ;      dey
+   ;      bny *-1
+
+         ; set dlab
+         lda #%10000011 ; we assmume 8n1
+         sta fifo_lcr
+
+         jsr popa
+         tay             ; save param
+
+         ; set baudrate
+         clc
+         lsr a		
+         lsr a
+         lsr a
+         lsr a
+         asl a
+         tax
+         lda _rs232_baudrates,x
+         sta fifo_dll
+         lda _rs232_baudrates+1,x
+         sta fifo_dlm
+
+         tya             ; param
+         and #$0f
+         ora _rs232_tmp1 ; parity
+
+         ; reset dlab
+         sta fifo_lcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+; check if byte available, returns AKKU=0 if none
+
+ss_getlsr:
+         lda fifo_lsr
+         and #$01
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_get (char* b);
+;/* Get a character from the serial port. If no characters are available, the
+; * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+; */
+;----------------------------------------------------------------------------------------------
+; get byte (non blocking, returns byte in A or CARRY=1 - error)
+
+_rs232_get:
+         sta ptr1
+         stx ptr1+1
+
+         jsr ss_getlsr  ; check if byte available
+;         bne sk32 ; yes
+         bne sk33 ; yes
+
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+sk32:
+
+         ; deactivate rts
+;         lda #%00000001
+;         sta fifo_mcr
+
+	 jsr ss_getlsr  ; check if byte available
+         bne sk33 ; yes
+
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #ErrNoData      ; no data
+         ldx #0
+         rts
+sk33:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         ; get byte
+         ldy #$00
+         lda fifo_rxd
+         sta (ptr1),y
+
+         lda #0      ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_put (char b);
+;/* Send a character via the serial port. There is a transmit buffer, but
+; * transmitting is not done via interrupt. The function returns
+; * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_put:
+         tax
+         ; transmit buf ready?
+         lda fifo_lsr
+         and #%00100000
+         bne @sk1
+@sk2:
+         lda #ErrOverflow       ; overflow
+         ldx #$00
+         rts
+@sk1:
+         ; reciever ready?
+         lda fifo_msr
+         and #%00010000
+         beq @sk2
+
+         stx fifo_txd
+
+         lda #$00               ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_pause (void);
+;/* Assert flow control and disable interrupts. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_pause:
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_unpause (void);
+;/* Re-enable interrupts and release flow control */
+;----------------------------------------------------------------------------------------------
+
+_rs232_unpause:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_status (unsigned char* status,
+;                                         unsigned char* errors);
+;/* Return the serial port status. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_status:
+ 	sta    	ptr2
+ 	stx    	ptr2+1
+ 	jsr    	popax
+ 	sta    	ptr1
+ 	stx    	ptr1+1
+
+        ldy     #$00
+
+        ; Get status
+        lda     fifo_iir
+        and     #%00000001
+        sta     _rs232_tmp1
+        lda     fifo_msr
+        lsr     a
+        and     #%01010000
+        ora     _rs232_tmp1
+        sta     _rs232_tmp1
+        lda     fifo_lsr
+        and     #%00101110
+        ora     _rs232_tmp1
+ 	sta    	(ptr1),y
+
+        ; Get errors
+        lda     #$00    ; ok
+       	sta    	(ptr2),y
+
+        lda     #$00    ; ok
+        tax
+        rts
diff --git a/contiki-c64/uip/rs232silversurfer.h b/contiki-c64/uip/rs232silversurfer.h
new file mode 100644
index 0000000..9e9a49f
--- /dev/null
+++ b/contiki-c64/uip/rs232silversurfer.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2003, Groepaz/Hitmen.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * rs232silversurfer.h
+ *
+ * Groepaz/Hitmen, 16.12.2001
+ *
+ * This defines for the SilverSurver (16c550 UART) what Ullrichs rs232 module
+ * defines for the Swithlink/Turbo232
+ *
+ * this driver operates in polling mode only atm !
+ *
+ */
+
+#ifndef _RS232silversurfer_H
+#define _RS232silversurfer_H
+
+/*****************************************************************************/
+/*                   Data                                                    */
+/*****************************************************************************/
+
+/* Baudrate settings */
+#define RS_BAUD_50                0x00
+#define RS_BAUD_110               0x10
+#define RS_BAUD_134_5             0x20
+#define RS_BAUD_300               0x30
+#define RS_BAUD_600               0x40
+#define RS_BAUD_1200              0x50
+#define RS_BAUD_2400              0x60
+#define RS_BAUD_4800              0x70
+#define RS_BAUD_9600              0x80
+#define RS_BAUD_19200             0x90
+#define RS_BAUD_38400             0xa0
+#define RS_BAUD_57600             0xb0
+#define RS_BAUD_115200            0xc0
+#define RS_BAUD_230400            0xd0
+
+/* Stop bit settings */
+#define RS_STOP_1      	       		0x00
+#define RS_STOP_2      	       		0x04
+
+/* Data bit settings */
+#define RS_BITS_5      	       		0x00
+#define RS_BITS_6      	       		0x01
+#define RS_BITS_7      	       		0x02
+#define RS_BITS_8      	       		0x03
+
+/* Parity settings */
+#define RS_PAR_NONE    	       		0x00
+#define RS_PAR_ODD     	       		0x28
+#define RS_PAR_EVEN    	       		0x38
+#define RS_PAR_MARK    	       		0x48
+#define RS_PAR_SPACE   	       		0x48
+
+/* Bit masks to mask out things from the status returned by rs232_status */
+#define RS_STATUS_IRQ                   0x01    /* (iir) IRQ condition */
+#define RS_STATUS_OVERRUN               0x02    /* (lsr) Overrun error */
+#define RS_STATUS_PE                    0x04    /* (lsr) Parity error */
+#define RS_STATUS_FE                    0x08    /* (lsr) Framing error */
+#define RS_STATUS_DSR                   0x10    /* (msr>>1) NOT data set ready */
+#define RS_STATUS_THRE                  0x20    /* (lsr) Transmit holding reg. empty */
+#define RS_STATUS_DCD                   0x40    /* (msr>>1) NOT data carrier detect */
+#define RS_STATUS_RDRF                  0x80    /* Receiver data register full */
+
+/* Error codes returned by all functions */
+#define RS_ERR_OK                       0x00    /* Not an error - relax */
+#define RS_ERR_NOT_INITIALIZED 		0x01   	/* Module not initialized */
+#define RS_ERR_BAUD_TOO_FAST            0x02    /* Cannot handle baud rate */
+#define RS_ERR_BAUD_NOT_AVAIL           0x03    /* Baud rate not available */
+#define RS_ERR_NO_DATA                  0x04    /* Nothing to read */
+#define RS_ERR_OVERFLOW                 0x05    /* No room in send buffer */
+
+/*****************************************************************************/
+/*				     Code			                                               	     */
+/*****************************************************************************/
+
+unsigned char __fastcall__ rs232_init (char hacked);
+/* Initialize the serial port, install the interrupt handler. The parameter
+ * has no effect for now and should be set to 0.
+ */
+
+unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+/* Set the port parameters. Use a combination of the #defined values above. */
+
+unsigned char __fastcall__ rs232_done (void);
+/* Close the port, deinstall the interrupt hander. You MUST call this function
+ * before terminating the program, otherwise the machine may crash later. If
+ * in doubt, install an exit handler using atexit(). The function will do
+ * nothing, if it was already called.
+ */
+
+unsigned char __fastcall__ rs232_get (char* b);
+/* Get a character from the serial port. If no characters are available, the
+ * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+ */
+
+unsigned char __fastcall__ rs232_put (char b);
+/* Send a character via the serial port. There is a transmit buffer, but
+ * transmitting is not done via interrupt. The function returns
+ * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+ */
+
+unsigned char __fastcall__ rs232_pause (void);
+/* Assert flow control and disable interrupts. */
+
+unsigned char __fastcall__ rs232_unpause (void);
+/* Re-enable interrupts and release flow control */
+
+unsigned char __fastcall__ rs232_status (unsigned char* status,
+					 unsigned char* errors);
+/* Return the serial port status. */
+
+/* End of rs232silversurfer.h */
+#endif
+
+
+
diff --git a/contiki-c64/uip/tfe-drv-asm.S b/contiki-c64/uip/tfe-drv-asm.S
new file mode 100644
index 0000000..d31c320
--- /dev/null
+++ b/contiki-c64/uip/tfe-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de00
+	_cs8900a_txcmd		= $de04
+	_cs8900a_txlen		= $de06
+	_cs8900a_packetpp	= $de0a
+	_cs8900a_ppdata		= $de0c
+
diff --git a/contiki-c64/uip/tfe-drv.c b/contiki-c64/uip/tfe-drv.c
new file mode 100644
index 0000000..3b8478b
--- /dev/null
+++ b/contiki-c64/uip/tfe-drv.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-drv.c,v 1.15 2005/01/26 23:56:10 oliverschmidt Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:0E:3A is the OUI of Cirrus Logic, 64:64:64 just means C64 */
+static const struct uip_eth_addr addr =
+  {{0x00,0x0e,0x3a,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/tfe-dsc.c b/contiki-c64/uip/tfe-dsc.c
new file mode 100644
index 0000000..2efbe4d
--- /dev/null
+++ b/contiki-c64/uip/tfe-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: tfe-dsc.c,v 1.4 2005/03/29 23:17:25 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon tfe_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+    "The Final Ethernet driver",
+    "tfe.drv",
+    tfe_init,
+    &tfe_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tfeicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tfeicon_textmap[9] = {
+  'T', 'C', 'P',
+  '/', 'I', 'P',
+  'T', 'F', 'E'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon tfe_icon =
+  {CTK_ICON("TFE driver", tfeicon_bitmap, tfeicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/tfe-dump-drv.c b/contiki-c64/uip/tfe-dump-drv.c
new file mode 100644
index 0000000..24d1d5c
--- /dev/null
+++ b/contiki-c64/uip/tfe-dump-drv.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-dump-drv.c,v 1.2 2005/01/26 23:56:10 oliverschmidt Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:0E:3A is the OUI of Cirrus Logic, 64:64:64 just means C64 */
+static const struct uip_eth_addr addr =
+  {{0x00,0x0e,0x3a,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cc65/Makefile.cc65 b/contiki-cc65/Makefile.cc65
new file mode 100644
index 0000000..5183e29
--- /dev/null
+++ b/contiki-cc65/Makefile.cc65
@@ -0,0 +1,60 @@
+-include *.u
+
+.SECONDARY:
+
+CC=cc65
+AS=ca65
+LD=ld65
+CL=cl65
+
+PORTDIRS=apps conf ctk lib loader uip
+CONTIKIDIRS=${addprefix $(CONTIKI)/, apps ctk ek lib uip}
+CONTIKICC65DIRS=${addprefix $(CONTIKICC65)/, apps ctk lib loader uip}
+
+CFLAGSCC65=${addprefix -I,$(PORTDIRS)} \
+           ${addprefix -I,$(CONTIKICC65DIRS)} \
+           ${addprefix -I,$(CONTIKIDIRS)} \
+          -t $(SYS) --add-source --create-dep
+
+CLFLAGS=-Ln contiki-labels
+
+OPT=-Or
+
+%.o: %.c
+
+%.s: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $(notdir $@) $<
+
+%.o: %.s
+	$(AS) $(AFLAGS) -o $@ $<
+
+%.o: %.S
+	$(AS) $(AFLAGS) -o $@ $<
+
+vpath %.c $(PORTDIRS) $(CONTIKICC65DIRS) $(CONTIKIDIRS)
+
+vpath %.S $(PORTDIRS) $(CONTIKICC65DIRS) $(CONTIKIDIRS)
+
+%.sav:  %.o contiki-labels.o
+	cl65 --module -t $(SYS) -m $(@:.sav=.map) -o $@ loader-arch-module.o $^
+
+%.prg:  %.o contiki-labels.o
+	cl65 --module -t $(SYS) -m $(@:.prg=.map) -o $@ loader-arch-module.o $^
+
+%.drv:  %-drv.o contiki-labels.o
+	cl65 --module -t $(SYS) -m $(@:.drv=.map) -o $@ loader-arch-module.o $^
+
+%.drv:  %.o contiki-labels.o
+	cl65 --module -t $(SYS) -m $(@:.drv=.map) -o $@ loader-arch-module.o $^
+
+%.dsc:  %-dsc.o contiki-labels.o
+	cl65 --module -t $(SYS) -o $@ loader-arch-module-dsc.o $^
+
+contiki-labels.s: contiki
+	./$(CONTIKICC65)/make-labels
+
+clean:
+	rm -f *.o *~ *core contiki *.map *.s *.u *.dsc *.prg *.drv *.sav contiki-labels
+
+codesize:
+	od65 --dump-segsize *.o | egrep '\.o|CODE'
diff --git a/contiki-cc65/apps/memstat-dsc.c b/contiki-cc65/apps/memstat-dsc.c
new file mode 100644
index 0000000..0efa882
--- /dev/null
+++ b/contiki-cc65/apps/memstat-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.c,v 1.3 2005/03/18 00:51:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon memstat_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(memstat_dsc,
+    "Memory stats",
+    "memstat.prg",
+    memstat_init,
+    &memstat_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char memstaticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char memstaticon_textmap[9] = {
+  '0', '0', '1',
+  '0', '1', '0',
+  '1', '0', '1'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon memstat_icon =
+  {CTK_ICON("Memory stats", memstaticon_bitmap, memstaticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/apps/memstat-dsc.h b/contiki-cc65/apps/memstat-dsc.h
new file mode 100644
index 0000000..6390d53
--- /dev/null
+++ b/contiki-cc65/apps/memstat-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.h,v 1.1 2003/08/05 13:47:36 adamdunkels Exp $
+ *
+ */
+#ifndef __MEMSTAT_DSC_H__
+#define __MEMSTAT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(memstat_dsc);
+
+#endif /* __MEMSTAT_DSC_H__ */
diff --git a/contiki-cc65/apps/memstat.c b/contiki-cc65/apps/memstat.c
new file mode 100644
index 0000000..faa6eb4
--- /dev/null
+++ b/contiki-cc65/apps/memstat.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat.c,v 1.5 2004/09/09 21:29:03 adamdunkels Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ek.h"
+#include "loader.h"
+
+static struct ctk_window window;
+static struct ctk_label freemsg =
+  {CTK_LABEL(2, 0, 12, 1, "Free memory:")};
+static char freemem[6];
+static struct ctk_label freenum =
+  {CTK_LABEL(18, 0, 5, 1, freemem)};
+
+static struct ctk_label lblockmsg =
+  {CTK_LABEL(2, 2, 14, 1, "Largest block:")};
+static char lblock[6];
+static struct ctk_label lblocknum =
+  {CTK_LABEL(18, 2, 5, 1, lblock)};
+
+static struct ctk_button updatebutton =
+  {CTK_BUTTON(0, 4, 6, "Update")};
+static struct ctk_button closebutton =
+  {CTK_BUTTON(17, 4, 5, "Close")};
+
+/*static DISPATCHER_SIGHANDLER(memstat_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Memory statistics", NULL, memstat_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data);
+EK_PROCESS(p, "Memory statistics", EK_PRIO_NORMAL,
+	   memstat_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+update(void)
+{
+  int mem;
+
+  mem = _heapmemavail();
+  freemem[0] = (mem/10000) % 10 + '0';
+  freemem[1] = (mem/1000) % 10 + '0';
+  freemem[2] = (mem/100) % 10 + '0';
+  freemem[3] = (mem/10) % 10 + '0';
+  freemem[4] = (mem) % 10 + '0';
+
+  mem = _heapmaxavail();
+  lblock[0] = (mem/10000) % 10 + '0';
+  lblock[1] = (mem/1000) % 10 + '0';
+  lblock[2] = (mem/100) % 10 + '0';
+  lblock[3] = (mem/10) % 10 + '0';
+  lblock[4] = (mem) % 10 + '0';
+
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(memstat_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+    
+  } else {
+    ctk_window_open(&window);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 24, 5, "Memory stats");
+    /*    ctk_window_move(&window, 0, 1);*/
+
+    CTK_WIDGET_ADD(&window, &freemsg);
+    CTK_WIDGET_ADD(&window, &freenum);
+
+    CTK_WIDGET_ADD(&window, &lblockmsg);
+    CTK_WIDGET_ADD(&window, &lblocknum);
+
+    CTK_WIDGET_ADD(&window, &updatebutton);
+    CTK_WIDGET_ADD(&window, &closebutton);
+
+    CTK_WIDGET_FOCUS(&window, &updatebutton);
+    
+    update();
+    
+    ctk_window_open(&window);
+    
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&updatebutton) {
+      update();
+      ctk_window_redraw(&window);
+    } else if(data == (ek_data_t)&closebutton) {
+      ctk_window_close(&window);
+      quit();
+    }
+  } else if((ev == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/ctk/ctk-mouse.c b/contiki-cc65/ctk/ctk-mouse.c
new file mode 100644
index 0000000..e36137d
--- /dev/null
+++ b/contiki-cc65/ctk/ctk-mouse.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.c,v 1.2 2006/05/07 23:05:57 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <mouse.h>
+
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "ctk-conf.h"
+
+#include "ctk-mouse-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+/* These two are defined in loader-arch.c */
+extern struct mod_ctrl ctrl;
+extern unsigned char load(const char *name);
+
+static struct mouse_pos pos;
+static unsigned char okay;
+
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mouse_init(void)
+{
+  okay = load(MOUSE_CONF_DRIVER) == LOADER_OK;
+  if(okay) {
+    okay = mouse_install(&mouse_def_callbacks, ctrl.module) == MOUSE_ERR_OK;
+    if(okay) {
+      atexit((void (*)(void))mouse_uninstall);
+    } else {
+      mod_free(ctrl.module);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+  if(okay) {
+    mouse_pos(&pos);
+  }
+  return pos.x;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+  if(okay) {
+    mouse_pos(&pos);
+  }
+  return pos.y;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+  if(okay) {
+    return mouse_buttons();
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+  return MOUSE_CONF_XTOC(x);
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+  return MOUSE_CONF_YTOC(y);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mouse_hide(void)
+{
+  if(okay) {
+    mouse_hide();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mouse_show(void)
+{
+  if(okay) {
+    mouse_show();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki-cc65/lib/clock.c b/contiki-cc65/lib/clock.c
new file mode 100644
index 0000000..f98ae12
--- /dev/null
+++ b/contiki-cc65/lib/clock.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock.c,v 1.2 2004/09/12 20:28:47 adamdunkels Exp $
+ */
+#include <time.h>
+
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
diff --git a/contiki-cc65/lib/lc-asm.S b/contiki-cc65/lib/lc-asm.S
new file mode 100644
index 0000000..327a20a
--- /dev/null
+++ b/contiki-cc65/lib/lc-asm.S
@@ -0,0 +1,30 @@
+;---------------------------------------------------------------------
+	.importzp ptr1
+	.export _lc_set
+	.export _lc_resume
+;---------------------------------------------------------------------
+_lc_set:
+	sta ptr1
+	stx ptr1+1
+	tsx
+	lda $0102,x
+	ldy #$01
+	sta (ptr1),y
+	lda $0101,x
+	dey
+	sta (ptr1),y
+	rts
+;---------------------------------------------------------------------
+_lc_resume:	
+	sta ptr1
+	stx ptr1+1
+	ldy #$01
+	lda (ptr1),y
+	beq :+
+	tsx
+	sta $0102,x
+	dey
+	lda (ptr1),y
+	sta $0101,x
+:	rts
+;---------------------------------------------------------------------	
diff --git a/contiki-cc65/lib/lc.h b/contiki-cc65/lib/lc.h
new file mode 100644
index 0000000..54a665d
--- /dev/null
+++ b/contiki-cc65/lib/lc.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and Oliver Schmidt
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>, Oliver Schmidt <ol.sc@web.de>
+ *
+ * $Id: lc.h,v 1.6 2005/02/15 00:26:47 oliverschmidt Exp $
+ */
+/* Local continuations: a form of continuation that only works locally
+   within a function.
+*/
+
+#ifndef __LC_H__
+#define __LC_H__
+
+#include "cc.h"
+
+typedef void * lc_t;
+
+void __fastcall__ lc_set(lc_t *lc);
+void __fastcall__ lc_resume(lc_t *lc);
+
+#define LC_SET(lc)    lc_set(&(lc))
+#define LC_RESUME(lc) lc_resume(&(lc))
+#define LC_INIT(lc)   (lc) = NULL
+#define LC_END(lc)
+
+#endif /* __LC_H__ */
diff --git a/contiki-cc65/loader/loader-arch-dsc.c b/contiki-cc65/loader/loader-arch-dsc.c
new file mode 100644
index 0000000..b142e18
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch-dsc.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch-dsc.c,v 1.1 2005/05/07 14:24:37 oliverschmidt Exp $
+ *
+ */
+
+#include <modload.h>
+
+#include "loader.h"
+
+extern struct mod_ctrl ctrl;
+
+unsigned char load(const char *name);
+
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+  unsigned char r;
+
+  r = load(name);
+  if(r == MLOAD_OK) {
+    return (struct dsc *)ctrl.module;    
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/loader/loader-arch-dsc.h b/contiki-cc65/loader/loader-arch-dsc.h
new file mode 100644
index 0000000..56bf735
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch-dsc.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch-dsc.h,v 1.1 2005/05/07 14:24:38 oliverschmidt Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_DSC_H__
+#define __LOADER_ARCH_DSC_H__
+
+#include "dsc.h"
+#include <modload.h>
+
+struct dsc *loader_arch_load_dsc(const char *name);
+
+#define LOADER_LOAD_DSC(name)  loader_arch_load_dsc(name)
+#define LOADER_UNLOAD_DSC(dsc) mod_free(dsc)
+
+#endif /* __LOADER_ARCH_DSC_H__ */
diff --git a/contiki-cc65/loader/loader-arch-module-dsc.S b/contiki-cc65/loader/loader-arch-module-dsc.S
new file mode 100644
index 0000000..dd82301
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch-module-dsc.S
@@ -0,0 +1 @@
+.segment        "JUMPTABLE"
diff --git a/contiki-cc65/loader/loader-arch-module.S b/contiki-cc65/loader/loader-arch-module.S
new file mode 100644
index 0000000..23e376a
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch-module.S
@@ -0,0 +1,8 @@
+.segment        "JUMPTABLE"
+	.import _loader_appinit
+	.export _loader_arch_loadaddr
+_loader_arch_loadaddr:
+arch:		.byte 0,0,0,0,0,0,0,0
+version:	.byte 0,0,0,0,0,0,0,0	
+	jmp _loader_appinit
+
diff --git a/contiki-cc65/loader/loader-arch.c b/contiki-cc65/loader/loader-arch.c
new file mode 100644
index 0000000..95be07e
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.8 2005/05/07 14:24:38 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <modload.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "loader.h"
+
+struct mod_ctrl ctrl = {
+  read            /* Read from disk */
+};
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  
+  /* Now open the file */
+  ctrl.callerdata = open(name, O_RDONLY);
+  if(ctrl.callerdata < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+
+  /* Load the module */
+  res = mod_load(&ctrl);
+  
+  /* Close the input file */
+  close(ctrl.callerdata);
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/loader/loader-arch.h b/contiki-cc65/loader/loader-arch.h
new file mode 100644
index 0000000..dbc31eb
--- /dev/null
+++ b/contiki-cc65/loader/loader-arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.5 2005/05/07 14:24:38 oliverschmidt Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+#include <modload.h>
+
+unsigned char loader_arch_load(const char *name, char *arg);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD(name, arg) loader_arch_load(name, arg)
+#define LOADER_UNLOAD()        mod_free(&loader_arch_loadaddr)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-cc65/make-labels b/contiki-cc65/make-labels
new file mode 100755
index 0000000..6dd73e6
--- /dev/null
+++ b/contiki-cc65/make-labels
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+
+egrep -v 'ZP|BSS' contiki-labels | perl -n -e 'if(/^al 0000(.+) \.([^@]+)\n/){if($l{$2} eq ""){$l{$2}=$1;print ".exportzp $2\n$2=\$$1\n";}} elsif(/^al 00(.+) \.([^@]+)\n/){if($l{$2} eq ""){$l{$2}=$1;print ".export $2\n$2=\$$1\n";}}' > contiki-labels.s
+
+echo '.segment        "EXTZP": zeropage' >> contiki-labels.s
\ No newline at end of file
diff --git a/contiki-cc65/uip/rs232dev.c b/contiki-cc65/uip/rs232dev.c
new file mode 100644
index 0000000..7668a4c
--- /dev/null
+++ b/contiki-cc65/uip/rs232dev.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.6 2005/02/23 22:43:23 oliverschmidt Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <serial.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(ser_get(&c) == SER_ERR_NO_DATA)
+#define SIO_POLL(c)  (ser_get(&c) != SER_ERR_NO_DATA)
+#define SIO_SEND(c)  ser_put(c)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+static char loaded = 0;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+/*static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+  
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == UIP_TCPIP_HLEN) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  if(loaded == 0) {
+    return 0;
+  }
+  
+  while(SIO_POLL(c)) {
+
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+            
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  struct ser_params p;
+  
+  err = ser_load_driver("c64-swlink.ser");
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+  p.baudrate = SER_BAUD_9600;
+  p.databits = SER_BITS_8;
+  p.stopbits = SER_STOP_1;
+  p.parity = SER_PAR_NONE;
+  p.handshake = SER_HS_HW;
+
+  err = ser_open(&p);
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+
+  loaded = 1;
+  
+  /*  err = rs232_init(0); */
+  /*  rs232_err(err);*/
+  /*  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);*/
+  /*  rs232_err(err);*/
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_unload(void)
+{
+  if(loaded){
+    ser_unload();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cc65/uip/rs232dev.h b/contiki-cc65/uip/rs232dev.h
new file mode 100644
index 0000000..b9d4224
--- /dev/null
+++ b/contiki-cc65/uip/rs232dev.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.3 2004/09/12 20:28:48 adamdunkels Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+
+u16_t rs232dev_poll(void);
+
+void rs232dev_unload(void);
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-cc65/uip/slip-drv.c b/contiki-cc65/uip/slip-drv.c
new file mode 100644
index 0000000..da137d3
--- /dev/null
+++ b/contiki-cc65/uip/slip-drv.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-drv.c,v 1.8 2004/09/03 10:04:30 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tapdev_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cc65/uip/slip-dsc.c b/contiki-cc65/uip/slip-dsc.c
new file mode 100644
index 0000000..613ed85
--- /dev/null
+++ b/contiki-cc65/uip/slip-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: slip-dsc.c,v 1.4 2005/04/12 20:49:53 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon slip_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(slip_dsc,
+    "SLIP driver",
+    "slip.drv",
+    slip_init,
+    &slip_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char slipicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char slipicon_textmap[9] = {
+  'R', 'S', ' ',
+  '2', '3', '2',
+  '/', 'I', 'P'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon slip_icon =
+  {CTK_ICON("SLIP driver", slipicon_bitmap, slipicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/uip/slip-dump-drv.c b/contiki-cc65/uip/slip-dump-drv.c
new file mode 100644
index 0000000..1641729
--- /dev/null
+++ b/contiki-cc65/uip/slip-dump-drv.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-dump-drv.c,v 1.1 2004/09/17 20:55:34 adamdunkels Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(slip_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "SLIP dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cc65/uip/uip_arch.c b/contiki-cc65/uip/uip_arch.c
new file mode 100644
index 0000000..bae557b
--- /dev/null
+++ b/contiki-cc65/uip/uip_arch.c
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.7 2005/02/24 22:04:53 oliverschmidt Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+#define IP_PROTO_UDP    17
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  asm("ldy #3");
+  asm("jsr ldaxysp");
+  asm("sta ptr1");
+  asm("stx ptr1+1");
+  asm("ldy #0");
+  asm("lda (sp),y");
+  asm("ldy #3");
+  asm("clc");
+  asm("adc (ptr1),y");
+  asm("sta _uip_acc32+3");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("ldy #1");
+  asm("adc (sp),y");
+  asm("sta _uip_acc32+2");
+  asm("ldy #1");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+1");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+0");  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u8_t chksum_protocol;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+chksum(void) {
+
+  asm("lda #0");
+  asm("sta tmp1");
+  asm("sta tmp1+1");
+  asm("lda _chksum_ptr");
+  asm("sta ptr1");
+  asm("lda _chksum_ptr+1");
+  asm("sta ptr1+1");
+
+
+  asm("lda _chksum_len+1");
+  asm("beq chksumlast");
+
+
+  /* If checksum is > 256, do the first runs. */
+  asm("ldy #0");
+  asm("clc");
+  asm("chksumloop_256:");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("iny");
+  asm("bne chksumloop_256");
+  asm("inc ptr1+1");
+  asm("dec _chksum_len+1");
+  asm("bne chksumloop_256");
+
+  asm("chksum_endloop_256:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop_256");
+  
+  asm("chksumlast:");
+  asm("lda _chksum_len");
+  asm("lsr");
+  asm("bcc chksum_noodd");  
+  asm("ldy _chksum_len");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("clc");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("bcc noinc1");
+  asm("inc tmp1+1");
+  asm("bne noinc1");
+  asm("inc tmp1");
+  asm("noinc1:");
+  asm("dec _chksum_len");
+
+  asm("chksum_noodd:");
+  asm("clc");
+  asm("php");
+  asm("ldy _chksum_len");
+  asm("chksum_loop1:");
+  asm("cpy #0");
+  asm("beq chksum_loop1_end");
+  asm("plp");
+  asm("dey");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("dey");
+  asm("php");
+  asm("jmp chksum_loop1");
+  asm("chksum_loop1_end:");
+  asm("plp");
+  
+  asm("chksum_endloop:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop");
+  
+  asm("lda tmp1");
+  asm("ldx tmp1+1");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *buf, u16_t len)
+{
+  /*  unsigned long sum;
+
+  sum = 0;
+
+  chksum_ptr = (u16_t)buf;
+  while(len >= 256) {  
+    chksum_len = 256;
+    sum += chksum();
+    len -= 256;
+    chksum_ptr += 256;
+  }
+
+  if(len < 256) {
+    chksum_len = len;
+    sum += chksum();
+  }
+
+  while((sum >> 16) != 0) {
+    sum = (sum >> 16) + (sum & 0xffff);
+  }
+
+  return sum;*/
+
+  chksum_len = len;
+  chksum_ptr = (u16_t)buf;
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{  
+  chksum_ptr = (u16_t)uip_buf + UIP_LLH_LEN;
+  chksum_len = UIP_IPH_LEN;  
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static u16_t
+transport_chksum(u8_t protocol)
+{
+  chksum_protocol = protocol;
+  chksum_ptr = (u16_t)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN];
+  chksum_len = UIP_TCPH_LEN;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #%b", UIP_IPTCPH_LEN);
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #%b", UIP_IPH_LEN);
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc %v", chksum_protocol);  
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+}
+#pragma optimize(pop)
+
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  return transport_chksum(IP_PROTO_TCP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[UIP_LLH_LEN + UIP_IPH_LEN];
+  chksum_len = UIP_TCPH_LEN;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #%b", UIP_IPTCPH_LEN);
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #%b", UIP_IPH_LEN);
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #6");  /* IP_PROTO_TCP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif 
+}
+
+/*-----------------------------------------------------------------------------------*/
+#if UIP_UDP_CHECKSUMS
+u16_t
+uip_udpchksum(void)
+{
+  return transport_chksum(IP_PROTO_UDP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #17");  /* IP_PROTO_UDP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif
+}
+#endif /* UIP_UDP_CHECKSUMS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cc65/uip/uip_arch.h b/contiki-cc65/uip/uip_arch.h
new file mode 100644
index 0000000..ba8efc4
--- /dev/null
+++ b/contiki-cc65/uip/uip_arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.3 2004/09/12 20:28:48 adamdunkels Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki-cpc/Makefile b/contiki-cpc/Makefile
new file mode 100644
index 0000000..83087fe
--- /dev/null
+++ b/contiki-cpc/Makefile
@@ -0,0 +1,64 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.2 2006/04/17 14:42:28 kthacker Exp $
+#
+
+CONTIKI=../contiki
+
+usage:
+	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+	@echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+	@echo 'is one of the following:'
+	@echo all
+	@echo cpc
+	@echo cpcnet
+	@echo programs
+	@echo netprogs
+	@echo '(Also check the Makefile for more targets to try...)'
+
+all: clean cpc cpcnet programs 
+
+programs:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.programs
+
+netprogs:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.netprogs
+
+cpc:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc
+
+cpcnet:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc-net
+
+include Makefile.common
+
diff --git a/contiki-cpc/Makefile.common b/contiki-cpc/Makefile.common
new file mode 100644
index 0000000..0c3c9e9
--- /dev/null
+++ b/contiki-cpc/Makefile.common
@@ -0,0 +1,162 @@
+CC=sdcc
+AS=as-z80
+CL=link-z80
+LD=link-z80
+
+CFLAGSCOMMON= \
+	-I apps \
+	-I conf \
+	-I ctk \
+	-I lib \
+	-I loader \
+	-I uip \
+	-I arch \
+	-I $(CONTIKI)/apps \
+	-I $(CONTIKI)/ctk \
+	-I $(CONTIKI)/ek \
+	-I $(CONTIKI)/lib \
+	-I $(CONTIKI)/ppp \
+	-I $(CONTIKI)/uip \
+	-mz80 -D__fastcall__=/**/ -D__CPC__ -DCLK_TCK=16384 \
+	--no-std-crt0 --opt-code-size --peep-file ~/peeph/peep.def
+
+CLFLAGS= 
+OPT=
+AFLAGS = -o -g
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $*.o $<
+
+%.o: %.s
+	$(AS) $(AFLAGS) $*.o $<
+
+UIP=	../contiki/uip/uip.o \
+	uip/uip_arch.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uiplib.o 
+
+
+#	../contiki/uip/uip-signal.o
+#	../contiki/uip/uip_main.o \
+
+
+WWW=	../contiki/apps/www.o \
+	../contiki/apps/webclient.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/http-user-agent-string.o \
+	../contiki/apps/htmlparser.o \
+	../contiki/apps/html-strings.o 
+
+EMAIL= ../contiki/apps/email.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/ctk-textedit.o \
+	../contiki/uip/socket.o \
+	./lib/lc-asm.o \
+	../lib/memb.o 
+
+WEBSERVER= ../contiki/apps/webserver.o ../contiki/apps/httpd.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/httpd-fs.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	../contiki/apps/httpd-cgi.o \
+	../contiki/lib/memb.o \
+	./lib/lc-asm.o 
+
+TELNET= ../contiki/apps/simpletelnet.o ../contiki/apps/telnet.o 
+
+WGET= apps/wget.o ../contiki/apps/webclient.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/http-user-agent-string.o 
+
+clean: 
+	rm -f ../arch/*.o
+	rm -f ../loader/*.o
+	rm -f ../contiki/ctk/*.o 
+	rm -f ../contiki/ctk/*.asm
+	rm -f ../contiki/ctk/*.lst
+	rm -f ../contiki/ctk/*.map
+	rm -f ../contiki/ctk/*.sym
+	rm -f ../contiki/ctk/*.rst
+	rm -f ../contiki/ek/*.o 
+	rm -f ../contiki/ek/*.asm 
+	rm -f ../contiki/ek/*.lst
+	rm -f ../contiki/ek/*.map
+	rm -f ../contiki/ek/*.sym
+	rm -f ../contiki/ek/*.rst
+	rm -f ../contiki/lib/*.o 
+	rm -f ../contiki/lib/*.asm 
+	rm -f ../contiki/lib/*.lst
+	rm -f ../contiki/lib/*.map
+	rm -f ../contiki/lib/*.sym
+	rm -f ../contiki/lib/*.rst
+	rm -f ../contiki/apps/*.o 
+	rm -f ../contiki/apps/*.ihx
+	rm -f ../contiki/apps/*.lnk 
+	rm -f ../contiki/apps/*.asm 
+	rm -f ../contiki/apps/*.lst
+	rm -f ../contiki/apps/*.sym
+	rm -f ../contiki/apps/*.prg
+	rm -f ../contiki/apps/*.dsc
+	rm -f ../contiki/apps/*.ams
+	rm -f ../contiki/apps/*.bin
+	rm -f ../contiki/apps/*.map
+	rm -f ../contiki/apps/*.rst
+	rm -f ../contiki/uip/*.o 
+	rm -f ../contiki/uip/*.ihx
+	rm -f ../contiki/uip/*.lnk 
+	rm -f ../contiki/uip/*.asm 
+	rm -f ../contiki/uip/*.lst
+	rm -f ../contiki/uip/*.sym
+	rm -f ../contiki/uip/*.prg
+	rm -f ../contiki/uip/*.dsc
+	rm -f ../contiki/uip/*.ams
+	rm -f ../contiki/uip/*.bin
+	rm -f ./apps/*.o 
+	rm -f ./apps/*.ihx
+	rm -f ./apps/*.lnk 
+	rm -f ./apps/*.asm 
+	rm -f ./apps/*.lst
+	rm -f ./apps/*.sym
+	rm -f ./apps/*.prg
+	rm -f ./apps/*.dsc
+	rm -f ./apps/*.ams
+	rm -f ./apps/*.bin
+	rm -f ./apps/*.map
+	rm -f ./apps/*.rst
+	rm -f ./ctk/*.o 
+	rm -f ./ctk/*.ihx
+	rm -f ./ctk/*.lnk 
+	rm -f ./ctk/*.asm 
+	rm -f ./ctk/*.lst
+	rm -f ./ctk/*.sym
+	rm -f ./ctk/*.prg
+	rm -f ./ctk/*.dsc
+	rm -f ./ctk/*.ams
+	rm -f ./ctk/*.bin
+	rm -f ./ctk/*.map
+	rm -f ./ctk/*.rst
+	rm -f lib/*.o 
+	rm -f lib/*.asm 
+	rm -f lib/*.lst
+	rm -f lib/*.map
+	rm -f lib/*.sym
+	rm -f loader/*.o 
+	rm -f loader/*.asm 
+	rm -f loader/*.lst
+	rm -f loader/*.map
+	rm -f loader/*.sym
+	rm -f uip/*.o 
+	rm -f uip/*.asm 
+	rm -f uip/*.lst
+	rm -f uip/*.map
+	rm -f uip/*.sym
+	rm -f arch/*.o 
+	rm -f arch/*.asm 
+	rm -f arch/*.lst
+	rm -f arch/*.map
+	rm -f arch/*.sym
+
+
diff --git a/contiki-cpc/Makefile.cpc b/contiki-cpc/Makefile.cpc
new file mode 100644
index 0000000..bd22100
--- /dev/null
+++ b/contiki-cpc/Makefile.cpc
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc,v 1.2 2006/04/17 14:42:28 kthacker Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+        -DWITH_ASCII \
+	-DCTK_CONIO \
+	-DWITH_LOADER_ARCH \
+	-DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/slipdev.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/tcpdump.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uip-fw.o \
+	../contiki/uip/uip-fw-service.o \
+	../contiki/uip/uip-split.o \
+	../contiki/uip/uip.o \
+	../contiki/uip/uip_arp.o \
+	../contiki/uip/uiplib.o \
+	./uip/uip_arch.o \
+	./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+	./loader/rel.o \
+	./arch/key.o \
+	./arch/mem.o \
+	./arch/malloc.o \
+	./arch/clock.o \
+	./loader/dir.o \
+	./loader/loader-arch-cpc.o \
+	./arch/putchar.o \
+	./arch/uip.o \
+	./arch/conio.o \
+	./apps/configedit.o \
+	./apps/configedit-dsc.o \
+	../contiki/apps/directory.o \
+	./apps/directory-dsc.o \
+	../contiki/apps/processes.o \
+	../contiki/apps/processes-dsc.o \
+	../contiki/apps/program-handler.o \
+	../contiki/ctk/ctk.o \
+	../contiki/ctk/ctk-conio-service.o \
+	../contiki/ctk/ctk-draw.o \
+	../contiki/ctk/ctk-term-in.o \
+	../contiki/ctk/ctk-term-out.o \
+	../contiki/ctk/ctk-term.o \
+	../contiki/ctk/ctk-termtelnet.o \
+	../contiki/ctk/ctk-vncfont.o \
+	../contiki/ctk/vnc-server.o \
+	../contiki/ek/ek-service.o \
+	../contiki/ek/ek.o \
+	../contiki/ek/arg.o \
+	../contiki/ek/mt.o \
+	../contiki/lib/cfs.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/lib/list.o \
+	../contiki/lib/memb.o \
+	../contiki/lib/timer.o \
+	../contiki/lib/strncasecmp.o \
+	./loader/cfs-cpc.o \
+	./arch/main.o \
+	./arch/arch.o \
+	$(UIP)
+
+
+contiki: $(CONTIKI_OBJ)
+	$(LD) -f arch/contiki.lnk
+	./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+	./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+	./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+	./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/Makefile.cpc-net b/contiki-cpc/Makefile.cpc-net
new file mode 100644
index 0000000..91b54d1
--- /dev/null
+++ b/contiki-cpc/Makefile.cpc-net
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc-net,v 1.2 2006/04/17 14:42:28 kthacker Exp $
+#
+
+all: contikin
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+        -DWITH_ASCII \
+	-DCTK_CONIO \
+	-DWITH_LOADER_ARCH \
+	-DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/slipdev.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/tcpdump.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uip-fw.o \
+	../contiki/uip/uip-fw-service.o \
+	../contiki/uip/uip-split.o \
+	../contiki/uip/uip.o \
+	../contiki/uip/uip_arp.o \
+	../contiki/uip/uiplib.o \
+	./uip/uip_arch.o \
+	./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+	./loader/rel.o \
+	./arch/key.o \
+	./arch/mem.o \
+	./arch/malloc.o \
+	./arch/clock.o \
+	./loader/dir.o \
+	./loader/loader-arch-cpc.o \
+	./arch/putchar.o \
+	./arch/uip.o \
+	./arch/conio.o \
+	./apps/configedit.o \
+	./apps/configedit-dsc.o \
+	../contiki/apps/directory.o \
+	./apps/directory-dsc.o \
+	../contiki/apps/processes.o \
+	../contiki/apps/processes-dsc.o \
+	../contiki/apps/program-handler.o \
+	../contiki/ctk/ctk.o \
+	../contiki/ctk/ctk-conio-service.o \
+	../contiki/ctk/ctk-draw.o \
+	../contiki/ctk/ctk-term-in.o \
+	../contiki/ctk/ctk-term-out.o \
+	../contiki/ctk/ctk-term.o \
+	../contiki/ctk/ctk-termtelnet.o \
+	../contiki/ctk/ctk-vncfont.o \
+	../contiki/ctk/vnc-server.o \
+	../contiki/ek/ek-service.o \
+	../contiki/ek/ek.o \
+	../contiki/ek/arg.o \
+	../contiki/ek/mt.o \
+	../contiki/lib/cfs.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/lib/list.o \
+	../contiki/lib/memb.o \
+	../contiki/lib/timer.o \
+	../contiki/lib/strncasecmp.o \
+	./loader/cfs-cpc.o \
+	./arch/main.o \
+	./arch/arch.o \
+	$(UIP)
+
+
+contikin: $(CONTIKI_OBJ)
+	$(LD) -f arch/contiki-uip.lnk
+	./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+	./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+	./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+	./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/Makefile.netprogs b/contiki-cpc/Makefile.netprogs
new file mode 100644
index 0000000..097026f
--- /dev/null
+++ b/contiki-cpc/Makefile.netprogs
@@ -0,0 +1,242 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.netprogs,v 1.2 2006/04/17 14:42:28 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+	../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+	../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+	../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+	../contiki/apps/email.prg ../contiki/apps/email.dsc \
+	../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+	../contiki/apps/wget.dsc \
+	../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+#	../contiki/apps/irc.prg ../contiki/apps/irc.dsc 
+#	../contiki/apps/wget.prg 
+#	../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: 	./arch/crt0-dsc.o \
+	./arch/crt0-prg.o \
+	./arch/contiki_labels.o \
+	./loader/loader-arch-module.o \
+	$(UIP_PRGS)
+
+SYS=cpc
+
+include Makefile.common 
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+	-DWITH_ASCII \
+	-DWITH_CONIO \
+	-DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+	bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+%.dsc: %-dsc.o 
+	$(MAKE_DSC)
+
+define MAKE_PRG
+	bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+	../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+	$(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+	$(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+	$(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+	$(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+	$(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+	$(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+	$(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+	$(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o	\
+	lib/lc-asm.o
+	$(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+	$(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	./lib/lc-asm.o 
+	$(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+	../contiki/apps/ftpc.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+	$(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ 	../contiki/apps/shell.o \
+	../contiki/lib/memb.o \
+	../contiki/apps/telnetd-gui.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+	$(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+	$(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+	../contiki/apps/vnc-viewer.o \
+	./apps/vnc-draw.o 
+
+../contiki/apps/conio.prg: \
+	../contiki/ctk/ctk-conio-service.o \
+	./arch/conio.o
+	$(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o 
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+	$(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+#	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+	$(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+	$(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/Makefile.programs b/contiki-cpc/Makefile.programs
new file mode 100644
index 0000000..75b1c76
--- /dev/null
+++ b/contiki-cpc/Makefile.programs
@@ -0,0 +1,263 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.2 2006/04/17 14:42:28 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+	../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+	../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+	../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+	../contiki/apps/email.prg ../contiki/apps/email.dsc \
+	../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+	../contiki/apps/wget.dsc \
+	../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+#	../contiki/apps/irc.prg ../contiki/apps/irc.dsc 
+#	../contiki/apps/wget.prg 
+#	../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: 	./arch/crt0-dsc.o \
+	./arch/crt0-prg.o \
+	./arch/contiki_labels.o \
+	./loader/loader-arch-module.o \
+	./apps/welcome.prg \
+	../contiki/apps/conio.prg \
+	../contiki/apps/about.prg ../contiki/apps/about.dsc \
+	../contiki/apps/netconf.prg ../contiki/apps/netconf.dsc \
+	../contiki/apps/process.prg ../contiki/apps/process.dsc \
+	../contiki/apps/calc.prg ../contiki/apps/calc.dsc \
+	../contiki/apps/editor.prg ../contiki/apps/editor.dsc \
+	../contiki/apps/dir.prg ./apps/dir.dsc \
+	./apps/config.prg \
+	./apps/confedit.prg \
+	./apps/confedit.dsc \
+	../contiki/apps/shell.prg ../contiki/apps/shell.dsc 
+#	$(UIP_PRGS) \
+
+#	./cfs-cpc.drv \
+#	./ctk-text.drv \
+#	./ctk-default.drv \
+#	./ctk-80col.drv \
+#	./slip.drv slip.dsc \
+#	./cgterm.prg cgterm.dsc \
+
+#	./apps/memstat.prg ./apps/memstat.dsc \
+
+SYS=cpc
+
+include Makefile.common 
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+	-DWITH_ASCII \
+	-DWITH_CONIO \
+	-DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+	bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+%.dsc: %-dsc.o 
+	$(MAKE_DSC)
+
+define MAKE_PRG
+	bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+	../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+	$(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+	$(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+	$(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+	$(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+	$(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+	$(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+	$(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+	$(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o	\
+	lib/lc-asm.o
+	$(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+	$(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	./lib/lc-asm.o 
+	$(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+	../contiki/apps/ftpc.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+	$(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ 	../contiki/apps/shell.o \
+	../contiki/lib/memb.o \
+	../contiki/apps/telnetd-gui.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+	$(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+	$(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+	../contiki/apps/vnc-viewer.o \
+	./apps/vnc-draw.o 
+
+../contiki/apps/conio.prg: \
+	../contiki/ctk/ctk-conio-service.o \
+	./arch/conio.o
+	$(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o 
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+	$(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+#	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+	$(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+	$(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/README b/contiki-cpc/README
new file mode 100644
index 0000000..854e27f
--- /dev/null
+++ b/contiki-cpc/README
@@ -0,0 +1,2 @@
+This is the Amstrad CPC port of Contiki, maintained by Kevin Thacker
+<amstrad@aiind.upv.es>
diff --git a/contiki-cpc/apps/blueround-dsc.c b/contiki-cpc/apps/blueround-dsc.c
new file mode 100644
index 0000000..f2d245b
--- /dev/null
+++ b/contiki-cpc/apps/blueround-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: blueround-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon blueround_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(blueround_dsc,
+    "Blueround CTK theme",
+    "blueround.prg",
+    blueround_init,
+    &blueround_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char blueroundicon_bitmap[3*3*8] = {
+  0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00,
+  0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00,
+  0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char blueroundicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon blueround_icon =
+  {CTK_ICON("Blueround", blueroundicon_bitmap, blueroundicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm-dsc.c b/contiki-cpc/apps/cgterm-dsc.c
new file mode 100644
index 0000000..acba8ba
--- /dev/null
+++ b/contiki-cpc/apps/cgterm-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: cgterm-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(cgterm_dsc,
+    "Program for connecting to C64 Telnet BBSes",
+    "cgterm.prg",
+    cgterm_init,
+    &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char cgtermicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char cgtermicon_textmap[9] = {
+  'T', 'e', 'l',
+  'n', 'e', 't',
+  'B', 'B', 'S'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon icon =
+  {CTK_ICON("C/G terminal", cgtermicon_bitmap, cgtermicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm.c b/contiki-cpc/apps/cgterm.c
new file mode 100644
index 0000000..fa85a40
--- /dev/null
+++ b/contiki-cpc/apps/cgterm.c
@@ -0,0 +1,243 @@
+#include "contiki.h"
+#include "socket.h"
+#include "ctk-draw.h"
+
+#include <cbm.h>
+#include <c64.h>
+#include <string.h>
+
+static struct {
+  struct socket sout, sin;
+  struct pt inpt, outpt;
+  char outputbuf[200];
+  char inputbuf[200];
+  unsigned short len;
+} s;
+
+#define CURSOR_ON()  *(char *)0xcc = 0
+#define CURSOR_OFF() *(char *)0xcc = 1
+static void ctkmode(void);
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send(void))
+{
+  SOCKET_BEGIN(&s.sout);
+  
+  SOCKET_SEND(&s.sout, s.outputbuf, s.len);
+  SOCKET_END(&s.sout);    
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(void))
+{
+  ctk_arch_key_t c;
+  char *ptr;
+  
+  PT_BEGIN(&s.outpt);
+  
+  while(1) {
+    PT_WAIT_UNTIL(&s.outpt, (ctk_mode_get() == CTK_MODE_EXTERNAL) &&
+		  kbhit());
+
+
+    ptr = s.outputbuf;
+    s.len = 0;    
+    while(kbhit() && s.len < sizeof(s.outputbuf)) {
+      c = cgetc();
+      *ptr = c;
+      ++ptr;
+      ++s.len;   
+    }
+
+    PT_WAIT_THREAD(&s.outpt, send());
+  }
+  PT_END(&s.outpt);      
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(void))
+{
+  unsigned short i;
+  char *ptr;
+  char next;
+  
+  next = 1; 
+  PT_BEGIN(&s.inpt);
+  
+  while(1) {
+    /* Wait until data arrives. */
+    next = 0;
+    PT_WAIT_UNTIL(&s.inpt, next && uip_newdata());
+
+    CURSOR_OFF();
+    /* Print it out on the screen. */
+    ptr = (char *)uip_appdata;
+    for(i = 0; i < uip_len; ++i) {
+      cbm_k_bsout(*ptr);
+      ++ptr;
+    }
+    CURSOR_ON();
+  }  
+  PT_END(&s.inpt);
+}
+/*---------------------------------------------------------------------------*/
+static void
+appcall(void *state)
+{
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    ctkmode();
+  } else if(uip_connected()) {
+  } else {
+    handle_input();
+    handle_output();   
+  }
+}
+/*---------------------------------------------------------------------------*/
+static struct uip_conn *
+connect(u16_t *host, u16_t port)
+{
+  SOCKET_INIT(&s.sin, s.inputbuf, sizeof(s.inputbuf));
+  SOCKET_INIT(&s.sout, s.inputbuf, sizeof(s.inputbuf));
+  PT_INIT(&s.inpt);
+  PT_INIT(&s.outpt);
+  return tcp_connect(host, htons(port), NULL);
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler);
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "C/G terminal", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+static struct uip_conn *conn;
+static u16_t serveraddr[2];
+static u16_t serverport;
+/*---------------------------------------------------------------------------*/
+static struct ctk_window window;
+static struct ctk_label hostlabel =
+  {CTK_LABEL(0, 0, 4, 1, "Host")};
+static char host[32];
+static struct ctk_textentry hostentry =
+  {CTK_TEXTENTRY(5, 0, 20, 1, host, sizeof(host) - 1)};
+static struct ctk_label portlabel =
+  {CTK_LABEL(27, 0, 4, 1, "Port")};
+static char port[7];
+static struct ctk_textentry portentry =
+  {CTK_TEXTENTRY(32, 0, 4, 1, port, sizeof(port) - 1)};
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(0, 2, 7, "Connect")};
+static struct ctk_button switchbutton =
+  {CTK_BUTTON(30, 2, 6, "Switch")};
+static struct ctk_label helplabel =
+  {CTK_LABEL(0, 4, 37, 1, "RUN/STOP to return from terminal view")};
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cgterm_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+ctkmode(void)
+{
+  ctk_mode_set(CTK_MODE_NORMAL);
+  ctk_draw_init();
+  ctk_desktop_redraw(NULL);
+}
+/*---------------------------------------------------------------------------*/
+static void
+textmode(void)
+{
+  ctk_mode_set(CTK_MODE_EXTERNAL);
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+  
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */
+
+  CURSOR_ON();
+}     
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t *ipaddr;
+  char *cptr;
+    
+  if(ev == tcpip_event) {
+    appcall(data);
+  } else if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 38, 5, "C/G term");
+    CTK_WIDGET_ADD(&window, &hostlabel);
+    CTK_WIDGET_ADD(&window, &hostentry);
+    CTK_WIDGET_ADD(&window, &portlabel);
+    CTK_WIDGET_ADD(&window, &portentry);
+    CTK_WIDGET_ADD(&window, &connectbutton);
+    CTK_WIDGET_ADD(&window, &switchbutton);
+    CTK_WIDGET_ADD(&window, &helplabel);
+    ctk_window_open(&window);
+  } else if(ev == ctk_signal_widget_activate) {
+
+    if(data == (ek_data_t)&switchbutton) {
+      textmode();
+    } else if(data == (ek_data_t)&connectbutton) {
+      serverport = 0;
+      for(cptr = port; *cptr != ' ' && *cptr != 0; ++cptr) {
+	if(*cptr < '0' || *cptr > '9') {
+	  return;
+	}
+	serverport = 10 * serverport + *cptr - '0';
+      }
+
+      ipaddr = serveraddr;
+      if(uiplib_ipaddrconv(host, (u8_t *)serveraddr) == 0) {
+	ipaddr = resolv_lookup(host);
+	if(ipaddr == NULL) {
+	  resolv_query(host);
+	} else {
+	  uip_ipaddr_copy(serveraddr, ipaddr);
+	}
+      }
+      if(ipaddr != NULL) {      
+	conn = connect(serveraddr, serverport);
+	if(conn != NULL) {
+	  memset((char *)0x0400, 0x20, 40*25);
+	  memset((char *)0xd800, 0x01, 40*25);
+	  textmode();
+	}
+      }
+    }
+  } else if(ev == resolv_event_found) {
+    ipaddr = resolv_lookup(host);
+    if(ipaddr != NULL) {
+      uip_ipaddr_copy(serveraddr, ipaddr);
+      
+      conn = connect(serveraddr, serverport);
+      if(conn != NULL) {
+	memset((char *)0x0400, 0x20, 40*25);
+	memset((char *)0xd800, 0x01, 40*25);
+	textmode();
+      }
+    }
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_window_close) {
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+  } 
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  if(ctk_mode_get() == CTK_MODE_EXTERNAL) {
+    if(CIA1.prb == 0x7f) {
+      ctkmode();
+    } else if(kbhit() && conn != NULL) {
+      tcpip_poll_tcp(conn);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/config.c b/contiki-cpc/apps/config.c
new file mode 100644
index 0000000..9fb37fe
--- /dev/null
+++ b/contiki-cpc/apps/config.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: config.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadfile(char *str)
+{
+  char *nt;
+
+  nt = nullterminate(str);
+  
+  /* Call loader function. */
+  program_handler_load(str, NULL);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+screensaverconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  program_handler_screensaver(str);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t addr[2];
+static char *
+ipaddrconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+
+
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_sethostaddr(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_setnetmask(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_setdraddr(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    resolv_conf(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry configparsetab[] =
+  {{'n', loadfile},
+   {'t', loadfile},
+   {'c', loadfile},   
+   {'s', screensaverconf},   
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+configscript(void)
+{
+  static char line[40], *lineptr;
+  /*  static struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, configparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+  arg_free(arg);
+  program_handler_screensaver(NULL);  
+  configscript();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.c b/contiki-cpc/apps/configedit-dsc.c
new file mode 100644
index 0000000..fcb9250
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+    "Edit Contiki configuration",
+    "confedit.prg",
+    configedit_init,
+    &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char tcpipconficon_textmap[9] = {
+  'C', 'F', 'G',
+  ' ', ' ', ' ',
+  'C', 'F', 'G'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon configedit_icon =
+  {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.h b/contiki-cpc/apps/configedit-dsc.h
new file mode 100644
index 0000000..368b45c
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-cpc/apps/configedit.c b/contiki-cpc/apps/configedit.c
new file mode 100644
index 0000000..5d43f72
--- /dev/null
+++ b/contiki-cpc/apps/configedit.c
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk-draw-service.h"
+#include "packet-service.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "program-handler.h"
+
+#include "cfs.h"
+
+//#include "cfs-init.h"
+#include "cfs-cpc.h"
+
+#include "loader.h"
+
+#include "log.h"
+
+
+#include <stdio.h>
+
+#include <string.h>
+
+/* TCP/IP configuration window. */
+static struct ctk_window window;
+
+#define LABELMAXWIDTH 12
+
+const static struct ctk_label cfslabel =
+  {CTK_LABEL(0, 1, LABELMAXWIDTH, 1, "Disk driver")};
+static char cfs[25];
+static struct ctk_textentry cfstextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 1, 16, 1, cfs, 24)};
+
+const static struct ctk_label themelabel =
+  {CTK_LABEL(0, 3, LABELMAXWIDTH, 1, "CTK theme")};
+static char theme[25];
+static struct ctk_textentry themetextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 3, 16, 1, theme, 24)};
+
+const static struct ctk_label driverlabel =
+  {CTK_LABEL(0, 5, LABELMAXWIDTH, 1, "Net driver")};
+static char driver[25];
+static struct ctk_textentry drivertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 5, 16, 1, driver, 24)};
+
+const static struct ctk_label screensaverlabel =
+  {CTK_LABEL(0, 7, LABELMAXWIDTH, 1, "Screensaver")};
+static char screensaver[25];
+struct ctk_textentry screensavertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 7, 16, 1, screensaver, 24)};
+
+
+const static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 9, LABELMAXWIDTH, 1, "IP address")};
+static char ipaddr[25];
+struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 9, 16, 1, ipaddr, 24)};
+const static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 11, LABELMAXWIDTH, 1, "Netmask")};
+static char netmask[25];
+static struct ctk_textentry netmasktextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 11, 16, 1, netmask, 24)};
+const static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 13, LABELMAXWIDTH, 1, "Gateway")};
+static char gateway[25];
+static struct ctk_textentry gatewaytextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 13, 16, 1, gateway, 24)};
+const static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 15, LABELMAXWIDTH, 1, "DNS server")};
+static char dnsserver[25];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 15, 16, 1, dnsserver, 24)};
+
+const static struct ctk_button savebutton =
+  {CTK_BUTTON(0, 17, 12, "Save & close")};
+const static struct ctk_button cancelbutton =
+  {CTK_BUTTON(24, 17, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(configedit_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Config editor", NULL, configedit_sighandler, NULL)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(configedit_eventhandler, ev, data);
+EK_PROCESS(p, "Config editor", EK_PRIO_NORMAL,
+	   configedit_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+/*-----------------------------------------------------------------------------------*/
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+    
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char * __fastcall__
+copystr(char *dst, char *src, int len)
+{
+  char *nt = nullterminate(src);
+  strncpy(dst, src, len);
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loaddriver(char *str)
+{
+  return copystr(driver, str, sizeof(driver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadtheme(char *str)
+{
+  return copystr(theme, str, sizeof(theme));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadcfs(char *str)
+{
+  return copystr(cfs, str, sizeof(cfs));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadscreensaver(char *str)
+{
+  return copystr(screensaver, str, sizeof(screensaver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+ipaddrconf(char *str)
+{
+  return copystr(ipaddr, str, sizeof(ipaddr));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  return copystr(netmask, str, sizeof(netmask));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  return copystr(gateway, str, sizeof(gateway));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  return copystr(dnsserver, str, sizeof(dnsserver));
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry initparsetab[] =
+  {{'n', loaddriver},
+   {'t', loadtheme},
+   {'c', loadcfs},
+   {'s', loadscreensaver},
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+initscript(void)
+{
+  char line[40], *lineptr;
+  /*  struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, initparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+static int makeline(char *line, char c, char *str)
+{
+  int len;
+
+  len = strlen(str);
+  
+  line[0] = c;
+  line[1] = ' ';
+  strcpy(&line[2], str);
+  line[2 + len] = '\n';
+  line[3 + len] = 0;
+  return len + 3;
+}
+
+#if 0
+struct scriptvar
+{
+ const char *var;
+ char chr;
+};
+
+cstatic struct scriptvar scriptvars[]=
+{
+{cfs,'c'},
+
+
+};
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+savescript(void)
+{
+  char line[40];
+  /*  struct c64_fs_file f;*/
+  int f;
+  
+  f = cfs_open("@:config.cfg", CFS_WRITE);
+  if(f == -1) {
+    log_message("Could not open config.cfg", "");
+    return;
+  }
+  if(cfs[0] != 0) {
+	int len = makeline(line, 'c',cfs);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'c', cfs));
+  }
+  if(theme[0] != 0) {
+	int len = makeline(line, 't',theme);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 't', theme));
+  }
+  if(driver[0] != 0) {
+	int len = makeline(line, 'n',driver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'n', driver));
+  }
+  if(ipaddr[0] != 0) {
+	int len = makeline(line, 'i',ipaddr);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'i', ipaddr));
+  }
+  if(netmask[0] != 0) {
+	int len = makeline(line, 'm',netmask);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'm', netmask));
+  }
+  if(gateway[0] != 0) {
+	int len = makeline(line, 'r',gateway);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'r', gateway));
+  }
+  if(dnsserver[0] != 0) {
+	int len = makeline(line, 'd',dnsserver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'd', dnsserver));
+  }
+  
+  if(screensaver[0] != 0) {
+	int len = makeline(line, 's',screensaver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 's', screensaver));
+  }
+  
+  strcpy(line, ".\n\0\n\n\n");
+  cfs_write(f, line, strlen(line));
+  
+  cfs_close(f);
+  
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(configedit_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------------*/
+static void
+configedit_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit_services(void)
+{
+  cfs_cpc_init(NULL);
+  ctk_draw_quit();  
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(configedit_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create window. */
+    ctk_window_new(&window, 32, 18, "Config editor");
+
+    CTK_WIDGET_ADD(&window, &cfslabel);  
+    CTK_WIDGET_ADD(&window, &cfstextentry);
+    CTK_TEXTENTRY_CLEAR(&cfstextentry);
+
+    CTK_WIDGET_ADD(&window, &themelabel);  
+    CTK_WIDGET_ADD(&window, &themetextentry);
+    CTK_TEXTENTRY_CLEAR(&themetextentry);
+    
+    CTK_WIDGET_ADD(&window, &driverlabel);  
+    CTK_WIDGET_ADD(&window, &drivertextentry);
+    CTK_TEXTENTRY_CLEAR(&drivertextentry);
+
+    CTK_WIDGET_ADD(&window, &screensaverlabel);
+    CTK_WIDGET_ADD(&window, &screensavertextentry);
+    CTK_TEXTENTRY_CLEAR(&screensavertextentry);
+
+    CTK_WIDGET_ADD(&window, &ipaddrlabel);  
+    CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+    CTK_TEXTENTRY_CLEAR(&ipaddrtextentry);
+
+    CTK_WIDGET_ADD(&window, &netmasklabel);
+    CTK_WIDGET_ADD(&window, &netmasktextentry);
+    CTK_TEXTENTRY_CLEAR(&netmasktextentry);
+
+    CTK_WIDGET_ADD(&window, &gatewaylabel);
+    CTK_WIDGET_ADD(&window, &gatewaytextentry);
+    CTK_TEXTENTRY_CLEAR(&gatewaytextentry);
+
+    CTK_WIDGET_ADD(&window, &dnsserverlabel);
+    CTK_WIDGET_ADD(&window, &dnsservertextentry);
+    CTK_TEXTENTRY_CLEAR(&dnsservertextentry);
+
+
+    CTK_WIDGET_ADD(&window, &savebutton);
+    CTK_WIDGET_ADD(&window, &cancelbutton);    
+    
+    CTK_WIDGET_FOCUS(&window, &cfstextentry);  
+
+    /* Fill the configuration strings with values from the current
+       configuration */
+    initscript();
+    
+    ctk_window_open(&window);
+
+  } else if(ev == ctk_signal_button_activate) {   
+    if(data == (ek_data_t)&savebutton) {
+      savescript();
+      quit_services();
+      ctk_window_close(&window);
+      configedit_quit();
+      program_handler_load("config.prg", NULL);
+    } else if(data == (ek_data_t)&cancelbutton) {
+      ctk_window_close(&window);
+      configedit_quit();
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&window);
+    configedit_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/default-dsc.c b/contiki-cpc/apps/default-dsc.c
new file mode 100644
index 0000000..96507ec
--- /dev/null
+++ b/contiki-cpc/apps/default-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: default-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon default_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(default_dsc,
+    "Default CTK theme",
+    "default.prg",
+    default_init,
+    &default_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char defaulticon_bitmap[3*3*8] = {
+  0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0,
+  0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00,
+  0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00,
+  0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,
+  0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff  
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char defaulticon_textmap[9] = {
+  '+', '=', '+',
+  '|', 'D', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon default_icon =
+  {CTK_ICON("Default", defaulticon_bitmap, defaulticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.c b/contiki-cpc/apps/directory-dsc.c
new file mode 100644
index 0000000..d4d1944
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon directory_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(directory_dsc,
+    "Directory reader",
+    "dir.prg",
+    directory_init,
+    &directory_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char directoryicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char directoryicon_textmap[9] = {
+  '+', '-', '+',
+  '|', 'o', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon directory_icon =
+  {CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.h b/contiki-cpc/apps/directory-dsc.h
new file mode 100644
index 0000000..da154fe
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+#ifndef __DIRECTORY_DSC_H__
+#define __DIRECTORY_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(directory_dsc);
+
+#endif /* __DIRECTORY_DSC_H__ */
diff --git a/contiki-cpc/apps/enabler-dsc.c b/contiki-cpc/apps/enabler-dsc.c
new file mode 100644
index 0000000..0051476
--- /dev/null
+++ b/contiki-cpc/apps/enabler-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: enabler-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon enabler_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(enabler_dsc,
+    "Colorless grayish CTK theme",
+    "enabler.prg",
+    enabler_init,
+    &enabler_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char enablericon_bitmap[3*3*8] = {
+  0xff,0xff,0xff,0xfc,0xf0,0xf0,0xe0,0xe0,
+  0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+  0xff,0xff,0xff,0x3f,0x0f,0x0f,0x07,0x07,
+
+  0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
+
+  0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff,
+  0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+  0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char enablericon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon enabler_icon =
+  {CTK_ICON("Enabler", enablericon_bitmap, enablericon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/http-user-agent-string b/contiki-cpc/apps/http-user-agent-string
new file mode 100644
index 0000000..1b3104c
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n"
diff --git a/contiki-cpc/apps/http-user-agent-string.c b/contiki-cpc/apps/http-user-agent-string.c
new file mode 100644
index 0000000..d4e1bc9
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+char http_user_agent_fields[100] = 
+/* "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x31, 0x2d, 0x72, 0x63, 0x30, 0x20, 0x28, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x20, 0x36, 0x34, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki-cpc/apps/http-user-agent-string.h b/contiki-cpc/apps/http-user-agent-string.h
new file mode 100644
index 0000000..402af57
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+extern char http_user_agent_fields[100];
diff --git a/contiki-cpc/apps/httpd-cgi.c b/contiki-cpc/apps/httpd-cgi.c
new file mode 100644
index 0000000..53c04a8
--- /dev/null
+++ b/contiki-cpc/apps/httpd-cgi.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#ifdef __CBM__
+#include <cbm.h>
+#include <c64.h>
+#endif /* __CBM__ */
+
+#include <stdio.h>
+#include <string.h>
+
+static u8_t file_stats(void);
+static u8_t tcp_stats(void);
+static u8_t processes(void);
+
+static u8_t d64output(void);
+static u8_t diroutput(void);
+
+httpd_cgifunction httpd_cgitab[] = {
+  NULL,
+  tcp_stats,     /* CGI function "b" */
+  processes,     /* CGI function "c" */
+
+  d64output,     /* CGI function "d" */
+};
+
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49, 
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+/*-----------------------------------------------------------------------------------*/
+#if 0
+static u8_t
+file_stats(void)
+{
+  /* We use sprintf() to print the number of file accesses to a
+     particular file (given as an argument to the function in the
+     script). We then use uip_send() to actually send the data. */
+  if(uip_acked()) {
+    return 1;
+  }
+  uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", httpd_fs_count(&hs->script[4])));
+  return 0;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+tcp_stats(void)
+{
+  register struct uip_conn *conn;  
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  conn = &uip_conns[hs->count];
+  while((conn->tcpstateflags & TS_MASK) == CLOSED) {
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+    conn = &uip_conns[hs->count];
+  }
+
+  uip_send(uip_appdata, sprintf((char *)uip_appdata,
+				"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+				htons(conn->lport),
+				htons(conn->ripaddr[0]) >> 8,
+				htons(conn->ripaddr[0]) & 0xff,
+				htons(conn->ripaddr[1]) >> 8,
+				htons(conn->ripaddr[1]) & 0xff,
+				htons(conn->rport),
+				states[conn->tcpstateflags & TS_MASK],
+				conn->nrtx,
+				conn->timer,
+				(uip_outstanding(conn))? '*':' ',
+				(uip_stopped(conn))? '!':' '));
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+processes(void)
+{
+  u8_t i;
+  register struct dispatcher_proc *p;
+  char name[40];
+
+  p = DISPATCHER_PROCS();
+  for(i = 0; i < hs->count; ++i) {
+    if(p != NULL) {
+      p = p->next;
+    }
+  }
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    ++hs->count;
+    if(p != NULL) {
+      p = p->next;
+    }
+    if(p == NULL) {
+      /* If all processes have been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  strncpy(name, p->name, 40);
+  petsciiconv_toascii(name, 40);
+  uip_send(uip_appdata,
+	   sprintf((char *)uip_appdata,
+		   "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%04x</td><td>0x%04x</td><td>0x%04x</td></tr>\r\n",
+		   p->id, name,
+		   p->idle, p->signalhandler, p->uiphandler));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+
+#include "c64-dio.h"
+
+static void
+read_sector(void)
+{
+  c64_dio_read_block(ds.track, ds.sect, uip_appdata);
+}
+
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+
+static u8_t
+d64output(void)
+{
+  if(hs->count == 0) {
+    ds.track = 1;
+    ds.sect = 0;
+    /*    c64_dio_init(8);*/
+  }
+  
+  if(uip_acked()) {
+    ++hs->count;
+    if(next_sector()) {
+      return 1;
+    }
+  }
+
+  read_sector();
+  uip_send(uip_appdata, 256);
+  return 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd-fs.h b/contiki-cpc/apps/httpd-fs.h
new file mode 100644
index 0000000..d641ba2
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 0
+
+struct httpd_fs_file {
+  char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1  
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki-cpc/apps/httpd-fsdata.c b/contiki-cpc/apps/httpd-fsdata.c
new file mode 100644
index 0000000..e0175d0
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fsdata.c
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ */
+static const char data_cgi_processes[] = {
+	/* /cgi/processes */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x74, 0x20, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 
+	0x6d, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x49, 0x64, 0x6c, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64, 
+	0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 
+	0x68, 0x3e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x68, 
+	0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x43, 0x50, 0x2f, 0x49, 
+	0x50, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 
+	0x63, 0x20, 0x63, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61, 
+	0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 
+	0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 
+	0xa, 0x2e, };
+
+static const char data_cgi_tcp[] = {
+	/* /cgi/tcp */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x74, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 
+	0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52, 
+	0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 
+	0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 0x6c, 0x61, 
+	0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0xa, 0x63, 0x20, 0x62, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 
+	0x61, 0x69, 0x6e, 0xa, 0x2e, };
+
+static const char data_cgi_d64[] = {
+	/* /cgi/d64 */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0,
+	0x69, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 
+	0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 
+	0x6e, 0xa, 0x63, 0x20, 0x64, 0xa, 0x2e, 0xa, };
+
+static const char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 
+	0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 
+	0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 
+	0x73, 0x72, 0x63, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x20, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3d, 0x22, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x22, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x57, 0x65, 0x6c, 
+	0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 
+	0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 
+	0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 
+	0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x77, 0x65, 0x62, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0x22, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x62, 0x3e, 0x3c, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 0x73, 0x65, 
+	0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 
+	0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 
+	0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x79, 0x6f, 0x75, 
+	0x72, 0x20, 0x43, 0x36, 0x34, 0x21, 0x3c, 0x2f, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x3e, 0xa, 
+	0x3c, 0x75, 0x6c, 0x3e, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x38, 0x2f, 
+	0x22, 0x3e, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x64, 0x69, 0x72, 
+	0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0x22, 0x3e, 0x44, 0x6f, 
+	0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x65, 0x6e, 0x74, 
+	0x69, 0x72, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x20, 0x69, 
+	0x6e, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x44, 0x36, 0x34, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e, 0x43, 0x75, 
+	0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 
+	0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 
+	0x73, 0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 
+	0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 
+	0x75, 0x6c, 0x3e, 0xa, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 
+	0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 
+	0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 
+	0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 
+	0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 
+	0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 
+	0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+};
+
+static const char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 
+	0x22, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 
+	0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20, 0x62, 
+	0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x68, 
+	0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 
+	0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 
+	0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 
+	0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 
+	0x65, 0x22, 0x3e, 0xa, };
+
+static const char data_footer_plain[] = {
+	/* /footer.plain */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 
+	0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 
+	0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 
+	0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 
+	0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 
+	0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 
+	0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 
+	0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 
+	0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 
+	0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x2e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 
+	0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_webserver_png[] = {
+	/* /webserver.png */
+	0x2f, 0x77, 0x65, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x1, 00, 
+	00, 00, 00, 0xc8, 0xc, 00, 0x55, 00, 00, 00, 
+	0x2, 0x62, 0x4b, 0x47, 0x44, 00, 0x1, 0xdd, 0x8a, 0x13, 
+	0xa4, 00, 00, 00, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x78, 
+	0xda, 0x1d, 0xc8, 0x21, 0xa, 0x80, 0x30, 00, 0x46, 0xe1, 
+	0xa7, 0xc7, 0x34, 0x78, 0x93, 0x89, 0xb, 0x1e, 0x43, 0x96, 
+	0x8c, 0x62, 0x14, 0x19, 0x6e, 0xc1, 0xe8, 0x19, 0x96, 0x97, 
+	0x8c, 0x6, 0xc3, 0xf8, 0x45, 0xc3, 0x83, 0x8f, 0x87, 0x24, 
+	0x7a, 0x2a, 0xe2, 0x54, 0x8, 0x32, 0x78, 0x25, 0x56, 0x5d, 
+	0xc4, 0xa3, 0xb0, 0x74, 0xf7, 0xff, 0x9c, 0x1e, 0x76, 0xed, 
+	0x8c, 0x79, 0xfb, 0xfb, 0xec, 0xf2, 0x43, 0xc8, 0x86, 0xa5, 
+	0xb9, 0x89, 0x67, 0x61, 0x3d, 0x2e, 0xfc, 0x9c, 0x8, 0x83, 
+	0x21, 0xda, 0x82, 0x6d, 0x2d, 0xaa, 0xf5, 0x2, 0x33, 0x91, 
+	0x35, 0x61, 0x3a, 0xe8, 0xa4, 0x34, 00, 00, 00, 00, 
+	0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
+
+static const char data_contiki_png[] = {
+	/* /contiki.png */
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x8, 0x2, 
+	00, 00, 00, 0x6f, 0x15, 0xaa, 0xaf, 00, 00, 00, 
+	0x9, 0x70, 0x48, 0x59, 0x73, 00, 00, 0x1c, 0x1f, 00, 
+	00, 0x1c, 0x1f, 0x1, 0x60, 0xfd, 0x4, 0xda, 00, 00, 
+	00, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xd3, 0x3, 0x9, 
+	0x16, 0x4, 0xd, 0x60, 0xa0, 0x97, 00, 00, 00, 00, 
+	0xad, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xad, 0x94, 0x41, 
+	0xe, 0xc5, 0x20, 0x8, 0x44, 0x9d, 0x1f, 0xee, 0x7f, 0xe5, 
+	0xf9, 0xb, 0x13, 0x6a, 0x1, 0x29, 0xa5, 0xb2, 0x53, 0xca, 
+	0xf0, 0x9c, 0x40, 0x41, 0x72, 0x1c, 0x89, 0x23, 0x42, 0x24, 
+	0xc5, 0xcb, 0x1, 0x48, 0x1a, 0xf8, 0xec, 0xbc, 0x91, 0xe4, 
+	0xa3, 0x79, 0x34, 0x9d, 0x67, 0xd6, 0xcb, 0x5d, 0x42, 0x3e, 
+	0x97, 0xbc, 0x9a, 0x24, 00, 00, 0xfa, 0x8d, 0x98, 0x74, 
+	0x8, 0x12, 0xa, 0x4d, 0xad, 0x8b, 0x43, 0xcf, 0x3d, 0xd7, 
+	0xb5, 0x36, 0xf0, 0xa8, 0x1e, 0x81, 0x47, 0xf3, 0xaa, 0x1, 
+	0xa5, 0xf, 0xb2, 0x66, 0x37, 0x84, 0x6e, 0x44, 0x3d, 0x9c, 
+	0x35, 0x3a, 0x44, 0x61, 0xcb, 0x26, 0x91, 0xef, 0xfa, 0x82, 
+	0x28, 0x9f, 0xb2, 0x77, 0x44, 0x49, 0xb3, 0xd2, 0x1c, 0x55, 
+	0x26, 0x5e, 0x54, 0x42, 0x17, 0xf2, 0x91, 0x25, 0xdc, 0x6a, 
+	0x49, 0xa, 0x4c, 0x99, 0x3f, 0xae, 0xeb, 0x26, 0xeb, 0xd5, 
+	0xe, 0xaa, 0x32, 0x19, 0xd6, 0x23, 0x6f, 0x47, 0x71, 0x2c, 
+	0x7e, 0xa6, 0x40, 0xb7, 0x59, 0x23, 0xa1, 0xdb, 0x7a, 0xb4, 
+	0xfb, 0xfb, 0x25, 0x5a, 0xb6, 0xf8, 0x63, 0x90, 0xc4, 0x11, 
+	0xa1, 0x31, 0xc6, 0x1f, 0x2c, 0x64, 0x9c, 0x21, 0xc5, 0x1a, 
+	0x66, 0x5d, 00, 00, 00, 00, 0x49, 0x45, 0x4e, 0x44, 
+	0xae, 0x42, 0x60, 0x82, };
+
+static const char data_binaryheader_plain[] = {
+	/* /binaryheader.plain */
+	0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 
+	0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 
+	0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+
+static const char data_dirheader_html[] = {
+	/* /dirheader.html */
+	0x2f, 0x64, 0x69, 0x72, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x46, 0x69, 0x6c, 
+	0x65, 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x64, 0x69, 0x73, 0x6b, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 
+	0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 
+	0x3c, 0x74, 0x68, 0x3e, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x28, 
+	0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x29, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, };
+
+static const char data_dirfooter_plain[] = {
+	/* /dirfooter.plain */
+	0x2f, 0x64, 0x69, 0x72, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 
+	0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 
+	0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 
+	0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 
+	0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 
+	0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 
+	0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 
+	0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 
+	0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x3c, 0x2f, 
+	0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 
+	0x6c, 0x3e, };
+
+const struct httpd_fsdata_file file_cgi_processes[] = {{NULL, data_cgi_processes, data_cgi_processes + 15, sizeof(data_cgi_processes) - 15}};
+
+const struct httpd_fsdata_file file_cgi_tcp[] = {{file_cgi_processes, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
+
+const struct httpd_fsdata_file file_cgi_d64[] = {{file_cgi_tcp, data_cgi_d64, data_cgi_d64 + 9, sizeof(data_cgi_d64) - 9}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_cgi_d64, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_index_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_404_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_footer_plain[] = {{file_header_html, data_footer_plain, data_footer_plain + 14, sizeof(data_footer_plain) - 14}};
+
+const struct httpd_fsdata_file file_webserver_png[] = {{file_footer_plain, data_webserver_png, data_webserver_png + 15, sizeof(data_webserver_png) - 15}};
+
+const struct httpd_fsdata_file file_contiki_png[] = {{file_webserver_png, data_contiki_png, data_contiki_png + 13, sizeof(data_contiki_png) - 13}};
+
+const struct httpd_fsdata_file file_binaryheader_plain[] = {{file_contiki_png, data_binaryheader_plain, data_binaryheader_plain + 20, sizeof(data_binaryheader_plain) - 20}};
+
+const struct httpd_fsdata_file file_dirheader_html[] = {{file_binaryheader_plain, data_dirheader_html, data_dirheader_html + 16, sizeof(data_dirheader_html) - 16}};
+
+const struct httpd_fsdata_file file_dirfooter_plain[] = {{file_dirheader_html, data_dirfooter_plain, data_dirfooter_plain + 17, sizeof(data_dirfooter_plain) - 17}};
+
+#define HTTPD_FS_ROOT file_dirfooter_plain
+
+#define HTTPD_FS_NUMFILES 12
\ No newline at end of file
diff --git a/contiki-cpc/apps/httpd.c b/contiki-cpc/apps/httpd.c
new file mode 100644
index 0000000..9726200
--- /dev/null
+++ b/contiki-cpc/apps/httpd.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+
+#include "http-strings.h"
+
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+#include "httpd-cgi.h"
+
+#include "tcpip.h"
+
+#include <stdio.h>
+
+/* The HTTP server states: */
+#define STATE_DEALLOCATED       0
+#define STATE_INITIAL           1
+#define STATE_GET               2
+#define STATE_HEADERS           3
+#define STATE_SEND_HEADERS      4
+#define STATE_SEND_CONTENT_TYPE 5
+#define STATE_SEND_DATA         6
+
+#define ISO_nl                  0x0a
+#define ISO_space               0x20
+#define ISO_slash               0x2f
+
+#ifdef DEBUG
+#include <stdio.h>
+#define PRINT(x) printf("%s", x)
+#define PRINTLN(x) printf("%s\n", x)
+#else /* DEBUG */
+#define PRINT(x)
+#define PRINTLN(x)
+#endif /* DEBUG */
+
+
+#define HTTPD_CONF_NUMCONNS 4
+static struct httpd_state conns[HTTPD_CONF_NUMCONNS];
+u8_t i;
+
+struct http_filetype {
+  const char *ext;
+  unsigned char extlen;
+  const char *type;
+  unsigned char typelen;
+};
+
+static struct http_filetype filetypes[] = {
+  {http_html, sizeof(http_html) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_htm, sizeof(http_htm) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_css, sizeof(http_css) - 1,
+   http_content_type_css, sizeof(http_content_type_css) - 1},
+  {http_png, sizeof(http_png) - 1,
+   http_content_type_png, sizeof(http_content_type_png) - 1},
+  {http_gif, sizeof(http_gif) - 1,
+   http_content_type_gif, sizeof(http_content_type_gif) - 1},
+  {http_jpg, sizeof(http_jpg) - 1,
+   http_content_type_jpg, sizeof(http_content_type_jpg) - 1},
+  {http_txt, sizeof(http_txt) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},
+  {http_text, sizeof(http_text) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},  
+  {NULL, 0, NULL, 0}
+};
+#define NUMFILETYPES (sizeof(filetypes) / sizeof(struct http_filetype))
+/*-----------------------------------------------------------------------------*/
+static struct httpd_state *
+alloc_state(void)
+{
+  
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    if(conns[i].state == STATE_DEALLOCATED) {
+      return &conns[i];
+    }
+  }
+
+  /* We are overloaded! XXX: we'll just kick all other connections! */
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+  
+  return NULL;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+dealloc_state(struct httpd_state *s)
+{
+  s->state = STATE_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+  httpd_fs_init();
+  
+  /* Listen to port 80. */
+  tcp_listen(HTONS(80));
+
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Buffer an amount of data from the incoming uIP data.
+ *
+ * \param buf A pointer to the buffer.
+ * \param len The length of data to buffer.
+ *
+ * \return Zero if the function wasn't able to buffer to buffer all
+ * data, non-zero otherwise.
+ */
+/*-----------------------------------------------------------------------------*/
+static unsigned char
+buffer(CC_REGISTER_ARG struct httpd_buffer *buf, int len, u8_t c)
+{
+  while(buf->ptr < len &&
+	uip_len > 0) {
+    buf->buf[buf->ptr] = *uip_appdata;
+    ++uip_appdata;
+    --uip_len;
+
+    if(buf->buf[buf->ptr] == c) {
+      return 1;
+    }
+    ++buf->ptr;
+  }
+  return (buf->ptr == len);
+}
+/*-----------------------------------------------------------------------------*/
+static void
+buffer_reset(struct httpd_buffer *buf)
+{
+  buf->ptr = 0;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+newdata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  int i;
+  struct http_filetype *filetype;
+    
+  while(uip_len > 0) {
+    switch(hs->state) {
+      
+    case STATE_INITIAL:
+      /* This is the first data that we receive, so we check if we can
+	 identify the "GET" request. We call the buffer() function to
+	 try to buffer 4 bytes of data from the incoming data stream. If
+	 the function isn't able to buffer enough data, we return and
+	 will try again next time around. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), 4, ISO_space)) {
+	if(strncmp(http_get, hs->buf.buf, 4) == 0) {
+	  hs->state = STATE_GET;
+	  buffer_reset(&(hs->buf));
+	} else {
+	  uip_abort();
+	  return;
+	}
+      }
+      break;
+    
+    case STATE_GET:
+      /* We will read one byte at a time from the GET request until we
+	 find a en end of the line (\n\r). The GET request is remembered
+	 in the httpd state since we might need to look at it later. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->getbuffer), ISO_nl)) {
+	hs->state = STATE_HEADERS;
+	hs->getlen = hs->buf.ptr - 1;
+	/* Null-terminate GET request string. */
+	hs->getbuffer[hs->getlen] = 0;
+
+	/* If there is a space character in the get request, we find
+	   it and null terminate the string there. */
+	for(i = 0; i < hs->getlen; ++i) {
+	  if(hs->getbuffer[i] == ISO_space) {
+	    hs->getbuffer[i] = 0;
+	    hs->getlen = i;
+	    break;
+	  }
+	}
+	buffer_reset(&(hs->buf));	
+      }
+      break;
+
+    case STATE_HEADERS:
+      hs->buf.buf = hs->hdrbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->hdrbuffer), '\n')) {
+	if(hs->buf.ptr == 1) {
+	  hs->state = STATE_SEND_HEADERS;
+	  if(httpd_fs_open(hs->getbuffer, &hs->file)) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_binary;
+	    hs->contentlen = sizeof(http_content_type_binary) - 1;
+	    for(filetype = filetypes;
+		filetype->ext != NULL;
+		++filetype) {
+	      if(strncmp(filetype->ext,
+			 hs->getbuffer + (hs->getlen - filetype->extlen),
+			 filetype->extlen) == 0) {
+		hs->contenttype = filetype->type;
+		hs->contentlen = filetype->typelen;
+		break;
+	      }
+	    }
+
+	  } else if(hs->getbuffer[0] == ISO_slash &&
+	      hs->getbuffer[1] == 0) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_index_html, &hs->file);
+	  } else {
+	    hs->count = sizeof(http_header_404) - 1;
+	    hs->dataptr = (char *)http_header_404;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_404_html, &hs->file);
+	  }
+	} else {
+	  buffer_reset(&(hs->buf));
+	}
+      }
+      break;
+
+    default:
+      uip_len = 0;
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+acked(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  hs->poll = 0;
+
+  
+  switch(hs->state) {
+
+  case STATE_SEND_HEADERS:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_CONTENT_TYPE;
+      hs->count = hs->contentlen;
+      hs->dataptr = (char *)hs->contenttype;
+    }
+    break;
+    
+  case STATE_SEND_CONTENT_TYPE:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_DATA;
+      hs->count = hs->file.len;
+      hs->dataptr = hs->file.data;
+    }
+    break;
+    
+  case STATE_SEND_DATA:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      uip_close();
+      dealloc_state(hs);
+    }
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+senddata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  if(hs->state == STATE_SEND_HEADERS ||
+     hs->state == STATE_SEND_CONTENT_TYPE ||
+     hs->state == STATE_SEND_DATA) {
+    uip_send(hs->dataptr,
+	     hs->count > uip_mss()? uip_mss(): hs->count);
+  }
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+  register struct httpd_state *hs;
+
+  hs = (struct httpd_state *)(state);
+
+
+  if(uip_connected()) {
+    /* Since we've just been connected, the state pointer should be
+       NULL and we need to allocate a new state object. If we have run
+       out of memory for state objects, we'll have to abort the
+       connection and return. */
+    if(hs == NULL) {
+      hs = alloc_state();
+      if(hs == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)hs);
+    }
+    /* Since we have just been connected with the remote host, we
+       reset the state for this connection. The ->count variable
+       contains the amount of data that is yet to be sent to the
+       remote host, and the ->state is set to HTTP_NOGET to signal
+       that we haven't received any HTTP GET request for this
+       connection yet. */
+    hs->state = STATE_INITIAL;
+    hs->count = 0;
+    hs->poll = 0;
+    buffer_reset(&(hs->buf));
+    return;
+  }
+
+  if(uip_closed() ||
+     uip_aborted() ||
+     uip_timedout()) {
+    if(hs != NULL) {
+      dealloc_state(hs);
+    }
+    return;
+  } else if(uip_poll()) {
+    /* If we are polled ten times, we abort the connection. This is
+       because we don't want connections lingering indefinately in
+       the system. */
+    if(hs != NULL) {
+      if(hs->state == STATE_DEALLOCATED) {
+	uip_abort();
+      } else if(hs->poll++ >= 100) {
+	uip_abort();
+	dealloc_state(hs);
+      }
+    }
+    return;
+  }
+  
+  if(uip_acked()) {
+    acked(hs);
+  }
+  
+  if(uip_newdata()) {
+    newdata(hs);
+  }
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata(hs);
+  } else if(uip_poll()) {    
+    senddata(hs);
+  }
+
+
+}
+/*-----------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd.h b/contiki-cpc/apps/httpd.h
new file mode 100644
index 0000000..08abced
--- /dev/null
+++ b/contiki-cpc/apps/httpd.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "ek.h"
+
+#include "httpd-fs.h"
+
+void httpd_init(void);
+/*DISPATCHER_UIPCALL(httpd_appcall, state);*/
+void httpd_appcall(void *state);
+
+struct httpd_buffer {
+  u8_t *buf;
+  int ptr;
+};
+
+struct httpd_state {
+  u8_t state; 
+  u16_t count;
+  u8_t poll;
+  char *dataptr;
+  struct httpd_fs_file file;
+
+  const char *contenttype;
+  int contentlen;
+  
+  char *script;
+
+  struct httpd_buffer buf;
+
+  int getlen;
+  u8_t getbuffer[100];
+  u8_t hdrbuffer[100];
+  
+  /*
+  union {
+    struct c64_fs_dir d;
+    struct c64_fs_file f;
+    } f;*/
+};
+
+extern struct httpd_state *hs;
+
+void webserver_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff --git a/contiki-cpc/apps/makefsdata b/contiki-cpc/apps/makefsdata
new file mode 100644
index 0000000..83bbc5b
--- /dev/null
+++ b/contiki-cpc/apps/makefsdata
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+open(FILES, "find . -type f |");
+
+
+while($file = <FILES>) {
+
+    # Do not include files in CVS directories nor backup files.
+    if($file =~ /(CVS|~)/) {
+    	next;
+    }
+    
+    chop($file);
+    
+    open(HEADER, "> /tmp/header") || die $!;
+    print(HEADER "HTTP/1.0 200 OK\r\n");
+    print(HEADER "Server: Contiki/pre-1.1 (http://dunkels.com/adam/contiki/)\r\n");
+    if($file =~ /\.html$/) {
+	print(HEADER "Content-type: text/html\r\n");
+    } elsif($file =~ /\.gif$/) {
+	print(HEADER "Content-type: image/gif\r\n");
+    } elsif($file =~ /\.png$/) {
+	print(HEADER "Content-type: image/png\r\n");
+    } elsif($file =~ /\.jpg$/) {
+	print(HEADER "Content-type: image/jpeg\r\n");
+    } elsif($file =~ /\.css$/) {
+	print(HEADER "Content-type: text/css\r\n");
+    } else {
+	print(HEADER "Content-type: text/plain\r\n");
+    }
+    print(HEADER "\r\n");
+    close(HEADER);
+
+    unless($file =~ /\.plain$/ || $file =~ /cgi/) {
+	system("cat /tmp/header $file > /tmp/file");
+    } else {
+	system("cp $file /tmp/file");
+    }
+    
+    open(FILE, "/tmp/file");
+    unlink("/tmp/file");
+    unlink("/tmp/header");
+
+    $file =~ s/\.//;
+    $fvar = $file;
+    $fvar =~ s-/-_-g;
+    $fvar =~ s-\.-_-g;
+    print(OUTPUT "static const char data".$fvar."[] = {\n");
+    print(OUTPUT "\t/* $file */\n\t");
+    for($j = 0; $j < length($file); $j++) {
+	printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+    }
+    printf(OUTPUT "0,\n");
+    
+    
+    $i = 0;        
+    while(read(FILE, $data, 1)) {
+        if($i == 0) {
+            print(OUTPUT "\t");
+        }
+        printf(OUTPUT "%#02x, ", unpack("C", $data));
+        $i++;
+        if($i == 10) {
+            print(OUTPUT "\n");
+            $i = 0;
+        }
+    }
+    print(OUTPUT "};\n\n");
+    close(FILE);
+    push(@fvars, $fvar);
+    push(@files, $file);
+}
+
+for($i = 0; $i < @fvars; $i++) {
+    $file = $files[$i];
+    $fvar = $fvars[$i];
+
+    if($i == 0) {
+        $prevfile = "NULL";
+    } else {
+        $prevfile = "file" . $fvars[$i - 1];
+    }
+    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i");
diff --git a/contiki-cpc/apps/makestrings b/contiki-cpc/apps/makestrings
new file mode 100644
index 0000000..e6e8470
--- /dev/null
+++ b/contiki-cpc/apps/makestrings
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+  my $name = shift(@_);
+  open(OUTPUTC, "> $name.c");
+  open(OUTPUTH, "> $name.h");
+  
+  open(FILE, "$name");
+  
+  while(<FILE>) {
+    if(/(.+) "(.+)"/) {
+      $var = $1;
+      $data = $2;
+      
+      $datan = $data;
+      $datan =~ s/\\r/\r/g;
+      $datan =~ s/\\n/\n/g;
+      $datan =~ s/\\0/\0/g;
+      
+      printf(OUTPUTC "char $var\[%d] = \n", length($datan) + 1);
+      printf(OUTPUTC "/* \"$data\" */\n");
+      printf(OUTPUTC "{");
+      for($j = 0; $j < length($datan); $j++) {
+	printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+      }
+      printf(OUTPUTC "};\n");
+      
+      printf(OUTPUTH "extern char $var\[%d];\n", length($datan) + 1);
+      
+    }
+  }
+  close(OUTPUTC);
+  close(OUTPUTH);
+}
+stringify("http-user-agent-string");
+
+exit 0;
+
diff --git a/contiki-cpc/apps/memstat-dsc.c b/contiki-cpc/apps/memstat-dsc.c
new file mode 100644
index 0000000..be3e3bf
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon memstat_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(memstat_dsc,
+    "Memory statistics",
+    "memstat.prg",
+    memstat_init,
+    &memstat_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char memstaticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char memstaticon_textmap[9] = {
+  '0', '0', '1',
+  '0', '1', '0',
+  '1', '0', '1'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon memstat_icon =
+  {CTK_ICON("Memory stats", memstaticon_bitmap, memstaticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/memstat-dsc.h b/contiki-cpc/apps/memstat-dsc.h
new file mode 100644
index 0000000..356c6cc
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.h,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+#ifndef __MEMSTAT_DSC_H__
+#define __MEMSTAT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(memstat_dsc);
+
+#endif /* __MEMSTAT_DSC_H__ */
diff --git a/contiki-cpc/apps/memstat.c b/contiki-cpc/apps/memstat.c
new file mode 100644
index 0000000..0b8f8b0
--- /dev/null
+++ b/contiki-cpc/apps/memstat.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ek.h"
+#include "loader.h"
+
+static struct ctk_window window;
+static struct ctk_label freemsg =
+  {CTK_LABEL(2, 0, 12, 1, "Free memory:")};
+static char freemem[6];
+static struct ctk_label freenum =
+  {CTK_LABEL(18, 0, 5, 1, freemem)};
+
+static struct ctk_label lblockmsg =
+  {CTK_LABEL(2, 2, 14, 1, "Largest block:")};
+static char lblock[6];
+static struct ctk_label lblocknum =
+  {CTK_LABEL(18, 2, 5, 1, lblock)};
+
+const static struct ctk_button updatebutton =
+  {CTK_BUTTON(0, 4, 6, "Update")};
+const static struct ctk_button closebutton =
+  {CTK_BUTTON(17, 4, 5, "Close")};
+
+/*static DISPATCHER_SIGHANDLER(memstat_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Memory statistics", NULL, memstat_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data);
+EK_PROCESS(p, "Memory statistics", EK_PRIO_NORMAL,
+	   memstat_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+update(void)
+{
+  int mem;
+
+  mem = _heapmemavail();
+  freemem[0] = (mem/10000) % 10 + '0';
+  freemem[1] = (mem/1000) % 10 + '0';
+  freemem[2] = (mem/100) % 10 + '0';
+  freemem[3] = (mem/10) % 10 + '0';
+  freemem[4] = (mem) % 10 + '0';
+
+  mem = _heapmaxavail();
+  lblock[0] = (mem/10000) % 10 + '0';
+  lblock[1] = (mem/1000) % 10 + '0';
+  lblock[2] = (mem/100) % 10 + '0';
+  lblock[3] = (mem/10) % 10 + '0';
+  lblock[4] = (mem) % 10 + '0';
+
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(memstat_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+    
+  } else {
+    ctk_window_open(&window);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 24, 5, "Memory stats");
+    /*    ctk_window_move(&window, 0, 1);*/
+
+    CTK_WIDGET_ADD(&window, &freemsg);
+    CTK_WIDGET_ADD(&window, &freenum);
+
+    CTK_WIDGET_ADD(&window, &lblockmsg);
+    CTK_WIDGET_ADD(&window, &lblocknum);
+
+    CTK_WIDGET_ADD(&window, &updatebutton);
+    CTK_WIDGET_ADD(&window, &closebutton);
+
+    CTK_WIDGET_FOCUS(&window, &updatebutton);
+    
+    update();
+    
+    ctk_window_open(&window);
+    
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&updatebutton) {
+      update();
+      ctk_window_redraw(&window);
+    } else if(data == (ek_data_t)&closebutton) {
+      ctk_window_close(&window);
+      quit();
+    }
+  } else if((ev == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/mtest.c b/contiki-cpc/apps/mtest.c
new file mode 100644
index 0000000..173092c
--- /dev/null
+++ b/contiki-cpc/apps/mtest.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtest.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ */
+#include "mt.h"
+
+MTP(t, p, "Test thread");
+/*--------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+test(void *data)
+{
+  while(1) {
+    asm("inc $d020");
+  }
+}
+#pragma optimize(pop)
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(mtest_init, arg)
+{
+  arg_free(arg);
+  mtp_start(&t, test, NULL);
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma-dsc.c b/contiki-cpc/apps/plasma-dsc.c
new file mode 100644
index 0000000..945215b
--- /dev/null
+++ b/contiki-cpc/apps/plasma-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+    "Screensaver with a plasma",
+    "plasma.sav",
+    plasma_init,
+    &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon plasma_icon =
+  {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma.c b/contiki-cpc/apps/plasma.c
new file mode 100644
index 0000000..d4bc8f6
--- /dev/null
+++ b/contiki-cpc/apps/plasma.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+  128, 131, 134, 137, 140, 143, 146, 149, 
+  152, 156, 159, 162, 165, 168, 171, 174, 
+  176, 179, 182, 185, 188, 191, 193, 196, 
+  199, 201, 204, 206, 209, 211, 213, 216, 
+  218, 220, 222, 224, 226, 228, 230, 232, 
+  234, 236, 237, 239, 240, 242, 243, 245, 
+  246, 247, 248, 249, 250, 251, 252, 252, 
+  253, 254, 254, 255, 255, 255, 255, 255, 
+  255, 255, 255, 255, 255, 255, 254, 254, 
+  253, 252, 252, 251, 250, 249, 248, 247, 
+  246, 245, 243, 242, 240, 239, 237, 236, 
+  234, 232, 230, 228, 226, 224, 222, 220, 
+  218, 216, 213, 211, 209, 206, 204, 201, 
+  199, 196, 193, 191, 188, 185, 182, 179, 
+  176, 174, 171, 168, 165, 162, 159, 156, 
+  152, 149, 146, 143, 140, 137, 134, 131, 
+  128, 124, 121, 118, 115, 112, 109, 106, 
+  103, 99, 96, 93, 90, 87, 84, 81, 
+  79, 76, 73, 70, 67, 64, 62, 59, 
+  56, 54, 51, 49, 46, 44, 42, 39, 
+  37, 35, 33, 31, 29, 27, 25, 23, 
+  21, 19, 18, 16, 15, 13, 12, 10, 
+  9, 8, 7, 6, 5, 4, 3, 3, 
+  2, 1, 1, 0, 0, 0, 0, 0, 
+  0, 0, 0, 0, 0, 0, 1, 1, 
+  2, 3, 3, 4, 5, 6, 7, 8, 
+  9, 10, 12, 13, 15, 16, 18, 19, 
+  21, 23, 25, 27, 29, 31, 33, 35, 
+  37, 39, 42, 44, 46, 49, 51, 54, 
+  56, 59, 62, 64, 67, 70, 73, 76, 
+  78, 81, 84, 87, 90, 93, 96, 99, 
+  103, 106, 109, 112, 115, 118, 121, 124,
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+  {
+    0x00, 0x06, 0x0b, 0x04,
+    0x0a, 0x0f, 0x07, 0x01,
+    0x07, 0x0f, 0x0a, 0x08,
+    0x02, 0x09, 0x00, 0x00,
+  };
+
+#define XSIZE 24
+#define YSIZE 25
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd01 = 0xfe;
+static unsigned char yadd01 = 0x05;
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char xadd1 = 0x04;
+static unsigned char yadd1 = 0x02;
+static unsigned char xadd2 = 0xfc;
+static unsigned char yadd2 = 0xf9;
+
+static unsigned char xadd = 0x03;
+static unsigned char yadd = 0xfe;
+
+static unsigned char movcnt;
+static unsigned char movadd = 0xfb;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Plasma screensaver", idle,
+		   sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+  unsigned char *ptr, *cptr;
+  static int i;
+  
+  /* Make sine tables */
+  for(i = 0; i < 256; ++i) {
+    sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+    sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;    
+  }
+    
+  /* Make color table */
+  for(i = 0; i < 256; ++i) {
+    colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+  }
+    
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  static unsigned char i, x, y;
+  register unsigned char *cptr;
+  
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+
+    xcnt1 = xcnt01;
+    xcnt2 = xcnt02;
+    
+    for(i = 0; i < XSIZE; ++i) {
+      xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+      xcnt1 += xadd1;
+      xcnt2 += xadd2;
+    }
+
+    ycnt1 = ycnt01;
+    ycnt2 = ycnt02;
+    
+    for(i = 0; i < YSIZE; ++i) {
+      yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+      ycnt1 += yadd1;
+      ycnt2 += yadd2;
+    }
+
+    xcnt01 += xadd01;
+    xcnt02 += xadd02;
+    ycnt01 += yadd01;
+    ycnt02 += yadd02;
+
+    
+    yadd02 = sinetab3[ycnt] / 4;
+    xadd02 = sinetab3[xcnt] / 4;
+
+    ycnt += yadd;
+    xcnt += xadd;
+
+    movcnt += movadd;
+    cptr = (unsigned char *)(0xd800 + sinetab1[movcnt]/16);
+    for(y = 0; y < YSIZE; ++y) {
+      for(x = 0; x < XSIZE; ++x) {
+	*cptr = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+	++cptr;
+      }
+      cptr += 40 - XSIZE;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+   
+    scrninit();
+
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+    /*    ctk_mode_set(CTK_MODE_NORMAL);*/
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+ 
diff --git a/contiki-cpc/apps/ravenpine-dsc.c b/contiki-cpc/apps/ravenpine-dsc.c
new file mode 100644
index 0000000..cd2cea8
--- /dev/null
+++ b/contiki-cpc/apps/ravenpine-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ravenpine-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ravenpine_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ravenpine_dsc,
+    "Terminal green CTK theme",
+    "ravenpine.prg",
+    ravenpine_init,
+    &ravenpine_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ravenpineicon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ravenpineicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ravenpine_icon =
+  {CTK_ICON("Ravenpine", ravenpineicon_bitmap, ravenpineicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/shell.c b/contiki-cpc/apps/shell.c
new file mode 100644
index 0000000..1575708
--- /dev/null
+++ b/contiki-cpc/apps/shell.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include <string.h>
+
+static char showingdir = 0;
+static struct cfs_dir dir;
+static unsigned int totsize;
+
+struct ptentry {
+  char c;
+  void (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+parse(CC_REGISTER_ARG char *str, struct ptentry *t)
+{
+  CC_REGISTER_ARG struct ptentry *p;
+  char *sstr;
+
+  sstr = str;
+  
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      p->pfunc(str);
+      return;
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+inttostr(CC_REGISTER_ARG char *str, unsigned int i)
+{
+  str[0] = '0' + i / 100;
+  if(str[0] == '0') {
+    str[0] = ' ';
+  }
+  str[1] = '0' + (i / 10) % 10;
+  if(str[0] == ' ' && str[1] == '0') {
+    str[1] = ' ';
+  }
+  str[2] = '0' + i % 10;
+  str[3] = ' ';
+  str[4] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes(char *str)
+{
+  static char idstr[5];
+  struct ek_proc *p;
+
+  shell_output("Processes:", "");
+  /* Step through each possible process ID and see if there is a
+     matching process. */
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    inttostr(idstr, p->id);
+    shell_output(idstr, (char *)p->name);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+runfile(char *str)
+{
+  nullterminate(str);
+
+  if(strlen(str) > 0) {
+    /* Call loader function. */
+    program_handler_load(str, NULL);
+    shell_output("Starting program ", str);  
+  } else {
+    shell_output("Must supply a program name", "");  
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+execfile(char *str)
+{
+  runfile(str);
+  shell_quit(NULL);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(char *str)
+{
+  char procnum, j, c;
+  char procstr[5];
+
+  nullterminate(str);
+  
+  procnum = 0;
+  
+  for(j = 0; j < 4; ++j) {
+    c = str[j];
+    if(c >= '0' && c <= '9') {
+      procnum = procnum * 10 + (str[j] - '0');
+    } else {
+      break;
+    }
+  }
+  if(procnum != 0) {
+    inttostr(procstr, procnum);
+    shell_output("Killing process ", procstr);
+    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+  } else {
+    shell_output("Invalid process number", "");
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+  shell_output("Available commands:", "");
+  shell_output("run  - start program", "");
+  shell_output("exec - start program & exit shell", "");  
+  shell_output("ps   - show processes", "");
+  shell_output("kill - kill process", "");
+  shell_output("ls   - display directory", "");
+  shell_output("quit - quit shell", "");
+  shell_output("?    - show this help", "");      
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+directory(char *str)
+{
+  if(cfs_opendir(&dir, "/") != 0) {
+    shell_output("Cannot open directory", "");
+    showingdir = 0;
+  } else {
+    shell_output("Disk directory:", "");
+    showingdir = 1;
+    totsize = 0;
+    ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+none(char *str)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+  {{'e', execfile},
+   {'r', runfile},
+   {'k', killproc},   
+   {'p', processes},
+   {'l', directory},
+   {'q', shell_quit},
+   {'?', help},
+
+   /* Default action */
+   {0, none}};
+/*-----------------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+  showingdir = 0;
+  shell_output("Contiki command shell", "");
+  shell_output("Type '?' and return for help", "");  
+  shell_prompt("contiki-c64> "); 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+  if(showingdir != 0) {
+    showingdir = 0;
+    shell_output("Directory stopped", "");
+    cfs_closedir(&dir);
+  }
+  parse(cmd, configparsetab);
+  if(showingdir == 0) {
+    shell_prompt("contiki-c64> ");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  static struct cfs_dirent dirent;
+  static char size[10];
+
+  if(ev == EK_EVENT_CONTINUE) {
+    if(showingdir != 0) {
+      if(cfs_readdir(&dir, &dirent) != 0) {
+	cfs_closedir(&dir);
+	showingdir = 0;
+	inttostr(size, totsize);
+	shell_output("Total number of blocks: ", size);
+	shell_prompt("contiki-c64> ");
+      } else {
+	totsize += dirent.size;
+	inttostr(size, dirent.size);
+	shell_output(size, dirent.name);
+	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/springlight-dsc.c b/contiki-cpc/apps/springlight-dsc.c
new file mode 100644
index 0000000..d9fed23
--- /dev/null
+++ b/contiki-cpc/apps/springlight-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: springlight-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon springlight_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(springlight_dsc,
+    "Spring green CTK theme",
+    "springlight.prg",
+    springlight_init,
+    &springlight_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char springlighticon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char springlighticon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon springlight_icon =
+  {CTK_ICON("Springlight", springlighticon_bitmap, springlighticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire-dsc.c b/contiki-cpc/apps/ssfire-dsc.c
new file mode 100644
index 0000000..51a3578
--- /dev/null
+++ b/contiki-cpc/apps/ssfire-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+    "Screensaver with two fires",
+    "ssfire.sav",
+    ssfire_init,
+    &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ssfire_icon =
+  {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire.c b/contiki-cpc/apps/ssfire.c
new file mode 100644
index 0000000..ed03af2
--- /dev/null
+++ b/contiki-cpc/apps/ssfire.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+		   ssfire_sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+	   ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+
+static const unsigned char flamecolors[16] =
+  {COLOR_BLACK,  COLOR_BLACK, COLOR_BLACK,
+   COLOR_RED,    COLOR_LIGHTRED,   COLOR_YELLOW, COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+   COLOR_WHITE};
+   
+
+static void fire_init(void);
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+  unsigned char *ptr, *cptr;
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+
+  SID.v3.freq = 0xffff;
+  SID.v3.ctrl = 0x80;
+  SID.amp = 0;  
+
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+    fire_init();
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    fire_quit();
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *flameptr, *colorptr1, *colorptr2;
+static unsigned char x, y;
+
+#pragma optimize(push, off)
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+  
+    /* Calculate new flames. */
+    asm("ldx #0");
+    asm("loop:");
+    asm("lda _flames+7,x");
+    asm("clc");
+    asm("adc _flames+8,x");
+    asm("adc _flames+9,x");
+    asm("adc _flames+16,x");
+    asm("lsr");
+    asm("lsr");
+    asm("sta _flames,x");
+    asm("inx");
+    asm("cpx #(8*15)");
+    asm("bne loop");
+
+    /* Fill last line with pseudo-random data from noise generator on
+       voice 3. */
+    asm("ldx #$05");
+    asm("loop2:");
+    asm("ldy #$20");
+    asm("delay:");
+    asm("dey");
+    asm("bne delay");
+    asm("lda $d41b");
+    asm("and #$0f");
+    asm("sta _flames+8*15+1,x");
+    asm("dex");
+    asm("bpl loop2");
+
+    /* Display flames on screen. */  
+    flameptr = flames;
+    colorptr1 = COLOR_RAM + 40*10;
+    colorptr2 = colorptr1 + 0x20;
+    for(y = 0; y < 15; ++y) {
+      for(x = 0; x < 8; ++x) {
+	colorptr1[x] = colorptr2[x] = flamecolors[flameptr[x]];
+      }
+      colorptr1 += 0x28;
+      colorptr2 += 0x28;
+      flameptr += 8;
+    }
+  
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/apps/themeloader.c b/contiki-cpc/apps/themeloader.c
new file mode 100644
index 0000000..7c00afa
--- /dev/null
+++ b/contiki-cpc/apps/themeloader.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: themeloader.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "loader.h"
+#include "ctk-draw.h"
+#include "ctk-hires-theme.h"
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(themeloader_init, arg)
+{
+  arg_free(arg);
+  
+  memcpy(ctk_hires_theme_ptr, &ctk_hires_theme,
+	 sizeof(struct ctk_hires_theme));
+  ctk_draw_init();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/unused/directory.c b/contiki-cpc/apps/unused/directory.c
new file mode 100644
index 0000000..d00245c
--- /dev/null
+++ b/contiki-cpc/apps/unused/directory.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory.c,v 1.1 2006/04/17 15:18:26 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+//#include <cbm.h>
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+#include "loader.h"
+
+#include "program-handler.h"
+
+#define MAX_NUMFILES 40
+#define WIDTH 36
+#define HEIGHT 22
+
+static struct dsc *dscs[MAX_NUMFILES];
+static char filenames[MAX_NUMFILES][16];
+static unsigned char numfiles, morestart;
+
+static struct ctk_window window;
+
+static struct ctk_label description =
+  {CTK_LABEL(0, HEIGHT - 1, WIDTH, 1, "")};
+
+static char autoexit = 1;
+const static struct ctk_button autoexitbutton =
+  {CTK_BUTTON(0, 20, 9, "Auto-exit")};
+const static char autoexiton[] = "is On ";
+const static char autoexitoff[] = "is Off";
+static struct ctk_label autoexitlabel =
+  {CTK_LABEL(12, 20, 6, 1, autoexiton)};
+
+const static struct ctk_button morebutton =
+  {CTK_BUTTON(0, 20, 4, "More")};
+
+const static struct ctk_button backbutton =
+  {CTK_BUTTON(0, 20, 4, "Back")};
+
+const static struct ctk_button reloadbutton =
+  {CTK_BUTTON(30, 20, 6, "Reload")};
+
+static DISPATCHER_SIGHANDLER(directory_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Directory browser", NULL, directory_sighandler, NULL)};
+static ek_id_t id;
+
+static unsigned char width, height;
+
+/*-----------------------------------------------------------------------------------*/
+//static struct cbm_dirent dirent;
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&description, text);
+  CTK_WIDGET_REDRAW(&description);
+}
+/*-----------------------------------------------------------------------------------*/
+#define LFN 9
+static void
+loaddirectory(void)
+{
+#if 0
+  unsigned char i, j;
+  
+  if(cbm_opendir(LFN, 8) != 0) {
+    show_statustext("Cannot open directory");
+  } else {
+    i = 0;
+    while(cbm_readdir(LFN, &dirent) == 0) {
+      if(strcmp(&dirent.name[strlen(dirent.name) - 4], ".dsc") == 0) {	
+	strncpy(filenames[i], dirent.name, 16);
+	++i;
+	if(i == MAX_NUMFILES) {
+	  break;
+	}
+      }
+    }
+    cbm_closedir(LFN);
+
+    numfiles = i;
+
+    j = 0;
+    for(i = 0; i < numfiles; ++i) {
+      dscs[j] = LOADER_LOAD_DSC(filenames[i]);
+      if(dscs[j] != NULL) {
+	++j;
+      }
+    }
+    show_statustext("Directory loaded");
+  }
+#endif
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makewindow(unsigned char i)
+{
+  unsigned char x, y;
+
+  ctk_window_clear(&window);
+  CTK_WIDGET_SET_YPOS(&description, height - 3);
+  CTK_WIDGET_SET_WIDTH(&description, width);
+  CTK_WIDGET_ADD(&window, &description);
+
+  morestart = i;
+  
+  x = 0; y = 1;
+  for(; dscs[i] != NULL; ++i) {
+
+    if(x + strlen(dscs[i]->icon->title) >= width) {
+      y += 5;
+      x = 0;
+      if(y >= height - 2 - 4) {
+	morestart = i;
+	break;
+      }
+    }
+    CTK_WIDGET_SET_XPOS(dscs[i]->icon, x);
+    CTK_WIDGET_SET_YPOS(dscs[i]->icon, y);
+    CTK_WIDGET_ADD(&window, dscs[i]->icon);
+
+    x += strlen(dscs[i]->icon->title) + 1;
+  }
+  CTK_WIDGET_SET_YPOS(&autoexitbutton, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitbutton);
+  CTK_WIDGET_SET_YPOS(&autoexitlabel, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitlabel);
+
+  if(i != morestart) {
+    CTK_WIDGET_SET_YPOS(&backbutton, height - 1);
+    CTK_WIDGET_ADD(&window, &backbutton);
+  } else {
+    CTK_WIDGET_SET_YPOS(&morebutton, height - 1);
+    CTK_WIDGET_ADD(&window, &morebutton);
+  }
+  CTK_WIDGET_SET_XPOS(&reloadbutton, width - 8);
+  CTK_WIDGET_SET_YPOS(&reloadbutton, height - 1);
+  CTK_WIDGET_ADD(&window, &reloadbutton);    
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(directory_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = dispatcher_start(&p);
+
+    width = ctk_draw_width() - 4;
+    height = ctk_draw_height() - 4;
+    
+    ctk_window_new(&window, width, height, "Directory");
+
+    loaddirectory();
+    makewindow(0);
+    
+    dispatcher_listen(ctk_signal_widget_activate);
+    dispatcher_listen(ctk_signal_widget_select);
+    dispatcher_listen(ctk_signal_window_close);
+  }
+  ctk_window_open(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  unsigned char i;
+
+  ctk_window_close(&window);
+  for(i = 0; dscs[i] != NULL; ++i) {
+    LOADER_UNLOAD_DSC(dscs[i]);
+  }
+  dispatcher_exit(&p);
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static
+DISPATCHER_SIGHANDLER(directory_sighandler, s, data)
+{
+  unsigned char i;
+  DISPATCHER_SIGHANDLER_ARGS(s, data);
+  
+  if(s == ctk_signal_widget_activate) {
+    if(data == (ek_data_t)&reloadbutton) {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	LOADER_UNLOAD_DSC(dscs[i]);
+      }     
+      loaddirectory();
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&morebutton) {
+      makewindow(morestart);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&backbutton) {
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      autoexit = 1 - autoexit;
+      if(autoexit == 1) {
+	ctk_label_set_text(&autoexitlabel, autoexiton);
+      } else {
+	ctk_label_set_text(&autoexitlabel, autoexitoff);
+      }
+      CTK_WIDGET_REDRAW(&autoexitlabel);
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  program_handler_load(dscs[i]->prgname);
+	  if(autoexit) {
+	    ctk_window_close(&window);
+	    quit();
+	  }
+	  break;
+	}
+      }
+    }
+  } else if(s == ctk_signal_widget_select) {
+    if(data == (ek_data_t)&reloadbutton) {
+      show_statustext("Reload directory");
+    } else if(data == (ek_data_t)&morebutton) {
+      show_statustext("Show more files");
+    } else if(data == (ek_data_t)&backbutton) {
+      show_statustext("Show first files");
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      show_statustext("Exit when loading program");
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  show_statustext(dscs[i]->description);
+	  break;
+	}
+      }
+    }
+  } else if(s == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) {
+    quit();
+  } else if(s == dispatcher_signal_quit) {
+    ctk_window_close(&window);
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/vnc-draw-asm.S b/contiki-cpc/apps/vnc-draw-asm.S
new file mode 100644
index 0000000..7522a43
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		_vnc_draw_datalen
+	.import		_vnc_draw_dataptr
+	.import		_vnc_draw_bitmapptr	
+	.import		_vnc_draw_x
+	.import		_vnc_draw_y
+;---------------------------------------------------------------------
+.bss
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
diff --git a/contiki-cpc/apps/vnc-draw-asm.h b/contiki-cpc/apps/vnc-draw-asm.h
new file mode 100644
index 0000000..b786fa9
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw-asm.h,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+#ifndef __VNC_DRAW_ASM_H__
+#define __VNC_DRAW_ASM_H__
+
+#include "vnc-draw.h"
+
+void vnc_draw_asm_pixelline(void);
+
+#endif /* __VNC_DRAW_ASM_H__ */
diff --git a/contiki-cpc/apps/vnc-draw.c b/contiki-cpc/apps/vnc-draw.c
new file mode 100644
index 0000000..78520ea
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw.c
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+
+
+#include "vnc-draw.h"
+#include "vnc-draw-asm.h"
+
+#include "vnc-conf.h"
+
+
+static unsigned char conv[256];
+
+const static unsigned char oratab[8] =
+  { 0x80, 0x40, 0x20, 0x10,
+    0x08, 0x04, 0x02, 0x01 };
+const static unsigned char andtab[8] =
+  { 0x7f, 0xbf, 0xdf, 0xef,
+    0xf7, 0xfb, 0xfd, 0xfe };
+
+static u8_t *bitmapptrtab[VNC_CONF_VIEWPORT_HEIGHT];
+
+static unsigned short viewport_x,
+  viewport_y, viewport_w, viewport_h;
+
+u8_t vnc_draw_bitmap[(VNC_CONF_VIEWPORT_WIDTH / 8) *
+		     VNC_CONF_VIEWPORT_HEIGHT];
+
+
+
+u16_t vnc_draw_x;
+u16_t vnc_draw_y;
+u8_t *vnc_draw_dataptr;
+u8_t *vnc_draw_bitmapptr;
+u16_t vnc_draw_datalen;
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixel(u16_t x, u8_t y, u8_t c)
+{
+  u8_t o, a;
+  
+  vnc_draw_bitmapptr = bitmapptrtab[y] + (x & 0x1f8);  
+  
+  if(c) {
+    o = oratab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr | o;
+  } else {
+    a = andtab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr & a;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixelline(u16_t x, u16_t y, u8_t *data, u16_t datalen)
+{
+  u8_t o, a;
+  register u8_t *bitmapptr;
+  
+  vnc_draw_x = x - viewport_x;
+  vnc_draw_y = y - viewport_y;
+
+  /*  if(vnc_draw_y & 1) {
+    return;
+  } else {
+    vnc_draw_y /= 2;
+    }*/
+
+  
+  
+  if(vnc_draw_y >= VNC_CONF_VIEWPORT_HEIGHT ||
+     vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    return;
+  }
+
+  vnc_draw_datalen = datalen;
+  
+  if(vnc_draw_datalen + vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    vnc_draw_datalen = VNC_CONF_VIEWPORT_WIDTH - vnc_draw_x;
+    if(vnc_draw_datalen == 0) {
+      return;
+    }
+  }
+  
+  vnc_draw_dataptr = data;
+
+  /*  vnc_draw_bitmapptr = bitmaptab[vnc_draw_y] +
+      (vnc_draw_x & 0x1f8);*/
+
+  for(; vnc_draw_datalen > 0; --vnc_draw_datalen) {
+    /*    vnc_draw_pixel(vnc_draw_x, vnc_draw_y,
+	  conv[*vnc_draw_dataptr]);*/
+
+    bitmapptr = bitmapptrtab[vnc_draw_y] + (vnc_draw_x & 0x1f8);  
+    
+    if(conv[*vnc_draw_dataptr]) {
+      o = oratab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr | o;
+    } else {
+      a = andtab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr & a;
+    }
+    ++vnc_draw_dataptr;
+    ++vnc_draw_x;
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_init(void)
+{
+  unsigned int tmp;
+  unsigned int i;
+  unsigned short ptr;
+
+
+  /* Create color conversion table. */
+  for(i = 0; i < 256; ++i) {
+    if(((i & 0xc0) > 0xc0) ||
+       ((i & 0x38) > 0x18) ||
+       ((i & 0x07) > 0x03)) {
+      conv[i] = 0;
+    } else {
+      conv[i] = 1;
+    }
+  }
+
+  memset(vnc_draw_bitmap, 0, sizeof(vnc_draw_bitmap));
+  
+  for(i = 0; i < VNC_CONF_VIEWPORT_HEIGHT; ++i) {
+    bitmapptrtab[i] = (u8_t *)((u16_t)vnc_draw_bitmap +
+			       ((i & 0xfff8)/8) * VNC_CONF_VIEWPORT_WIDTH +
+			       (i & 7));
+  }
+
+  viewport_x = 0;
+  viewport_y = 0;
+
+  viewport_w = VNC_CONF_VIEWPORT_WIDTH;
+  viewport_h = VNC_CONF_VIEWPORT_HEIGHT;
+  
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_x(void)
+{
+  return viewport_x;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_y(void)
+{
+  return viewport_y;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_w(void)
+{
+  return viewport_w;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_h(void)
+{
+  return viewport_h;
+}
+/*-----------------------------------------------------------------------------------*/
+#if 0
+signed short
+c64_mouse_x(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+signed short
+c64_mouse_y(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+u8_t
+c64_mouse_buttons(void)
+{
+  return firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_x(unsigned short x)
+{
+  joyx = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_y(unsigned short y)
+{
+  joyy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_x(unsigned short x)
+{
+  viewport_x = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_y(unsigned short y)
+{
+  viewport_y = y;
+}
+/*-----------------------------------------------------------------------------------*/
+
+#endif /* 0 */
+#if 0
+#pragma optimize(push, off)
+void
+c64_scroll_up(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$80");
+  asm("sta $f7");
+  asm("lda #$a2");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$80");
+  asm("sta $fb");
+  asm("lda #$e2");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("lda $fc");
+  asm("cmp #$00");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $fe00,y");
+  asm("sta $be00,y");
+  asm("sta $fcc0,y");
+  asm("sta $bcc0,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $ff00,y");
+  asm("sta $bf00,y");
+  asm("sta $fdc0,y");
+  asm("sta $bdc0,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_down(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$c0");
+  asm("sta $fb");
+  asm("lda #$fb");
+  asm("sta $fc");
+  asm("lda #$40");
+  asm("sta $fd");
+  asm("lda #$fe");
+  asm("sta $fe");
+
+  asm("lda #$c0");
+  asm("sta $f7");
+  asm("lda #$bb");
+  asm("sta $f8");
+  asm("lda #$40");
+  asm("sta $f9");
+  asm("lda #$be");
+  asm("sta $fa");
+
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("dec $f8");
+  asm("dec $fa");
+  asm("dec $fc");
+  asm("dec $fe");
+
+
+  asm("lda $fe");
+  asm("cmp #$df");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $e000,y");
+  asm("sta $a000,y");
+  asm("sta $e140,y");
+  asm("sta $a140,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $e100,y");
+  asm("sta $a100,y");
+  asm("sta $e240,y");
+  asm("sta $a240,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_right(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$00");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$10");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$00");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$10");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  
+  asm("loop3:");
+  
+  asm("ldy #$ff");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #$30");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_left(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$10");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$10");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  asm("loop3:");
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #0");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("cpy #$30");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
+
+
+#endif /* 0 */
diff --git a/contiki-cpc/apps/welcome.c b/contiki-cpc/apps/welcome.c
new file mode 100644
index 0000000..709da3d
--- /dev/null
+++ b/contiki-cpc/apps/welcome.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+const static struct ctk_label welcomelabel1 =
+  {CTK_LABEL(1, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING "!")};
+const static struct ctk_label welcomelabel2 =
+  {CTK_LABEL(2, 4, 28, 1, "F1     - open menus")};
+const static struct ctk_label welcomelabel3 =
+  {CTK_LABEL(2, 6, 28, 1, "F3     - cycle windows")};
+const static struct ctk_label welcomelabel4 =
+  {CTK_LABEL(2, 8, 28, 1, "F7     - select up")};
+const static struct ctk_label welcomelabel5 =
+  {CTK_LABEL(2, 10, 28, 1, "F4     - select down")};
+const static struct ctk_label welcomelabel6 =
+  {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
+const static struct ctk_label welcomelabel7 =
+  {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+  ctk_dialog_close();
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+  unsigned char width;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    width = ctk_desktop_width(NULL);
+    
+    if(width > 34) {
+      ctk_dialog_new(&welcomedialog, 32, 17);
+    } else {
+      ctk_dialog_new(&welcomedialog, width - 2, 17);
+    }
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);    
+    
+    ctk_dialog_open(&welcomedialog);
+    
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_keypress) {
+    welcome_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.c b/contiki-cpc/apps/wget-dsc.c
new file mode 100644
index 0000000..0e0f12d
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+    "Downloads files or D64 disks from the web",
+    "wget.prg",
+    wget_init,
+    &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char wgeticon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char wgeticon_textmap[9] = {
+  'w', 'e', 'b',
+  'p', 'r', 'g',
+  'd', '6', '4'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon icon =
+  {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.h b/contiki-cpc/apps/wget-dsc.h
new file mode 100644
index 0000000..1b13211
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2006/04/17 15:18:23 kthacker Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-cpc/apps/wget.c b/contiki-cpc/apps/wget.c
new file mode 100644
index 0000000..20b403e
--- /dev/null
+++ b/contiki-cpc/apps/wget.c
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.1 2006/04/17 15:18:24 kthacker Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "loader.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <c64.h>
+#include <cbm.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "c64-dio.h"
+
+#define USE_KERNAL 0
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+  {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+  {CTK_TEXTENTRY(5, 1, 29, 1, urledit, 78)};
+
+
+static struct ctk_label savefilenamelabel =
+  {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+  {CTK_TEXTENTRY(15, 3, 19, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+  {CTK_BUTTON(0, 5, 13, "Download file")};
+
+static struct ctk_button d64button =
+  {CTK_BUTTON(17, 5, 18, "Download D64 disk")};
+
+static struct ctk_label statustext =
+  {CTK_LABEL(0, 7, 36, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window d64dialog;
+static struct ctk_label overwritelabel =
+  {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+  {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+  {CTK_LABEL(6, 4, 24, 1, "right disk in the drive!")};
+static struct ctk_button overwritebutton =
+  {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(wget_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Web downloader", NULL, wget_sighandler, webclient_appcall)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+	   wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_D64  2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+
+
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+static char buffer[256];
+static u16_t bufferptr;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+  if(arg != NULL) {
+    strncpy(url, arg, sizeof(url));
+    strncpy(urledit, arg, sizeof(urledit));
+    petsciiconv_topetscii(urledit, sizeof(urledit));
+  } else {
+#ifdef WGET_CONF_URL
+    strncpy(url, WGET_CONF_URL, sizeof(url));
+    strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL  */
+  }
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&statustext, text);
+  CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+  u16_t addr[2];
+  unsigned char i;
+  static char host[32];
+  char *file;
+  register char *urlptr;
+  unsigned short port;
+
+  /* Trim off any spaces in the end of the url. */
+  urlptr = url + strlen(url) - 1;
+  while(*urlptr == ' ' && urlptr > url) {
+    *urlptr = 0;
+    --urlptr;
+  }
+
+  /* Don't even try to go further if the URL is empty. */
+  if(urlptr == url) {
+    return;
+  }
+
+  /* See if the URL starts with http://, otherwise prepend it. */
+  if(strncmp(url, http_http, 7) != 0) {
+    while(urlptr >= url) {
+      *(urlptr + 7) = *urlptr;
+      --urlptr;
+    }
+    strncpy(url, http_http, 7);
+  } 
+
+  /* Find host part of the URL. */
+  urlptr = &url[7];  
+  for(i = 0; i < sizeof(host); ++i) {
+    if(*urlptr == 0 ||
+       *urlptr == '/' ||
+       *urlptr == ' ' ||
+       *urlptr == ':') {
+      host[i] = 0;
+      break;
+    }
+    host[i] = *urlptr;
+    ++urlptr;
+  }
+
+  /* XXX: Here we should find the port part of the URL, but this isn't
+     currently done because of laziness from the programmer's side
+     :-) */
+  
+  /* Find file part of the URL. */
+  while(*urlptr != '/' && *urlptr != 0) {
+    ++urlptr;
+  }
+  if(*urlptr == '/') {
+    file = urlptr;
+  } else {
+    file = "/";
+  }
+      
+  
+  /* First check if the host is an IP address. */
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    
+    /* Try to lookup the hostname. If it fails, we initiate a hostname
+       lookup and print out an informative message on the
+       statusbar. */
+    if(resolv_lookup(host) == NULL) {
+      resolv_query(host);
+      show_statustext("Resolving host...");
+      return;
+    }
+  }
+
+  /* The hostname we present in the hostname table, so we send out the
+     initial GET request. */
+  if(webclient_get(host, 80, file) == 0) {
+    show_statustext("Out of memory error.");
+  } else {
+    show_statustext("Connecting...");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+  int ret;
+  static unsigned char i;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create the main window. */
+    ctk_window_new(&window, 36, 8, "Web downloader");
+
+    
+    CTK_WIDGET_ADD(&window, &urllabel);
+    CTK_WIDGET_ADD(&window, &urltextentry);
+    
+    CTK_WIDGET_ADD(&window, &savefilenamelabel);
+    CTK_WIDGET_ADD(&window, &savefilenametextentry);
+
+    /*    CTK_WIDGET_ADD(&window, &filebutton);*/
+
+    CTK_WIDGET_ADD(&window, &d64button);
+
+    CTK_WIDGET_ADD(&window, &statustext);
+
+    dload_state = DLOAD_NONE;
+      
+    memset(savefilename, 0, sizeof(savefilename));
+    memset(url, 0, sizeof(url));
+
+    ctk_dialog_new(&d64dialog, 36, 8);
+    CTK_WIDGET_ADD(&d64dialog, &overwritelabel);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel1);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel2);
+    CTK_WIDGET_ADD(&d64dialog, &overwritebutton);
+    CTK_WIDGET_ADD(&d64dialog, &cancelbutton);
+    
+    
+    ctk_window_open(&window);
+  } else if(ev == tcpip_event) {
+    webclient_appcall(data);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (void *)&filebutton) {
+      /*      ret = cbm_open(2, 8, 2, savefilename);
+	      if(ret == -1) {*/
+	sprintf(statusmsg, "Open error with '%s'", savefilename);
+	show_statustext(statusmsg);
+	/*      } else {
+	strncpy(url, urledit, sizeof(url));
+	petsciiconv_toascii(url, sizeof(url));
+	start_get();
+	dload_bytes = 0;
+	dload_state = DLOAD_FILE;
+	}*/
+    } else if(data == (void *)&d64button) {
+      ctk_dialog_open(&d64dialog);
+    } else if(data == (void *)&cancelbutton) {
+      ctk_dialog_close();
+    } else if(data == (void *)&overwritebutton) {
+      ctk_dialog_close();
+
+      /* Turn of screensaver. */
+      program_handler_screensaver(NULL);
+      
+      strncpy(url, urledit, sizeof(url));
+      petsciiconv_toascii(url, sizeof(url));
+      start_get();
+      dload_bytes = 0;
+      dload_state = DLOAD_D64;
+      ds.track = 1;
+      ds.sect = 0;
+      bufferptr = 0;
+#if USE_KERNAL
+#else
+      c64_dio_init(_curunit);
+#endif
+      
+      /*      c64_dio_init(8);*/
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    if(dload_state == DLOAD_NONE) {
+      /*      open_link(w->widget.hyperlink.url);*/
+      strncpy(urledit,
+	      ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+      petsciiconv_topetscii(urledit, sizeof(urledit));
+      CTK_WIDGET_REDRAW(&urltextentry);
+      CTK_WIDGET_FOCUS(&window, &urltextentry);
+    }
+  } else if(ev == resolv_event_found) {
+    /* Either found a hostname, or not. */
+    if((char *)data != NULL &&
+       resolv_lookup((char *)data) != NULL) {
+      start_get();
+    } else {
+      show_statustext("Host not found.");
+    }
+  } else if(ev == ctk_signal_window_close) {
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+  show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+  show_statustext("Connection timed out");
+  if(dload_state == DLOAD_FILE) {
+    cbm_close(2);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{  
+  show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{    
+  show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+x_open(u8_t f, u8_t d, u8_t cmd, u8_t *fname)
+{
+  u8_t ret;
+  
+  ret = cbm_open(f, d, cmd, fname);
+  if(ret != 0) {
+    /*    printf("open: error %d\n", ret);*/
+    /*    ctk_label_set_text(&statuslabel, "Open err");
+	  CTK_WIDGET_REDRAW(&statuslabel);*/
+    show_statustext("Open error");
+  }
+  
+}
+static void
+write_sector(u8_t device, u8_t track, u8_t sect, void *mem)
+{
+  u16_t ret;
+  static u8_t cmd[32];
+  
+  x_open(15, device, 15, NULL);
+  x_open(2, device, 2, "#");
+
+  ret = cbm_write(2, mem, 256);
+  
+  sprintf(cmd, "u2: 2 0 %d %d", track, sect);  
+  cbm_write(15, cmd, strlen(cmd));
+  /*  printf("%s\n", cmd);*/
+    
+
+  /*  ret = 0;*/
+  if(ret == -1) {
+    sprintf(statusmsg, "Write error at %d:%d", track, sect);
+    show_statustext(statusmsg);
+  } else {
+    sprintf(statusmsg, "Wrote %d bytes to %d:%d", ret, track, sect);
+    show_statustext(statusmsg);
+  }
+  /*  printf("write: wrote %d bytes\n", ret);*/
+
+  cbm_close(2);
+  cbm_close(15);
+}
+
+static void
+write_buffer(void)
+{
+#if USE_KERNAL
+  write_sector(8, ds.track, ds.sect, buffer);
+#else
+  c64_dio_write_block(ds.track, ds.sect, buffer);
+#endif
+  if(next_sector() != 0) {
+    dload_state = DLOAD_NONE;
+  }
+}
+static void
+handle_d64_data(char *data, u16_t len)
+{
+  u16_t bufferlen;
+
+  while(dload_state == DLOAD_D64 &&
+	len > 0) {
+    bufferlen = sizeof(buffer) - bufferptr;
+    if(len < bufferlen) {
+      bufferlen = len;
+    }
+    
+    memcpy(&buffer[bufferptr], data, bufferlen);
+
+    data += bufferlen;
+    bufferptr += bufferlen;
+    len -= bufferlen;
+    
+    if(bufferptr == sizeof(buffer)) {
+      write_buffer();
+      bufferptr = 0;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():   
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+  int ret;
+  
+  if(len > 0) {
+    dload_bytes += len;    
+    sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+    show_statustext(statusmsg);
+    if(dload_state == DLOAD_D64) {
+      handle_d64_data(data, len);
+    } else if(dload_state == DLOAD_FILE) {      
+      ret = cbm_write(2, data, len);       
+      if(ret != len) {
+	sprintf(statusmsg, "Wrote only %d bytes", ret);
+	  show_statustext(statusmsg);	  
+      }
+    }
+  }
+  
+  if(data == NULL) {
+    if(dload_state == DLOAD_FILE) {
+      cbm_close(2);
+    }
+    dload_state = DLOAD_NONE;
+    sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+    show_statustext(statusmsg);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/arch/amsgraph.h b/contiki-cpc/arch/amsgraph.h
new file mode 100644
index 0000000..a84151b
--- /dev/null
+++ b/contiki-cpc/arch/amsgraph.h
@@ -0,0 +1,18 @@
+/* AMSGRAPH.H A Graphics library for the AMSTRAD CPC range of computers
+   Uses firmware to realize graphics IO..
+
+   2003 H. Hansen
+
+*/
+
+#ifndef  __amsgraph_h__
+#define __amsgraph_h__
+
+void draw(int x, int y);
+void plot(int x, int y);
+void move(int x, int y);
+void gpen(unsigned char pencolor);
+unsigned char getgpen(void);
+
+#endif /* __amsgraph_h__ */
+
diff --git a/contiki-cpc/arch/amshw.h b/contiki-cpc/arch/amshw.h
new file mode 100644
index 0000000..433837e
--- /dev/null
+++ b/contiki-cpc/arch/amshw.h
@@ -0,0 +1,31 @@
+/* Amstrad hardware I/O ports 
+ 
+Although these I/O port addresses are actually partially decoded,
+we use the recommended address here.
+*/
+
+/* Gate Array */
+sfr banked at 0x07F00 IO_GateArray;
+
+/* CRTC */
+sfr banked at 0x0BC00 IO_CRTC_Register;
+sfr banked at 0x0BD00 IO_CRTC_Data;
+
+/* FDD */
+sfr banked at 0x0FA7E IO_FDD_Motor;		/* motor state for all floppy disc drives */
+
+/* FDC 
+
+NOTE: The Amstrad Floppy Disc Controller is polled for data and has strict timing constraints.
+Therefore it is best to perform all floppy access using assembler code, or using the firmware or
+CP/M functions 
+*/
+sfr banked at 0x0FB7E IO_FDC_Status;	/* FDC Main Status register */
+sfr banked at 0x0FB7F IO_FDC_Data;		/* FDC Data register */
+
+/* PPI */
+sfr banked at 0x0F400 IO_PPI_PortA;
+sfr banked at 0x0F500 IO_PPI_PortB;
+sfr banked at 0x0F600 IO_PPI_PortC;
+sfr banked at 0x0F700 IO_PPI_Control;
+
diff --git a/contiki-cpc/arch/arch.c b/contiki-cpc/arch/arch.c
new file mode 100644
index 0000000..b090326
--- /dev/null
+++ b/contiki-cpc/arch/arch.c
@@ -0,0 +1,18 @@
+#include "clock.h"
+#include "arch.h"
+
+extern clock_time_t _clock_val;
+
+clock_time_t clock_time()
+{
+	return _clock_val;
+}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+int ctk_arch_isprint(char c)
+{
+	return isprint(c);
+}
diff --git a/contiki-cpc/arch/arch.h b/contiki-cpc/arch/arch.h
new file mode 100644
index 0000000..6b1ee94
--- /dev/null
+++ b/contiki-cpc/arch/arch.h
@@ -0,0 +1,11 @@
+extern int _curunit;
+
+
+#define COLOR_BLACK 0
+#define COLOR_GRAY1 1
+#define COLOR_GRAY2 2
+#define COLOR_GRAY3 3
+#define COLOR_WHITE 4
+#define COLOR_YELLOW 5
+#define COLOR_BLUE 6
+#define COLOR_LIGHTBLUE 7
diff --git a/contiki-cpc/arch/clock.s b/contiki-cpc/arch/clock.s
new file mode 100644
index 0000000..f74781e
--- /dev/null
+++ b/contiki-cpc/arch/clock.s
@@ -0,0 +1,29 @@
+	.module clock
+	.area GSINIT
+	call __clock_init
+
+	.globl __clock_val
+	.globl __clock_init
+
+	.area _CODE
+__clock_init::
+	ld hl,#event_block
+	ld b,#0x01
+	ld c,#0x00
+	ld de,#event_routine
+	call #0xbce0		;; KL NEW FAST TICKER
+	ret
+
+event_routine::
+	push hl
+	ld hl,(__clock_val)
+	inc hl
+	ld (__clock_val),hl
+	pop hl
+	ret
+
+__clock_val:: .dw 0
+
+event_block::
+	.ds 9
+
diff --git a/contiki-cpc/arch/conio.s b/contiki-cpc/arch/conio.s
new file mode 100644
index 0000000..f6a1937
--- /dev/null
+++ b/contiki-cpc/arch/conio.s
@@ -0,0 +1,432 @@
+;*****************************************************************************/
+; CONIO.S - Amstrad CPC version of the Contiki conio.h (derived from
+;borland C) ; To use with the Small Devices C Compiler ; ; 2003 H. Hansen
+;*****************************************************************************/
+
+;; contiki uses coordinates between 0..width-1, 0..height-1
+;; cpc uses coordinates between 1..width, 1..height
+; void clrscr (void);
+; Clear the whole screen and put the cursor into the top left corner 
+; TESTED
+
+.globl _clrscr	
+		.area _CODE
+
+_clrscr::
+		ld		a,#1
+		call 	0xBC0E	; SCR SET MODE
+		ret
+
+
+; void gotox (unsigned char x);
+; Set the cursor to the specified X position, leave the Y position untouched 
+
+.globl _gotox
+
+_gotox::
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		inc		a
+		call	0xBB6F	; TXT SET COLUMN
+		ret
+
+; void gotoy (unsigned char y);
+; Set the cursor to the specified Y position, leave the X position untouched
+
+.globl _gotoy
+
+_gotoy::
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		inc		a
+		call	0xBB72	; TXT SET ROW
+		ret
+
+; void gotoxy (unsigned char x, unsigned char y)
+; Set the cursor to the specified position 
+; y pushed first, then x
+
+.globl _gotoxy
+
+_gotoxy::
+		ld		hl,#2
+		add		hl,sp
+		ld 		a,(hl)
+		inc hl
+		ld 		l,(hl)
+		ld h,a
+		inc h
+		inc l
+		call	0xBB75	; TXT SET CURSOR
+		ret
+
+; unsigned char wherex (void);
+; Return the X position of the cursor 
+
+.globl _wherex
+
+_wherex::
+		call	0xBB78	; TXT GET CURSOR
+		ld		l,h
+		dec l
+		ret
+
+; unsigned char wherey (void);
+; Return the Y position of the cursor 
+
+.globl _wherey
+
+_wherey::
+		call	0xBB78	; TXT GET CURSOR
+		dec l
+		ret
+
+.globl _outchar
+
+_outchar::
+		push af
+		push bc
+		push de
+		push hl
+		call 0xbb5d
+		pop hl
+		pop de
+		pop bc
+		pop af
+		ret
+
+; void cputc (char c);
+; Output one character at the current cursor position
+
+.globl _cputc
+
+_cputc::
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		call	_outchar	; TXT OUTPUT
+		ret
+
+; void cputcxy (unsigned char x, unsigned char y, char c)
+; Same as "gotoxy (x, y); cputc (c);"
+
+.globl _cputcxy
+
+_cputcxy::
+		ld		hl,#4
+		add		hl,sp
+		ld		e,(hl)
+		dec		hl
+		ld		a,(hl)
+		dec 		hl
+		ld 		h,(hl)
+		ld 		l,a
+		inc h
+		inc l
+		call	0xBB75	; TXT SET CURSOR
+		ld		a,e		
+		call	_outchar
+		ret
+
+; void cputs (const char* s);
+; Output a NUL terminated string at the current cursor position 
+; TESTED
+
+.globl _cputs
+
+_cputs::
+		ld		hl,#2
+		add		hl,sp
+		ld		e,(hl)
+		inc 		hl
+		ld		d,(hl)
+		
+cputs$:
+		ld		a,(de)
+		inc de
+		or a
+		ret		z
+		call	_outchar
+		jr		cputs$
+
+; void cputsxy (unsigned char x, unsigned char y, const char* s);
+; Same as "gotoxy (x, y); puts (s);" 
+; TESTED
+.globl _cputsxy
+
+_cputsxy::
+		ld		hl,#4
+		add		hl,sp
+		ld		e,(hl)
+		inc		hl
+		ld		d,(hl)
+
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		inc 		hl
+		ld		l,(hl)
+		ld 		h,a		
+		inc h
+		inc l
+		call	0xBB75	; TXT SET CURSOR
+
+		jr		cputs$
+
+; int cprintf (const char* format, ...);
+; Like printf, but uses direct screen I/O 
+
+; int vcprintf (const char* format, va_list ap);
+; Like vprintf, but uses direct screen I/O 
+
+; unsigned char cursor (unsigned char onoff);
+; If onoff is 1, a cursor is display when waiting for keyboard input. If
+; onoff is 0, the cursor is hidden when waiting for keyboard input. The
+; function returns the old cursor setting.
+
+
+; unsigned char revers (unsigned char onoff);
+; Enable/disable reverse character display. This may not be supported by
+; the output device. Return the old setting.
+; TESTED
+
+.globl _revers
+
+_revers::
+		call	0xBB9C	; TXT INVERSE
+		ret
+
+; unsigned char textcolor (unsigned char color);
+; Set the color for text output. The old color setting is returned. 
+
+
+
+.globl	_textcolor
+
+_textcolor::
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		ld		d,a
+		call	0xBB93  ; TXT GET PEN
+		ld		e,a
+		ld		a,d
+		call	0xBB90	; TXT SET PEN
+		ld		l,e
+		ret
+
+; unsigned char bgcolor (unsigned char color);
+; Set the color for the background. The old color setting is returned. */
+
+.globl	_bgcolor
+
+_bgcolor::	
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		ld		d,a
+		call	0xBB99   ; TXT GET PAPER
+		ld		e,a
+		ld		a,d
+		call	0xBB96   ; TXT SET PAPER
+		ld		l,e
+		ret
+
+; unsigned char bordercolor (unsigned char color);
+; Set the color for the border. The old color setting is returned. 
+
+.globl	_bordercolor
+
+_bordercolor::
+
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		push	af
+		call	0xBC3B   ; SCR GET BORDER
+		pop		af
+		ld		d,b
+		ld		b,a
+		ld		c,a
+		push	de
+		call	0xBC38   ; SCR SET BORDER
+		pop		de
+		ld		l,d
+		ret
+
+; void chline (unsigned char length);
+; Output a horizontal line with the given length starting at the current
+; cursor position.
+
+.globl	_chline
+
+_chline::	
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		or		a
+		ret		z
+		ld		b,a
+		ld a,#0x09a
+chlineloop$:
+		call	_outchar
+		djnz    chlineloop$
+		ret
+
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); chline (length);"
+; TESTED
+
+.globl _chlinexy
+
+_chlinexy::
+		ld		hl,#2
+		add		hl,sp
+		ld		d,(hl)
+		inc		hl
+		ld		e,(hl)
+		inc 		hl
+		ld		a,(hl)
+		or		a
+		ret		z
+		ld		b,a
+		ld		h,d
+		ld		l,e
+		inc h
+		inc l
+		call	0xBB75
+		ld		a,#0x9a  ; Horizontal line char.
+chxyloop$:
+		call	_outchar ; TXT OUT
+		djnz	chxyloop$
+		ret
+
+; void cvline (unsigned char length);
+; Output a vertical line with the given length at the current cursor
+; position.
+
+.globl _cvline
+
+_cvline::	
+		ld		hl,#2
+		add		hl,sp
+		ld		a,(hl)
+		or		a
+		ret		z
+		ld		b,a
+		call	0xBB78  ; TXT GET CURSOR
+		ld a,#0x095
+cvloop$:
+		push af
+		push hl
+		call	0xBB75
+		pop hl
+		pop af
+		inc l
+		call	_outchar
+		djnz	cvloop$
+		ret
+
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); cvline (length);"
+
+.globl _cvlinexy
+
+_cvlinexy::	
+		ld		hl,#2
+		add		hl,sp
+		ld		d,(hl)
+		inc 		hl
+		ld		e,(hl)
+		inc		hl
+		ld		a,(hl)
+		or		a
+		ret		z
+		ld		b,a
+		ld		h,d
+		ld		l,e
+		inc 		h
+		inc 		l
+		ld a,#149
+cvxyloop$:
+		push hl
+		push af
+		call	0xBB75
+		pop af
+		pop hl
+		inc		l
+		call	_outchar
+		djnz	cvxyloop$
+		ret
+
+; void cclear (unsigned char length);
+; Clear part of a line (write length spaces).
+
+.globl _cclear
+
+_cclear::	
+		ld		hl,#2
+		add		hl,sp
+		ld		b,(hl)
+		ld		a,#0x020 ; White space
+cclearloop$:
+		call	_outchar
+		djnz	cclearloop$
+		ret
+
+; void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); cclear (length);"
+
+.globl _cclearxy
+
+_cclearxy::
+		ld		hl,#2
+		add		hl,sp
+		ld		d,(hl)
+		inc		hl
+		ld		e,(hl)
+		inc		hl
+		ld		b,(hl)
+		ld		h,d
+		ld		l,e
+		inc 		h
+		inc 		l
+		call	0xBB75
+		ld		a,#0x020 ; White space
+
+cclearxyloop$:
+		call	_outchar
+		djnz	cclearxyloop$
+		ret
+
+; void screensize (unsigned char* x, unsigned char* y);
+; Return the current screen size.
+
+.globl _screensize
+
+_screensize::
+
+		ld		hl,#2
+		add		hl,sp
+		ld		e,(hl)
+		inc		hl
+		ld 		d,(hl)
+
+		ld		a,#40    ; X Size
+		ld		(de),a
+
+		ld		hl,#4
+		add		hl,sp
+		ld		e,(hl)
+		inc		hl
+		ld 		d,(hl)
+
+		ld		a,#24    ; Y Size
+		ld		(de),a
+		ret
+
+; void cputhex8 (unsigned char val);
+; void cputhex16 (unsigned val);
+; These shouldn't be here... 
diff --git a/contiki-cpc/arch/contiki-uip.link b/contiki-cpc/arch/contiki-uip.link
new file mode 100644
index 0000000..1b20b9d
--- /dev/null
+++ b/contiki-cpc/arch/contiki-uip.link
@@ -0,0 +1,35 @@
+-im contiki
+-k /usr/local/share/sdcc/lib/z80
+-b _CODE=0x0100
+-l z80
+./arch/crt0.o
+./arch/key.o
+./arch/mem.o
+./arch/malloc.o
+./arch/clock.o
+./loader/loader-arch-cpc.o
+./loader/rel.o
+./loader/cfs-cpc.o
+../contiki/lib/cfs.o
+./loader/dir.o
+../contiki/apps/program-handler.o
+../contiki/ctk/ctk.o
+../contiki/ctk/ctk-draw.o
+../contiki/ek/ek-service.o
+../contiki/ek/ek.o
+../contiki/ek/arg.o
+../contiki/lib/cfs.o
+../contiki/lib/list.o
+../contiki/lib/timer.o
+../contiki/uip/tcpip.o
+../contiki/uip/uip.o
+../contiki/uip/resolv.o
+../contiki/uip/uiplib.o
+./uip/uip_arch.o
+./apps/directory-dsc.o
+./apps/configedit-dsc.o
+../contiki/apps/processes-dsc.o
+./arch/main.o
+./arch/arch.o
+./arch/uip.o
+-e
diff --git a/contiki-cpc/arch/contiki.link b/contiki-cpc/arch/contiki.link
new file mode 100644
index 0000000..902e616
--- /dev/null
+++ b/contiki-cpc/arch/contiki.link
@@ -0,0 +1,28 @@
+-im contiki
+-k /usr/local/share/sdcc/lib/z80
+-b _CODE=0x0100
+-l z80
+./arch/crt0.o
+./arch/key.o
+./arch/mem.o
+./arch/malloc.o
+./arch/clock.o
+./loader/loader-arch-cpc.o
+./loader/rel.o
+./loader/cfs-cpc.o
+../contiki/lib/cfs.o
+./loader/dir.o
+../contiki/apps/program-handler.o
+../contiki/ctk/ctk.o
+../contiki/ctk/ctk-draw.o
+../contiki/ek/ek-service.o
+../contiki/ek/ek.o
+../contiki/ek/arg.o
+../contiki/lib/list.o
+../contiki/lib/timer.o
+./apps/directory-dsc.o
+./apps/configedit-dsc.o
+../contiki/apps/processes-dsc.o
+./arch/main.o
+./arch/arch.o
+-e
diff --git a/contiki-cpc/arch/contiki_labels.s b/contiki-cpc/arch/contiki_labels.s
new file mode 100644
index 0000000..8192104
--- /dev/null
+++ b/contiki-cpc/arch/contiki_labels.s
@@ -0,0 +1,346 @@
+__jpbc == 0x0107
+_kbhit == 0x0109
+_cgetc == 0x0115
+_calc_free_ram == 0x011B
+_get_ram_start == 0x0183
+_get_ram_end == 0x0187
+ram_start == 0x018B
+ram_end == 0x018D
+__sdcc_heap_init == 0x018F
+__sdcc_heap_init_start == 0x018F
+__sdcc_heap_init_end == 0x021B
+_malloc == 0x021B
+_malloc_start == 0x021B
+_free == 0x0366
+_free_start == 0x0366
+_malloc_end == 0x0366
+_free_end == 0x03CE
+__clock_init == 0x03CE
+event_routine == 0x03DC
+__clock_val == 0x03E6
+event_block == 0x03E8
+_loader_arch_load == 0x03F1
+_loader_arch_load_start == 0x03F1
+_loader_arch_load_end == 0x0455
+_loader_arch_load_dsc == 0x0455
+_loader_arch_load_dsc_start == 0x0455
+_loader_arch_load_dsc_end == 0x04A7
+_loader_arch_free == 0x04A7
+_loader_arch_free_start == 0x04A7
+_loader_arch_free_end == 0x04BF
+_loader_arch_free_dsc == 0x04BF
+_loader_arch_free_dsc_start == 0x04BF
+_loader_arch_free_dsc_end == 0x04D7
+_get_file_length == 0x04D7
+_load_file == 0x04FB
+_relocate == 0x0519
+_cfs_cpc_init == 0x05B8
+_cfs_cpc_init_start == 0x05B8
+_cfs_cpc_init_end == 0x05DB
+_cfs_find_service == 0x08B2
+_cfs_find_service_start == 0x08B2
+_cfs_find_service_end == 0x08CE
+__readdir == 0x08E8
+fetch_directory == 0x0901
+_program_handler_add == 0x091D
+_program_handler_add_start == 0x091D
+_program_handler_add_end == 0x0977
+_program_handler_init == 0x0A59
+_program_handler_init_start == 0x0A59
+_program_handler_init_end == 0x0AB0
+_pnarg_init == 0x0AB8
+_pnarg_init_start == 0x0AB8
+_pnarg_init_end == 0x0ACB
+_program_handler_load == 0x0B62
+_program_handler_load_start == 0x0B62
+_program_handler_load_end == 0x0BA9
+_program_handler_screensaver == 0x0BB7
+_program_handler_screensaver_sta == 0x0BB7
+_program_handler_screensaver_end == 0x0BE6
+_ctk_restore == 0x109A
+_ctk_restore_start == 0x109A
+_ctk_init_start == 0x10BF
+_ctk_restore_end == 0x10BF
+_ctk_init == 0x10BF
+_ctk_init_end == 0x11F2
+_ctk_mode_set == 0x11FA
+_ctk_mode_set_start == 0x11FA
+_ctk_mode_get == 0x120F
+_ctk_mode_get_start == 0x120F
+_ctk_mode_set_end == 0x120F
+_ctk_mode_get_end == 0x1217
+_ctk_icon_add == 0x1217
+_ctk_icon_add_start == 0x1217
+_ctk_dialog_open == 0x1243
+_ctk_icon_add_end == 0x1243
+_ctk_dialog_open_start == 0x1243
+_ctk_dialog_open_end == 0x126A
+_ctk_dialog_close == 0x126A
+_ctk_dialog_close_start == 0x126A
+_ctk_window_open == 0x1283
+_ctk_window_open_start == 0x1283
+_ctk_dialog_close_end == 0x1283
+_ctk_window_close == 0x139C
+_ctk_window_close_start == 0x139C
+_ctk_window_open_end == 0x139C
+_ctk_window_close_end == 0x14CB
+_ctk_window_clear_start == 0x163B
+_ctk_window_clear == 0x163B
+_ctk_menu_add_start == 0x1695
+_ctk_window_clear_end == 0x1695
+_ctk_menu_add == 0x1695
+_ctk_menu_add_end == 0x1707
+_ctk_menu_remove == 0x1707
+_ctk_menu_remove_start == 0x1707
+_ctk_menu_remove_end == 0x178B
+_ctk_desktop_redraw == 0x18E0
+_ctk_desktop_redraw_start == 0x18E0
+_ctk_window_redraw_start == 0x192F
+_ctk_desktop_redraw_end == 0x192F
+_ctk_window_redraw == 0x192F
+_ctk_window_redraw_end == 0x19AC
+_ctk_window_new == 0x1B5F
+_ctk_window_new_start == 0x1B5F
+_ctk_window_new_end == 0x1B93
+_ctk_dialog_new == 0x1B93
+_ctk_dialog_new_start == 0x1B93
+_ctk_menu_new == 0x1BB9
+_ctk_menu_new_start == 0x1BB9
+_ctk_dialog_new_end == 0x1BB9
+_ctk_menuitem_add == 0x1C1B
+_ctk_menu_new_end == 0x1C1B
+_ctk_menuitem_add_start == 0x1C1B
+_ctk_menuitem_add_end == 0x1C9E
+_ctk_widget_redraw == 0x1DCD
+_ctk_widget_redraw_start == 0x1DCD
+_ctk_widget_add == 0x1DF7
+_ctk_widget_add_start == 0x1DF7
+_ctk_widget_redraw_end == 0x1DF7
+_ctk_desktop_width_start == 0x1EA6
+_ctk_widget_add_end == 0x1EA6
+_ctk_desktop_width == 0x1EA6
+_ctk_desktop_width_end == 0x1EB4
+_ctk_desktop_height == 0x1EB4
+_ctk_desktop_height_start == 0x1EB4
+_ctk_desktop_height_end == 0x1EC2
+_ctk_draw_init == 0x2EFD
+_ctk_draw_init_start == 0x2EFD
+_ctk_draw_clear == 0x2F46
+_ctk_draw_init_end == 0x2F46
+_ctk_draw_clear_start == 0x2F46
+_ctk_draw_clear_window == 0x2F79
+_ctk_draw_clear_window_start == 0x2F79
+_ctk_draw_clear_end == 0x2F79
+_ctk_draw_clear_window_end == 0x2FBA
+_ctk_draw_window == 0x2FBA
+_ctk_draw_window_start == 0x2FBA
+_ctk_draw_dialog_start == 0x2FFB
+_ctk_draw_window_end == 0x2FFB
+_ctk_draw_dialog == 0x2FFB
+_ctk_draw_widget == 0x302B
+_ctk_draw_dialog_end == 0x302B
+_ctk_draw_widget_start == 0x302B
+_ctk_draw_menus_start == 0x306C
+_ctk_draw_widget_end == 0x306C
+_ctk_draw_menus == 0x306C
+_ctk_draw_menus_end == 0x309C
+_ctk_draw_width == 0x309C
+_ctk_draw_width_start == 0x309C
+_ctk_draw_width_end == 0x30BE
+_ctk_draw_height == 0x30BE
+_ctk_draw_height_start == 0x30BE
+_ctk_mouse_xtoc == 0x30E0
+_ctk_mouse_xtoc_start == 0x30E0
+_ctk_draw_height_end == 0x30E0
+_ctk_mouse_ytoc == 0x3115
+_ctk_mouse_ytoc_start == 0x3115
+_ctk_mouse_xtoc_end == 0x3115
+_ctk_draw_quit == 0x314A
+_ctk_mouse_ytoc_end == 0x314A
+_ctk_draw_quit_start == 0x314A
+_ctk_draw_quit_end == 0x3168
+_ek_service_start == 0x3173
+_ek_service_start_start == 0x3173
+_ek_service_find_start == 0x31B2
+_ek_service_start_end == 0x31B2
+_ek_service_find == 0x31B2
+_ek_service_state_start == 0x31DF
+_ek_service_find_end == 0x31DF
+_ek_service_state == 0x31DF
+_ek_service_reset == 0x3229
+_ek_service_reset_start == 0x3229
+_ek_service_state_end == 0x3229
+_ek_service_reset_end == 0x323F
+_ek_alloc_event == 0x323F
+_ek_alloc_event_start == 0x323F
+_ek_alloc_event_end == 0x324A
+_ek_start_start == 0x3369
+_ek_start == 0x3369
+_ek_exit == 0x33F8
+_ek_start_end == 0x33F8
+_ek_exit_start == 0x33F8
+_ek_process == 0x352B
+_ek_process_start == 0x352B
+_ek_exit_end == 0x352B
+_ek_init == 0x3558
+_ek_init_start == 0x3558
+_ek_process_end == 0x3558
+_ek_process_event == 0x35AC
+_ek_init_end == 0x35AC
+_ek_process_event_start == 0x35AC
+_ek_process_poll == 0x3743
+_ek_process_event_end == 0x3743
+_ek_process_poll_start == 0x3743
+_ek_run == 0x378B
+_ek_run_start == 0x378B
+_ek_process_poll_end == 0x378B
+_ek_post == 0x37AD
+_ek_post_start == 0x37AD
+_ek_run_end == 0x37AD
+_ek_post_synch == 0x3828
+_ek_post_synch_start == 0x3828
+_ek_post_end == 0x3828
+_ek_post_synch_end == 0x3887
+_ek_find == 0x3887
+_ek_find_start == 0x3887
+_ek_find_end == 0x38F2
+_ek_replace == 0x38F2
+_ek_replace_start == 0x38F2
+_ek_replace_end == 0x394A
+_ek_procstate == 0x394A
+_ek_procstate_start == 0x394A
+_ek_procstate_end == 0x397F
+_arg_init == 0x397F
+_arg_init_start == 0x397F
+_arg_init_end == 0x3986
+_arg_alloc == 0x3986
+_arg_alloc_start == 0x3986
+_arg_alloc_end == 0x39A4
+_arg_free == 0x39A4
+_arg_free_start == 0x39A4
+_arg_free_end == 0x39C5
+_list_init == 0x39C5
+_list_init_start == 0x39C5
+_list_init_end == 0x39E1
+_list_head == 0x39E1
+_list_head_start == 0x39E1
+_list_copy_start == 0x39FD
+_list_head_end == 0x39FD
+_list_copy == 0x39FD
+_list_copy_end == 0x3A22
+_list_tail == 0x3A22
+_list_tail_start == 0x3A22
+_list_add == 0x3A54
+_list_add_start == 0x3A54
+_list_tail_end == 0x3A54
+_list_push_start == 0x3A95
+_list_add_end == 0x3A95
+_list_push == 0x3A95
+_list_push_end == 0x3AC0
+_list_chop == 0x3AC0
+_list_chop_start == 0x3AC0
+_list_pop == 0x3B46
+_list_pop_start == 0x3B46
+_list_chop_end == 0x3B46
+_list_pop_end == 0x3B71
+_timer_set == 0x3B71
+_timer_set_start == 0x3B71
+_timer_set_end == 0x3B9D
+_timer_reset == 0x3B9D
+_timer_reset_start == 0x3B9D
+_timer_expired == 0x3BBA
+_timer_reset_end == 0x3BBA
+_timer_expired_start == 0x3BBA
+_timer_expired_end == 0x3C04
+_directory_dsc == 0x3C04
+_directory_icon == 0x3C5D
+_configedit_dsc == 0x3C90
+_configedit_icon == 0x3CE9
+_processes_dsc == 0x3D2F
+_processes_icon == 0x3D88
+_uip_fw_forward_start == 0x3DC2
+_uip_fw_forward == 0x3DC2
+_uip_fw_forward_end == 0x3DC5
+_uip_fw_periodic == 0x3DC5
+_uip_fw_periodic_start == 0x3DC5
+_uip_fw_periodic_end == 0x3DC6
+_main_start == 0x3DEF
+_main_end == 0x3E48
+_reset == 0x3E68
+_reset_start == 0x3E68
+_reset_end == 0x3E69
+_clock_time_start == 0x3E6E
+_clock_time == 0x3E6E
+_ctk_arch_isprint == 0x3E72
+_clock_time_end == 0x3E72
+_ctk_arch_isprint_start == 0x3E72
+_ctk_arch_isprint_end == 0x3E8D
+_strcpy == 0x3E8D
+_strcpy_start == 0x3E8D
+_strcpy_end == 0x3EB2
+__divschar_rrx_s == 0x3EB2
+__divschar_rrx_hds == 0x3EB9
+__modschar_rrx_s == 0x3EC0
+__modschar_rrx_hds == 0x3EC7
+__divsint_rrx_s == 0x3ECE
+__divsint_rrx_hds == 0x3EDA
+__modsint_rrx_s == 0x3EE2
+__modsint_rrx_hds == 0x3EEE
+__divuchar_rrx_s == 0x3EF6
+__divuchar_rrx_hds == 0x3EFD
+__moduchar_rrx_s == 0x3F04
+__moduchar_rrx_hds == 0x3F0B
+__divuint_rrx_s == 0x3F12
+__divuint_rrx_hds == 0x3F1E
+__moduint_rrx_s == 0x3F26
+__moduint_rrx_hds == 0x3F32
+.mod8 == 0x3F3A
+.div8 == 0x3F3A
+.mod16 == 0x3F42
+.div16 == 0x3F42
+.modu8 == 0x3F7F
+.divu8 == 0x3F7F
+.modu16 == 0x3F82
+.divu16 == 0x3F82
+_strncmp == 0x3FB3
+_strncmp_start == 0x3FB3
+_strncmp_end == 0x4040
+_isprint == 0x4040
+_isprint_start == 0x4040
+_isprint_end == 0x4062
+_memset == 0x4062
+_memset_start == 0x4062
+_memset_end == 0x40AA
+__mulschar_rrx_s == 0x40AA
+__mulschar_rrx_hds == 0x40B1
+__muluchar_rrx_s == 0x40BD
+__mulint_rrx_s == 0x40CA
+__mulint_rrx_hds == 0x40D6
+__muluchar_rrx_hds == 0x40D6
+_strncpy == 0x40EF
+_strncpy_start == 0x40EF
+_strncpy_end == 0x415E
+_strlen_start == 0x415E
+_strlen == 0x415E
+_strlen_end == 0x417E
+_ctk_signal_keypress == 0x439D
+_ctk_signal_widget_activate == 0x439E
+_ctk_signal_button_activate == 0x439F
+_ctk_signal_widget_select == 0x43A0
+_ctk_signal_button_hover == 0x43A1
+_ctk_signal_hyperlink_activate == 0x43A2
+_ctk_signal_hyperlink_hover == 0x43A3
+_ctk_signal_menu_activate == 0x43A4
+_ctk_signal_window_close == 0x43A5
+_ctk_signal_pointer_move == 0x43A6
+_ctk_signal_pointer_button == 0x43A7
+_ctk_screensaver_timeout == 0x43AA
+_ctk_draw_windowborder_width == 0x43BC
+_ctk_draw_windowborder_height == 0x43BD
+_ctk_draw_windowtitle_height == 0x43BE
+_ek_procs == 0x43C2
+_ek_proclist == 0x43C4
+_ek_current == 0x4404
+_ek_event_quit == 0x4406
+_ek_event_msg == 0x4407
+_ek_poll_request == 0x448B
diff --git a/contiki-cpc/arch/crt0-backup.s b/contiki-cpc/arch/crt0-backup.s
new file mode 100644
index 0000000..b014aa8
--- /dev/null
+++ b/contiki-cpc/arch/crt0-backup.s
@@ -0,0 +1,33 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+    .module crt0
+	.globl	_main
+	.globl _progend
+	.area _HEADER (ABS)
+	.org 	0x100 ;; Start from address &100
+init:
+
+;; Initialise global variables
+    call    gsinit
+	call	_main
+
+_exit::
+	ret
+
+	;; Ordering of segments for the linker.
+	.area	_HOME
+	.area	_CODE
+	.area	_DATA
+	 .area   _BSS
+	
+	.area   _GSINIT
+gsinit::	
+
+    .area   _GSFINAL
+    ret
+    	.area   _HEAP
+_progend::
diff --git a/contiki-cpc/arch/crt0-dsc.s b/contiki-cpc/arch/crt0-dsc.s
new file mode 100644
index 0000000..381bc27
--- /dev/null
+++ b/contiki-cpc/arch/crt0-dsc.s
@@ -0,0 +1,26 @@
+;; File: crt0-dsc.s
+
+    .module crt0
+	.globl	_main
+
+	.area _HEADER (REL)
+;;	.org 	0x100 ;; Start from address &100
+
+init:
+_main:
+	;; Ordering of segments for the linker.
+	.area	_HOME (REL)
+	.area	_CODE (REL)
+    .area   _GSINIT (REL)
+    .area   _GSFINAL (REL)
+        
+	.area	_DATA (REL)
+    .area   _BSS (REL)
+    .area   _HEAP (REL)
+
+   .area   _CODE (REL)
+	
+_exit::
+	.area   _GSINIT (REL)
+gsinit::	
+    .area   _GSFINAL (REL)
diff --git a/contiki-cpc/arch/crt0-prg.s b/contiki-cpc/arch/crt0-prg.s
new file mode 100644
index 0000000..8984742
--- /dev/null
+++ b/contiki-cpc/arch/crt0-prg.s
@@ -0,0 +1,16 @@
+;; File: crt0-dsc.s
+
+    .module crt0
+	.area _HEADER (ABS)
+	.area _HOME (REL)	
+	.area _CODE (REL)
+	;; relocation data
+	.dw 0
+     .area _DATA (REL)
+    .area   _BSS (REL)
+    .area   _HEAP (REL)
+
+	.area   _GSINIT (REL)
+gsinit::	
+    .area   _GSFINAL (REL)
+	ret
diff --git a/contiki-cpc/arch/crt0.s b/contiki-cpc/arch/crt0.s
new file mode 100644
index 0000000..a8aafdb
--- /dev/null
+++ b/contiki-cpc/arch/crt0.s
@@ -0,0 +1,35 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+    .module crt0
+	.globl	_main
+	.globl _progend
+	.globl __jpbc
+	.area	_HEADER (ABS)
+	;; Ordering of segments for the linker.
+	.area	_CODE
+init:
+
+;; Initialise global variables
+    call    gsinit
+	call	_main
+
+_exit::
+	ret
+__jpbc:
+	push bc
+	ret
+
+	.area	_DATA (REL)
+	 .area   _BSS (REL)
+	
+	.area   _GSINIT (REL)
+gsinit::	
+
+    .area   _GSFINAL (REL)
+    ret
+    	.area   _HEAP (REL)
+_progend::
diff --git a/contiki-cpc/arch/hires.s b/contiki-cpc/arch/hires.s
new file mode 100644
index 0000000..c482768
--- /dev/null
+++ b/contiki-cpc/arch/hires.s
@@ -0,0 +1,101 @@
+;; Hires: 
+;;
+;; Mode 0, 40 columns. Each character is 4 pixels wide and 8 pixels tall.
+;; Each character is two bytes wide and 8 lines tall.
+;;
+;; The graphics for each character is a bitmap defined using
+;; pen 0 and pen 15.
+;;
+;; The bitmap is processed at runtime to convert the font to the 
+;; appropiate pixel colours.
+		.area _CODE
+;; This table converts between pen index (0-15) and pixel bitmap.
+.pen_table
+defb #00	;; pen 0  (%00000000)
+defb #c0	;; pen 1  (%11000000)
+defb #0c	;; pen 2  (%00001100)
+defb #cc	;; pen 3  (%11001100)
+defb #30	;; pen 4  (%00110000)
+defb #f0	;; pen 5  (%11110000)
+defb #3c	;; pen 6  (%00111100)
+defb #fc	;; pen 7  (%11111100)
+defb #03	;; pen 8  (%00000011)
+defb #c3	;; pen 9  (%11000011)
+defb #0f	;; pen 10 (%00001111)
+defb #cf	;; pen 11 (%11001111)
+defb #33	;; pen 12 (%00110011)
+defb #f3	;; pen 13 (%11110011)
+defb #3f	;; pen 14 (%00111111)
+defb #ff	;; pen 15 (%11111111)
+
+;; A = pen
+.get_pen_mask
+ld hl,pen_table
+add a,l
+ld l,a
+ld a,h
+adc a,0
+ld h,a
+ld a,(hl)
+ret
+
+.set_pen
+call get_pen_mask
+ld (pen_mask+1),a
+ld (pen_mask2+1),a
+ret
+
+.set_paper
+call get_pen_mask
+ld (paper_mask+1),a
+ld (paper_mask2+1),a
+ret
+
+;; enter:
+;; HL = current memory address
+;; exit:
+;; HL = memory address of byte immediatly below
+;; AF corrupt.
+.scr_next_line
+ld a,h
+add a,8
+ld h,a
+ret nc
+ld a,l
+add a,&50
+ld l,a
+ld a,h
+adc a,&c0
+ld h,a
+ret
+
+;; enter:
+;; HL = screen address
+;; DE = character pixel graphics
+;; exit:
+;; AF, BC, HL, DE corrupt
+.plot_char
+ld b,8
+.pc1
+ld a,(de)		;; convert 'on' pixels
+.pen_mask and 1
+ld c,a
+ld a,(de)
+cpl 
+.paper_mask and 1
+or c
+ld (hl),a
+inc l
+ld a,(de)
+.pen_mask2 and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask2 and 1
+or c
+ld (hl),a
+dec l
+call scr_next_line
+djnz pc1
+ret
+
diff --git a/contiki-cpc/arch/key.s b/contiki-cpc/arch/key.s
new file mode 100644
index 0000000..8ca55ad
--- /dev/null
+++ b/contiki-cpc/arch/key.s
@@ -0,0 +1,33 @@
+; unsigned char kbhit (void);
+; Return true if there's a key waiting, return false if not 
+; TESTED
+
+.globl _kbhit
+		.area _CODE
+_kbhit::
+		call	0xBB09	; KM READ KEY
+		ld (key),a
+		ld		l,#1
+		ret		c
+		ld		l,#0
+		ret
+
+; char cgetc (void);
+; Return a character from the keyboard. If there is no character available,
+; the functions waits until the user does press a key. If cursor is set to
+; 1 (see below), a blinking cursor is displayed while waiting.
+; TESTED
+
+.globl _cgetc
+
+_cgetc::	
+		ld a,(key)
+		ld l,a
+		ret
+
+;;		call	0xBB09
+;;		jr nc,_cgetc
+;;		ld		l,a
+;;		ret
+
+key:		.db 0
diff --git a/contiki-cpc/arch/main.c b/contiki-cpc/arch/main.c
new file mode 100644
index 0000000..06a0656
--- /dev/null
+++ b/contiki-cpc/arch/main.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main.c,v 1.1 2006/04/17 15:15:44 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "log.h"
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "configedit-dsc.h"
+#include "directory-dsc.h"
+#include "processes-dsc.h"
+
+//#include "cfs-cbm.h"
+#include "cfs-cpc.h"
+
+#include "clock.h"
+
+#include "arch.h"
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(init_eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    program_handler_load("conio.prg",NULL);
+//    program_handler_load("config.prg", NULL);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   init_eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+#if LOG_CONF_ENABLED
+void
+log_message(char *part1, char *part2)
+{
+}
+#endif
+void
+main(void)
+{
+  
+ log_message("Starting ", CONTIKI_VERSION_STRING);
+  
+  ek_init();
+
+  ek_start(&init);
+    
+ // log_message(": TCP/IP", "");
+    
+ // tcpip_init(NULL);
+
+ // resolv_init(NULL); 
+
+  log_message(": CTK GUI", "");
+  ctk_init();
+
+  log_message(": Initial filesystem", "");
+  cfs_cpc_init(NULL);
+
+  program_handler_init();
+   
+  program_handler_add(&directory_dsc, "Directory", 1);
+//  program_handler_add(&configedit_dsc, "Configuration", 1);
+  program_handler_add(&processes_dsc, "Processes", 1);  
+  
+  
+  log_message("Starting process scheduling", "");  
+
+  while(1) {
+    if(ek_run() == 0) {
+      program_handler_load("welcome.prg", NULL);
+      break;
+    }
+  }
+    
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+reset(void)
+{
+/*  asm("lda #$36");
+  asm("sta $01");
+  asm("jmp $fce2");
+*/
+}
+
diff --git a/contiki-cpc/arch/malloc.c b/contiki-cpc/arch/malloc.c
new file mode 100644
index 0000000..d4e91b5
--- /dev/null
+++ b/contiki-cpc/arch/malloc.c
@@ -0,0 +1,268 @@
+#include <sdcc-lib.h>
+#include <malloc.h>
+
+#if _SDCC_MALLOC_TYPE_MLH
+
+typedef struct _MEMHEADER MEMHEADER;
+
+struct _MEMHEADER
+{
+  MEMHEADER *  next;
+  MEMHEADER *  prev;
+  unsigned int       len;
+  unsigned char      mem;
+};
+
+#define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
+
+/* These veriables are defined through the crt0 functions. */
+/* Base of this variable is the first byte of the heap. */
+//extern MEMHEADER _sdcc_heap_start;
+/* Address of this variable is the last byte of the heap. */
+//extern char _sdcc_heap_end;
+
+extern char *get_ram_start();
+extern char *get_ram_end();
+extern void calc_free_ram();
+extern char progend;
+
+static MEMHEADER *firstheader;
+/* setup two headers. One at start of free ram, second at end of free ram.
+ We find free ram range by asking Amstrad's firmware. */
+
+void
+_sdcc_heap_init(void)
+{
+  MEMHEADER *lastheader;
+  unsigned int size;
+  char * ramstart;
+
+  /* ask firmware for free ram */
+  calc_free_ram();
+
+  /* start of ram is either start of range given by firmware,
+  or end of program; whichever is largest */
+  ramstart = get_ram_start();
+  if (ramstart<&progend)
+	ramstart = &progend;
+
+  /* this is our first mem header */
+  firstheader = (MEMHEADER *)ramstart;
+  
+  /* this is the size of ram available */
+  size = get_ram_end() - ramstart;
+
+  /* calc address of last header */
+  lastheader = (MEMHEADER *)((char *)firstheader + size - HEADER_SIZE); 
+  
+  /* setup last header */
+  lastheader->next = NULL;
+  lastheader->prev = firstheader;
+  lastheader->len = 0;
+
+  /* setup first header */
+  firstheader->next = lastheader;
+  firstheader->prev       = NULL; //and mark first as first
+  firstheader->len        = 0;    //Empty and ready.
+}
+
+void *
+malloc (unsigned int size)
+{
+  MEMHEADER * current_header;
+  MEMHEADER * new_header;
+
+  if (size>(0xFFFF-HEADER_SIZE))
+    {
+      return NULL; //To prevent overflow in next line
+    }
+
+  size += HEADER_SIZE; //We need a memory for header too
+  current_header = firstheader;
+
+  while (1)
+    {
+      //    current
+      //    |   len       next
+      //    v   v         v
+      //....*****.........******....
+      //         ^^^^^^^^^
+      //           spare
+
+      if ((((unsigned int)current_header->next) -
+           ((unsigned int)current_header) -
+           current_header->len) >= size) 
+        {
+          break; //if spare is more than need
+        }
+      current_header = current_header->next;    //else try next             
+      if (!current_header->next)  
+        {
+          return NULL;  //if end_of_list reached    
+        }
+    }
+
+  if (!current_header->len)
+    { //This code works only for first_header in the list and only
+      current_header->len = size; //for first allocation
+      return &current_header->mem;
+    } 
+  else
+    {
+      //else create new header at the begin of spare
+      new_header = (MEMHEADER * )((char *)current_header + current_header->len);
+      new_header->next = current_header->next; //and plug it into the chain
+      new_header->prev = current_header;
+      current_header->next  = new_header;
+      if (new_header->next)
+        {
+          new_header->next->prev = new_header;
+        }
+      new_header->len  = size; //mark as used
+      return &new_header->mem;
+    }
+}
+
+void
+free (void *p)
+{
+  MEMHEADER *prev_header, *pthis;
+
+  if ( p ) //For allocated pointers only!
+    {
+      pthis = (MEMHEADER * )((char *)  p - HEADER_SIZE); //to start of header
+      if ( pthis->prev ) // For the regular header
+        {
+          prev_header = pthis->prev;
+          prev_header->next = pthis->next;
+          if (pthis->next)
+            {
+              pthis->next->prev = prev_header;
+            }
+        }
+      else
+        {
+          pthis->len = 0; //For the first header
+        }
+    }
+}
+
+#else
+
+            //--------------------------------------------------------------------
+            //Written by Dmitry S. Obukhov, 1997
+            //dso@usa.net
+            //--------------------------------------------------------------------
+            //Modified for SDCC by Sandeep Dutta, 1999
+            //sandeep.dutta@usa.net
+            //--------------------------------------------------------------------
+            //malloc and free functions implementation for embedded system
+            //Non-ANSI keywords are C51 specific.
+            // xdata - variable in external memory (just RAM)
+            //--------------------------------------------------------------------
+
+            #define MEMHEADER   struct MAH// Memory Allocation Header
+
+            MEMHEADER
+            {
+              MEMHEADER xdata *  next;
+              MEMHEADER xdata *  prev;
+              unsigned int       len;
+	      unsigned char      mem;
+            };
+
+            #define HEADER_SIZE (sizeof(MEMHEADER)-1)
+
+            //Static here means: can be accessed from this module only
+            static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
+            void init_dynamic_memory(MEMHEADER xdata * array, unsigned int size) 
+            {
+
+            //This function MUST be called after the RESET.
+            //Parameters: array - pointer to memory allocated by the linker
+            //            size  - size of this memory pool
+            //Example:
+            //     #define DYNAMIC_MEMORY_SIZE 0x2000
+            //     .....
+            //     unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
+            //     unsigned char xdata * current_buffer;
+            //     .....
+            //     void main(void)
+            //     {
+            //         ...
+            //         init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
+            //         Now it is possible to use malloc.
+            //         ...
+            //         current_buffer = malloc(0x100);
+            //
+            //
+
+              if ( !array ) /*Reserved memory starts on 0x0000 but it's NULL...*/
+              {             //So, we lost one byte!
+                 array = (MEMHEADER xdata * )((char xdata * ) array + 1) ;
+                 size --;
+              }
+              FIRST_MEMORY_HEADER_PTR = array;
+              //Reserve a mem for last header
+              array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
+              array->next->next = (void xdata * ) NULL; //And mark it as last
+              array->prev       = (void xdata * ) NULL; //and mark first as first
+              array->len        = 0;    //Empty and ready.
+            }
+
+            void  xdata * malloc (unsigned int size)
+            {
+              register MEMHEADER xdata * current_header;
+              register MEMHEADER xdata * new_header;
+
+              if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
+              size += HEADER_SIZE; //We need a memory for header too
+              current_header = FIRST_MEMORY_HEADER_PTR;
+              while (1)
+              {
+
+                //    current
+                //    |   len       next
+                //    v   v         v
+                //....*****.........******....
+                //         ^^^^^^^^^
+                //           spare
+
+                if ((((unsigned int)current_header->next) -
+                     ((unsigned int)current_header) -
+                     current_header->len) >= size) break; //if spare is more than need
+                current_header = current_header->next;    //else try next             
+                if (!current_header->next)  return (void xdata *) NULL;  //if end_of_list reached
+              }
+              if (!current_header->len)
+              { //This code works only for first_header in the list and only
+                 current_header->len = size; //for first allocation
+                 return ((xdata *)&(current_header->mem));
+              } //else create new header at the begin of spare
+              new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len);
+              new_header->next = current_header->next; //and plug it into the chain
+              new_header->prev = current_header;
+              current_header->next  = new_header;
+              if (new_header->next)  new_header->next->prev = new_header;
+              new_header->len  = size; //mark as used
+              return ((xdata *)&(new_header->mem));
+            }
+
+            void free (void xdata * p)
+            {
+              register MEMHEADER xdata * prev_header;
+              if ( p ) //For allocated pointers only!
+              {
+                  p = (MEMHEADER xdata * )((char xdata *)  p - HEADER_SIZE); //to start of header
+                  if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
+                  {
+                    prev_header = ((MEMHEADER xdata * ) p)->prev;
+                    prev_header->next = ((MEMHEADER xdata * ) p)->next;
+                    if (((MEMHEADER xdata * ) p)->next)
+		       ((MEMHEADER xdata * ) p)->next->prev = prev_header;
+                  }
+                  else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
+              }
+            }
+            //END OF MODULE
+#endif
diff --git a/contiki-cpc/arch/mem.s b/contiki-cpc/arch/mem.s
new file mode 100644
index 0000000..e994238
--- /dev/null
+++ b/contiki-cpc/arch/mem.s
@@ -0,0 +1,105 @@
+	.globl _calc_free_ram
+	.globl _get_ram_start
+	.globl _get_ram_end
+	.globl __sdcc_heap_init
+
+	.area _GSINIT
+	call __sdcc_heap_init
+
+	.area _CODE
+
+_calc_free_ram::
+	push bc
+        ;; get information about BASIC ROM
+        ld c,#0x0
+        call  #0xb915
+        cp #0x80
+        jr nz,gfr
+        ;; must be built in ROM
+
+        ;; v1.0 (BASIC 1.0 in CPC464)
+        ;; v1.1 (BASIC 1.1 in CPC664)
+        ;; v1.2 (BASIC 1.1 in CPC6128 and KC Compact)
+        ;; v1.4 (BASIC 1.1 in CPC+)
+
+        ld a,h
+        cp #0x1
+        ret z
+        ld a,l
+        or a
+        jr z,basic10       
+
+        ;; basic 1.1       
+  
+        ld hl,(#0xb073)
+        inc hl
+        ld bc,(#0xb736)
+        or a
+        sbc hl,bc
+        jr nz,after_himem11
+
+        ld hl,(#0xae6c)
+        ld (ram_start),hl
+
+        ld hl,(#0xb071)
+        ld (ram_end),hl
+gfr:
+	pop bc
+        ret
+
+after_himem11:
+
+        ;; after himem
+        ld hl,(#0xb073)
+        inc hl
+        ld (ram_start),hl
+        
+        ;; start of UDG
+        ld hl,(#0xb736)
+        dec hl
+        ld (ram_end),hl
+	pop bc
+        ret
+
+
+basic10:
+        ld hl,(#0xb08f)
+        inc hl
+        ld bc,(#0xb296)
+        or a
+        sbc hl,bc
+        jr nz,after_himem10
+
+        ld hl,(#0xae89)
+        ld (ram_start),hl
+
+        ld hl,(#0xb08d)
+        ld (ram_end),hl
+	pop bc
+        ret
+
+after_himem10:
+
+        ;; after himem
+        ld hl,(#0xb08f)
+        inc hl
+        ld (ram_start),hl
+
+        ;; start of UDG
+        ld hl,(#0xb296)
+        dec hl
+        ld (ram_end),hl
+	pop bc
+        ret
+
+_get_ram_start:: 
+	ld hl,(ram_start)
+	ret
+_get_ram_end::
+	ld hl,(ram_end)
+	ret
+	
+ram_start:: 
+	.dw 0
+ram_end:: 
+	.dw 0
diff --git a/contiki-cpc/arch/putchar.s b/contiki-cpc/arch/putchar.s
new file mode 100644
index 0000000..cc98c8d
--- /dev/null
+++ b/contiki-cpc/arch/putchar.s
@@ -0,0 +1,27 @@
+;; File: putchar.s
+;; Modified to suit execution on the Amstrad CPC
+;; by H. Hansen 2003
+;; Original lines has been marked out!
+
+		.area _CODE
+_putchar::       
+_putchar_rr_s:: 
+        ld      hl,#2
+        add     hl,sp
+        
+        ld      a,(hl)
+;;      ld      a,#1
+;;      rst     0x08
+        call	0xBB5A
+        ret
+           
+_putchar_rr_dbs::
+
+;;      ld      l,e
+;;		ld		a,#1
+;;      rst     0x08
+
+        ld		a,e
+        call	0xBB5A
+        ret
+			
\ No newline at end of file
diff --git a/contiki-cpc/arch/uip.c b/contiki-cpc/arch/uip.c
new file mode 100644
index 0000000..76f0d0a
--- /dev/null
+++ b/contiki-cpc/arch/uip.c
@@ -0,0 +1,9 @@
+void chksumi()
+{
+}
+
+void add32i()
+{
+}
+
+
diff --git a/contiki-cpc/arch/unused/clock.c b/contiki-cpc/arch/unused/clock.c
new file mode 100644
index 0000000..caa5657
--- /dev/null
+++ b/contiki-cpc/arch/unused/clock.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock.c,v 1.1 2006/04/17 15:18:29 kthacker Exp $
+ */
+#include <time.h>
+
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
diff --git a/contiki-cpc/arch/unused/main-rrnet.c b/contiki-cpc/arch/unused/main-rrnet.c
new file mode 100644
index 0000000..0b16c87
--- /dev/null
+++ b/contiki-cpc/arch/unused/main-rrnet.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main-rrnet.c,v 1.1 2006/04/17 15:18:29 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "netconf-dsc.h"
+#include "irc-dsc.h"
+#include "dhcp-dsc.h"
+
+#include "cfs-cbm.h"
+
+#include "clock.h"
+
+#include <cbm.h>
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t addr[2];
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+void
+log_message(char *part1, char *part2)
+{
+  while(*part1 != 0) {
+    cbm_k_bsout(*part1++);
+  }
+
+  while(*part2 != 0) {
+    cbm_k_bsout(*part2++);
+  }
+
+  
+  cbm_k_bsout('\n');
+}
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+  return clock();
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_curunit(void)
+{
+  asm("lda $ba");
+  asm("sta %v", _curunit);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+void
+main(void)
+{
+
+  setup_curunit();
+  
+  log_message("Starting ", CONTIKI_VERSION_STRING);
+  
+  ek_init();
+
+  ek_start(&init);
+    
+  log_message(": TCP/IP", "");
+    
+  tcpip_init(NULL);
+
+  resolv_init(NULL); 
+
+  log_message(": CTK GUI", "");
+  ctk_init();
+
+  /*  log_message(": Initial filesystem", "");
+      cfs_init_init(NULL);*/
+
+  program_handler_init();
+   
+  program_handler_add(&netconf_dsc, "Network config", 1);
+  program_handler_add(&dhcp_dsc, "DHCP", 1);
+  program_handler_add(&irc_dsc, "IRC", 1);
+  
+
+  ctk_80col_service_init(NULL);
+  rrnet_drv_init(NULL);  
+  
+  log_message("Starting process scheduling", "");  
+
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/arch/unused/rel.s b/contiki-cpc/arch/unused/rel.s
new file mode 100644
index 0000000..6388d6c
--- /dev/null
+++ b/contiki-cpc/arch/unused/rel.s
@@ -0,0 +1,91 @@
+	.globl _relocate
+	.area _CODE
+
+;; IX = address of relocate data
+_relocate::
+	call relocate_16bit
+	call relocate_8bit	;; lower byte
+	ld c,b
+	call relocate_8bit	;; upper byte
+	ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;; 
+relocate_8bit:
+	ld a,0(ix)
+	inc ix
+rel8bit: push af
+	ld e,0(ix)
+	inc ix
+	ld d,0(ix)
+inc ix
+
+ld a,(de)
+add c
+ld (de),a
+pop af
+dec a
+jr nz,rel8bit
+ret
+
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit 
+;; value to relocate. 
+;;
+;; BC = base address
+;; 
+;; NOTE: 
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix)		;; number of items to relocate
+inc ix
+
+rel16bit:
+push af
+;; get address of 16-bit value to relocate
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+
+;; get the 16-bit value
+ld a,(de)
+ld l,a
+inc de
+ld a,(de)
+ld h,a
+
+;; add base address; therefore relocating it.
+add hl,bc
+
+;; write relocated value
+ld a,h
+ld (de),a
+dec de
+ld a,l
+ld (de),a
+pop af
+dec a
+jr nz,rel16bit
+ret
+
+;;--------------------------------------------------------------------------
+
+	.area	_DATA
+ 	.area   _BSS
+	.area   _GSINIT
+        .area   _GSFINAL
+
+_relocate_data::
diff --git a/contiki-cpc/conf/FILES b/contiki-cpc/conf/FILES
new file mode 100644
index 0000000..72ec6f2
--- /dev/null
+++ b/contiki-cpc/conf/FILES
@@ -0,0 +1,30 @@
+The contiki/conf/ directory contains example configuration
+files.
+
+cc-conf.h.example
+
+  An example configuration file for C compiler tweaks.
+
+clock-conf.h.example
+
+  An example configuration file for the clock module.
+
+ctk-conf.h.example
+
+  An example configuration file for the CTK GUI module.
+
+ek-conf.h.example
+
+  An example configuration file for the Contiki event kernel.
+
+telnetd-conf.h.example
+
+  An example configuration file for the telnet server.
+
+uip-conf.h.example
+
+  An example configuration file for the uIP TCP/IP stack.
+
+www-conf.h.example
+
+  An example configuration file for the web browser.
\ No newline at end of file
diff --git a/contiki-cpc/conf/cc-conf.h b/contiki-cpc/conf/cc-conf.h
new file mode 100644
index 0000000..4fc7e7d
--- /dev/null
+++ b/contiki-cpc/conf/cc-conf.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+/* This file is used to configure stuff that depends on the
+   capabilities of the C compiler used. */
+
+/* CC_CONF_REGISTER_ARGS: 1 or 0; 1 if the C compiler can handle the
+   "register" keyword in function argument, 0 otherwise. */
+#define CC_CONF_REGISTER_ARGS          0
+
+/* CC_CONF_FUNCTION_POINTR_ARGS: 1 or 0; 1 if the C compiler can
+   handle function arguments with function pointers, 0 otherwise. */
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+/* CC_CONF_FASTCALL: if the C compiler supports the fastcall keyword,
+   it should be defined here. If the C compiler does not support it,
+   leave the definition blank. 
+
+   Example:
+   #define CC_CONF_FASTCALL               fastcall */
+#define CC_CONF_FASTCALL
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/conf/cc-conf.h.old b/contiki-cpc/conf/cc-conf.h.old
new file mode 100644
index 0000000..6e972ee
--- /dev/null
+++ b/contiki-cpc/conf/cc-conf.h.old
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h.old,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define register			/**/
+#define CC_CONF_REGISTER_ARGS          0
+#define CC_CONF_FUNCTION_POINTER_ARGS  0
+
+#define CC_CONF_FASTCALL               /*fastcall*/
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/conf/clock-conf.h b/contiki-cpc/conf/clock-conf.h
new file mode 100644
index 0000000..a690e15
--- /dev/null
+++ b/contiki-cpc/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-cpc/conf/ctk-conf.h b/contiki-cpc/conf/ctk-conf.h
new file mode 100644
index 0000000..0ba9df1
--- /dev/null
+++ b/contiki-cpc/conf/ctk-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F2
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         CH_F7
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F4
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/conf/ctk-conf.h.old b/contiki-cpc/conf/ctk-conf.h.old
new file mode 100644
index 0000000..3c8404f
--- /dev/null
+++ b/contiki-cpc/conf/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE  0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/conf/ctk-term-conf.h b/contiki-cpc/conf/ctk-term-conf.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contiki-cpc/conf/ctk-term-conf.h
diff --git a/contiki-cpc/conf/ctk-vncserver-conf.h b/contiki-cpc/conf/ctk-vncserver-conf.h
new file mode 100644
index 0000000..fd45e81
--- /dev/null
+++ b/contiki-cpc/conf/ctk-vncserver-conf.h
@@ -0,0 +1 @@
+#define CTK_VNCSERVER_CONF_MAX_ICONS 1
diff --git a/contiki-cpc/conf/ek-conf.h b/contiki-cpc/conf/ek-conf.h
new file mode 100644
index 0000000..862682b
--- /dev/null
+++ b/contiki-cpc/conf/ek-conf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_EVENTS   32    /* Must be 2^n */
+#define EK_CONF_NUMEVENTS EK_CONF_EVENTS
+
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 32
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/conf/ek-conf.h.old b/contiki-cpc/conf/ek-conf.h.old
new file mode 100644
index 0000000..8465281
--- /dev/null
+++ b/contiki-cpc/conf/ek-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h.old,v 1.1 2006/04/17 15:02:26 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   16    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  16    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/conf/irc-conf.h b/contiki-cpc/conf/irc-conf.h
new file mode 100644
index 0000000..0450b30
--- /dev/null
+++ b/contiki-cpc/conf/irc-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#define IRC_CONF_WIDTH 78
+#define IRC_CONF_HEIGHT 21
+
+#define IRC_CONF_SYSTEM_STRING "c64"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-cpc/conf/libconio-conf.h b/contiki-cpc/conf/libconio-conf.h
new file mode 100644
index 0000000..d420d5c
--- /dev/null
+++ b/contiki-cpc/conf/libconio-conf.h
@@ -0,0 +1,2 @@
+#define LIBCONIO_CONF_SCREEN_WIDTH 40
+#define LIBCONIO_CONF_SCREEN_HEIGHT 25
diff --git a/contiki-cpc/conf/log-conf.h b/contiki-cpc/conf/log-conf.h
new file mode 100644
index 0000000..1036014
--- /dev/null
+++ b/contiki-cpc/conf/log-conf.h
@@ -0,0 +1 @@
+#define LOG_CONF_ENABLED 0
diff --git a/contiki-cpc/conf/shell-gui-conf.h b/contiki-cpc/conf/shell-gui-conf.h
new file mode 100644
index 0000000..235b1c6
--- /dev/null
+++ b/contiki-cpc/conf/shell-gui-conf.h
@@ -0,0 +1,2 @@
+#define SHELL_GUI_CONF_XSIZE 20
+#define SHELL_GUI_CONF_YSIZE 20
diff --git a/contiki-cpc/conf/telnetd-conf.h b/contiki-cpc/conf/telnetd-conf.h
new file mode 100644
index 0000000..c4df972
--- /dev/null
+++ b/contiki-cpc/conf/telnetd-conf.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+#define __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 36
+#define TELNETD_CONF_NUMLINES 24
+
+#endif /* __TELNETD_CONF_H__ */
+
+
+
+
+
+
+
+
diff --git a/contiki-cpc/conf/uip-conf.h b/contiki-cpc/conf/uip-conf.h
new file mode 100644
index 0000000..e6392f4
--- /dev/null
+++ b/contiki-cpc/conf/uip-conf.h
@@ -0,0 +1,93 @@
+/**
+ * \file
+ * uIP configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file contains configuration options for the uIP TCP/IP
+ * stack. Each Contiki port will contain its own uip-conf.h file
+ * containing architecture specific configuration options.
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+/**
+ * The maximum number of TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ */
+#define UIP_CONF_MAX_CONNECTIONS 40
+
+/**
+ * The maximum number of listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ */
+#define UIP_CONF_MAX_LISTENPORTS 40
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ */
+#define UIP_CONF_BUFFER_SIZE     400
+
+/**
+ * The host byte order.
+ *
+ * Used for telling uIP if the architecture has LITTLE_ENDIAN or
+ * BIG_ENDIAN byte order. x86 CPUs have LITTLE_ENDIAN byte order,
+ * whereas Motorola CPUs have BIG_ENDIAN. Check the documentation of
+ * the CPU to find out the byte order.
+ */
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+
+/**
+ * IP address configuration through ping.
+ *
+ * uIP features IP address configuration using an ICMP echo (ping)
+ * packet. In this mode, the destination IP address of the first ICMP
+ * echo packet that is received is used to set the host IP address.  
+ */
+#define UIP_CONF_PINGADDRCONF    0
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/conf/uip-conf.h.old b/contiki-cpc/conf/uip-conf.h.old
new file mode 100644
index 0000000..3dc49f4
--- /dev/null
+++ b/contiki-cpc/conf/uip-conf.h.old
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h.old,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE     310
+
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/conf/vnc-conf.h b/contiki-cpc/conf/vnc-conf.h
new file mode 100644
index 0000000..f79ed62
--- /dev/null
+++ b/contiki-cpc/conf/vnc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH  (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS    8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/conf/vnc-conf.h.old b/contiki-cpc/conf/vnc-conf.h.old
new file mode 100644
index 0000000..f1316fe
--- /dev/null
+++ b/contiki-cpc/conf/vnc-conf.h.old
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h.old,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH  (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS    8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/conf/www-conf.h b/contiki-cpc/conf/www-conf.h
new file mode 100644
index 0000000..73e4373
--- /dev/null
+++ b/contiki-cpc/conf/www-conf.h
@@ -0,0 +1,110 @@
+/**
+ * \file
+ * The Contiki web browser configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/**
+ * The width of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+
+/**
+ * The height of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/**
+ * The size of the "Back" history.
+ */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/**
+ * The maximum length of the URLs the web browser will handle.
+ */
+#define WWW_CONF_MAX_URLLEN 100
+
+/**
+ * The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ * a single web page view.
+ *
+ * \note This does not limit the total number of widgets in a web
+ * page, only the number of widget that are visible simultaneously.
+ */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
+
+/**
+ * Turns support for the \<center\> tag on or off, and must be on for
+ * HTML forms to work.
+ */
+#define WWW_CONF_RENDERSTATE 1
+
+/**
+ * Toggles support for HTML forms.
+ */
+#define WWW_CONF_FORMS       1
+
+/**
+ * Maximum length of HTML form action URLs.
+ */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+
+/**
+ * Maximum length of HTML form name.
+ */
+#define WWW_CONF_MAX_FORMNAMELEN    20
+
+/**
+ * Maximum length of HTML form input name.
+ */
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+/**
+ * Maximum length of HTML form input value.
+ */
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+/**
+ * The defaule home page.
+ */
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/conf/www-conf.h.old b/contiki-cpc/conf/www-conf.h.old
new file mode 100644
index 0000000..14dcd56
--- /dev/null
+++ b/contiki-cpc/conf/www-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h.old,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 65
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 26
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  30
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/Makefile b/contiki-cpc/contiki-cpc/Makefile
new file mode 100644
index 0000000..7834d44
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile
@@ -0,0 +1,64 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+CONTIKI=../contiki
+
+usage:
+	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+	@echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+	@echo 'is one of the following:'
+	@echo all
+	@echo cpc
+	@echo cpcnet
+	@echo programs
+	@echo netprogs
+	@echo '(Also check the Makefile for more targets to try...)'
+
+all: clean cpc cpcnet programs 
+
+programs:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.programs
+
+netprogs:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.netprogs
+
+cpc:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc
+
+cpcnet:
+	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc-net
+
+include Makefile.common
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.common b/contiki-cpc/contiki-cpc/Makefile.common
new file mode 100644
index 0000000..0c3c9e9
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.common
@@ -0,0 +1,162 @@
+CC=sdcc
+AS=as-z80
+CL=link-z80
+LD=link-z80
+
+CFLAGSCOMMON= \
+	-I apps \
+	-I conf \
+	-I ctk \
+	-I lib \
+	-I loader \
+	-I uip \
+	-I arch \
+	-I $(CONTIKI)/apps \
+	-I $(CONTIKI)/ctk \
+	-I $(CONTIKI)/ek \
+	-I $(CONTIKI)/lib \
+	-I $(CONTIKI)/ppp \
+	-I $(CONTIKI)/uip \
+	-mz80 -D__fastcall__=/**/ -D__CPC__ -DCLK_TCK=16384 \
+	--no-std-crt0 --opt-code-size --peep-file ~/peeph/peep.def
+
+CLFLAGS= 
+OPT=
+AFLAGS = -o -g
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $*.o $<
+
+%.o: %.s
+	$(AS) $(AFLAGS) $*.o $<
+
+UIP=	../contiki/uip/uip.o \
+	uip/uip_arch.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uiplib.o 
+
+
+#	../contiki/uip/uip-signal.o
+#	../contiki/uip/uip_main.o \
+
+
+WWW=	../contiki/apps/www.o \
+	../contiki/apps/webclient.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/http-user-agent-string.o \
+	../contiki/apps/htmlparser.o \
+	../contiki/apps/html-strings.o 
+
+EMAIL= ../contiki/apps/email.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/ctk-textedit.o \
+	../contiki/uip/socket.o \
+	./lib/lc-asm.o \
+	../lib/memb.o 
+
+WEBSERVER= ../contiki/apps/webserver.o ../contiki/apps/httpd.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/httpd-fs.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	../contiki/apps/httpd-cgi.o \
+	../contiki/lib/memb.o \
+	./lib/lc-asm.o 
+
+TELNET= ../contiki/apps/simpletelnet.o ../contiki/apps/telnet.o 
+
+WGET= apps/wget.o ../contiki/apps/webclient.o \
+	../contiki/apps/http-strings.o \
+	../contiki/apps/http-user-agent-string.o 
+
+clean: 
+	rm -f ../arch/*.o
+	rm -f ../loader/*.o
+	rm -f ../contiki/ctk/*.o 
+	rm -f ../contiki/ctk/*.asm
+	rm -f ../contiki/ctk/*.lst
+	rm -f ../contiki/ctk/*.map
+	rm -f ../contiki/ctk/*.sym
+	rm -f ../contiki/ctk/*.rst
+	rm -f ../contiki/ek/*.o 
+	rm -f ../contiki/ek/*.asm 
+	rm -f ../contiki/ek/*.lst
+	rm -f ../contiki/ek/*.map
+	rm -f ../contiki/ek/*.sym
+	rm -f ../contiki/ek/*.rst
+	rm -f ../contiki/lib/*.o 
+	rm -f ../contiki/lib/*.asm 
+	rm -f ../contiki/lib/*.lst
+	rm -f ../contiki/lib/*.map
+	rm -f ../contiki/lib/*.sym
+	rm -f ../contiki/lib/*.rst
+	rm -f ../contiki/apps/*.o 
+	rm -f ../contiki/apps/*.ihx
+	rm -f ../contiki/apps/*.lnk 
+	rm -f ../contiki/apps/*.asm 
+	rm -f ../contiki/apps/*.lst
+	rm -f ../contiki/apps/*.sym
+	rm -f ../contiki/apps/*.prg
+	rm -f ../contiki/apps/*.dsc
+	rm -f ../contiki/apps/*.ams
+	rm -f ../contiki/apps/*.bin
+	rm -f ../contiki/apps/*.map
+	rm -f ../contiki/apps/*.rst
+	rm -f ../contiki/uip/*.o 
+	rm -f ../contiki/uip/*.ihx
+	rm -f ../contiki/uip/*.lnk 
+	rm -f ../contiki/uip/*.asm 
+	rm -f ../contiki/uip/*.lst
+	rm -f ../contiki/uip/*.sym
+	rm -f ../contiki/uip/*.prg
+	rm -f ../contiki/uip/*.dsc
+	rm -f ../contiki/uip/*.ams
+	rm -f ../contiki/uip/*.bin
+	rm -f ./apps/*.o 
+	rm -f ./apps/*.ihx
+	rm -f ./apps/*.lnk 
+	rm -f ./apps/*.asm 
+	rm -f ./apps/*.lst
+	rm -f ./apps/*.sym
+	rm -f ./apps/*.prg
+	rm -f ./apps/*.dsc
+	rm -f ./apps/*.ams
+	rm -f ./apps/*.bin
+	rm -f ./apps/*.map
+	rm -f ./apps/*.rst
+	rm -f ./ctk/*.o 
+	rm -f ./ctk/*.ihx
+	rm -f ./ctk/*.lnk 
+	rm -f ./ctk/*.asm 
+	rm -f ./ctk/*.lst
+	rm -f ./ctk/*.sym
+	rm -f ./ctk/*.prg
+	rm -f ./ctk/*.dsc
+	rm -f ./ctk/*.ams
+	rm -f ./ctk/*.bin
+	rm -f ./ctk/*.map
+	rm -f ./ctk/*.rst
+	rm -f lib/*.o 
+	rm -f lib/*.asm 
+	rm -f lib/*.lst
+	rm -f lib/*.map
+	rm -f lib/*.sym
+	rm -f loader/*.o 
+	rm -f loader/*.asm 
+	rm -f loader/*.lst
+	rm -f loader/*.map
+	rm -f loader/*.sym
+	rm -f uip/*.o 
+	rm -f uip/*.asm 
+	rm -f uip/*.lst
+	rm -f uip/*.map
+	rm -f uip/*.sym
+	rm -f arch/*.o 
+	rm -f arch/*.asm 
+	rm -f arch/*.lst
+	rm -f arch/*.map
+	rm -f arch/*.sym
+
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.cpc b/contiki-cpc/contiki-cpc/Makefile.cpc
new file mode 100644
index 0000000..3f8a4d7
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.cpc
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+        -DWITH_ASCII \
+	-DCTK_CONIO \
+	-DWITH_LOADER_ARCH \
+	-DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/slipdev.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/tcpdump.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uip-fw.o \
+	../contiki/uip/uip-fw-service.o \
+	../contiki/uip/uip-split.o \
+	../contiki/uip/uip.o \
+	../contiki/uip/uip_arp.o \
+	../contiki/uip/uiplib.o \
+	./uip/uip_arch.o \
+	./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+	./loader/rel.o \
+	./arch/key.o \
+	./arch/mem.o \
+	./arch/malloc.o \
+	./arch/clock.o \
+	./loader/dir.o \
+	./loader/loader-arch-cpc.o \
+	./arch/putchar.o \
+	./arch/uip.o \
+	./arch/conio.o \
+	./apps/configedit.o \
+	./apps/configedit-dsc.o \
+	../contiki/apps/directory.o \
+	./apps/directory-dsc.o \
+	../contiki/apps/processes.o \
+	../contiki/apps/processes-dsc.o \
+	../contiki/apps/program-handler.o \
+	../contiki/ctk/ctk.o \
+	../contiki/ctk/ctk-conio-service.o \
+	../contiki/ctk/ctk-draw.o \
+	../contiki/ctk/ctk-term-in.o \
+	../contiki/ctk/ctk-term-out.o \
+	../contiki/ctk/ctk-term.o \
+	../contiki/ctk/ctk-termtelnet.o \
+	../contiki/ctk/ctk-vncfont.o \
+	../contiki/ctk/vnc-server.o \
+	../contiki/ek/ek-service.o \
+	../contiki/ek/ek.o \
+	../contiki/ek/arg.o \
+	../contiki/ek/mt.o \
+	../contiki/lib/cfs.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/lib/list.o \
+	../contiki/lib/memb.o \
+	../contiki/lib/timer.o \
+	../contiki/lib/strncasecmp.o \
+	./loader/cfs-cpc.o \
+	./arch/main.o \
+	./arch/arch.o \
+	$(UIP)
+
+
+contiki: $(CONTIKI_OBJ)
+	$(LD) -f arch/contiki.lnk
+	./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+	./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+	./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+	./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.cpc-net b/contiki-cpc/contiki-cpc/Makefile.cpc-net
new file mode 100644
index 0000000..f76aee2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.cpc-net
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc-net,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+all: contikin
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+        -DWITH_ASCII \
+	-DCTK_CONIO \
+	-DWITH_LOADER_ARCH \
+	-DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+	../contiki/uip/resolv.o \
+	../contiki/uip/slipdev.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/tcpdump.o \
+	../contiki/uip/tcpip.o \
+	../contiki/uip/uip-fw.o \
+	../contiki/uip/uip-fw-service.o \
+	../contiki/uip/uip-split.o \
+	../contiki/uip/uip.o \
+	../contiki/uip/uip_arp.o \
+	../contiki/uip/uiplib.o \
+	./uip/uip_arch.o \
+	./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+	./loader/rel.o \
+	./arch/key.o \
+	./arch/mem.o \
+	./arch/malloc.o \
+	./arch/clock.o \
+	./loader/dir.o \
+	./loader/loader-arch-cpc.o \
+	./arch/putchar.o \
+	./arch/uip.o \
+	./arch/conio.o \
+	./apps/configedit.o \
+	./apps/configedit-dsc.o \
+	../contiki/apps/directory.o \
+	./apps/directory-dsc.o \
+	../contiki/apps/processes.o \
+	../contiki/apps/processes-dsc.o \
+	../contiki/apps/program-handler.o \
+	../contiki/ctk/ctk.o \
+	../contiki/ctk/ctk-conio-service.o \
+	../contiki/ctk/ctk-draw.o \
+	../contiki/ctk/ctk-term-in.o \
+	../contiki/ctk/ctk-term-out.o \
+	../contiki/ctk/ctk-term.o \
+	../contiki/ctk/ctk-termtelnet.o \
+	../contiki/ctk/ctk-vncfont.o \
+	../contiki/ctk/vnc-server.o \
+	../contiki/ek/ek-service.o \
+	../contiki/ek/ek.o \
+	../contiki/ek/arg.o \
+	../contiki/ek/mt.o \
+	../contiki/lib/cfs.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/lib/list.o \
+	../contiki/lib/memb.o \
+	../contiki/lib/timer.o \
+	../contiki/lib/strncasecmp.o \
+	./loader/cfs-cpc.o \
+	./arch/main.o \
+	./arch/arch.o \
+	$(UIP)
+
+
+contikin: $(CONTIKI_OBJ)
+	$(LD) -f arch/contiki-uip.lnk
+	./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+	./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+	./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+	./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.netprogs b/contiki-cpc/contiki-cpc/Makefile.netprogs
new file mode 100644
index 0000000..e05a810
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.netprogs
@@ -0,0 +1,242 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.netprogs,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+	../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+	../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+	../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+	../contiki/apps/email.prg ../contiki/apps/email.dsc \
+	../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+	../contiki/apps/wget.dsc \
+	../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+#	../contiki/apps/irc.prg ../contiki/apps/irc.dsc 
+#	../contiki/apps/wget.prg 
+#	../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: 	./arch/crt0-dsc.o \
+	./arch/crt0-prg.o \
+	./arch/contiki_labels.o \
+	./loader/loader-arch-module.o \
+	$(UIP_PRGS)
+
+SYS=cpc
+
+include Makefile.common 
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+	-DWITH_ASCII \
+	-DWITH_CONIO \
+	-DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+	bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+%.dsc: %-dsc.o 
+	$(MAKE_DSC)
+
+define MAKE_PRG
+	bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+	../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+	$(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+	$(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+	$(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+	$(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+	$(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+	$(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+	$(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+	$(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o	\
+	lib/lc-asm.o
+	$(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+	$(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	./lib/lc-asm.o 
+	$(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+	../contiki/apps/ftpc.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+	$(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ 	../contiki/apps/shell.o \
+	../contiki/lib/memb.o \
+	../contiki/apps/telnetd-gui.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+	$(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+	$(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+	../contiki/apps/vnc-viewer.o \
+	./apps/vnc-draw.o 
+
+../contiki/apps/conio.prg: \
+	../contiki/ctk/ctk-conio-service.o \
+	./arch/conio.o
+	$(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o 
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+	$(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+#	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+	$(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+	$(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/contiki-cpc/Makefile.programs b/contiki-cpc/contiki-cpc/Makefile.programs
new file mode 100644
index 0000000..8e98e91
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.programs
@@ -0,0 +1,263 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.1 2006/04/17 15:11:36 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+	../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+	../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+	../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+	../contiki/apps/email.prg ../contiki/apps/email.dsc \
+	../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+	../contiki/apps/wget.dsc \
+	../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+#	../contiki/apps/irc.prg ../contiki/apps/irc.dsc 
+#	../contiki/apps/wget.prg 
+#	../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: 	./arch/crt0-dsc.o \
+	./arch/crt0-prg.o \
+	./arch/contiki_labels.o \
+	./loader/loader-arch-module.o \
+	./apps/welcome.prg \
+	../contiki/apps/conio.prg \
+	../contiki/apps/about.prg ../contiki/apps/about.dsc \
+	../contiki/apps/netconf.prg ../contiki/apps/netconf.dsc \
+	../contiki/apps/process.prg ../contiki/apps/process.dsc \
+	../contiki/apps/calc.prg ../contiki/apps/calc.dsc \
+	../contiki/apps/editor.prg ../contiki/apps/editor.dsc \
+	../contiki/apps/dir.prg ./apps/dir.dsc \
+	./apps/config.prg \
+	./apps/confedit.prg \
+	./apps/confedit.dsc \
+	../contiki/apps/shell.prg ../contiki/apps/shell.dsc 
+#	$(UIP_PRGS) \
+
+#	./cfs-cpc.drv \
+#	./ctk-text.drv \
+#	./ctk-default.drv \
+#	./ctk-80col.drv \
+#	./slip.drv slip.dsc \
+#	./cgterm.prg cgterm.dsc \
+
+#	./apps/memstat.prg ./apps/memstat.dsc \
+
+SYS=cpc
+
+include Makefile.common 
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+	-DWITH_ASCII \
+	-DWITH_CONIO \
+	-DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+	bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+%.dsc: %-dsc.o 
+	$(MAKE_DSC)
+
+define MAKE_PRG
+	bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+	$(LD) -f $@.lnk
+	bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+	bin/addhead  $@.bin $@.bin.ams
+	bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef	
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+	../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+	$(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+	$(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+	$(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+	$(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+	$(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+	$(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+	$(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+	$(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o	\
+	lib/lc-asm.o
+	$(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+	$(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+	../contiki/lib/ctk-filedialog.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+	../contiki/lib/ctk-textedit.o \
+	../contiki/apps/smtp-socket.o \
+	../contiki/apps/smtp-strings.o \
+	../contiki/uip/socket.o \
+	../contiki/uip/uipbuf.o \
+	./lib/lc-asm.o 
+	$(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+	../contiki/apps/ftpc.o \
+	../contiki/lib/memb.o
+	$(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+	$(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+	$(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ 	../contiki/apps/shell.o \
+	../contiki/lib/memb.o \
+	../contiki/apps/telnetd-gui.o
+	$(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o 
+	$(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+	$(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+	$(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+	$(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+	$(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+	../contiki/apps/vnc-viewer.o \
+	./apps/vnc-draw.o 
+
+../contiki/apps/conio.prg: \
+	../contiki/ctk/ctk-conio-service.o \
+	./arch/conio.o
+	$(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o 
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+	$(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+#	cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+#	cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+	$(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+	$(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/contiki-cpc/README b/contiki-cpc/contiki-cpc/README
new file mode 100644
index 0000000..854e27f
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/README
@@ -0,0 +1,2 @@
+This is the Amstrad CPC port of Contiki, maintained by Kevin Thacker
+<amstrad@aiind.upv.es>
diff --git a/contiki-cpc/contiki-cpc/arch/contiki_labels.s b/contiki-cpc/contiki-cpc/arch/contiki_labels.s
new file mode 100644
index 0000000..8192104
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/contiki_labels.s
@@ -0,0 +1,346 @@
+__jpbc == 0x0107
+_kbhit == 0x0109
+_cgetc == 0x0115
+_calc_free_ram == 0x011B
+_get_ram_start == 0x0183
+_get_ram_end == 0x0187
+ram_start == 0x018B
+ram_end == 0x018D
+__sdcc_heap_init == 0x018F
+__sdcc_heap_init_start == 0x018F
+__sdcc_heap_init_end == 0x021B
+_malloc == 0x021B
+_malloc_start == 0x021B
+_free == 0x0366
+_free_start == 0x0366
+_malloc_end == 0x0366
+_free_end == 0x03CE
+__clock_init == 0x03CE
+event_routine == 0x03DC
+__clock_val == 0x03E6
+event_block == 0x03E8
+_loader_arch_load == 0x03F1
+_loader_arch_load_start == 0x03F1
+_loader_arch_load_end == 0x0455
+_loader_arch_load_dsc == 0x0455
+_loader_arch_load_dsc_start == 0x0455
+_loader_arch_load_dsc_end == 0x04A7
+_loader_arch_free == 0x04A7
+_loader_arch_free_start == 0x04A7
+_loader_arch_free_end == 0x04BF
+_loader_arch_free_dsc == 0x04BF
+_loader_arch_free_dsc_start == 0x04BF
+_loader_arch_free_dsc_end == 0x04D7
+_get_file_length == 0x04D7
+_load_file == 0x04FB
+_relocate == 0x0519
+_cfs_cpc_init == 0x05B8
+_cfs_cpc_init_start == 0x05B8
+_cfs_cpc_init_end == 0x05DB
+_cfs_find_service == 0x08B2
+_cfs_find_service_start == 0x08B2
+_cfs_find_service_end == 0x08CE
+__readdir == 0x08E8
+fetch_directory == 0x0901
+_program_handler_add == 0x091D
+_program_handler_add_start == 0x091D
+_program_handler_add_end == 0x0977
+_program_handler_init == 0x0A59
+_program_handler_init_start == 0x0A59
+_program_handler_init_end == 0x0AB0
+_pnarg_init == 0x0AB8
+_pnarg_init_start == 0x0AB8
+_pnarg_init_end == 0x0ACB
+_program_handler_load == 0x0B62
+_program_handler_load_start == 0x0B62
+_program_handler_load_end == 0x0BA9
+_program_handler_screensaver == 0x0BB7
+_program_handler_screensaver_sta == 0x0BB7
+_program_handler_screensaver_end == 0x0BE6
+_ctk_restore == 0x109A
+_ctk_restore_start == 0x109A
+_ctk_init_start == 0x10BF
+_ctk_restore_end == 0x10BF
+_ctk_init == 0x10BF
+_ctk_init_end == 0x11F2
+_ctk_mode_set == 0x11FA
+_ctk_mode_set_start == 0x11FA
+_ctk_mode_get == 0x120F
+_ctk_mode_get_start == 0x120F
+_ctk_mode_set_end == 0x120F
+_ctk_mode_get_end == 0x1217
+_ctk_icon_add == 0x1217
+_ctk_icon_add_start == 0x1217
+_ctk_dialog_open == 0x1243
+_ctk_icon_add_end == 0x1243
+_ctk_dialog_open_start == 0x1243
+_ctk_dialog_open_end == 0x126A
+_ctk_dialog_close == 0x126A
+_ctk_dialog_close_start == 0x126A
+_ctk_window_open == 0x1283
+_ctk_window_open_start == 0x1283
+_ctk_dialog_close_end == 0x1283
+_ctk_window_close == 0x139C
+_ctk_window_close_start == 0x139C
+_ctk_window_open_end == 0x139C
+_ctk_window_close_end == 0x14CB
+_ctk_window_clear_start == 0x163B
+_ctk_window_clear == 0x163B
+_ctk_menu_add_start == 0x1695
+_ctk_window_clear_end == 0x1695
+_ctk_menu_add == 0x1695
+_ctk_menu_add_end == 0x1707
+_ctk_menu_remove == 0x1707
+_ctk_menu_remove_start == 0x1707
+_ctk_menu_remove_end == 0x178B
+_ctk_desktop_redraw == 0x18E0
+_ctk_desktop_redraw_start == 0x18E0
+_ctk_window_redraw_start == 0x192F
+_ctk_desktop_redraw_end == 0x192F
+_ctk_window_redraw == 0x192F
+_ctk_window_redraw_end == 0x19AC
+_ctk_window_new == 0x1B5F
+_ctk_window_new_start == 0x1B5F
+_ctk_window_new_end == 0x1B93
+_ctk_dialog_new == 0x1B93
+_ctk_dialog_new_start == 0x1B93
+_ctk_menu_new == 0x1BB9
+_ctk_menu_new_start == 0x1BB9
+_ctk_dialog_new_end == 0x1BB9
+_ctk_menuitem_add == 0x1C1B
+_ctk_menu_new_end == 0x1C1B
+_ctk_menuitem_add_start == 0x1C1B
+_ctk_menuitem_add_end == 0x1C9E
+_ctk_widget_redraw == 0x1DCD
+_ctk_widget_redraw_start == 0x1DCD
+_ctk_widget_add == 0x1DF7
+_ctk_widget_add_start == 0x1DF7
+_ctk_widget_redraw_end == 0x1DF7
+_ctk_desktop_width_start == 0x1EA6
+_ctk_widget_add_end == 0x1EA6
+_ctk_desktop_width == 0x1EA6
+_ctk_desktop_width_end == 0x1EB4
+_ctk_desktop_height == 0x1EB4
+_ctk_desktop_height_start == 0x1EB4
+_ctk_desktop_height_end == 0x1EC2
+_ctk_draw_init == 0x2EFD
+_ctk_draw_init_start == 0x2EFD
+_ctk_draw_clear == 0x2F46
+_ctk_draw_init_end == 0x2F46
+_ctk_draw_clear_start == 0x2F46
+_ctk_draw_clear_window == 0x2F79
+_ctk_draw_clear_window_start == 0x2F79
+_ctk_draw_clear_end == 0x2F79
+_ctk_draw_clear_window_end == 0x2FBA
+_ctk_draw_window == 0x2FBA
+_ctk_draw_window_start == 0x2FBA
+_ctk_draw_dialog_start == 0x2FFB
+_ctk_draw_window_end == 0x2FFB
+_ctk_draw_dialog == 0x2FFB
+_ctk_draw_widget == 0x302B
+_ctk_draw_dialog_end == 0x302B
+_ctk_draw_widget_start == 0x302B
+_ctk_draw_menus_start == 0x306C
+_ctk_draw_widget_end == 0x306C
+_ctk_draw_menus == 0x306C
+_ctk_draw_menus_end == 0x309C
+_ctk_draw_width == 0x309C
+_ctk_draw_width_start == 0x309C
+_ctk_draw_width_end == 0x30BE
+_ctk_draw_height == 0x30BE
+_ctk_draw_height_start == 0x30BE
+_ctk_mouse_xtoc == 0x30E0
+_ctk_mouse_xtoc_start == 0x30E0
+_ctk_draw_height_end == 0x30E0
+_ctk_mouse_ytoc == 0x3115
+_ctk_mouse_ytoc_start == 0x3115
+_ctk_mouse_xtoc_end == 0x3115
+_ctk_draw_quit == 0x314A
+_ctk_mouse_ytoc_end == 0x314A
+_ctk_draw_quit_start == 0x314A
+_ctk_draw_quit_end == 0x3168
+_ek_service_start == 0x3173
+_ek_service_start_start == 0x3173
+_ek_service_find_start == 0x31B2
+_ek_service_start_end == 0x31B2
+_ek_service_find == 0x31B2
+_ek_service_state_start == 0x31DF
+_ek_service_find_end == 0x31DF
+_ek_service_state == 0x31DF
+_ek_service_reset == 0x3229
+_ek_service_reset_start == 0x3229
+_ek_service_state_end == 0x3229
+_ek_service_reset_end == 0x323F
+_ek_alloc_event == 0x323F
+_ek_alloc_event_start == 0x323F
+_ek_alloc_event_end == 0x324A
+_ek_start_start == 0x3369
+_ek_start == 0x3369
+_ek_exit == 0x33F8
+_ek_start_end == 0x33F8
+_ek_exit_start == 0x33F8
+_ek_process == 0x352B
+_ek_process_start == 0x352B
+_ek_exit_end == 0x352B
+_ek_init == 0x3558
+_ek_init_start == 0x3558
+_ek_process_end == 0x3558
+_ek_process_event == 0x35AC
+_ek_init_end == 0x35AC
+_ek_process_event_start == 0x35AC
+_ek_process_poll == 0x3743
+_ek_process_event_end == 0x3743
+_ek_process_poll_start == 0x3743
+_ek_run == 0x378B
+_ek_run_start == 0x378B
+_ek_process_poll_end == 0x378B
+_ek_post == 0x37AD
+_ek_post_start == 0x37AD
+_ek_run_end == 0x37AD
+_ek_post_synch == 0x3828
+_ek_post_synch_start == 0x3828
+_ek_post_end == 0x3828
+_ek_post_synch_end == 0x3887
+_ek_find == 0x3887
+_ek_find_start == 0x3887
+_ek_find_end == 0x38F2
+_ek_replace == 0x38F2
+_ek_replace_start == 0x38F2
+_ek_replace_end == 0x394A
+_ek_procstate == 0x394A
+_ek_procstate_start == 0x394A
+_ek_procstate_end == 0x397F
+_arg_init == 0x397F
+_arg_init_start == 0x397F
+_arg_init_end == 0x3986
+_arg_alloc == 0x3986
+_arg_alloc_start == 0x3986
+_arg_alloc_end == 0x39A4
+_arg_free == 0x39A4
+_arg_free_start == 0x39A4
+_arg_free_end == 0x39C5
+_list_init == 0x39C5
+_list_init_start == 0x39C5
+_list_init_end == 0x39E1
+_list_head == 0x39E1
+_list_head_start == 0x39E1
+_list_copy_start == 0x39FD
+_list_head_end == 0x39FD
+_list_copy == 0x39FD
+_list_copy_end == 0x3A22
+_list_tail == 0x3A22
+_list_tail_start == 0x3A22
+_list_add == 0x3A54
+_list_add_start == 0x3A54
+_list_tail_end == 0x3A54
+_list_push_start == 0x3A95
+_list_add_end == 0x3A95
+_list_push == 0x3A95
+_list_push_end == 0x3AC0
+_list_chop == 0x3AC0
+_list_chop_start == 0x3AC0
+_list_pop == 0x3B46
+_list_pop_start == 0x3B46
+_list_chop_end == 0x3B46
+_list_pop_end == 0x3B71
+_timer_set == 0x3B71
+_timer_set_start == 0x3B71
+_timer_set_end == 0x3B9D
+_timer_reset == 0x3B9D
+_timer_reset_start == 0x3B9D
+_timer_expired == 0x3BBA
+_timer_reset_end == 0x3BBA
+_timer_expired_start == 0x3BBA
+_timer_expired_end == 0x3C04
+_directory_dsc == 0x3C04
+_directory_icon == 0x3C5D
+_configedit_dsc == 0x3C90
+_configedit_icon == 0x3CE9
+_processes_dsc == 0x3D2F
+_processes_icon == 0x3D88
+_uip_fw_forward_start == 0x3DC2
+_uip_fw_forward == 0x3DC2
+_uip_fw_forward_end == 0x3DC5
+_uip_fw_periodic == 0x3DC5
+_uip_fw_periodic_start == 0x3DC5
+_uip_fw_periodic_end == 0x3DC6
+_main_start == 0x3DEF
+_main_end == 0x3E48
+_reset == 0x3E68
+_reset_start == 0x3E68
+_reset_end == 0x3E69
+_clock_time_start == 0x3E6E
+_clock_time == 0x3E6E
+_ctk_arch_isprint == 0x3E72
+_clock_time_end == 0x3E72
+_ctk_arch_isprint_start == 0x3E72
+_ctk_arch_isprint_end == 0x3E8D
+_strcpy == 0x3E8D
+_strcpy_start == 0x3E8D
+_strcpy_end == 0x3EB2
+__divschar_rrx_s == 0x3EB2
+__divschar_rrx_hds == 0x3EB9
+__modschar_rrx_s == 0x3EC0
+__modschar_rrx_hds == 0x3EC7
+__divsint_rrx_s == 0x3ECE
+__divsint_rrx_hds == 0x3EDA
+__modsint_rrx_s == 0x3EE2
+__modsint_rrx_hds == 0x3EEE
+__divuchar_rrx_s == 0x3EF6
+__divuchar_rrx_hds == 0x3EFD
+__moduchar_rrx_s == 0x3F04
+__moduchar_rrx_hds == 0x3F0B
+__divuint_rrx_s == 0x3F12
+__divuint_rrx_hds == 0x3F1E
+__moduint_rrx_s == 0x3F26
+__moduint_rrx_hds == 0x3F32
+.mod8 == 0x3F3A
+.div8 == 0x3F3A
+.mod16 == 0x3F42
+.div16 == 0x3F42
+.modu8 == 0x3F7F
+.divu8 == 0x3F7F
+.modu16 == 0x3F82
+.divu16 == 0x3F82
+_strncmp == 0x3FB3
+_strncmp_start == 0x3FB3
+_strncmp_end == 0x4040
+_isprint == 0x4040
+_isprint_start == 0x4040
+_isprint_end == 0x4062
+_memset == 0x4062
+_memset_start == 0x4062
+_memset_end == 0x40AA
+__mulschar_rrx_s == 0x40AA
+__mulschar_rrx_hds == 0x40B1
+__muluchar_rrx_s == 0x40BD
+__mulint_rrx_s == 0x40CA
+__mulint_rrx_hds == 0x40D6
+__muluchar_rrx_hds == 0x40D6
+_strncpy == 0x40EF
+_strncpy_start == 0x40EF
+_strncpy_end == 0x415E
+_strlen_start == 0x415E
+_strlen == 0x415E
+_strlen_end == 0x417E
+_ctk_signal_keypress == 0x439D
+_ctk_signal_widget_activate == 0x439E
+_ctk_signal_button_activate == 0x439F
+_ctk_signal_widget_select == 0x43A0
+_ctk_signal_button_hover == 0x43A1
+_ctk_signal_hyperlink_activate == 0x43A2
+_ctk_signal_hyperlink_hover == 0x43A3
+_ctk_signal_menu_activate == 0x43A4
+_ctk_signal_window_close == 0x43A5
+_ctk_signal_pointer_move == 0x43A6
+_ctk_signal_pointer_button == 0x43A7
+_ctk_screensaver_timeout == 0x43AA
+_ctk_draw_windowborder_width == 0x43BC
+_ctk_draw_windowborder_height == 0x43BD
+_ctk_draw_windowtitle_height == 0x43BE
+_ek_procs == 0x43C2
+_ek_proclist == 0x43C4
+_ek_current == 0x4404
+_ek_event_quit == 0x4406
+_ek_event_msg == 0x4407
+_ek_poll_request == 0x448B
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-backup.s b/contiki-cpc/contiki-cpc/arch/crt0-backup.s
new file mode 100644
index 0000000..b014aa8
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-backup.s
@@ -0,0 +1,33 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+    .module crt0
+	.globl	_main
+	.globl _progend
+	.area _HEADER (ABS)
+	.org 	0x100 ;; Start from address &100
+init:
+
+;; Initialise global variables
+    call    gsinit
+	call	_main
+
+_exit::
+	ret
+
+	;; Ordering of segments for the linker.
+	.area	_HOME
+	.area	_CODE
+	.area	_DATA
+	 .area   _BSS
+	
+	.area   _GSINIT
+gsinit::	
+
+    .area   _GSFINAL
+    ret
+    	.area   _HEAP
+_progend::
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-dsc.s b/contiki-cpc/contiki-cpc/arch/crt0-dsc.s
new file mode 100644
index 0000000..381bc27
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-dsc.s
@@ -0,0 +1,26 @@
+;; File: crt0-dsc.s
+
+    .module crt0
+	.globl	_main
+
+	.area _HEADER (REL)
+;;	.org 	0x100 ;; Start from address &100
+
+init:
+_main:
+	;; Ordering of segments for the linker.
+	.area	_HOME (REL)
+	.area	_CODE (REL)
+    .area   _GSINIT (REL)
+    .area   _GSFINAL (REL)
+        
+	.area	_DATA (REL)
+    .area   _BSS (REL)
+    .area   _HEAP (REL)
+
+   .area   _CODE (REL)
+	
+_exit::
+	.area   _GSINIT (REL)
+gsinit::	
+    .area   _GSFINAL (REL)
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-prg.s b/contiki-cpc/contiki-cpc/arch/crt0-prg.s
new file mode 100644
index 0000000..8984742
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-prg.s
@@ -0,0 +1,16 @@
+;; File: crt0-dsc.s
+
+    .module crt0
+	.area _HEADER (ABS)
+	.area _HOME (REL)	
+	.area _CODE (REL)
+	;; relocation data
+	.dw 0
+     .area _DATA (REL)
+    .area   _BSS (REL)
+    .area   _HEAP (REL)
+
+	.area   _GSINIT (REL)
+gsinit::	
+    .area   _GSFINAL (REL)
+	ret
diff --git a/contiki-cpc/contiki-cpc/arch/crt0.s b/contiki-cpc/contiki-cpc/arch/crt0.s
new file mode 100644
index 0000000..a8aafdb
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0.s
@@ -0,0 +1,35 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+    .module crt0
+	.globl	_main
+	.globl _progend
+	.globl __jpbc
+	.area	_HEADER (ABS)
+	;; Ordering of segments for the linker.
+	.area	_CODE
+init:
+
+;; Initialise global variables
+    call    gsinit
+	call	_main
+
+_exit::
+	ret
+__jpbc:
+	push bc
+	ret
+
+	.area	_DATA (REL)
+	 .area   _BSS (REL)
+	
+	.area   _GSINIT (REL)
+gsinit::	
+
+    .area   _GSFINAL (REL)
+    ret
+    	.area   _HEAP (REL)
+_progend::
diff --git a/contiki-cpc/contiki-cpc/arch/hires.s b/contiki-cpc/contiki-cpc/arch/hires.s
new file mode 100644
index 0000000..c482768
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/hires.s
@@ -0,0 +1,101 @@
+;; Hires: 
+;;
+;; Mode 0, 40 columns. Each character is 4 pixels wide and 8 pixels tall.
+;; Each character is two bytes wide and 8 lines tall.
+;;
+;; The graphics for each character is a bitmap defined using
+;; pen 0 and pen 15.
+;;
+;; The bitmap is processed at runtime to convert the font to the 
+;; appropiate pixel colours.
+		.area _CODE
+;; This table converts between pen index (0-15) and pixel bitmap.
+.pen_table
+defb #00	;; pen 0  (%00000000)
+defb #c0	;; pen 1  (%11000000)
+defb #0c	;; pen 2  (%00001100)
+defb #cc	;; pen 3  (%11001100)
+defb #30	;; pen 4  (%00110000)
+defb #f0	;; pen 5  (%11110000)
+defb #3c	;; pen 6  (%00111100)
+defb #fc	;; pen 7  (%11111100)
+defb #03	;; pen 8  (%00000011)
+defb #c3	;; pen 9  (%11000011)
+defb #0f	;; pen 10 (%00001111)
+defb #cf	;; pen 11 (%11001111)
+defb #33	;; pen 12 (%00110011)
+defb #f3	;; pen 13 (%11110011)
+defb #3f	;; pen 14 (%00111111)
+defb #ff	;; pen 15 (%11111111)
+
+;; A = pen
+.get_pen_mask
+ld hl,pen_table
+add a,l
+ld l,a
+ld a,h
+adc a,0
+ld h,a
+ld a,(hl)
+ret
+
+.set_pen
+call get_pen_mask
+ld (pen_mask+1),a
+ld (pen_mask2+1),a
+ret
+
+.set_paper
+call get_pen_mask
+ld (paper_mask+1),a
+ld (paper_mask2+1),a
+ret
+
+;; enter:
+;; HL = current memory address
+;; exit:
+;; HL = memory address of byte immediatly below
+;; AF corrupt.
+.scr_next_line
+ld a,h
+add a,8
+ld h,a
+ret nc
+ld a,l
+add a,&50
+ld l,a
+ld a,h
+adc a,&c0
+ld h,a
+ret
+
+;; enter:
+;; HL = screen address
+;; DE = character pixel graphics
+;; exit:
+;; AF, BC, HL, DE corrupt
+.plot_char
+ld b,8
+.pc1
+ld a,(de)		;; convert 'on' pixels
+.pen_mask and 1
+ld c,a
+ld a,(de)
+cpl 
+.paper_mask and 1
+or c
+ld (hl),a
+inc l
+ld a,(de)
+.pen_mask2 and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask2 and 1
+or c
+ld (hl),a
+dec l
+call scr_next_line
+djnz pc1
+ret
+
diff --git a/contiki-cpc/contiki-cpc/arch/key.s b/contiki-cpc/contiki-cpc/arch/key.s
new file mode 100644
index 0000000..8ca55ad
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/key.s
@@ -0,0 +1,33 @@
+; unsigned char kbhit (void);
+; Return true if there's a key waiting, return false if not 
+; TESTED
+
+.globl _kbhit
+		.area _CODE
+_kbhit::
+		call	0xBB09	; KM READ KEY
+		ld (key),a
+		ld		l,#1
+		ret		c
+		ld		l,#0
+		ret
+
+; char cgetc (void);
+; Return a character from the keyboard. If there is no character available,
+; the functions waits until the user does press a key. If cursor is set to
+; 1 (see below), a blinking cursor is displayed while waiting.
+; TESTED
+
+.globl _cgetc
+
+_cgetc::	
+		ld a,(key)
+		ld l,a
+		ret
+
+;;		call	0xBB09
+;;		jr nc,_cgetc
+;;		ld		l,a
+;;		ret
+
+key:		.db 0
diff --git a/contiki-cpc/contiki-cpc/arch/main.c b/contiki-cpc/contiki-cpc/arch/main.c
new file mode 100644
index 0000000..a7f8d2c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/main.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main.c,v 1.1 2006/04/17 15:11:44 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "log.h"
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "configedit-dsc.h"
+#include "directory-dsc.h"
+#include "processes-dsc.h"
+
+//#include "cfs-cbm.h"
+#include "cfs-cpc.h"
+
+#include "clock.h"
+
+#include "arch.h"
+
+unsigned char
+uip_fw_forward(void)
+{
+  return 0;
+}
+void
+uip_fw_periodic(void)
+{
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(init_eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    program_handler_load("conio.prg",NULL);
+//    program_handler_load("config.prg", NULL);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+	   init_eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+#if LOG_CONF_ENABLED
+void
+log_message(char *part1, char *part2)
+{
+}
+#endif
+void
+main(void)
+{
+  
+ log_message("Starting ", CONTIKI_VERSION_STRING);
+  
+  ek_init();
+
+  ek_start(&init);
+    
+ // log_message(": TCP/IP", "");
+    
+ // tcpip_init(NULL);
+
+ // resolv_init(NULL); 
+
+  log_message(": CTK GUI", "");
+  ctk_init();
+
+  log_message(": Initial filesystem", "");
+  cfs_cpc_init(NULL);
+
+  program_handler_init();
+   
+  program_handler_add(&directory_dsc, "Directory", 1);
+//  program_handler_add(&configedit_dsc, "Configuration", 1);
+  program_handler_add(&processes_dsc, "Processes", 1);  
+  
+  
+  log_message("Starting process scheduling", "");  
+
+  while(1) {
+    if(ek_run() == 0) {
+      program_handler_load("welcome.prg", NULL);
+      break;
+    }
+  }
+    
+  while(1) {
+    ek_run();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+reset(void)
+{
+/*  asm("lda #$36");
+  asm("sta $01");
+  asm("jmp $fce2");
+*/
+}
+
diff --git a/contiki-cpc/contiki-cpc/arch/malloc.c b/contiki-cpc/contiki-cpc/arch/malloc.c
new file mode 100644
index 0000000..d4e91b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/malloc.c
@@ -0,0 +1,268 @@
+#include <sdcc-lib.h>
+#include <malloc.h>
+
+#if _SDCC_MALLOC_TYPE_MLH
+
+typedef struct _MEMHEADER MEMHEADER;
+
+struct _MEMHEADER
+{
+  MEMHEADER *  next;
+  MEMHEADER *  prev;
+  unsigned int       len;
+  unsigned char      mem;
+};
+
+#define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
+
+/* These veriables are defined through the crt0 functions. */
+/* Base of this variable is the first byte of the heap. */
+//extern MEMHEADER _sdcc_heap_start;
+/* Address of this variable is the last byte of the heap. */
+//extern char _sdcc_heap_end;
+
+extern char *get_ram_start();
+extern char *get_ram_end();
+extern void calc_free_ram();
+extern char progend;
+
+static MEMHEADER *firstheader;
+/* setup two headers. One at start of free ram, second at end of free ram.
+ We find free ram range by asking Amstrad's firmware. */
+
+void
+_sdcc_heap_init(void)
+{
+  MEMHEADER *lastheader;
+  unsigned int size;
+  char * ramstart;
+
+  /* ask firmware for free ram */
+  calc_free_ram();
+
+  /* start of ram is either start of range given by firmware,
+  or end of program; whichever is largest */
+  ramstart = get_ram_start();
+  if (ramstart<&progend)
+	ramstart = &progend;
+
+  /* this is our first mem header */
+  firstheader = (MEMHEADER *)ramstart;
+  
+  /* this is the size of ram available */
+  size = get_ram_end() - ramstart;
+
+  /* calc address of last header */
+  lastheader = (MEMHEADER *)((char *)firstheader + size - HEADER_SIZE); 
+  
+  /* setup last header */
+  lastheader->next = NULL;
+  lastheader->prev = firstheader;
+  lastheader->len = 0;
+
+  /* setup first header */
+  firstheader->next = lastheader;
+  firstheader->prev       = NULL; //and mark first as first
+  firstheader->len        = 0;    //Empty and ready.
+}
+
+void *
+malloc (unsigned int size)
+{
+  MEMHEADER * current_header;
+  MEMHEADER * new_header;
+
+  if (size>(0xFFFF-HEADER_SIZE))
+    {
+      return NULL; //To prevent overflow in next line
+    }
+
+  size += HEADER_SIZE; //We need a memory for header too
+  current_header = firstheader;
+
+  while (1)
+    {
+      //    current
+      //    |   len       next
+      //    v   v         v
+      //....*****.........******....
+      //         ^^^^^^^^^
+      //           spare
+
+      if ((((unsigned int)current_header->next) -
+           ((unsigned int)current_header) -
+           current_header->len) >= size) 
+        {
+          break; //if spare is more than need
+        }
+      current_header = current_header->next;    //else try next             
+      if (!current_header->next)  
+        {
+          return NULL;  //if end_of_list reached    
+        }
+    }
+
+  if (!current_header->len)
+    { //This code works only for first_header in the list and only
+      current_header->len = size; //for first allocation
+      return &current_header->mem;
+    } 
+  else
+    {
+      //else create new header at the begin of spare
+      new_header = (MEMHEADER * )((char *)current_header + current_header->len);
+      new_header->next = current_header->next; //and plug it into the chain
+      new_header->prev = current_header;
+      current_header->next  = new_header;
+      if (new_header->next)
+        {
+          new_header->next->prev = new_header;
+        }
+      new_header->len  = size; //mark as used
+      return &new_header->mem;
+    }
+}
+
+void
+free (void *p)
+{
+  MEMHEADER *prev_header, *pthis;
+
+  if ( p ) //For allocated pointers only!
+    {
+      pthis = (MEMHEADER * )((char *)  p - HEADER_SIZE); //to start of header
+      if ( pthis->prev ) // For the regular header
+        {
+          prev_header = pthis->prev;
+          prev_header->next = pthis->next;
+          if (pthis->next)
+            {
+              pthis->next->prev = prev_header;
+            }
+        }
+      else
+        {
+          pthis->len = 0; //For the first header
+        }
+    }
+}
+
+#else
+
+            //--------------------------------------------------------------------
+            //Written by Dmitry S. Obukhov, 1997
+            //dso@usa.net
+            //--------------------------------------------------------------------
+            //Modified for SDCC by Sandeep Dutta, 1999
+            //sandeep.dutta@usa.net
+            //--------------------------------------------------------------------
+            //malloc and free functions implementation for embedded system
+            //Non-ANSI keywords are C51 specific.
+            // xdata - variable in external memory (just RAM)
+            //--------------------------------------------------------------------
+
+            #define MEMHEADER   struct MAH// Memory Allocation Header
+
+            MEMHEADER
+            {
+              MEMHEADER xdata *  next;
+              MEMHEADER xdata *  prev;
+              unsigned int       len;
+	      unsigned char      mem;
+            };
+
+            #define HEADER_SIZE (sizeof(MEMHEADER)-1)
+
+            //Static here means: can be accessed from this module only
+            static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
+            void init_dynamic_memory(MEMHEADER xdata * array, unsigned int size) 
+            {
+
+            //This function MUST be called after the RESET.
+            //Parameters: array - pointer to memory allocated by the linker
+            //            size  - size of this memory pool
+            //Example:
+            //     #define DYNAMIC_MEMORY_SIZE 0x2000
+            //     .....
+            //     unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
+            //     unsigned char xdata * current_buffer;
+            //     .....
+            //     void main(void)
+            //     {
+            //         ...
+            //         init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
+            //         Now it is possible to use malloc.
+            //         ...
+            //         current_buffer = malloc(0x100);
+            //
+            //
+
+              if ( !array ) /*Reserved memory starts on 0x0000 but it's NULL...*/
+              {             //So, we lost one byte!
+                 array = (MEMHEADER xdata * )((char xdata * ) array + 1) ;
+                 size --;
+              }
+              FIRST_MEMORY_HEADER_PTR = array;
+              //Reserve a mem for last header
+              array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
+              array->next->next = (void xdata * ) NULL; //And mark it as last
+              array->prev       = (void xdata * ) NULL; //and mark first as first
+              array->len        = 0;    //Empty and ready.
+            }
+
+            void  xdata * malloc (unsigned int size)
+            {
+              register MEMHEADER xdata * current_header;
+              register MEMHEADER xdata * new_header;
+
+              if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
+              size += HEADER_SIZE; //We need a memory for header too
+              current_header = FIRST_MEMORY_HEADER_PTR;
+              while (1)
+              {
+
+                //    current
+                //    |   len       next
+                //    v   v         v
+                //....*****.........******....
+                //         ^^^^^^^^^
+                //           spare
+
+                if ((((unsigned int)current_header->next) -
+                     ((unsigned int)current_header) -
+                     current_header->len) >= size) break; //if spare is more than need
+                current_header = current_header->next;    //else try next             
+                if (!current_header->next)  return (void xdata *) NULL;  //if end_of_list reached
+              }
+              if (!current_header->len)
+              { //This code works only for first_header in the list and only
+                 current_header->len = size; //for first allocation
+                 return ((xdata *)&(current_header->mem));
+              } //else create new header at the begin of spare
+              new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len);
+              new_header->next = current_header->next; //and plug it into the chain
+              new_header->prev = current_header;
+              current_header->next  = new_header;
+              if (new_header->next)  new_header->next->prev = new_header;
+              new_header->len  = size; //mark as used
+              return ((xdata *)&(new_header->mem));
+            }
+
+            void free (void xdata * p)
+            {
+              register MEMHEADER xdata * prev_header;
+              if ( p ) //For allocated pointers only!
+              {
+                  p = (MEMHEADER xdata * )((char xdata *)  p - HEADER_SIZE); //to start of header
+                  if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
+                  {
+                    prev_header = ((MEMHEADER xdata * ) p)->prev;
+                    prev_header->next = ((MEMHEADER xdata * ) p)->next;
+                    if (((MEMHEADER xdata * ) p)->next)
+		       ((MEMHEADER xdata * ) p)->next->prev = prev_header;
+                  }
+                  else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
+              }
+            }
+            //END OF MODULE
+#endif
diff --git a/contiki-cpc/contiki-cpc/arch/mem.s b/contiki-cpc/contiki-cpc/arch/mem.s
new file mode 100644
index 0000000..e994238
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/mem.s
@@ -0,0 +1,105 @@
+	.globl _calc_free_ram
+	.globl _get_ram_start
+	.globl _get_ram_end
+	.globl __sdcc_heap_init
+
+	.area _GSINIT
+	call __sdcc_heap_init
+
+	.area _CODE
+
+_calc_free_ram::
+	push bc
+        ;; get information about BASIC ROM
+        ld c,#0x0
+        call  #0xb915
+        cp #0x80
+        jr nz,gfr
+        ;; must be built in ROM
+
+        ;; v1.0 (BASIC 1.0 in CPC464)
+        ;; v1.1 (BASIC 1.1 in CPC664)
+        ;; v1.2 (BASIC 1.1 in CPC6128 and KC Compact)
+        ;; v1.4 (BASIC 1.1 in CPC+)
+
+        ld a,h
+        cp #0x1
+        ret z
+        ld a,l
+        or a
+        jr z,basic10       
+
+        ;; basic 1.1       
+  
+        ld hl,(#0xb073)
+        inc hl
+        ld bc,(#0xb736)
+        or a
+        sbc hl,bc
+        jr nz,after_himem11
+
+        ld hl,(#0xae6c)
+        ld (ram_start),hl
+
+        ld hl,(#0xb071)
+        ld (ram_end),hl
+gfr:
+	pop bc
+        ret
+
+after_himem11:
+
+        ;; after himem
+        ld hl,(#0xb073)
+        inc hl
+        ld (ram_start),hl
+        
+        ;; start of UDG
+        ld hl,(#0xb736)
+        dec hl
+        ld (ram_end),hl
+	pop bc
+        ret
+
+
+basic10:
+        ld hl,(#0xb08f)
+        inc hl
+        ld bc,(#0xb296)
+        or a
+        sbc hl,bc
+        jr nz,after_himem10
+
+        ld hl,(#0xae89)
+        ld (ram_start),hl
+
+        ld hl,(#0xb08d)
+        ld (ram_end),hl
+	pop bc
+        ret
+
+after_himem10:
+
+        ;; after himem
+        ld hl,(#0xb08f)
+        inc hl
+        ld (ram_start),hl
+
+        ;; start of UDG
+        ld hl,(#0xb296)
+        dec hl
+        ld (ram_end),hl
+	pop bc
+        ret
+
+_get_ram_start:: 
+	ld hl,(ram_start)
+	ret
+_get_ram_end::
+	ld hl,(ram_end)
+	ret
+	
+ram_start:: 
+	.dw 0
+ram_end:: 
+	.dw 0
diff --git a/contiki-cpc/contiki-cpc/arch/putchar.s b/contiki-cpc/contiki-cpc/arch/putchar.s
new file mode 100644
index 0000000..cc98c8d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/putchar.s
@@ -0,0 +1,27 @@
+;; File: putchar.s
+;; Modified to suit execution on the Amstrad CPC
+;; by H. Hansen 2003
+;; Original lines has been marked out!
+
+		.area _CODE
+_putchar::       
+_putchar_rr_s:: 
+        ld      hl,#2
+        add     hl,sp
+        
+        ld      a,(hl)
+;;      ld      a,#1
+;;      rst     0x08
+        call	0xBB5A
+        ret
+           
+_putchar_rr_dbs::
+
+;;      ld      l,e
+;;		ld		a,#1
+;;      rst     0x08
+
+        ld		a,e
+        call	0xBB5A
+        ret
+			
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/arch/uip.c b/contiki-cpc/contiki-cpc/arch/uip.c
new file mode 100644
index 0000000..76f0d0a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/uip.c
@@ -0,0 +1,9 @@
+void chksumi()
+{
+}
+
+void add32i()
+{
+}
+
+
diff --git a/contiki-cpc/contiki-cpc/conf/FILES b/contiki-cpc/contiki-cpc/conf/FILES
new file mode 100644
index 0000000..72ec6f2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/FILES
@@ -0,0 +1,30 @@
+The contiki/conf/ directory contains example configuration
+files.
+
+cc-conf.h.example
+
+  An example configuration file for C compiler tweaks.
+
+clock-conf.h.example
+
+  An example configuration file for the clock module.
+
+ctk-conf.h.example
+
+  An example configuration file for the CTK GUI module.
+
+ek-conf.h.example
+
+  An example configuration file for the Contiki event kernel.
+
+telnetd-conf.h.example
+
+  An example configuration file for the telnet server.
+
+uip-conf.h.example
+
+  An example configuration file for the uIP TCP/IP stack.
+
+www-conf.h.example
+
+  An example configuration file for the web browser.
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/conf/cc-conf.h b/contiki-cpc/contiki-cpc/conf/cc-conf.h
new file mode 100644
index 0000000..8ba952a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/cc-conf.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2006/04/17 15:11:45 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+/* This file is used to configure stuff that depends on the
+   capabilities of the C compiler used. */
+
+/* CC_CONF_REGISTER_ARGS: 1 or 0; 1 if the C compiler can handle the
+   "register" keyword in function argument, 0 otherwise. */
+#define CC_CONF_REGISTER_ARGS          0
+
+/* CC_CONF_FUNCTION_POINTR_ARGS: 1 or 0; 1 if the C compiler can
+   handle function arguments with function pointers, 0 otherwise. */
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+/* CC_CONF_FASTCALL: if the C compiler supports the fastcall keyword,
+   it should be defined here. If the C compiler does not support it,
+   leave the definition blank. 
+
+   Example:
+   #define CC_CONF_FASTCALL               fastcall */
+#define CC_CONF_FASTCALL
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/contiki-cpc/conf/cc-conf.h.old b/contiki-cpc/contiki-cpc/conf/cc-conf.h.old
new file mode 100644
index 0000000..c416ebf
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/cc-conf.h.old
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h.old,v 1.1 2006/04/17 15:11:45 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define register			/**/
+#define CC_CONF_REGISTER_ARGS          0
+#define CC_CONF_FUNCTION_POINTER_ARGS  0
+
+#define CC_CONF_FASTCALL               /*fastcall*/
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/contiki-cpc/conf/clock-conf.h b/contiki-cpc/contiki-cpc/conf/clock-conf.h
new file mode 100644
index 0000000..a690e15
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-conf.h
new file mode 100644
index 0000000..8496fc2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F2
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         CH_F7
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F4
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old b/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old
new file mode 100644
index 0000000..5c832c9
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE  0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h
new file mode 100644
index 0000000..fd45e81
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h
@@ -0,0 +1 @@
+#define CTK_VNCSERVER_CONF_MAX_ICONS 1
diff --git a/contiki-cpc/contiki-cpc/conf/ek-conf.h b/contiki-cpc/contiki-cpc/conf/ek-conf.h
new file mode 100644
index 0000000..bfbcfb1
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ek-conf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_EVENTS   32    /* Must be 2^n */
+#define EK_CONF_NUMEVENTS EK_CONF_EVENTS
+
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 32
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ek-conf.h.old b/contiki-cpc/contiki-cpc/conf/ek-conf.h.old
new file mode 100644
index 0000000..a64bbe7
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ek-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   16    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  16    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/irc-conf.h b/contiki-cpc/contiki-cpc/conf/irc-conf.h
new file mode 100644
index 0000000..056f71a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/irc-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#define IRC_CONF_WIDTH 78
+#define IRC_CONF_HEIGHT 21
+
+#define IRC_CONF_SYSTEM_STRING "c64"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/libconio-conf.h b/contiki-cpc/contiki-cpc/conf/libconio-conf.h
new file mode 100644
index 0000000..d420d5c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/libconio-conf.h
@@ -0,0 +1,2 @@
+#define LIBCONIO_CONF_SCREEN_WIDTH 40
+#define LIBCONIO_CONF_SCREEN_HEIGHT 25
diff --git a/contiki-cpc/contiki-cpc/conf/log-conf.h b/contiki-cpc/contiki-cpc/conf/log-conf.h
new file mode 100644
index 0000000..1036014
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/log-conf.h
@@ -0,0 +1 @@
+#define LOG_CONF_ENABLED 0
diff --git a/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h b/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h
new file mode 100644
index 0000000..235b1c6
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h
@@ -0,0 +1,2 @@
+#define SHELL_GUI_CONF_XSIZE 20
+#define SHELL_GUI_CONF_YSIZE 20
diff --git a/contiki-cpc/contiki-cpc/conf/telnetd-conf.h b/contiki-cpc/contiki-cpc/conf/telnetd-conf.h
new file mode 100644
index 0000000..8355598
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/telnetd-conf.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+#define __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 36
+#define TELNETD_CONF_NUMLINES 24
+
+#endif /* __TELNETD_CONF_H__ */
+
+
+
+
+
+
+
+
diff --git a/contiki-cpc/contiki-cpc/conf/uip-conf.h b/contiki-cpc/contiki-cpc/conf/uip-conf.h
new file mode 100644
index 0000000..8955c6d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/uip-conf.h
@@ -0,0 +1,93 @@
+/**
+ * \file
+ * uIP configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file contains configuration options for the uIP TCP/IP
+ * stack. Each Contiki port will contain its own uip-conf.h file
+ * containing architecture specific configuration options.
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+/**
+ * The maximum number of TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ */
+#define UIP_CONF_MAX_CONNECTIONS 40
+
+/**
+ * The maximum number of listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ */
+#define UIP_CONF_MAX_LISTENPORTS 40
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ */
+#define UIP_CONF_BUFFER_SIZE     400
+
+/**
+ * The host byte order.
+ *
+ * Used for telling uIP if the architecture has LITTLE_ENDIAN or
+ * BIG_ENDIAN byte order. x86 CPUs have LITTLE_ENDIAN byte order,
+ * whereas Motorola CPUs have BIG_ENDIAN. Check the documentation of
+ * the CPU to find out the byte order.
+ */
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+
+/**
+ * IP address configuration through ping.
+ *
+ * uIP features IP address configuration using an ICMP echo (ping)
+ * packet. In this mode, the destination IP address of the first ICMP
+ * echo packet that is received is used to set the host IP address.  
+ */
+#define UIP_CONF_PINGADDRCONF    0
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/uip-conf.h.old b/contiki-cpc/contiki-cpc/conf/uip-conf.h.old
new file mode 100644
index 0000000..8de8b7a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/uip-conf.h.old
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE     310
+
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/vnc-conf.h b/contiki-cpc/contiki-cpc/conf/vnc-conf.h
new file mode 100644
index 0000000..1e6906a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/vnc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH  (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS    8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old b/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old
new file mode 100644
index 0000000..fedc904
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH  (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS    8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/www-conf.h b/contiki-cpc/contiki-cpc/conf/www-conf.h
new file mode 100644
index 0000000..5178724
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/www-conf.h
@@ -0,0 +1,110 @@
+/**
+ * \file
+ * The Contiki web browser configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/**
+ * The width of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+
+/**
+ * The height of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/**
+ * The size of the "Back" history.
+ */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/**
+ * The maximum length of the URLs the web browser will handle.
+ */
+#define WWW_CONF_MAX_URLLEN 100
+
+/**
+ * The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ * a single web page view.
+ *
+ * \note This does not limit the total number of widgets in a web
+ * page, only the number of widget that are visible simultaneously.
+ */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
+
+/**
+ * Turns support for the \<center\> tag on or off, and must be on for
+ * HTML forms to work.
+ */
+#define WWW_CONF_RENDERSTATE 1
+
+/**
+ * Toggles support for HTML forms.
+ */
+#define WWW_CONF_FORMS       1
+
+/**
+ * Maximum length of HTML form action URLs.
+ */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+
+/**
+ * Maximum length of HTML form name.
+ */
+#define WWW_CONF_MAX_FORMNAMELEN    20
+
+/**
+ * Maximum length of HTML form input name.
+ */
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+/**
+ * Maximum length of HTML form input value.
+ */
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+/**
+ * The defaule home page.
+ */
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/www-conf.h.old b/contiki-cpc/contiki-cpc/conf/www-conf.h.old
new file mode 100644
index 0000000..9ac8b4b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/www-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h.old,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 65
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 26
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS       1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN  30
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/conio.h b/contiki-cpc/contiki-cpc/ctk/conio.h
new file mode 100644
index 0000000..e8c3cdb
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/conio.h
@@ -0,0 +1,66 @@
+/*
+ CONIO.H - Console I/O library for the Amsrad CPC
+ To use with the Small Devices C Compiler
+ CONIO.H is a implementation of the Contiki CONIO.H (Derived from the borland CONIO.H)
+
+ 2003 H. Hansen
+*/
+
+#ifndef  __conio_h__
+#define __conio_h__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "arch.h"
+
+#define CH_ULCORNER 0x096
+#define CH_URCORNER 0x09c
+#define CH_LLCORNER 0x093
+#define CH_LRCORNER 0x099
+
+void clrscr (void);
+
+unsigned char kbhit (void);
+
+void gotox (unsigned char x);
+
+void gotoy (unsigned char y);
+
+void gotoxy (unsigned char x, unsigned char y);
+
+unsigned char wherex (void);
+
+unsigned char wherey (void);
+
+void cputc (char c);
+
+void cputcxy (unsigned char x, unsigned char y, char c);
+
+void cputs (char* s);
+
+char cgetc (void);
+
+void  revers ();
+
+void textcolor (unsigned char color);
+
+void bgcolor (unsigned char color);
+
+void  bordercolor (unsigned char color);
+
+void chline (unsigned char length);
+
+void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cvline (unsigned char length);
+
+void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cclear (unsigned char length);
+
+void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+
+void screensize (unsigned char* x, unsigned char* y);
+
+#endif /* __conio_h__ */
+
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-arch.h b/contiki-cpc/contiki-cpc/ctk/ctk-arch.h
new file mode 100644
index 0000000..b043013
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-arch.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#if CTK_HIRES
+#include "ctk-hires.h"
+#endif 
+
+#if CTK_CONIO
+#include "ctk-conio.h"
+#endif 
+
+#if CTK_VNCSERVER
+#include "ctk-vncarch.h"
+#endif
+
+#include <ctype.h>
+
+//#define ctk_arch_isprint(c) isprint(c)
+
+#include "ctk-arch2.h"
+
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h b/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h
new file mode 100644
index 0000000..1d39254
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h
@@ -0,0 +1,39 @@
+/*#include "fire.h"*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//char *strncpy(char *, const char *, unsigned int);
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+// have to undefine because of it being defined in
+// ctk-conio.h
+#undef CH_ENTER
+#undef CH_F1
+#undef CH_F3
+#undef CH_CURS_LEFT
+#undef CH_CURS_RIGHT
+
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F2 0x032
+#define CH_F3 0x033
+#define CH_F4 0x034
+#define CH_F5 0x035
+#define CH_F6 0x036
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+#define CH_TAB 0x09
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC CH_STOP
+
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old b/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old
new file mode 100644
index 0000000..84666d0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE  0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h b/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..89c47c5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         0
+#define SCREENCOLOR         0
+
+#define BACKGROUNDCOLOR		0
+
+
+#define WINDOWCOLOR_FOCUS   1		/* colour of window which has focus */
+#define WINDOWCOLOR         2		/* colour of window which doesn't have focus */
+
+#define DIALOGCOLOR         1
+
+#define WIDGETCOLOR_HLINK   3
+#define WIDGETCOLOR_FWIN    2		/* colour of widget */
+#define WIDGETCOLOR         2
+#define WIDGETCOLOR_DIALOG  2
+#define WIDGETCOLOR_FOCUS   3		/* colour of widge which has focus */
+
+// 0 = blue
+// 1 = yellow
+// 2 = cyan
+// 3 = red
+
+#define MENUCOLOR           2
+#define OPENMENUCOLOR       1	
+#define ACTIVEMENUITEMCOLOR 3
+
+#endif
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S
new file mode 100644
index 0000000..4df6cad
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S
@@ -0,0 +1,986 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		pushax
+	.import		incsp2
+
+	.import		_ctk_80col_screencolors
+	.import		_ctk_80col_screenpattern	
+		
+	.import		_ctk_80col_lefttab
+	.import		_ctk_80col_righttab
+	
+	.import		_ctk_80col_cursx
+	.import		_ctk_80col_cursy
+	.import		_ctk_80col_color
+	.import		_ctk_80col_underline	
+	.import		_ctk_80col_reversed
+
+	.import		_ctk_80col_yscreenaddr
+	.import		_ctk_80col_yhiresaddr
+
+	.import		_ctk_80col_windowparams
+	
+	.import		_ctk_80col_bitmapptr
+
+	.import		_ctk_80col_versionstring
+	.import		_ctk_80col_versionstring_len	
+	
+	.import		_ctk_80col_theme
+			
+	.export		_ctk_80col_cclear
+	.export		_ctk_80col_chline
+	.export		_ctk_80col_cputc
+	.export		_ctk_80col_cputsn
+	
+	.export		_ctk_80col_clear_line
+	.export		_ctk_80col_draw_bitmapline
+	
+	.export		_ctk_80col_draw_windowborders
+
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlecolor:  .res 1
+wptitlecolor = 6
+titlelen:    .res 1
+wptitlelen   = 7
+title:	.res 2
+wptitle      = 8
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_80col_cursx
+	asl
+	rol ptr1+1
+; 	asl	
+; 	rol ptr1+1	
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	and #$f8
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+	;; Find screen address. 
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_cursx
+	lsr
+	clc
+	adc _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+	
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_80col_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	ldy tmpl
+	lda _ctk_80col_color
+:		
+	sta (ptr1),y
+	dey
+	bpl :-
+	
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_80col_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf
+
+		
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_80col_cursx
+
+	dex
+	bpl @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_80col_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_80col_cputc:
+	sta tmpc
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+
+	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_80col_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+        jmp incsp2	
+:		
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:		
+
+	
+	lda #0
+	sta ptr1+1		  	
+
+	ldy tmpc
+	lda (ptr3),y
+	bne :+
+	jmp @end
+:	
+			
+	;; Convert from PETSCII to screen encoding
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp @loopend
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+			
+	inc _ctk_80col_cursx	
+@loopend:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	beq :+
+	jmp @loop1
+:	
+	
+@end:
+	jsr restore01
+	
+        jmp incsp2	
+;---------------------------------------------------------------------
+_ctk_80col_clear_line:
+	sta tmpl
+	asl
+	tax
+	lda _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	sta ptr1+1	
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+	
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+
+	ldy #39
+	ldx tmpl
+	lda _ctk_80col_screencolors,x
+:	
+	sta (ptr1),y
+	dey
+	bpl :-
+
+	lda tmpl
+	asl
+	asl
+	asl
+	tax
+	ldy #0
+:
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	bne :-
+
+	inc ptr2+1
+	
+:	
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	cpy #$40
+	bne :-
+
+	lda tmpl
+	cmp #24
+	bne :+			
+
+	sta _ctk_80col_cursy
+	lda #2
+	sta _ctk_80col_cursx
+
+	jsr restore01
+		
+	lda #<_ctk_80col_versionstring
+	ldx #>_ctk_80col_versionstring
+ 	jsr pushax		
+	lda _ctk_80col_versionstring_len
+	jmp _ctk_80col_cputsn
+:		
+	jmp restore01	
+;---------------------------------------------------------------------	
+_ctk_80col_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_80col_color
+:	
+	sta (ptr1),y	
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_80col_bitmapptr
+	sta ptr1
+	lda _ctk_80col_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_80col_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_80col_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	lda _ctk_80col_windowparams + wpw
+	sta tmpw	
+
+	
+	ldy #0
+	lda _ctk_80col_windowparams + wptitlecolor	
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	dec tmpw
+
+	;; Set color for upper right corner
+	sta (ptr1),y	
+	iny
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_80col_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+
+	
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_80col_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	bpl @titlebarloop
+
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_80col_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_80col_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_80col_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_80col_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_80col_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_80col_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_80col_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_80col_windowparams + wpw
+	lda _ctk_80col_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_80col_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_80col_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_80col_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_80col_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_80col_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_80col_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_80col_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+	
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h
new file mode 100644
index 0000000..21787d4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-80col-asm.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_80COL_ASM_H__
+#define __CTK_80COL_ASM_H__
+
+void __fastcall__ ctk_80col_cclear(unsigned char len);
+void __fastcall__ ctk_80col_chline(unsigned char len);
+void __fastcall__ ctk_80col_cputc(unsigned char c);
+void __fastcall__ ctk_80col_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_80col_draw_buttonleft(void);
+void ctk_80col_draw_buttonright(void);
+
+struct ctk_80col_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlecolor;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_80col_windowparams ctk_80col_windowparams;
+void ctk_80col_draw_windowborders(void);
+
+extern unsigned char ctk_80col_cursx,
+  ctk_80col_cursy,
+  ctk_80col_color,
+  ctk_80col_reversed,
+  ctk_80col_underline;
+
+
+void __fastcall__ ctk_80col_draw_bitmapline(unsigned char len);
+
+void __fastcall__ ctk_80col_clear_line(unsigned char len);
+
+#endif /* __CTK_80COL_ASM_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h
new file mode 100644
index 0000000..ffc168c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h
@@ -0,0 +1,83 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-80col-theme.h,v 1.1 2006/04/17 15:11:48 kthacker Exp $
+ *
+ */
+#ifndef __CTK_80COL_THEME_H__
+#define __CTK_80COL_THEME_H__
+
+struct ctk_80col_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpattern[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+
+};
+
+extern struct ctk_80col_theme ctk_80col_theme;
+extern struct ctk_80col_theme *ctk_80col_theme_ptr;
+
+#endif /* __CTK_80COL_THEME_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c
new file mode 100644
index 0000000..fc7d5f6
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c
@@ -0,0 +1,1200 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-80col.c,v 1.2 2006/05/28 20:42:34 oliverschmidt Exp $
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+
+#include "ctk-80col-asm.h"
+
+#include "ctk-80col-theme.h"
+
+#include <string.h>
+
+unsigned char ctk_80col_cursx, ctk_80col_cursy;
+unsigned char ctk_80col_reversed;
+unsigned char ctk_80col_color;
+unsigned char *ctk_80col_bitmapptr;
+unsigned char ctk_80col_underline = 0;
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  80
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+unsigned char ctk_80col_lefttab[256];
+unsigned char ctk_80col_righttab[256];
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define COLOR_DIALOG            0x01
+#define COLOR_FOCUS_WINDOW      0xbf
+#define COLOR_BACKGROUND_WINDOW 0x0c
+
+#define color(c) ctk_80col_color = c
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+unsigned char ctk_80col_screencolors[25] =
+  {COLOR(BGCOLOR4,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,1)};
+
+unsigned char ctk_80col_screenpattern[25*8] =
+  {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+unsigned short ctk_80col_yscreenaddr[25] =
+  {0 * 40 + SCREENADDR, 1 * 40 + SCREENADDR,
+   2 * 40 + SCREENADDR, 3 * 40 + SCREENADDR,
+   4 * 40 + SCREENADDR, 5 * 40 + SCREENADDR,
+   6 * 40 + SCREENADDR, 7 * 40 + SCREENADDR,
+   8 * 40 + SCREENADDR, 9 * 40 + SCREENADDR,
+   10 * 40 + SCREENADDR, 11 * 40 + SCREENADDR,
+   12 * 40 + SCREENADDR, 13 * 40 + SCREENADDR,
+   14 * 40 + SCREENADDR, 15 * 40 + SCREENADDR,
+   16 * 40 + SCREENADDR, 17 * 40 + SCREENADDR,
+   18 * 40 + SCREENADDR, 19 * 40 + SCREENADDR,
+   20 * 40 + SCREENADDR, 21 * 40 + SCREENADDR,
+   22 * 40 + SCREENADDR, 23 * 40 + SCREENADDR,
+   24 * 40 + SCREENADDR};
+
+unsigned short ctk_80col_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+
+
+struct ctk_80col_theme ctk_80col_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xc0,0x80,0xbf,0x80,0xbf,0x80,0x80},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x03,0x01,0xfd,0x01,0xfd,0x01,0x01},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x03,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0x0f,0x3f,0x3f,0x7f,0x7f,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xf0,0xfc,0xfc,0xfe,0xfe,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_WHITE),
+    
+  };
+char ctk_80col_versionstring[] = CONTIKI_VERSION_STRING;
+char ctk_80col_versionstring_len = sizeof(CONTIKI_VERSION_STRING) - 1;
+
+struct ctk_80col_windowparams ctk_80col_windowparams;
+
+/*---------------------------------------------------------------------------*/
+/*void
+ctk_arch_draw_char(char c,
+		   unsigned char xpos,
+		   unsigned char ypos,
+		   unsigned char reversedflag,
+		   unsigned char color)
+{
+  ctk_80col_cursx = xpos;
+  ctk_80col_cursy = ypos;
+  ctk_80col_reversed = reversedflag;
+  ctk_80col_color = color;
+  
+  ctk_80col_cputc(c);
+}*/
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+void reset(void);
+void
+quit(void)
+{
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+  VIC.bordercolor = 0x0e; /* $D020 */
+  VIC.bgcolor0 = 0x06; /* $D021 */
+
+  memset((char *)0xd800, 0x0e, 40*25);
+
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+ctk_80col_init(void)
+{
+  int i;
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = 0x06; /* $D020 */
+  VIC.bgcolor0 = 0x0b; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  memset((char *)0xe000, 0, 8000);
+
+  for(i = 0; i < 256; ++i) {
+#if 0
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x20) << 1) |
+      ((i & 0x08) << 2) |
+      ((i & 0x02) << 3);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x20) >> 3) |
+      ((i & 0x08) >> 2) |
+      ((i & 0x02) >> 1);
+#else
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x10) << 2) |
+      ((i & 0x04) << 3) |
+      ((i & 0x01) << 4);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x10) >> 2) |
+      ((i & 0x04) >> 1) |
+      ((i & 0x01));
+#endif
+  }
+  
+#if 0
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_80col_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+#endif
+  return;
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+/*static unsigned char cursx, cursy;
+  static unsigned char reversed;*/
+
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+cputc(char c) 
+{
+  /*  ctk_arch_draw_char(c, cursx, cursy, reversed, 0);*/
+  ctk_80col_cputc(c);
+  /*  ++cursx;*/
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+  return ctk_80col_cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+  return ctk_80col_cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+/*void
+clrscr(void)
+{
+  unsigned char x, y;
+
+  for(x = 0; x < SCREEN_WIDTH; ++x) {
+    for(y = 0; y < SCREEN_HEIGHT; ++y) {
+      gotoxy(x, y);
+      cputc(' ');
+    }
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+#define revers(c) ctk_80col_reversed = c
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+_cputs(char *str)
+{
+  char *ptr = str;
+  
+  while(*ptr != 0) {
+    cputc(*ptr++);
+  }
+
+  /*  int i;
+  for(i = 0; i < strlen(str); ++i) {
+    cputc(str[i]);
+    }*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+cclear(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc(' ');
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('-');
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('|');
+    --ctk_80col_cursx;
+    ++ctk_80col_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_80col_cursx = x;
+  ctk_80col_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+_cputsxy(unsigned char x, unsigned char y, char *str)
+{
+  gotoxy(x, y);
+  _cputs(str);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cputcxy(unsigned char x, unsigned char y, char c)
+{
+  gotoxy(x, y);
+  cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+/*void CC_FASTCALL
+screensize(unsigned char *x, unsigned char *y)
+{
+  *x = SCREEN_WIDTH;
+  *y = SCREEN_HEIGHT;
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*static unsigned char sizex, sizey;*/
+/*-----------------------------------------------------------------------------------*/
+static void
+_cputsn(char *str, unsigned char len)
+{
+  /*  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+    }*/  
+  ctk_80col_cputsn(str, len);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_init(void)
+{
+  ctk_80col_init();
+
+  /*  screensize(&sizex, &sizey);*/
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else {
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	_cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      cputcxy(xpos, ypos, '[');
+      _cputsn(w->widget.button.text, w->w);
+      cputc(']');
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(0);
+      } else {
+	revers(1);
+      }
+      gotoxy(xpos, ypos);
+      _cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    if(wfocus != 0) {
+      revers(1);
+    } else {
+      revers(0);
+    }
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      revers(1);
+	    } else {
+	      revers(0);
+	    }
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	    revers(0);
+	  }
+	  cputc('<');
+	} else {
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  _cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      color(ctk_80col_theme.iconcolors[focus]);
+      
+      /*      if(focus & 1) {
+	
+	revers(1);
+      } else {
+	revers(0);
+	}*/
+      /*      gotoxy(xpos, ypos);*/
+      if(xpos >= 73) {
+	xpos = 73;
+      }
+      if(xpos <= 2) {
+	xpos = 2;
+      }
+      if(w->widget.icon.textmap != NULL) {
+	ctk_80col_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    gotoxy(xpos, ypos);
+	    ctk_80col_draw_bitmapline(3);	    
+	  }
+	  ctk_80col_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+      }
+      x = xpos;
+  
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      if(ypos >= clipy1 && ypos < clipy2) {
+	len = strlen(w->widget.icon.title);
+	gotoxy((x & 0xfe) + 1, ypos);
+	ctk_80col_cclear((len - 1)/ 2);
+	gotoxy(x, ypos);
+	ctk_80col_cputsn(w->widget.icon.title, len);
+      }
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		  unsigned char focus,
+		  unsigned char clipy1,
+		  unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = (win->x & 0xfe) + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+  
+  if(focus & CTK_FOCUS_WINDOW) {
+    color(COLOR_FOCUS_WINDOW);
+  } else {
+    color(COLOR_BACKGROUND_WINDOW);
+  }
+    
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      gotoxy((window->x & 0xfe) + 1, i);
+      ctk_80col_cclear((window->w + 1)/2);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		  unsigned char clipy1, unsigned char clipy2)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+
+  
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x & 0xfe;
+  y = window->y + 1;
+  
+/*  if(focus & CTK_FOCUS_WINDOW) {
+  } else {
+  }*/
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  /* Draw window frame. */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (window->w-1)/2;
+  ctk_80col_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_80col_windowparams.clipy1 = 0;
+  } else {
+    ctk_80col_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_80col_windowparams.clipy2 = clipy2 - y + 1;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[focus+1];
+  ctk_80col_windowparams.title = window->title;
+  ctk_80col_windowparams.titlelen = window->titlelen/2;
+
+  if(ctk_80col_windowparams.clipy1 < ctk_80col_windowparams.clipy2 &&
+     ctk_80col_windowparams.clipy2 > 0) {
+    ctk_80col_draw_windowborders();
+  }
+  /*  
+  if(y >= clipy1) {
+    cputcxy(x, y, CH_ULCORNER);
+    gotoxy(wherex() + window->titlelen + 2, wherey());
+    chline(window->w - (wherex() - x) - 2);
+    cputcxy(x2, y, CH_URCORNER);
+  }
+
+  h = window->h;
+  
+  if(clipy1 > y1) {
+    if(clipy1 - y1 < h) {
+      h = clipy1 - y1;
+            y1 = clipy1;
+    } else {
+      h = 0;
+    }
+  }
+
+  if(clipy2 < y1 + h) {
+    if(y1 >= clipy2) {
+      h = 0;
+    } else {
+      h = clipy2 - y1;
+    }
+  }
+
+  cvlinexy(x, y1, h);
+  cvlinexy(x2, y1, h);  
+
+  if(y + window->h >= clipy1 &&
+     y + window->h < clipy2) {
+    cputcxy(x, y2, CH_LLCORNER);
+    chlinexy(x1, y2, window->w);
+    cputcxy(x2, y2, CH_LRCORNER);
+  }
+  */
+  if(ctk_mode_get() != CTK_MODE_WINDOWMOVE) {
+    draw_window_contents(window, focus & CTK_FOCUS_WINDOW, clipy1, clipy2,
+			 x1, x2, y + 1, y2);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  
+  x = dialog->x & 0xfe;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  /*  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (dialog->w-1)/2;
+  ctk_80col_windowparams.h = dialog->h;
+  ctk_80col_windowparams.clipy1 = 0;
+  ctk_80col_windowparams.clipy2 = SCREEN_HEIGHT;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[5];
+
+  ctk_80col_draw_windowborders();  
+  
+  /* Clear dialog contents. */
+  color(COLOR_DIALOG);
+  for(i = y1; i < y2; ++i) {
+    gotoxy((x1 & 0xfe) + 2, i);
+    ctk_80col_cclear((dialog->w + 1)/2 - 2);
+    /*    cclearxy(x1, i, dialog->w);*/
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, SCREEN_HEIGHT,
+		       x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+
+  
+  for(i = y1; i < y2; ++i) {
+    
+    ctk_80col_clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  
+  color(ctk_80col_theme.openmenucolor);
+  
+  revers(0);
+  x = wherex();
+  _cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH - 2;
+  }
+    
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      color(ctk_80col_theme.activemenucolor);
+    } else {
+      color(ctk_80col_theme.openmenucolor);
+    }
+    gotoxy(x, y + 1);
+    ctk_80col_cclear(CTK_CONF_MENUWIDTH/2);
+
+    gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      /*      _cputs(m->items[y].title);*/
+      ctk_80col_cputsn(m->items[y].title, m->items[y].titlelen);
+    }
+    /*    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear(x + CTK_CONF_MENUWIDTH - wherex());
+      }*/
+  
+  }
+  gotoxy(x2, 0);
+  revers(1);
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+  
+  memcpy((char *)0xe000, ctk_80col_theme.menuleftpattern, 8);
+  /* Draw menus */
+  gotoxy(2, 0);
+
+  revers(1); 
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    color(ctk_80col_theme.menucolor);
+    if(m != menus->open) {
+      /*      _cputs(m->title);*/
+      ctk_80col_cputsn(m->title, m->titlelen);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+  color(ctk_80col_theme.menucolor);
+    
+  if(wherex() + strlen(menus->desktopmenu->title) + 2 >= SCREEN_WIDTH) {
+    gotoxy(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 2, 0);
+  } else {
+    cclear(SCREEN_WIDTH - wherex() -
+	   strlen(menus->desktopmenu->title) - 2);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    ctk_80col_cputsn(menus->desktopmenu->title, menus->desktopmenu->titlelen);
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  /*  gotoxy(78, 0);
+  color(ctk_80col_screencolors[0]);
+  cputc(' ');
+  cputc(' ');    */
+  
+  revers(0);
+  memcpy((char *)0xe138, ctk_80col_theme.menurightpattern, 8);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 4;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": 80col", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_80col_service_init, arg)
+{ 
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    quit();
+    ek_exit();
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S
new file mode 100644
index 0000000..8d52510
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S
@@ -0,0 +1,934 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		incsp2
+
+	
+	.import		_ctk_hires_cursx
+	.import		_ctk_hires_cursy
+	.import		_ctk_hires_color
+	.import		_ctk_hires_underline
+	.import		_ctk_hires_reversed
+
+	.import		_ctk_hires_yscreenaddr
+	.import		_ctk_hires_yhiresaddr
+
+	.import		_ctk_hires_windowparams
+	
+	.import		_ctk_hires_bitmapptr
+
+	.import		_ctk_hires_theme
+			
+	.export		_ctk_hires_cclear
+	.export		_ctk_hires_chline
+	.export		_ctk_hires_cputc
+	.export		_ctk_hires_cputsn
+
+	.export		_ctk_hires_draw_buttonleft
+	.export		_ctk_hires_draw_buttonright
+	
+	.export		_ctk_hires_draw_windowborders
+
+	.export		_ctk_hires_draw_bitmapline
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlelen:	.res 1
+wptitlelen   = 6
+title:	.res 2
+wptitle      = 7	
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_hires_cursy
+	asl
+	tax
+	lda _ctk_hires_yhiresaddr,x
+	sta ptr2
+	lda _ctk_hires_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_hires_cursx
+	asl
+	rol ptr1+1
+	asl	
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+
+	;; Find screen address. 
+	lda _ctk_hires_cursy
+	asl
+	tax	
+	lda _ctk_hires_yscreenaddr,x
+	clc
+	adc _ctk_hires_cursx
+	sta ptr1
+	lda _ctk_hires_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_hires_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_hires_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf	
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_cputc:
+	sta tmpc
+
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_hires_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+	
+	jsr setupptrs
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+			
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:	
+	
+	lda #0
+	sta ptr1+1		  
+		
+	ldy tmpc
+	lda (ptr3),y
+	beq @end
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	bne @loop1
+	
+@end:		
+	jsr restore01
+	
+        jmp incsp2
+	
+;---------------------------------------------------------------------
+_ctk_hires_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_hires_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y	
+	dey
+	dey
+	dey
+	sty tmpw	
+
+	ldy _ctk_hires_windowparams + wptitlelen
+	iny
+	iny
+	iny
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	inc tmpw
+
+	;; Set color for upper left corner
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_hires_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	;; Draw first empty char left of the title
+	ldy #8
+	lda #0
+:		
+; 	sta (ptr3),y		
+	iny
+	cpy #$10
+	bne :-
+
+	lda ptr3
+	clc
+	adc #$10
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;;  Draw the title
+	lda _ctk_hires_windowparams + wptitle
+	sta ptr4
+	lda _ctk_hires_windowparams + wptitle+1
+	sta ptr4+1
+	
+
+	lda #0
+	sta tmpc
+@titleloop:
+	lda #0
+	sta ptr5+1
+
+	ldy tmpc
+	lda (ptr4),y
+
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	;; Convert to address in character ROM
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	sta ptr5
+	lda #$d8
+	adc ptr5+1
+	sta ptr5+1
+
+	;; Print on hires screen, character by character, bottom-up.
+	ldy #7
+:
+	lda (ptr5),y
+; 	sta (ptr3),y		
+	dey
+	bpl :-
+	
+	lda ptr3
+	clc
+	adc #8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+	
+	inc tmpc
+	lda tmpc
+	cmp _ctk_hires_windowparams + wptitlelen
+	bne @titleloop
+
+	;; Draw empty char after the title
+	ldy #7
+	lda #0
+:		
+; 	sta (ptr3),y
+	dey	
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_hires_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	lda tmpw
+	cmp #3
+	bcs @titlebarloop
+
+	lda ptr3
+	clc
+	adc #$18
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:		
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_hires_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_hires_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_hires_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_hires_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_hires_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_hires_windowparams + wpw
+	lda _ctk_hires_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_hires_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_hires_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_hires_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_hires_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_hires_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_hires_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_hires_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonleft:
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonleftpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonright:
+	jsr setupptrs
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonrightpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_hires_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_hires_color
+:	
+ 	sta (ptr1),y
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_hires_bitmapptr
+	sta ptr1
+	lda _ctk_hires_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+	
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h
new file mode 100644
index 0000000..58fea69
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-asm.h,v 1.1 2006/04/17 15:11:49 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_ASM_H__
+#define __CTK_HIRES_ASM_H__
+
+void __fastcall__ ctk_hires_cclear(unsigned char len);
+void __fastcall__ ctk_hires_chline(unsigned char len);
+void __fastcall__ ctk_hires_cputc(unsigned char c);
+void __fastcall__ ctk_hires_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_hires_draw_buttonleft(void);
+void ctk_hires_draw_buttonright(void);
+
+struct ctk_hires_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_hires_windowparams ctk_hires_windowparams;
+void ctk_hires_draw_windowborders(void);
+
+extern unsigned char ctk_hires_cursx,
+  ctk_hires_cursy,
+  ctk_hires_color,
+  ctk_hires_reversed,
+  ctk_hires_underline;
+
+
+void __fastcall__ ctk_hires_draw_bitmapline(unsigned char len);
+
+#endif /* __CTK_HIRES_ASM_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c
new file mode 100644
index 0000000..c35b3cd
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c
@@ -0,0 +1,931 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-service.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+/*unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;*/
+
+static void s_ctk_draw_clear(unsigned char y1, unsigned char y2);
+
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+s_ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+  
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  s_ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  focus = focus & CTK_FOCUS_WINDOW;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": hires", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_conio_service_init, arg)
+{
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
new file mode 100644
index 0000000..10fc27e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
@@ -0,0 +1,313 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-blueround.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x06
+#define BGCOLOR2 0x00
+#define BGCOLOR3 0x06
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_CYAN)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_CYAN),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_CYAN, COLOR_BLUE),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    /*unsigned char pointermaskcolor,*/
+    3,
+
+    /* Pointer sprite 1 color */
+    /*     pointercolor; */
+    6,
+
+    
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+     
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    },
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+
+      COLOR(BGCOLOR4,BGCOLOR4)},
+      
+    
+
+  };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
new file mode 100644
index 0000000..ad8b430
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-default.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_YELLOW),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    6,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
new file mode 100644
index 0000000..996a558
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-enabler.c,v 1.1 2006/04/17 15:11:52 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x0f
+#define BGCOLOR2 0x0c
+#define BGCOLOR3 0x0b
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xfc,0xf0,0xf0,0xe0,0xe0,0xe0,0xe0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x3f,0x0f,0x0f,0x07,0x07,0x07,0x07},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},    
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GRAY3, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_GRAY1, COLOR_GRAY3),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
new file mode 100644
index 0000000..71dd3fe
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
@@ -0,0 +1,288 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-ravenpine.c,v 1.1 2006/04/17 15:11:52 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x00
+#define BGCOLOR2 0x05
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xfc,0xfc,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0xfc,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x3e,0x30,0x30,0x30,0x30,0x30,0x30,0x3c},
+    
+    /* buttonright[8]; */
+    {0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_GREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+        
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GREEN, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_LIGHTGREEN, COLOR_GREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_LIGHTGREEN,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+    },
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
new file mode 100644
index 0000000..0dcdf2e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
@@ -0,0 +1,284 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-springlight.c,v 1.1 2006/04/17 15:11:53 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x05
+#define BGCOLOR2 0x0d
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x0f,0x18,0x10,0x10,0x10,0x10,0x10,0x00},    
+    
+    /* buttonright[8]; */
+    {0x00,0x08,0x08,0x08,0x08,0x08,0x18,0xf0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GREEN, COLOR_CYAN),
+     COLOR(COLOR_GREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTGREEN)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_LIGHTGREEN),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    5,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_WHITE,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 223, 255, 255, 247, 255, 255, 191, 247, 255, 255, 219, 255, 255, 187,
+255, 239, 251, 191, 239, 253, 223, 251, 223, 253, 183, 255, 213, 127, 237, 191,
+245, 95, 245, 223, 181, 255, 85, 255, 85, 219, 118, 219, 109, 219, 182, 109, 219, 182, 109, 219, 170, 109, 219, 170, 181, 173, 85, 218, 85, 173, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 146, 85, 146, 170, 82, 138, 50, 74, 164, 73,
+146, 84, 137, 82, 4, 169, 18, 164, 2, 168, 18, 68, 18, 160, 10, 32, 74, 0, 42, 128, 18, 64, 20, 0, 82, 0, 4, 80, 4, 0, 72, 2, 0, 16, 132, 0, 0, 72, 0, 0, 4, 64, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h
new file mode 100644
index 0000000..8659e07
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h
@@ -0,0 +1,105 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme.h,v 1.1 2006/04/17 15:11:53 kthacker Exp $
+ *
+ */
+#ifndef __CTK_HIRES_THEME_H__
+#define __CTK_HIRES_THEME_H__
+
+struct ctk_hires_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpatterns[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  
+  /* Button corner colors. */
+  unsigned char buttonleftcolors[6],
+    buttonrightcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+ 
+  /* Border and screen colors. */
+  unsigned char bordercolor,
+    screencolor;
+
+  /* Pointer sprite colors. */
+  unsigned char pointermaskcolor,
+    pointercolor;
+  
+  /* Pointer sprite. */
+  unsigned char pointer[128];
+
+  /* Background pattern fill. */
+  unsigned char backgroundpattern[8*25];
+
+  /* Background colors. */
+  unsigned char backgroundpatterncolors[25];
+
+};
+
+extern struct ctk_hires_theme ctk_hires_theme;
+extern struct ctk_hires_theme *ctk_hires_theme_ptr;
+
+#endif /* __CTK_HIRES_THEME_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c
new file mode 100644
index 0000000..49a2b8c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c
@@ -0,0 +1,872 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.c,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  focus = focus & CTK_FOCUS_WINDOW;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+/*unsigned char
+ctk_arch_isprint(char c)
+{
+  return isprint(c);
+}*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h
new file mode 100644
index 0000000..5d8db4b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.h,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_H__
+#define __CTK_HIRES_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey   cgetc
+
+#define CH_ENTER '\n'
+
+#endif /* __CTK_HIRES_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c
new file mode 100644
index 0000000..d3e8f03
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c
@@ -0,0 +1,30 @@
+void ctk_hires_cputc(unsigned char ch)
+{
+}
+
+void ctk_hires_cclear(unsigned char len)
+{
+}
+
+void ctk_hires_chline(unsigned char len)
+{
+}
+void ctk_hires_cputsn(unsigned char *str, unsigned char len)
+{
+}
+
+void ctk_hires_draw_buttonleft()
+{
+}
+
+void ctk_hires_draw_buttonright()
+{
+}
+
+void ctk_hires_draw_bitmapline(unsigned char len)
+{
+}
+
+void ctk_hires_draw_windowborders()
+{
+}
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S
new file mode 100644
index 0000000..eeef7b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S
@@ -0,0 +1,149 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_1351
+;---------------------------------------------------------------------
+.bss
+OldValue:       .res    1               ; Temp for MoveCheck routine
+NewValue:       .res    1               ; Temp for MoveCheck routine
+YCorr:          .res    1               ; Correction for Y coordinate
+	
+OldPotX:        .res    1               ; Old hw counter values
+OldPotY:        .res    1
+ 
+SID_ADConv1     = $D419
+SID_ADConv2     = $D41A
+CIA1_PRA        = $DC00	
+CIA1_PRB        = $DC01	
+CIA1_DDRB       = $DC03	
+
+
+;---------------------------------------------------------------------
+.data
+XMin:           .word    0               ; X1 value of bounding box
+YMin:           .word    0               ; Y1 value of bounding box
+XMax:           .word    319             ; X2 value of bounding box
+YMax:           .word    199             ; Y2 value of bounding box
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+;---------------------------------------------------------------------
+	;; Most of the mouse code is taken from the CC65 libraries written by
+	;; Ullrich von Bassewitz
+MoveCheck:
+        sty     OldValue
+        sta     NewValue
+        ldx     #$00
+ 
+        sub     OldValue                ; a = mod64 (new - old)
+        and     #%01111111
+        cmp     #%01000000              ; if (a > 0)
+        bcs     @L1                     ;
+        lsr     a                       ;   a /= 2;
+        beq     @L2                     ;   if (a != 0)
+        ldy     NewValue                ;     y = NewValue
+        rts                             ;   return
+ 
+@L1:    ora     #%11000000              ; else or in high order bits
+        cmp     #$FF                    ; if (a != -1)
+        beq     @L2
+        sec
+        ror     a                       ;   a /= 2
+        dex                             ;   high byte = -1 (X = $FF)
+        ldy     NewValue
+        rts
+                                                                               
+@L2:    txa                             ; A = $00
+        rts
+                                                                               
+;---------------------------------------------------------------------	
+_ctk_mouse_1351:
+        lda     SID_ADConv1             ; Get mouse X movement
+        ldy     OldPotX
+        jsr     MoveCheck               ; Calculate movement vector
+        sty     OldPotX
+ 
+; Calculate the new X coordinate (--> a/y)
+ 
+        add     _ctk_mouse_joyx
+        tay                             ; Remember low byte
+        txa
+        adc     _ctk_mouse_joyx+1
+        tax
+ 
+; Limit the X coordinate to the bounding box
+ 
+        cpy     XMin
+        sbc     XMin+1
+        bpl     @L1
+        ldy     XMin
+        ldx     XMin+1
+        jmp     @L2
+@L1:    txa
+ 
+        cpy     XMax
+        sbc     XMax+1
+        bmi     @L2
+        ldy     XMax
+        ldx     XMax+1
+@L2:    sty     _ctk_mouse_joyx
+        stx     _ctk_mouse_joyx+1
+; Calculate the Y movement vector
+ 
+        lda     SID_ADConv2             ; Get mouse Y movement
+        ldy     OldPotY
+        jsr     MoveCheck               ; Calculate movement
+        sty     OldPotY
+ 
+; Calculate the new Y coordinate (--> a/y)
+ 
+        sta     OldValue
+        lda     _ctk_mouse_joyy
+        sub     OldValue
+        tay
+        stx     OldValue
+        lda     _ctk_mouse_joyy+1
+        sbc     OldValue
+        tax
+ 
+        cpy     YMin
+        sbc     YMin+1
+        bpl     @L3
+        ldy     YMin
+        ldx     YMin+1
+        jmp     @L4
+@L3:    txa
+                                                                               
+        cpy     YMax
+        sbc     YMax+1
+        bmi     @L4
+        ldy     YMax
+        ldx     YMax+1
+@L4:    sty     _ctk_mouse_joyy
+        stx     _ctk_mouse_joyy+1
+
+	;; Get mouse button
+        lda     #$7F
+        sta     CIA1_PRA
+        lda     CIA1_PRB                ; Read joystick #0
+        ldx     #0
+        and     #$1F
+        eor     #$1F
+	
+	ora     _ctk_mouse_firebutton
+	sta	_ctk_mouse_firebutton
+	
+	lda	#0
+	sta	CIA1_PRA
+	sta	CIA1_DDRB	
+	rts	
+;---------------------------------------------------------------------			
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S
new file mode 100644
index 0000000..6aa53b4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S
@@ -0,0 +1,48 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton
+	.export		_ctk_mouse_asm_irq
+	.import		_ctk_mouse_joy, _ctk_mouse_1351
+;---------------------------------------------------------------------
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------			
+_ctk_mouse_asm_irq:
+	lda #0
+	sta _ctk_mouse_firebutton
+	
+	jsr _ctk_mouse_joy
+	;; jsr_ctk_mouse_1351
+
+ ; 	lda _ctk_mouse_joybutton
+ ; 	ora _ctk_mouse_1351button
+ ; 	sta _ctk_mouse_firebutton
+	
+	  lda _ctk_mouse_joyy
+	  clc
+	  adc #$32
+	  sta $d001
+	  sta $d003	
+
+	  lda _ctk_mouse_joyx
+	  clc
+	  adc #$18
+	  sta $d000
+	  sta $d002	
+	  lda #0
+	  adc _ctk_mouse_joyx+1
+	  and #1
+	  beq :+
+	  lda #3
+:		
+	  sta $d010                                                                                       
+	  jmp $ea31
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S
new file mode 100644
index 0000000..963ca36
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S
@@ -0,0 +1,135 @@
+
+;---------------------------------------------------------------------
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_joy	
+;---------------------------------------------------------------------
+.bss
+lastjoydy:	.res 1
+lastjoydx:	.res 1
+joydycnt:	.res 1
+joydxcnt:	.res 1
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+_ctk_mouse_joy:
+	  ldy $dc02
+	  lda #0
+          sta $dc02
+          lda $dc00
+          sty $dc02
+	  ldy #0
+	  ldx #0
+	  lsr
+	  bcs nodey
+	  dey
+nodey:
+	  lsr
+	  bcs noiny
+	  iny
+noiny:
+	  lsr
+	  bcs nodex
+	  dex
+nodex:
+	  lsr
+	  bcs noinx
+	  inx
+noinx:
+	  and #1
+	  eor #1
+	  ora _ctk_mouse_firebutton
+	  sta _ctk_mouse_firebutton
+
+	  cpy lastjoydy
+	  sty lastjoydy
+	  bne noydy
+	  tya
+	  pha
+	  inc joydycnt
+	  lda joydycnt
+          cmp #$1f
+          bmi nostajoydycnt
+          lda #$20
+	  sta joydycnt
+nostajoydycnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tay
+	  pla
+asldeyloop:
+	  asl
+	  dey
+	  bpl asldeyloop
+	  tay
+	  jmp ydy
+noydy:
+	  lda #0
+	  sta joydycnt
+ydy:
+
+	  tya
+	  clc
+	  adc _ctk_mouse_joyy
+
+	  cmp #240
+	  bcc :+
+	  lda #0
+:	
+		
+ 	  cmp #200
+ 	  bcc :+
+ 	  lda #199		
+:
+	  sta _ctk_mouse_joyy
+	
+	  cpx lastjoydx
+	  stx lastjoydx
+	  bne noxdx
+	  txa
+	  pha
+	  inc joydxcnt
+	  lda joydxcnt
+          cmp #$1f
+          bmi nostajoydxcnt
+          lda #$20
+	  sta joydxcnt
+nostajoydxcnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tax
+	  pla
+asldexloop:
+	  asl
+	  dex
+	  bpl asldexloop
+	  tax
+	  jmp xdx
+noxdx:
+	  lda #0
+	  sta joydxcnt
+xdx:
+	                                                                                       
+	  txa
+	  clc
+	  adc _ctk_mouse_joyx
+	  sta _ctk_mouse_joyx
+	  php
+	  lda #$ff
+	  cpx #0
+	  bmi nolda02
+	  lda #0
+nolda02:
+	  plp
+	  adc _ctk_mouse_joyx+1
+	  sta _ctk_mouse_joyx+1
+	  rts	                                                                                       
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c
new file mode 100644
index 0000000..98ef49c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.c,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+unsigned short ctk_mouse_joyy, ctk_mouse_joyx;
+unsigned char ctk_mouse_firebutton;
+
+extern void ctk_mouse_asm_irq(void);
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_init(void)
+{
+  /* Place mouse pointer at the middle of the screen. */
+  ctk_mouse_joyx = 160;
+  ctk_mouse_joyy = 100;
+  
+  /* Setup and start IRQ */
+  asm("sei");
+  asm("lda #<%v", ctk_mouse_asm_irq);
+  asm("sta $0314");
+  asm("lda #>%v", ctk_mouse_asm_irq);
+  asm("sta $0315");   
+  asm("cli");
+  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+  if(ctk_mouse_joyx >= 342) {
+    ctk_mouse_joyx = 0;
+  } else if(ctk_mouse_joyx >= 320) {
+    ctk_mouse_joyx = 319;
+  }
+  return ctk_mouse_joyx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+  return ctk_mouse_joyy;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+  return ctk_mouse_firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_hide(void)
+{
+  /* Turn off sprites 0 and 1 */
+  asm("lda #0");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_show(void)
+{  
+  /* Turn on sprites 0 and 1 */
+  asm("lda #3");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki-cpc/contiki-cpc/lib/lc-asm.s b/contiki-cpc/contiki-cpc/lib/lc-asm.s
new file mode 100644
index 0000000..05f773d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/lc-asm.s
@@ -0,0 +1,30 @@
+;---------------------------------------------------------------------
+;;	.globl ptr1
+;---------------------------------------------------------------------
+_lc_set::
+;;	sta ptr1
+;;	stx ptr1+1
+;;	tsx
+;;	lda $0102,x
+;;	ldy #$01
+;;	sta (ptr1),y
+;;	lda $0101,x
+;;	dey
+;;	sta (ptr1),y
+
+	ret
+;---------------------------------------------------------------------
+_lc_resume::
+;;	sta ptr1
+;;	stx ptr1+1
+;;	ldy #$01
+;;	lda (ptr1),y
+;;	beq :+
+;;	tsx
+;;	sta $0102,x
+;;	dey
+;;	lda (ptr1),y
+;;	sta $0101,x
+
+	ret
+;---------------------------------------------------------------------	
diff --git a/contiki-cpc/contiki-cpc/lib/lc.h b/contiki-cpc/contiki-cpc/lib/lc.h
new file mode 100644
index 0000000..a90c7ae
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/lc.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and Oliver Schmidt
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>, Oliver Schmidt <ol.sc0web.de>
+ *
+ * $Id: lc.h,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ */
+/* Local continuations: a form of continuation that only works locally
+   within a function.
+*/
+
+#ifndef __LC_H__
+#define __LC_H__
+
+#include "cc.h"
+
+typedef void * lc_t;
+
+void __fastcall__ lc_set(lc_t *lc);
+void __fastcall__ lc_resume(lc_t *lc);
+
+#define LC_SET(lc)    lc_set(&(lc))
+#define LC_RESUME(lc) lc_resume(&(lc))
+#define LC_INIT(lc)   (lc) = NULL
+#define LC_END(lc)
+
+#endif /* __LC_H__ */
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch-asm.S b/contiki-cpc/contiki-cpc/lib/mtarch-asm.S
new file mode 100644
index 0000000..22ab609
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch-asm.S
@@ -0,0 +1,245 @@
+;---------------------------------------------------------------------       
+	.importzp       ptr1
+	.importzp	sp
+	.import		__ZP_START__
+
+	
+	.import		_mtarch_asm_threadstack
+	.import		_mtarch_asm_threadsp
+	.import		_mtarch_asm_threadspreg
+	.import		_mtarch_asm_threadzp	
+	
+	.export		_mtarch_asm_exec
+	.export		_mtarch_yield
+	.export		_mtarch_asm_start
+	.export		_mtarch_pstart, _mtarch_pstop
+	
+;---------------------------------------------------------------------
+.bss
+kernelsp:	.res 2
+kernelspreg:	.res 1		
+	
+oldirq:		.res 2
+
+	zpsize = 32
+.code
+;---------------------------------------------------------------------	
+	;; Switch to thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped onto the threadstack, and the
+	;; sp and spreg are saved to the local variables "kernelsp" and
+	;; "kernelspreg". Also, the zeropage variables are saved.
+	
+_mtarch_asm_exec:
+	sei
+	;; Save current stack pointer
+	lda sp
+	sta kernelsp
+	lda sp+1
+	sta kernelsp+1
+	
+	tsx
+	stx kernelspreg
+	
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda _mtarch_asm_threadsp
+	sta sp
+	lda _mtarch_asm_threadsp+1
+	sta sp+1
+	
+	ldx _mtarch_asm_threadspreg
+	txs
+
+; 	jsr _mtarch_pstart	
+
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315
+
+	
+	pla
+	tay
+	pla
+	tax
+	pla
+	
+	rti
+
+	;; Switch from thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped back from the threadstack, and the
+	;; sp and spreg are restored from the local variables "kernelsp" and
+	;; "kernelspreg".
+yield:
+	sei
+	lda sp
+	sta _mtarch_asm_threadsp
+	lda sp+1
+	sta _mtarch_asm_threadsp+1
+
+	tsx
+	stx _mtarch_asm_threadspreg
+
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy #0
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda kernelsp
+	sta sp
+	lda kernelsp+1
+	sta sp+1
+	
+	ldx kernelspreg
+	txs
+
+	cli
+	
+	rts
+;---------------------------------------------------------------------
+	;; Simulate an IRQ by pushing CPU status and CPu registers
+	;; onto the stack. Then call the yield function to yield the
+	;; process.		
+_mtarch_yield:	
+	php
+	pha
+	txa
+	pha
+	tya
+	pha
+
+        tsx
+         
+                                ; the rts adds 1 to the PC
+                                ; saved on the stack. We want
+        lda $0105,x             ; the stack to look like is would
+        clc                     ; do inside of an interrupt.
+        adc #1                  ; (this is what the 'rts' does,
+        sta $0105,x             ;  but not the 'rti')
+        lda $0106,x
+        adc #0
+        sta $0106,x
+ 
+	
+	jmp yield		
+;---------------------------------------------------------------------
+_mtarch_asm_start:
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	rts
+
+;---------------------------------------------------------------------
+irq:
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	jmp yield
+;---------------------------------------------------------------------	
+	;; Setup preemption IRQ
+_mtarch_pstart:
+	sei
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315		
+	cli
+	rts
+;---------------------------------------------------------------------
+_mtarch_pstop:
+	sei
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	cli
+	rts	
+;---------------------------------------------------------------------
+
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch.c b/contiki-cpc/contiki-cpc/lib/mtarch.c
new file mode 100644
index 0000000..dc8e3cd
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.c,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#include "mtarch.h"
+#include <string.h>
+
+unsigned char  mtarch_asm_threadspreg;
+unsigned char *mtarch_asm_threadsp;
+unsigned char *mtarch_asm_threadzp;
+unsigned char *mtarch_asm_threadstack;
+
+void mtarch_asm_start(void);
+void mtarch_asm_exec(void);
+
+
+/*--------------------------------------------------------------------------*/
+void
+mtarch_start(struct mtarch_thread *thread,
+	     void (* function)(void *data),
+	     void *data)
+{
+  memset(thread->cpustack, 0, sizeof(thread->cpustack));
+  memset(thread->cstack, 0, sizeof(thread->cstack));
+  
+  /* Create a CPU stack frame with the appropriate values... */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((unsigned short)function) >> 8; /* high byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((unsigned short)function) & 0xff; /* low byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21; /* processor flags. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 5] =       /* a register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 6] =     /* x register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0;  /* y register */
+  thread->spreg = MTARCH_CPUSTACKSIZE - 8;
+
+  /* Setup the C stack with the data pointer. */
+  thread->sp = &thread->cstack[MTARCH_CSTACKSIZE - 1];
+  
+  mtarch_asm_threadzp    = &(thread->zp);  
+  mtarch_asm_start();
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_exec(struct mtarch_thread *thread)
+{
+  /* Switch processor stack. The call to mtarch_asm_switch() will not
+     return until the process that we switch to calls yield(). */
+  mtarch_asm_threadspreg = thread->spreg;
+  mtarch_asm_threadsp    = thread->sp;
+
+  mtarch_asm_threadstack = &(thread->cpustack[0]);  
+  mtarch_asm_threadzp    = &(thread->zp[0]);
+  
+  mtarch_asm_exec();
+
+  thread->sp = mtarch_asm_threadsp;
+  thread->spreg = mtarch_asm_threadspreg;  
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_init(void) {
+
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_remove(void)
+{
+
+}
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch.h b/contiki-cpc/contiki-cpc/lib/mtarch.h
new file mode 100644
index 0000000..44a8424
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#ifndef __MTARCH_H__
+#define __MTARCH_H__
+
+#define MTARCH_CPUSTACKSIZE 256
+#define MTARCH_CSTACKSIZE 256
+#define MTARCH_ZPSIZE 32
+
+struct mtarch_thread {
+  unsigned char  spreg;
+  unsigned char *sp;
+  unsigned char  cpustack[MTARCH_CPUSTACKSIZE];
+  unsigned char  cstack[MTARCH_CSTACKSIZE];
+  unsigned char  zp[MTARCH_ZPSIZE];
+};
+
+#endif /* __MTARCH_H__ */
+	
diff --git a/contiki-cpc/contiki-cpc/loader/cfs-cpc.c b/contiki-cpc/contiki-cpc/loader/cfs-cpc.c
new file mode 100644
index 0000000..7976d7e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/cfs-cpc.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.c,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+extern void _readdir(void *);
+
+struct cpc_dir 
+{
+	char *buffer; 
+	char *ptr;
+};
+
+//#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+           cpc_cfs_eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_cpc_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    log_message("Starting KERNAL CFS", "");
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+ // if(cbm_open(2, 8, f, n) == 0) {
+ //   return 2;
+ // }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+ // cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return 0; //return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return 0; //  return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+	struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+
+	char *buffer = malloc(2048);
+	
+	if (buffer)
+	{
+		cpcdir->buffer = buffer;
+		cpcdir->ptr = buffer;	
+		_readdir(buffer);
+		return 0;
+	}
+	return 1;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  int i;
+  int size;
+  int npos;
+  struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+  char *ptr = cpcdir->ptr;
+
+  if (ptr[0]!=0xff)
+	return 1;
+  
+  ptr++;
+
+  npos = 0;
+  for (i=0; i<8; i++)
+  {  
+    char ch = ptr[0]&0x07f;
+    ptr++;
+    e->name[npos] = ch;
+    npos++;    
+  }
+  e->name[npos] = '.';
+  npos++;
+  for (i=0; i<3; i++)
+  {
+    char ch = ptr[0]&0x07f;
+    ptr++;
+    e->name[npos] = ch;
+    npos++;
+  }
+  e->name[npos] = '\0';
+ 
+  size = (ptr[0]&0x0ff) + ((ptr[1]&0x0ff)<<8);  
+  size = size*1024;
+  ptr+=2;
+  e->size = size;
+  cpcdir->ptr = ptr;
+
+  return 0;
+
+/* 1 = if no more dir entries
+ 0 = more dir entries */
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+	struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+	free(cpcdir->buffer);
+	return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/cfs-cpc.h b/contiki-cpc/contiki-cpc/loader/cfs-cpc.h
new file mode 100644
index 0000000..ddf55a0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/cfs-cpc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#ifndef __CFS_CPC_H__
+#define __CFS_CPC_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cpc_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/dir.s b/contiki-cpc/contiki-cpc/loader/dir.s
new file mode 100644
index 0000000..2de266a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/dir.s
@@ -0,0 +1,99 @@
+;; This example shows how to perform a directory of a disc
+;; and extract the filenames. 
+;;
+;; This code is public domain and can freely be used in your
+;; own programs.
+;;
+;; Written by Kevin Thacker. 2002
+
+
+
+;;------------------------------------------------------------------
+
+;; firmware function to catalog a disc or cassette
+cas_catalog == 0xbc9b
+;; firmware function to disable text output
+txt_vdu_enable == 0xbb54
+;; firmware function to enable text output
+txt_vdu_disable == 0xbb57
+;; firmware function to find a RSX 
+kl_find_command == 0xbcd4
+
+		.globl __readdir
+		.area _CODE
+
+;;------------------------------------------------------------------
+;; find BIOS SET MESSAGE command
+;; this is used to disable disc messages.
+;; this is compatible with other DOSs that also provide this command
+__readdir::
+
+ld hl,#cmd_bios_set_message
+call kl_find_command
+ret nc
+
+;; command found
+
+;; store address of command
+ld (bios_set_message),hl
+ld a,c
+;; store "rom select" of command
+ld (bios_set_message+2),a
+
+;;------------------------------------------------------------------
+
+;; do CAT
+ld hl,#2
+add hl,sp
+ld e,(hl)
+inc hl
+ld d,(hl)
+call fetch_directory
+ret
+
+
+;;------------------------------------------------------------------
+;; display files from data generated by CAS CATALOG function
+
+;; perform a CAT command
+
+fetch_directory::
+push de
+;; disable disc messages. Error messages will not be displayed.
+ld a,#0xff
+rst 0x018						;; KL FAR CALL
+.dw bios_set_message
+
+;; disable text output
+call txt_vdu_disable
+
+pop de
+
+;; initialise in case of an error
+xor a
+ld (de),a
+
+;; do catalog
+call cas_catalog
+
+;; enable text output
+call txt_vdu_enable
+
+;; enable disc messages. Error messages will be displayed
+ld a,#0x0
+rst 0x018						;; KL FAR CALL
+.dw bios_set_message
+ret
+
+
+;;------------------------------------------------------------------
+
+;; this is initialised when the "BIOS SET MESSAGE" RSX has been found.
+bios_set_message:
+.dw 0                    ;; address of function
+.db 0                    ;; "rom select" for function
+
+
+cmd_bios_set_message:
+.db #0x01+#0x80				;; this is the "BIOS SET MESSAGE" RSX
+
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c b/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c
new file mode 100644
index 0000000..84d12be
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c
@@ -0,0 +1,93 @@
+#include "loader-arch.h"
+#include "rel.h"
+#include <stddef.h>
+#include <malloc.h>
+
+extern void *progend;
+
+struct prg_hdr {
+	char *relocatedata;
+	char arch[8];
+	char version[8];
+	char initfunc[1];
+};
+
+struct dsc_hdr {
+	char *relocatedata;
+	struct dsc dscdata;
+};
+
+unsigned char loader_arch_load(const char *name, char *arg)
+{
+	char *loadaddr;	
+	struct prg_hdr *prghdr;
+	int length;
+
+	/* get length of file */
+	length = get_file_length(name);
+	if (length==0)
+		return LOADER_ERR_OPEN;
+
+	/* allocate memory */
+	loadaddr = malloc(length);
+	if (loadaddr==NULL)
+		return LOADER_ERR_MEM;
+	
+	/* load the file */
+	load_file(name,loadaddr);
+
+	prghdr = (struct prg_hdr *)loadaddr;
+
+	/* relocate it */
+	relocate(prghdr->relocatedata,loadaddr);
+
+	((void (*)(char *))prghdr->initfunc)(arg);
+
+	return LOADER_OK;
+}
+
+struct dsc *loader_arch_load_dsc(const char *name)
+{
+	char *loadaddr;
+	struct dsc_hdr *dschdr;
+	int length;
+
+	/* get length of file */
+	length = get_file_length(name);
+	if (length==0)
+		return NULL;
+
+	/* allocate memory */
+	loadaddr = malloc(length);
+	if (loadaddr==NULL)
+		return NULL;
+
+	/* load the file */
+	load_file(name, loadaddr);
+	
+	dschdr = (struct dsc_hdr *)loadaddr;
+	/* relocate it */
+	relocate(dschdr->relocatedata, loadaddr);
+
+	return &dschdr->dscdata;
+}
+
+void loader_arch_free(void *loadaddr)
+{
+	/* free module */
+	/* we're given the start of 'arch' member of the prg_hdr,
+	calculate the real start address and then free the block */
+	void *header = (void *)((char *)loadaddr - offsetof(struct prg_hdr,arch));
+	free(header);
+}
+
+void loader_arch_free_dsc(struct dsc *dscdata)
+{
+	/* we're given the start of 'dsc' member of the dsc_hdr,
+	calculate the real start address and then free the block */
+	void *header = (void *)((char *)dscdata - 2);
+//offsetof(struct 
+//dsc_hdr,dscdata));
+	free(header);
+}
+
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch-module.s b/contiki-cpc/contiki-cpc/loader/loader-arch-module.s
new file mode 100644
index 0000000..2539b86
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch-module.s
@@ -0,0 +1,16 @@
+;; This is the header for Contiki program files
+;;
+;; This must always be at at the start of the file
+;; The order of the data must not change.
+;;
+.globl _loader_appinit
+		.area _CODE
+
+_loader_arch_loadaddr::
+arch:		.byte	0,0,0,0,0,1,1,1
+version:	.byte	0,0,0,0,0,1,1,1
+
+;; The position of the init function can be anywhere in the file.
+;; This jump is always in the same place, and points to the actual init function.
+	call gsinit
+	jp _loader_appinit
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch.h b/contiki-cpc/contiki-cpc/loader/loader-arch.h
new file mode 100644
index 0000000..efce757
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+#include "dsc.h"
+
+unsigned char loader_arch_load(const char *name, char *arg);
+struct dsc *loader_arch_load_dsc(const char *name);
+void loader_arch_free(void *addr);
+void loader_arch_free_dsc(struct dsc *);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD_DSC(name) loader_arch_load_dsc(name)
+#define LOADER_LOAD(name, arg) loader_arch_load(name, arg)
+#define LOADER_UNLOAD() loader_arch_free(&loader_arch_loadaddr)
+#define LOADER_UNLOAD_DSC(dsc) loader_arch_free_dsc(dsc)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/rel.h b/contiki-cpc/contiki-cpc/loader/rel.h
new file mode 100644
index 0000000..fd3c264
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/rel.h
@@ -0,0 +1,3 @@
+int get_file_length(const char *);
+void load_file(const char *, void *);
+void relocate(void *relocate_data, void *base);
diff --git a/contiki-cpc/contiki-cpc/loader/rel.s b/contiki-cpc/contiki-cpc/loader/rel.s
new file mode 100644
index 0000000..be8f085
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/rel.s
@@ -0,0 +1,219 @@
+	.area _CODE
+	.globl _get_file_length
+	.globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+	ld hl,#2
+	add hl,sp
+	ld a,(hl)
+	inc hl
+	ld h,(hl)
+	ld l,a
+
+	;; HL = address of null terminated string
+	call count_string_length
+	ld de,#0x0c000		;; points to unused 2k buffer
+	call 0x0bc77		;; cas in open
+	push bc			;; BC = length of file
+	call 0x0bc7d		;; cas in abandon
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+	push hl
+	ld b,#0
+csl:	ld a,(hl)
+	or a
+	jr z,csl2
+	inc hl
+	inc b
+	jr csl
+csl2:
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+	ld hl,#5
+	add hl,sp
+	ld d,(hl)
+	dec hl
+	ld e,(hl)
+	dec hl
+
+	push de
+	ld a,(hl)
+	dec hl
+	ld l,(hl)
+	ld h,a
+
+	call count_string_length
+	ld de,#0x0c000
+	call 0x0bc77		;; cas in open
+	pop hl			;; load address
+	call 0x0bc83		;; cas in direct
+	call 0x0bc7a		;; cas in close
+	ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+	ld hl,#5
+	add hl,sp
+	push ix
+	ld b,(hl)			;; base address
+	dec hl
+	ld c,(hl)
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld h,a	
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld l,a				;; IX is offset of table from start of loaded file
+	add ix,bc			;; relocate IX to give absolute address of table.
+
+	push bc
+	pop hl
+	call relocate_16bit
+	push bc
+	pop hl
+	call relocate_8bitl	;; lower byte
+	push bc
+	pop hl
+	call relocate_8bith	;; upper byte
+	pop ix
+	ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;; 
+relocate_8bith:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bh
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bith
+
+r8bh:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get low byte of address
+ld e,0(ix)
+inc ix
+
+;; get high byte to relocate
+ld d,(hl)
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),d
+jr relocate_8bith
+
+relocate_8bitl:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bl
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bitl
+
+r8bl:
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+ld e,(hl)
+ld d,#0x0
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),e
+jr relocate_8bitl
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit 
+;; value to relocate. 
+;;
+;; BC = base address
+;; 
+;; NOTE: 
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix)		;; number of items to relocate
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r16
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_16bit
+
+r16:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+jr relocate_16bit
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S
new file mode 100644
index 0000000..86b9639
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S
@@ -0,0 +1,505 @@
+
+	
+	.export _c64_dio_asm_init
+	.export _c64_dio_asm_read_block
+	.export _c64_dio_asm_write_block	
+
+	.export _c64_dio_asm_track, _c64_dio_asm_sector
+
+	.export _c64_dio_asm_ptr
+	
+	.importzp ptr1, ptr2
+		
+	;; job code $80 read, $90 write
+	
+
+ciout    = $ffa8
+listen   = $ffb1
+second   = $ff93
+unlsn    = $ffae
+
+nbytes   = 34
+esc      = $42
+
+blockread = 1
+blockwrite = 2
+
+errok    = 0
+errerr   = 1
+
+.data
+_c64_dio_asm_track: .byte 0
+_c64_dio_asm_sector: .byte 0
+_c64_dio_asm_ptr: .byte 0,0			
+
+.code
+;---------------------------------------
+_c64_dio_asm_read_block:		
+
+  	lda #blockread
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+	 lda _c64_dio_asm_sector
+         jsr send
+
+
+         jsr recv
+         cmp #errok
+         bne readerr
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+readl:	
+         jsr recv
+         sta (ptr1),y
+         iny
+         bne readl
+         clc
+	 lda #0
+         tax	
+         rts
+readerr:	
+	;          sta $07c0	
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_write_block:		
+
+ 	lda #blockwrite
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+         lda _c64_dio_asm_sector
+         jsr send
+
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+writel:
+         lda (ptr1),y	
+         jsr send
+         iny
+         bne writel
+
+         jsr recv
+         cmp #errok
+         bne writeerr
+         lda #0
+	 tax
+         rts
+
+writeerr:	
+	;          sta $07c0
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_init:		
+         sta devnr
+         lda #$00
+         sta drvmem
+         lda #$05
+         sta drvmem+1
+
+         lda #<drive
+         sta ptr1
+         lda #>drive
+         sta ptr1+1
+
+       ; lda devnr
+       ; ldx #<icmd
+       ; ldy #>icmd
+       ; jsr drvcmd
+       ; jsr unlsn
+
+mwl:	
+         lda devnr
+         ldx #<mwcmd
+         ldy #>mwcmd
+         jsr drvcmd
+
+         ldy #0
+         lda (ptr1),y
+         jsr ciout
+         iny
+         cpy #nbytes
+         bne *-8
+
+         jsr unlsn
+
+         lda drvmem
+         clc
+         adc #nbytes
+         sta drvmem
+         lda drvmem+1
+         adc #0
+         sta drvmem+1
+
+         lda ptr1
+         clc
+         adc #nbytes
+         sta ptr1
+         tax
+         lda ptr1+1
+         adc #0
+         sta ptr1+1
+         cpx #<driveend
+         sbc #>driveend
+         bcc mwl
+
+         lda devnr
+         ldx #<mecmd
+         ldy #>mecmd
+         jsr drvcmd
+         jsr unlsn
+
+         rts
+;---------------------------------------
+drvcmd:	
+         stx ptr2
+         sty ptr2+1
+         jsr listen
+         lda #$6f
+         jsr second
+
+         ldy #0
+         lda (ptr2),y
+         sta drvcmdcmp+1
+         inc ptr2
+         bne *+4
+         inc ptr2+1
+
+         ldy #0
+         lda (ptr2),y
+         jsr ciout
+         iny
+drvcmdcmp:	 cpy #0
+         bne *-8
+         rts
+;---------------------------------------
+devnr:	    .byte 8
+mwcmd:	    .byte 6
+	.byte $4d, $2d, $57
+drvmem:	   .word $0500
+         .byte nbytes
+         .byte 0
+mecmd:	    .byte 2
+	 .byte $55, $33
+         .byte 0
+;---------------------------------------
+send:
+
+         sta ptr2
+         ldx #7
+sendl:	
+         lsr ptr2
+
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcc *+4
+         eor #$30
+         sta $dd00
+
+         lda #$c0
+         bit $dd00
+         bne *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         lda $dd00
+         and #$c0
+         eor #$c0
+         bne *-7
+
+         dex
+         bpl sendl
+
+	 ldx $d020
+	 lda #1
+	 sta $d020
+	 stx $d020
+		
+         rts
+;---------------------------------------
+recv:
+	 ldx $d020
+	 lda #0
+	 sta $d020
+	 stx $d020
+	
+         ldx #7
+recvl:	
+         lda $dd00
+         and #$c0
+         eor #$c0
+         beq *-7
+         asl a
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcs *+4
+         eor #$30
+         sta $dd00
+         ror ptr2
+
+         lda #$c0
+         bit $dd00
+         beq *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         dex
+         bpl recvl
+         lda ptr2
+         rts
+;---------------------------------------
+
+;---------------------------------------
+;the code residing in the drive:
+;---------------------------------------
+dtmp     = $46
+dtmp2    = $97
+dbuf     = $0300
+dbufcmd  = $00
+dbuftrack = $06
+dbufsect = $07
+
+retries  = 10
+bretries = 2
+;---------------------------------------
+drive  :		
+	.org $0500
+
+
+
+         cld
+         tsx
+         stx dstack
+         sei
+         jsr ledoff
+
+drivel:	
+         jsr dload
+         jsr ledoff
+         cli
+         jmp drivel
+;---------------------------------------
+ledon:	
+         lda $1c00
+         ora #$08
+         sta $1c00
+         rts
+ledoff:	
+         lda $1c00
+         and #$f7
+         sta $1c00
+         rts
+;---------------------------------------
+drecv:	
+         ldx #7
+drecvl:	
+         lda $1800
+         bmi atn
+         and #5
+         beq *-7
+         lsr a
+         lda #2
+         bcc *+4
+         lda #8
+         sta $1800
+         ror dtmp
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         beq *-9
+         lda #0
+         sta $1800
+         dex
+         bpl drecvl
+         lda dtmp
+         rts
+;---------------------------------------
+atn:	
+         ldx dstack
+         txs
+         cli
+         rts
+;---------------------------------------
+dsend:	
+         sta dtmp
+         ldx #7
+dsendl:	
+         lsr dtmp
+         lda #2
+         bcs *+4
+         lda #8
+         sta $1800
+
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         bne *-9
+
+         sta $1800
+
+         lda #5
+         bit $1800
+         bne *-3
+         dex
+         bpl dsendl
+         rts
+;---------------------------------------
+dload:
+         ldy #0
+
+         jsr drecv
+         sta dcmd
+	
+         jsr ledon
+	
+         jsr drecv
+         sta dbuftrack
+
+         jsr drecv
+         sta dbufsect
+
+	 lda dcmd
+	 cmp #blockwrite
+	 bne dblockread
+dblockwrite:
+         ldy #0
+drecvpl:	
+         jsr drecv
+         sta dbuf,y	
+         iny
+         bne drecvpl
+	
+	 jmp dputsect
+
+dblockread:		
+         jsr dgetsect
+
+dsendpage:	
+         ldy #0
+dsendpl:	
+         lda dbuf,y
+         jsr dsend
+         iny
+         bne dsendpl
+         rts
+;---------------------------------------
+dgetsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dgetsectl:	
+         lda #$80
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dgsnoerr
+
+         cpx #0
+         beq dgsserr
+         dex
+         cpx #bretries
+         bcs dgetsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dgetsectl
+
+dgsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dgsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+dputsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dputsectl:	
+         lda #$90
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dpsnoerr
+
+         cpx #0
+         beq dpsserr
+         dex
+         cpx #bretries
+         bcs dputsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dputsectl
+
+dpsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dpsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+led:	      .byte 0,0
+dstack:	   .byte 0
+dcmd:	     .byte 0
+.RELOC
+driveend:	
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h
new file mode 100644
index 0000000..c00355a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio-asm.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_ASM_H__
+#define __C64_DIO_ASM_H__
+
+extern unsigned char c64_dio_asm_track,
+  c64_dio_asm_sector;
+
+extern unsigned char *c64_dio_asm_ptr;
+
+void __fastcall__ c64_dio_asm_init(unsigned char drive);
+unsigned char c64_dio_asm_read_block(void);
+unsigned char c64_dio_asm_write_block(void);
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c
new file mode 100644
index 0000000..ff09e03
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c
@@ -0,0 +1,119 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * C64 direct disk I/O.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */ 
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.c,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read a block of data (256 bytes) from the disk.
+ *
+ * \param track The track of the disk block to be read.
+ *
+ * \param sector The sector of the disk block to be read.
+ *
+ * \param ptr A pointer to a buffer than must be able to accomodate
+ * 256 bytes of data.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * read.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_read_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_read_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write a block of data (256 bytes) to the disk.
+ *
+ * \param track The track of the disk block to be written.
+ *
+ * \param sector The sector of the disk block to be written.
+ *
+ * \param ptr A pointer to a buffer containing the 256 bytes of data
+ * to be written.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * written.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_write_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_write_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the direct disk I/O routines for a particular disk drive.
+ *
+ * This function must be called before any of the other direct disk
+ * I/O functions can be used.
+ *
+ * \param drive The drive number of the disk drive for which the
+ * direct disk I/O should be enabled.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_dio_init(unsigned char drive)
+{
+  c64_dio_asm_init(drive);
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h
new file mode 100644
index 0000000..6773c0e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_H__
+#define __C64_DIO_H__
+
+void c64_dio_init(unsigned char drive);
+
+unsigned char c64_dio_read_block(unsigned char track,
+				 unsigned char sector,
+				 unsigned char *buf);
+
+unsigned char c64_dio_write_block(unsigned char track,
+				  unsigned char sector,
+				  unsigned char *buf);
+
+#define C64_DIO_OK 0
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c
new file mode 100644
index 0000000..7b8577c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c
@@ -0,0 +1,205 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * "Raw" C64 file system access.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file provides functions that allow reading data from files
+ * without updating the file descriptor pointer. The functions are not
+ * automatically included in the core Contiki code and therefore
+ * application programs that use tham must manually link with this
+ * file.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.c,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+
+#include "c64-fs-raw.h"
+
+#include <string.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+
+extern unsigned char _c64_fs_dirbuf[256];
+extern unsigned char _c64_fs_dirbuftrack, _c64_fs_dirbufsect;
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack, _c64_fs_filebufsect;
+
+void _c64_fs_readdirbuf(unsigned char track, unsigned char sect);
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from a file without updating the file descriptor pointer.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller, but does not update the file
+ * description pointer like the c64_fs_read() function does.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_read_raw(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+  unsigned char fptr, ftrack, fsect;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  fptr = f->ptr;
+  ftrack = f->track;
+  fsect = f->sect;
+  
+  for(i = 0; i < len; ++i) {
+    *buf = _c64_fs_filebuf[fptr];
+    
+    ++fptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(fptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(fptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = ftrack = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = fsect = _c64_fs_filebuf[1];
+      fptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the file descriptior pointer forward in the file.
+ *
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param len The number of bytes the pointer should be moved forward.
+ *
+ * \return The number of bytes that the pointer actually was moved, or
+ * 0 if an end of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_read_next(register struct c64_fs_file *f, int len)
+{
+  int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+    
+    ++f->ptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }    
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h
new file mode 100644
index 0000000..9e434d6
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_RAW_H__
+#define __C64_FS_RAW_H__
+
+#include "c64-fs.h"
+
+int __fastcall__ c64_fs_read_raw(struct c64_fs_file *f,
+				 char *buf, int len);
+
+int c64_fs_read_next(struct c64_fs_file *f, int len);
+
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c
new file mode 100644
index 0000000..8f74c00
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c
@@ -0,0 +1,121 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of C64 file writes.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The functions in this file are not included in the core Contiki
+ * code, but must be explicitly linked by an application that that
+ * wishes to be able to write to files.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-write.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-fs.h"
+#include <string.h>
+
+/* An *UGLY* implementation of c64_fs_write that only can be used to
+   overwrite a single block file. */
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack,
+  _c64_fs_filebufsect;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write data to an open file.
+ *
+ * \note This function currently does not support writing to other than a single block file (cannot be more than 254 bytes long).
+ *
+ * \param f A pointer to a file descriptor previously opened with c64_fs_open().
+ *
+ * \param buf A pointer to a buffer with data that should be written
+ * to the file.
+ *
+ * \param len The length of the data that should be written.
+ *
+ * \return The number of bytes actually written.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_write(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+
+  if(len <= 0) {
+    return 0;
+  }
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+
+  i = 256 - f->ptr;
+  if(len < i) {
+    i = len;
+  }
+
+  memcpy(&_c64_fs_filebuf[f->ptr], buf, i);
+
+  f->ptr += i;
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr > _c64_fs_filebuf[1]) {
+    _c64_fs_filebuf[1] = f->ptr;    
+  }
+
+  c64_dio_write_block(_c64_fs_filebuftrack,
+		      _c64_fs_filebufsect,
+		      _c64_fs_filebuf);
+  
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c
new file mode 100644
index 0000000..d0b8f47
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c
@@ -0,0 +1,411 @@
+/**
+ * \defgroup c64fs C64 file system and disk functions.
+ * @{
+ *
+ * The C64 file system functions are divided into two categories:
+ * those that deal with C64 files and the C64 disk directory, and
+ * those that allow direct block access to the disk. The former
+ * functions can be used for accessing regular files, whereas the
+ * latter functions are used e.g. to download D64 files onto 1541
+ * disks.
+ *
+ * \note The C64 filesystem functions currently only work with the
+ * 1541/1541-II/1571 and compatible drives, and not with the IDE64
+ * hard disks or the 1581/FD2000 3.5" drives.
+ *
+ * 
+ */
+
+/**
+ * \file
+ * C64 file system operations interface for Contiki.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+#include "c64-fs.h"
+
+#include <string.h>
+#include <stdio.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+unsigned char _c64_fs_dirbuf[256];
+unsigned char _c64_fs_dirbuftrack = 0, _c64_fs_dirbufsect = 0;
+
+unsigned char _c64_fs_filebuf[256];
+unsigned char _c64_fs_filebuftrack = 0, _c64_fs_filebufsect = 0;
+
+static struct c64_fs_dirent lastdirent;
+
+static struct c64_fs_dir opendir;
+static struct c64_fs_dirent opendirent;
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a file.
+ *
+ * The file description must be allocated by the caller and a pointer
+ * to it is passed to this function.
+ *
+ * \param name A pointer to the name of the file to be opened.
+ * \param f A pointer to the file descriptor struct.
+ *
+ * \retval 0 If the file was successfully opened.
+ * \retval -1 If the file does not exist.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_open(const char *name, register struct c64_fs_file *f)
+{
+  /* First check if we already have the file cached. If so, we don't
+     need to do an expensive directory lookup. */
+  if(strncmp(lastdirent.name, name, 16) == 0) {
+    f->track = lastdirent.track;
+    f->sect = lastdirent.sect;
+    f->ptr = 2;
+    return 0;
+  }
+
+  /* Not in cache, so we walk through directory instead. */
+  c64_fs_opendir(&opendir);
+
+  do {
+    c64_fs_readdir_dirent(&opendir, &opendirent);
+    if(strncmp(opendirent.name, name, 16) == 0) {
+      f->track = opendirent.track;
+      f->sect = opendirent.sect;
+      f->ptr = 2;
+      return 0;
+    }
+  } while(c64_fs_readdir_next(&opendir) == 0);
+
+  /* The file was not found in the directory. We flush the directory
+     buffer cache now in order to prevent a nasty problem from
+     happening: If the first directory block of an empty disk was
+     cached, *all* subsequent file opens would return "file not
+     found". */
+  _c64_fs_dirbuftrack = 0; /* There are no disk blocks on track 0. */
+  return -1;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from an open file.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if !NOASM
+#pragma optimize(push, off)
+#endif /* !NOASM */
+int __fastcall__
+c64_fs_read(register struct c64_fs_file *f, char *buf, int len)
+{
+  static int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+
+#if NOASM
+  if(f->track != _c64_fs_filebuftrack ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack, _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+#else /* NOASM */
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebuftrack);
+  asm("bne doblock");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebufsect);
+  asm("bne doblock");
+
+  asm("jmp noblock");
+
+  asm("doblock:");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebuftrack);
+  asm("sta %v", c64_dio_asm_track);
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebufsect);
+  asm("sta %v", c64_dio_asm_sector);
+
+  asm("lda #<(%v)", _c64_fs_filebuf);
+  asm("sta %v", c64_dio_asm_ptr);
+  asm("lda #>(%v)", _c64_fs_filebuf);
+  asm("sta %v+1", c64_dio_asm_ptr);
+
+  asm("jsr %v", c64_dio_asm_read_block);
+
+  asm("noblock:");
+
+#endif /* NOASM */
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+#if NOASM    
+    *buf = _c64_fs_filebuf[f->ptr];
+    ++f->ptr;
+#else /* NOASM */	
+    asm("ldy #%o+1", buf);
+    asm("jsr ldaxysp");
+    asm("sta ptr2");
+    asm("stx ptr2+1");
+
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("lda (regbank+%b),y", 4);    
+    asm("tax");
+
+    asm("ldy #0");
+    asm("lda %v,x", _c64_fs_filebuf);
+    asm("sta (ptr2),y");
+
+    asm("inx");
+    asm("txa");
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("sta (regbank+%b),y", 4);    
+#endif /* NOASM */
+
+    
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+#if !NOASM    
+#pragma optimize(pop)
+#endif /* !NOASM */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close an open file.
+ *
+ * \param f A pointer to a file descriptor struct that previously has
+ * been opened with c64_fs_open().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_close(struct c64_fs_file *f)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Read a directory buffer into the _c64_fs_dirbuf buffer.
+ *
+ * This function is shared between this and  the c64-fs-raw module.
+ *
+ * \param track The track of the directory block.
+ * \param sect The sector of the directory block.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+_c64_fs_readdirbuf(unsigned char track, unsigned char sect)
+{
+  if(_c64_fs_dirbuftrack == track &&
+     _c64_fs_dirbufsect == sect) {
+    /* Buffer already contains requested block, return. */
+    return;
+  }
+  c64_dio_read_block(track, sect, _c64_fs_dirbuf);
+  _c64_fs_dirbuftrack = track;
+  _c64_fs_dirbufsect = sect;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open the disk directory for reading.
+ *
+ * The caller must supply a pointer to a directory descriptor.
+ *
+ * \param d A pointer to a directory description that must be
+ * allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_opendir(register struct c64_fs_dir *d)
+{
+  d->track = 18;
+  d->sect = 1;
+  d->ptr = 2;
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read the current directory entry.
+ *
+ * This function reads the directory entry to which the directory
+ * descriptor currently points into a struct c64_fs_dirent supplied by
+ * the caller.
+ *
+ * The function c64_fs_readdir_next() is used to move the directory
+ * entry pointer forward in the directory.
+ *
+ * \param d A pointer to a directory descriptor previously opened with c64_fs_opendir().
+ *
+ * \param f A pointer to a directory entry that must have been
+ * previously allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_readdir_dirent(register struct c64_fs_dir *d,
+		      register struct c64_fs_dirent *f)
+{
+  struct directory_entry *de;
+  int i;
+  register char *nameptr;
+  
+  _c64_fs_readdirbuf(d->track, d->sect);
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  nameptr = de->name;
+  for(i = 0; i < 16; ++i) {
+    if(*nameptr == 0xa0) {
+      *nameptr = 0;
+      break;
+    }
+    ++nameptr;
+  }
+  strncpy(f->name, de->name, 16);
+  f->track = de->track;
+  f->sect = de->sect;
+  f->size = de->blockslo + (de->blockshi >> 8);
+  memcpy(&lastdirent, f, sizeof(struct c64_fs_dirent));
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the directory pointer forward.
+ *
+ * This function moves the directory entry pointer in the directory
+ * descriptor forward so that it points to the next file.
+ *
+ * \param d A pointer to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ *
+ * \retval 1 If there are no more directory entried in the directory.
+ * \retval 0 There were more directory entries and the pointer has
+ * been moved to point to the next one.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_readdir_next(struct c64_fs_dir *d)
+{
+  struct directory_entry *de;
+ again:
+  _c64_fs_readdirbuf(d->track, d->sect);
+  if(d->ptr == 226) {
+    if(_c64_fs_dirbuf[0] == 0) {
+      return 1;
+    }
+    d->track = _c64_fs_dirbuf[0];
+    d->sect = _c64_fs_dirbuf[1];
+    d->ptr = 2;
+  } else {
+    d->ptr += 32;
+  }
+
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  if(de->type == 0) {
+    goto again;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close a directory descriptor previously opened by c64_fs_opendir().
+ *
+ * \param d A poitner to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_closedir(struct c64_fs_dir *d)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h
new file mode 100644
index 0000000..bfacb70
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h
@@ -0,0 +1,97 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the C64 filesystem functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.h,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_H__
+#define __C64_FS_H__
+
+#include "c64-dio.h"
+
+/**
+ * An opaque structure with no user visible elements that represents
+ * an open file.
+ */
+struct c64_fs_file {
+  unsigned char track, sect, ptr;
+};
+
+int c64_fs_open(const char *name, struct c64_fs_file *f);
+void c64_fs_close(struct c64_fs_file *f);
+int __fastcall__ c64_fs_read(struct c64_fs_file *f,
+			     char *buf, int len);
+
+int __fastcall__ c64_fs_write(struct c64_fs_file *f,
+			      char *buf, int len);
+
+/**
+ * An opaque structure with no user visible elements that represents a
+ * directory descriptor.
+ */
+struct c64_fs_dir {
+  unsigned char track, sect, ptr;
+};
+
+/**
+ * A C64 directory entry.
+ */
+struct c64_fs_dirent {
+  char name[17];        /**< The name of the directory entry. */
+  unsigned short size;  /**< The size of the directory entry in 256 byte blocks. */
+  unsigned char track,  
+    sect;
+};
+
+
+unsigned char c64_fs_opendir(struct c64_fs_dir *d);
+
+void c64_fs_readdir_dirent(struct c64_fs_dir *d,
+			   struct c64_fs_dirent *f);
+unsigned char c64_fs_readdir_next(struct c64_fs_dir *d);
+
+void c64_fs_closedir(struct c64_fs_dir *d);
+
+/** @} */
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c
new file mode 100644
index 0000000..66aaa2d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cfs_cbm_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    log_message("Starting KERNAL CFS", "");
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, f, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+  return cbm_opendir(4, 8);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  struct cbm_dirent ce;
+  int ret;
+  ret = cbm_readdir(4, &ce);
+  strncpy(e->name, ce.name, sizeof(ce.name));
+  e->size = ce.size;
+  return ret;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+  cbm_closedir(4);
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h
new file mode 100644
index 0000000..774d855
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.h,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#ifndef __CFS_CBM_H__
+#define __CFS_CBM_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cbm_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c
new file mode 100644
index 0000000..b4536f5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.c,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l) {return -1;}
+static int  s_opendir(struct cfs_dir *p, const char *n) {return -1;}
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;}
+static int  s_closedir(struct cfs_dir *p) {return -1;}
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": init", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_init_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, CBM_READ, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h
new file mode 100644
index 0000000..6289941
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.h,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#ifndef __CFS_INIT_H__
+#define __CFS_INIT_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_init_init, arg);
+
+#endif /* __CFS_INIT_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h b/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h
new file mode 100644
index 0000000..9a2a22e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h
@@ -0,0 +1,19 @@
+int cpc_load(char *name, char *arg);
+void cpc_unload();
+struct dsc *cpc_load_dsc(char *name);
+void cpc_unload_dsc(struct dsc *dsc);
+
+#define LOADER_LOAD(name,arg) \
+	cpc_load(name, arg)
+
+#define LOADER_UNLOAD() \
+	cpc_unload()
+
+#define LOADER_LOAD_DSC(name) \
+	cpc_load_dsc(name)
+
+#define LOADER_UNLOAD_DSC(dsc) \
+	cpc_unload_dsc(dsc)
+
+
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c
new file mode 100644
index 0000000..0785ce0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c
@@ -0,0 +1,185 @@
+/**
+ * \file
+ * File loader implementation.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file implements dynamically loadable files for Contiki using
+ * the cc65 module loading system. The actual file operations are
+ * implemented in other files.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include "modload.h" 
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cfs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+static int __fastcall__
+do_read(int f, char *buf, unsigned int len)
+{
+  return cfs_read(f, buf, len);
+}
+
+static struct mod_ctrl ctrl = {
+  (void *)do_read            /* Read from disk */
+};
+
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Load a program from disk and execute it.
+ *
+ * Code originally written by Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  
+  /* Now open the file */
+  ctrl.callerdata = cfs_open(name, 0);
+  if(ctrl.callerdata < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+  
+  /* Load the module */
+  res = mod_load(&ctrl);
+  
+  /* Close the input file */
+  cfs_close(ctrl.callerdata);
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load and start a program.
+ *
+ * \param name The name of the program file.
+ * \param arg A pointer that will be passed to the new process.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load a DSC file into memory.
+ *
+ * The memory must be deallocated with the loader_arch_free() function
+ * after is has been used.
+ *
+ * \param name The name of the DSC file.
+ *
+ * \return A pointer to the struct dsc or NULL if the DSC file could
+ * not be loaded.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+  unsigned char r;
+
+  r = load(name);
+  if(r == MLOAD_OK) {
+    return (struct dsc *)ctrl.module;
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Deallocate memory previously allocated by the loader.
+ *
+ * The loader allocates memory when it loads programs or DSC
+ * files. All such memory must be deallocated with this function. Memory for programs is automatically deallocated when calling the LOADER_UNLOAD() function, but memory for DSCs must be explicitly deallcated with this function.
+ *
+ * \param addr A pointer to memory allocated by the loader.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+  mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old
new file mode 100644
index 0000000..d76c3cc
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c.old,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <modload.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cpc-fs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  int ret;
+  
+  /* Now open the file */
+  ret = cpc_fs_open(name);
+  if(ret < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+/*  ctrl.callerdata = (int)&file; */
+  
+  /* Load the module */
+  res = cpc_fs_read();
+  
+  /* Close the input file */
+  cpc_fs_close();
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+//  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+  unsigned char r;
+
+  r = load(name);
+  if(r == MLOAD_OK) {
+    return (struct dsc *)ctrl.module;    
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+  mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/modload.c b/contiki-cpc/contiki-cpc/loader/unused/modload.c
new file mode 100644
index 0000000..9c33b16
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/modload.c
@@ -0,0 +1,12 @@
+#include "modload.h"
+
+void mod_free(struct dsc *d)
+{
+
+
+}
+
+int mod_load(struct mod_ctrl *ctrl)
+{
+	return MLOAD_OK;
+}
diff --git a/contiki-cpc/contiki-cpc/loader/unused/modload.h b/contiki-cpc/contiki-cpc/loader/unused/modload.h
new file mode 100644
index 0000000..ff0dc41
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/modload.h
@@ -0,0 +1,13 @@
+void mod_free(struct dsc *);
+
+struct mod_ctrl
+{ 
+	void *read;
+	void *module;
+	int callerdata;
+}; 
+
+#define MLOAD_OK 0
+
+int mod_load(struct mod_ctrl *);
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/rel-old.s b/contiki-cpc/contiki-cpc/loader/unused/rel-old.s
new file mode 100644
index 0000000..8b03baa
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/rel-old.s
@@ -0,0 +1,167 @@
+	.area _CODE
+	.globl _get_file_length
+	.globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+	ld hl,#2
+	add hl,sp
+	ld a,(hl)
+	inc hl
+	ld h,(hl)
+	ld l,a
+
+	;; HL = address of null terminated string
+	call count_string_length
+	ld de,#0x0c000		;; points to unused 2k buffer
+	call 0x0bc77		;; cas in open
+	push bc			;; BC = length of file
+	call 0x0bc7d		;; cas in abandon
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+	push hl
+	ld b,#0
+csl:	ld a,(hl)
+	or a
+	jr z,csl2
+	inc hl
+	inc b
+	jr csl
+csl2:
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+	ld hl,#5
+	add hl,sp
+	ld d,(hl)
+	dec hl
+	ld e,(hl)
+	dec hl
+
+	push de
+	ld a,(hl)
+	dec hl
+	ld l,(hl)
+	ld h,a
+
+	call count_string_length
+	ld de,#0x0c000
+	call 0x0bc77		;; cas in open
+	pop hl			;; load address
+	call 0x0bc83		;; cas in direct
+	call 0x0bc7a		;; cas in close
+	ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+	ld hl,#5
+	add hl,sp
+	push ix
+	ld b,(hl)			;; base address
+	dec hl
+	ld c,(hl)
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld h,a	
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld l,a				;; IX is offset of table from start of loaded file
+	add ix,bc			;; relocate IX to give absolute address of table.
+	call relocate_16bit
+	ld e,c
+	call relocate_8bit	;; lower byte
+	ld e,b
+	call relocate_8bit	;; upper byte
+	pop ix
+	ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;; 
+relocate_8bit:
+	ld a,0(ix)
+	or a
+	ret z
+	inc ix
+rel8bit: push af
+	ld l,0(ix)
+	inc ix
+	ld h,0(ix)
+inc ix
+add hl,bc
+ld a,(hl)
+add e
+ld (hl),a
+pop af
+dec a
+jr nz,rel8bit
+ret
+
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit 
+;; value to relocate. 
+;;
+;; BC = base address
+;; 
+;; NOTE: 
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix)		;; number of items to relocate
+or a
+ret z
+
+inc ix
+
+rel16bit:
+push af
+;; get offset (from start of file) of 16-bit value to relocate
+ld l,0(ix)
+inc ix
+ld h,0(ix)
+inc ix
+add hl,bc
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+pop af
+dec a
+jr nz,rel16bit
+ret
+
diff --git a/contiki-cpc/contiki-cpc/readme.txt b/contiki-cpc/contiki-cpc/readme.txt
new file mode 100644
index 0000000..2fc791a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/readme.txt
@@ -0,0 +1,22 @@
+What I did to make contiki for CPC:
+
+1. I took the contiki sources and made it compile with gcc on linux.
+2. Next I made it compile with sdcc
+3. Next I added cpc version of some files.
+4. Then I prayed.
+
+About contiki:
+
+contiki is both the initial program to run to start the operating system 
+AND contains a library of functions to use by the other programs. 
+
+Compile contiki executable to generate the executable and to generate a 
+list of symbols.
+
+These symbols are used to compile the other programs. When they are run 
+they will automatically call the appropiate functions.
+
+This is not as good as referencing a fixed location jumptable, because 
+each utility has to be recompiled if the contiki executable is recompiled 
+:(
+
diff --git a/contiki-cpc/contiki-cpc/uip/cs8900a.c b/contiki-cpc/contiki-cpc/uip/cs8900a.c
new file mode 100644
index 0000000..ebb525c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/cs8900a.c
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+   written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+/*#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x00
+#define UIP_ETHADDR2 0x00
+#define UIP_ETHADDR3 0x64
+#define UIP_ETHADDR4 0x64
+#define UIP_ETHADDR5 0x64*/
+
+extern u8_t *cs8900a_rxtxreg,
+  *cs8900a_txcmd,
+  *cs8900a_txlen,
+  *cs8900a_packetpp,
+  *cs8900a_ppdata;
+
+static u16_t len;
+static u8_t r;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+  /* Turn on transmission and reception of frames. */
+  /* PACKETPP = 0x0112;
+     PPDATA   = 0x00c0; */
+  asm("lda #$12");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Accept valid unicast+broadcast frames. */
+  /* PACKETPP = 0x0104;
+     PPDATA   = 0x0d05; */
+  asm("lda #$04");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$05");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$0d");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Set MAC address. */
+  /* PACKETPP = 0x0158;
+     PPDATA   = (ETHADDR1 << 8) | (ETHADDR0); */
+  asm("lda #$58");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015a;
+     PPDATA   = (ETHADDR3 << 8) | (ETHADDR2); */
+  asm("lda #$5a");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015c;
+     PPDATA   = (ETHADDR5 << 8) | (ETHADDR4); */
+  asm("lda #$5c");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+  if(uip_len > UIP_BUFSIZE) {
+    asm("inc $d020");
+    return;
+  }
+    
+  /* Transmit command. */
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_txcmd);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_txcmd);
+  asm("lda _uip_len");
+  asm("sta %v", cs8900a_txlen);
+#if UIP_BUFSIZE > 255  
+  asm("lda _uip_len+1");
+#else
+  asm("lda #0");
+#endif      
+  asm("sta %v+1", cs8900a_txlen);
+
+  asm("ldx #8");
+  asm("tryagain:");
+  /* Check for avaliable buffer space. */
+  asm("lda #$38");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #1");
+  asm("bne send");
+
+  /* No space avaliable, skip a received frame and try again. */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+
+  asm("dex");
+  asm("bne tryagain");
+  
+  asm("bailout:");
+  return;
+
+  /* Send the frame. */
+  asm("send:");
+
+  
+  /* First, send 40+14=54 bytes of header. */
+  
+  asm("ldx #54");
+  asm("ldy #0");
+  asm("sendloop1:");
+  asm("lda _uip_buf,y");
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("lda _uip_buf+1,y");
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("iny");
+  asm("dex");
+  asm("dex");
+  asm("bne sendloop1");
+
+  if(uip_len <= 54) {
+    return;
+  }
+
+  /* Next, send rest of the packet. */
+
+  uip_len -= 54;
+
+
+  asm("lda ptr1");
+  asm("pha");
+  asm("lda ptr1+1");
+  asm("pha");
+  
+  asm("lda _uip_appdata");
+  asm("sta ptr1");
+  asm("lda _uip_appdata+1");
+  asm("sta ptr1+1");  
+
+  asm("sendloop2:");
+  asm("lda _uip_len");  
+  asm("tax");
+  asm("and #1");
+  asm("beq noinc");
+  asm("inx");
+  asm("noinc:");
+#if UIP_BUFSIZE > 255
+  asm("lda _uip_len+1");
+#else
+  asm("lda #0");
+#endif
+  asm("beq nozero");
+  asm("ldx #0");
+  asm("nozero:");
+  asm("ldy #0");
+  asm("sendloop:");
+  asm("lda (ptr1),y");
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("dex");
+  asm("dex");
+  asm("bne sendloop");
+  asm("inc ptr1+1");
+#if UIP_BUFSIZE > 255
+  asm("dec _uip_len+1");
+  asm("bpl sendloop2");
+#endif
+
+  asm("pla");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("sta ptr1");  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+  /* PACKETPP = 0x0102;
+     PPDATA   = PPDATA | 0x0040; */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u8_t
+cs8900a_poll(void)
+{
+  /* Check receiver event register to see if there are any valid
+     unicast frames avaliable.  */
+  /* PACKETPP = 0x0124;
+     if(PPDATA & 0x000d == 0x0000) {
+       return 0;
+     }
+  */
+  asm("lda #$24");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #$0d");
+  asm("cmp #$00");
+  asm("bne noreturn");
+  /* No frame ready. */
+  return 0;
+  
+  asm("noreturn:");
+  /* Process the incoming frame. */
+  
+  /* Read receiver event and discard it. */
+  /* dummy = RXTXREG; */
+     
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta _len+1");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta _len");
+  
+  /* Read frame length. */
+  /* len = uip_len = RXTXREG; */
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta _len+1");
+  asm("sta _uip_len+1");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta _len");
+  asm("sta _uip_len");
+
+  
+  if(len > UIP_BUFSIZE) {
+    skip_frame();
+    return 0;
+  }
+  
+  /* Read bytes into uip_buf. */
+  asm("lda ptr1");
+  asm("pha");
+  asm("lda ptr1+1");
+  asm("pha");
+  
+  asm("lda #<_uip_buf");
+  asm("sta ptr1");
+  asm("lda #>_uip_buf");
+  asm("sta ptr1+1");  
+  
+  asm("lda _len+1");
+  asm("beq read256");
+  
+    /* Read first 256*n bytes. */
+  asm("ldy #0");
+  asm("read256loop:");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne read256loop");
+  asm("inc ptr1+1");
+  
+  asm("dec _len+1");
+  asm("bne read256loop");
+  
+  /* Read last 255 or less bytes. */
+  asm("read256:");
+  asm("lda _len");
+  asm("lsr");
+  asm("bcc noinc");
+  asm("inc _len");
+  asm("noinc:");
+  asm("ldy #$0");
+  asm("readloop:");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("cpy _len");
+  asm("bne readloop");
+
+  asm("pla");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("sta ptr1");
+  return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-cpc/contiki-cpc/uip/cs8900a.h b/contiki-cpc/contiki-cpc/uip/cs8900a.h
new file mode 100644
index 0000000..0112450
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u8_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-drv.c b/contiki-cpc/contiki-cpc/uip/eth64-drv.c
new file mode 100644
index 0000000..73b12bc
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-drv.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(eth64_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-dsc.c b/contiki-cpc/contiki-cpc/uip/eth64-dsc.c
new file mode 100644
index 0000000..5504061
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: eth64-dsc.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lan91c96_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(lan91c96_dsc,
+    "IDE64/ETH64 driver",
+    "lan91c96.drv",
+    lan91c96_init,
+    &lan91c96_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lan91c96icon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lan91c96icon_textmap[9] = {
+  'I', 'D', 'E',
+  ' ', '6', '4',
+  'E', 'T', 'H'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon lan91c96_icon =
+  {CTK_ICON("ETH64 driver", lan91c96icon_bitmap, lan91c96icon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c b/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c
new file mode 100644
index 0000000..9adf3aa
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-dump-drv.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      dump_packet();
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/lan91c96.c b/contiki-cpc/contiki-cpc/uip/lan91c96.c
new file mode 100644
index 0000000..485b974
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/lan91c96.c
@@ -0,0 +1,486 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Ethernet card for Commodore 64, based on lan91c96 chip
+ * is a device created by IDE64 Project team.
+ * More information: http://ide64.come.to
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x0d
+#define UIP_ETHADDR2 0x60
+#define UIP_ETHADDR3 0x80
+#define UIP_ETHADDR4 0x3d
+#define UIP_ETHADDR5 0xb9
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+// #define DEBUG
+
+#define ETHBASE 0xde10
+
+#define ETHBSR     ETHBASE+0x0e  //Bank select register             R/W (2B)
+
+/* Register bank 0 */
+
+#define ETHTCR     ETHBASE       //Transmition control register     R/W (2B)
+#define ETHEPHSR   ETHBASE+2     //EPH status register              R/O (2B)
+#define ETHRCR     ETHBASE+4     //Receive control register         R/W (2B)
+#define ETHECR     ETHBASE+6     //Counter register                 R/O (2B)
+#define ETHMIR     (ETHBASE+8)     //Memory information register      R/O (2B)
+#define ETHMCR     ETHBASE+0x0a  //Memory Config. reg.    +0 R/W +1 R/O (2B)
+
+/* Register bank 1 */
+
+#define ETHCR      ETHBASE       //Configuration register           R/W (2B)
+#define ETHBAR     ETHBASE+2     //Base address register            R/W (2B)
+#define ETHIAR     ETHBASE+4     //Individual address register      R/W (6B)
+#define ETHGPR     ETHBASE+0x0a  //General address register         R/W (2B)
+#define ETHCTR     ETHBASE+0x0c  //Control register                 R/W (2B)
+
+/* Register bank 2 */
+
+#define ETHMMUCR   ETHBASE       //MMU command register             W/O (1B)
+#define ETHAUTOTX  ETHBASE+1     //AUTO TX start register           R/W (1B)
+#define ETHPNR     ETHBASE+2     //Packet number register           R/W (1B)
+#define ETHARR     ETHBASE+3     //Allocation result register       R/O (1B)
+#define ETHFIFO    ETHBASE+4     //FIFO ports register              R/O (2B)
+#define ETHPTR     ETHBASE+6     //Pointer register                 R/W (2B)
+#define ETHDATA    ETHBASE+8     //Data register                    R/W (4B)
+#define ETHIST     (ETHBASE+0x0c)  //Interrupt status register        R/O (1B)
+#define ETHACK     ETHBASE+0x0c  //Interrupt acknowledge register   W/O (1B)
+#define ETHMSK     ETHBASE+0x0d  //Interrupt mask register          R/W (1B)
+
+/* Register bank 3 */
+
+#define ETHMT      ETHBASE       //Multicast table                  R/W (8B)
+#define ETHMGMT    ETHBASE+8     //Management interface             R/W (2B)
+#define ETHREV     ETHBASE+0x0a  //Revision register                R/W (2B)
+#define ETHERCV    ETHBASE+0x0c  //Early RCV register               R/W (2B)
+
+#define BANK(num) asm("lda #%b",num); asm("sta %w",ETHBSR);
+
+#ifdef DEBUG
+static void print_packet(u8_t *, u16_t);
+#endif
+
+static u8_t packet_status;
+static u16_t packet_length;
+
+extern u16_t uip_len;
+
+
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+  /* Check if high byte is 0x33 */
+  asm("lda %w", ETHBSR+1);
+  asm("cmp #$33");
+  asm("beq @L1");
+
+  asm("inc $d021");              // Error
+
+  asm("@L1:");
+
+  /* Reset ETH card */
+  BANK(0);
+  asm("lda #%%10000000");        //Software reset
+  asm("sta %w", ETHRCR+1);
+
+  asm("lda #0");
+  asm("sta %w", ETHRCR);
+  asm("sta %w", ETHRCR+1);
+
+  /* delay */
+  asm("ldx #0");
+  asm("@L2:");
+  asm("cmp ($ff,x)");            //6 cycles
+  asm("cmp ($ff,x)");            //6 cycles
+  asm("dex");                    //2 cycles
+  asm("bne @L2");                //3 cycles
+                                 //17*256=4352 => 4,4 ms
+
+  /* Enable transmit and receive */
+  asm("lda #%%10000001");        //Enable transmit TXENA, PAD_EN
+  asm("sta %w", ETHTCR);
+  asm("lda #%%00000011");        //Enable receive, strip CRC ???
+  asm("sta %w", ETHRCR+1);
+
+  BANK(1);
+  asm("lda %w", ETHCR+1);
+  asm("ora #%%00010000");        //No wait (IOCHRDY)
+  asm("sta %w", ETHCR+1);
+
+  asm("lda #%%00001001");        //Auto release
+  asm("sta %w", ETHCTR+1);
+  
+  /* Set MAC address */
+  asm("lda #%b", (unsigned)UIP_ETHADDR0);
+  asm("sta %w", ETHIAR);
+  asm("lda #%b", (unsigned)UIP_ETHADDR1);
+  asm("sta %w", ETHIAR+1);
+  asm("lda #%b", (unsigned)UIP_ETHADDR2);
+  asm("sta %w", ETHIAR+2);
+  asm("lda #%b", (unsigned)UIP_ETHADDR3);
+  asm("sta %w", ETHIAR+3);
+  asm("lda #%b", (unsigned)UIP_ETHADDR4);
+  asm("sta %w", ETHIAR+4);
+  asm("lda #%b", (unsigned)UIP_ETHADDR5);
+  asm("sta %w", ETHIAR+5);
+
+  BANK(2);
+  asm("lda #%%00001111");               //RCV INT, ALLOC INT, TX INT, TX EMPTY 
+  asm("sta %w", ETHMSK);
+}
+#pragma optimize(pop)
+
+
+#pragma optimize(push, off)
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void)
+#else
+u8_t lan91c96_poll(void)
+#endif
+{
+  // #######
+//  BANK(0);
+//  printf("RAM: %d ", ((*(unsigned int *)ETHMIR) & 0xff00));
+//  BANK(2);
+  // #######
+
+  asm("lda %w", ETHIST);
+  asm("and #%%00000001");                //RCV INT
+  asm("bne @L1");
+
+  /* No packet available */
+  return 0;
+
+  asm("@L1:");
+
+  #ifdef DEBUG
+  printf("RCV: IRQ\n");
+  #endif
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%11100000");               //RCV,AUTO INCR.,READ
+  asm("sta %w", ETHPTR+1);
+
+  asm("lda %w", ETHDATA);               //Status word
+  asm("lda %w", ETHDATA);
+  asm("sta _packet_status");            //High byte only
+
+  asm("lda %w", ETHDATA);               //Total number of bytes
+  asm("sta _packet_length");
+  asm("lda %w", ETHDATA);
+  asm("sta _packet_length+1");
+
+  /* Last word contain 'last data byte' and 0x60 */
+  /* or 'fill byte' and 0x40 */
+
+  packet_length -= 6;            //The packet contains 3 extra words
+
+  asm("lda _packet_status");
+  asm("and #$10");
+  asm("beq @L2");
+
+  packet_length++;
+
+  #ifdef DEBUG
+  printf("RCV: odd number of bytes\n");
+  #endif
+
+  asm("@L2:");
+                    
+  #ifdef DEBUG
+  printf("RCV: L:%d ST-HIGH:0x%02x ",packet_length,packet_status);
+  #endif
+
+  if (packet_length > UIP_BUFSIZE)
+  {
+    /* Remove and release RX packet from FIFO*/ 
+    asm("lda #%%10000000");
+    asm("sta %w", ETHMMUCR);
+
+    #ifdef DEBUG
+    printf("RCV: UIP_BUFSIZE exceeded - packet dropped!\n");
+    #endif
+
+    return 0;
+  }
+
+  asm("lda #<_uip_buf");
+  asm("sta ptr1");
+  asm("lda #>_uip_buf");
+  asm("sta ptr1+1");
+
+  asm("ldy #0");
+  asm("ldx _packet_length+1");
+  asm("beq @RE1");               //packet_length < 256
+
+  asm("@RL1:");
+  asm("lda %w", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne @RL1");
+  asm("inc ptr1+1");
+  asm("dex");
+  asm("bne @RL1");
+
+  asm("@RE1:");
+  asm("lda %w", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("cpy _packet_length");
+  asm("bne @RE1");
+
+  /* Remove and release RX packet from FIFO*/ 
+  asm("lda #%%10000000");
+  asm("sta %w", ETHMMUCR);
+
+  #ifdef DEBUG
+//  print_packet(uip_buf, packet_length);
+  #endif
+
+  return packet_length;
+}
+#pragma optimize(pop)
+
+/* First 40+14 (IP nad TCP header) is send from uip_buf */
+/* than data from uip_appdata                           */
+
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+  #ifdef DEBUG
+  printf("SND: send packet\n");
+  #endif
+
+  #if UIP_BUFSIZE > 255
+  asm("lda _uip_len+1");  
+  #else
+  asm("lda #0");
+  #endif
+  asm("ora #%%00100000");        //Allocate memory for TX
+  asm("sta %w", ETHMMUCR);
+
+  asm("ldx #8");                 //Wait...
+  asm("@L1:");                   //Wait for allocation ready
+  asm("lda %w", ETHIST);
+  asm("and #%%00001000");        //ALLOC INT
+  asm("bne @X1");
+  asm("dex");
+  asm("bne @L1");
+
+    #ifdef DEBUG
+    printf("SND: ERR: memory alloc timeout\n");
+    #endif
+
+    return;
+
+  asm("@X1:");
+  #ifdef DEBUG
+  printf("SND: packet memory allocated\n");
+  #endif
+
+  asm("lda #%%00001000");        //Acknowledge int, is it necessary ???
+  asm("sta %w", ETHACK);
+
+  asm("lda %w", ETHARR);
+  asm("sta %w", ETHPNR);         //Set packet address
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%01000000");        //AUTO INCR.
+  asm("sta %w", ETHPTR+1);
+
+  #ifdef DEBUG
+  printf("SND: L:%d ", uip_len);
+  #endif
+
+  asm("lda #0");                 //Status written by CSMA
+  asm("sta %w", ETHDATA);
+  asm("sta %w", ETHDATA);
+
+  asm("lda _uip_len");
+  asm("and #$01");
+  asm("beq @SD1");
+
+    packet_length=uip_len+5;
+    asm("jmp @LC1");
+
+  asm("@SD1:");
+
+    packet_length=uip_len+6;       //+6 for status word, length and ctl byte
+
+  asm("@LC1:");
+
+//  printf("SND: L:%d ", packet_length);
+
+  asm("lda _packet_length");
+  asm("sta %w", ETHDATA);
+  asm("lda _packet_length+1");
+  asm("sta %w", ETHDATA);
+
+  #ifdef DEBUG
+//  print_packet(uip_buf, uip_len);
+  #endif
+
+  /* Send 40+14=54 bytes of header */
+
+  if(uip_len <= 54) {
+
+    #ifdef DEBUG
+    printf("SND: short packet sent.\n");
+    #endif
+
+    asm("ldx _uip_len");
+    asm("ldy #0");
+    asm("@WL1:");
+    asm("lda _uip_buf,y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("dex");
+    asm("bne @WL1");
+
+  } else {
+
+    asm("ldx #54");
+    asm("ldy #0");
+    asm("@WL2:");
+    asm("lda _uip_buf,y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("dex");
+    asm("bne @WL2");
+
+    uip_len -= 54;
+
+    asm("lda _uip_appdata");       //uip_appdata is pointer
+    asm("sta ptr1");
+    asm("lda _uip_appdata+1");
+    asm("sta ptr1+1");
+
+    asm("ldy #0");
+    #if UIP_BUFSIZE > 255
+    asm("ldx _uip_len+1");
+    #else
+    asm("ldx #0");
+    #endif
+    asm("beq @RE1");               //packet_length < 256
+
+    asm("@RL1:");
+    asm("lda (ptr1),y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("bne @RL1");
+    asm("inc ptr1+1");
+    asm("dex");
+    asm("bne @RL1");
+
+    asm("@RE1:");
+    asm("lda (ptr1),y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("cpy _uip_len");
+    asm("bne @RE1");
+
+  }
+
+  asm("lda _uip_len");
+  asm("and #$01");
+  asm("beq @R3");
+
+  asm("lda #%%00100000");
+  asm("sta %w", ETHDATA);        //Control byte
+
+  asm("lda #%%11000000");        //ENQUEUE PACKET - transmit packet
+  asm("sta %w", ETHMMUCR);
+
+//  printf("\n## %02x", *(unsigned char *)ETHIST);
+
+  return;
+
+  asm("@R3:");
+
+  asm("lda #0");
+  asm("sta %w", ETHDATA);        //Fill byte
+  asm("sta %w", ETHDATA);        //Control byte
+
+  asm("lda #%%11000000");        //ENQUEUE PACKET - transmit packet
+  asm("sta %w", ETHMMUCR);
+
+//  printf("\n## %02x\n", *(unsigned char *)ETHIST);
+  return;
+}
+#pragma optimize(pop)
+
+#ifdef DEBUG
+static void print_packet(u8_t *buf, u16_t length)
+{
+  int i;
+  int remainder;
+  int lines;
+  u8_t a;
+  int cur;
+  int address=0;
+
+  printf("\nPacket of length %d \n", length );
+
+  lines = length / 8;
+  remainder = length % 8;
+
+  for ( i = 0; i < lines ; i ++ ) {
+    printf(":%04x ", address=i*8);
+
+    for ( cur = 0; cur < 8; cur ++ ) {
+      a = *(buf ++ );
+      printf("%02x ", a);
+    }
+    printf("\n");
+  }
+
+  printf(":%04x ", address+8);
+
+  for ( i = 0; i < remainder ; i++ ) {
+    a = *(buf ++ );
+    printf("%02x ", a);
+  }
+  printf("\n");
+}
+#endif /* DEBUG */
+
diff --git a/contiki-cpc/contiki-cpc/uip/lan91c96.h b/contiki-cpc/contiki-cpc/uip/lan91c96.h
new file mode 100644
index 0000000..762a1e4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/lan91c96.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ */
+
+#ifndef _LAN91C96_H
+#define _LAN91C96_H
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_done(void);
+void lan91c96_send(void);
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void);
+#else
+u8_t lan91c96_poll(void);
+#endif
+
+/* End of lan91c96.h */
+#endif
+
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S b/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S
new file mode 100644
index 0000000..595c00c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de08
+	_cs8900a_txcmd		= $de0c
+	_cs8900a_txlen		= $de0e
+	_cs8900a_packetpp	= $de02
+	_cs8900a_ppdata		= $de04
+
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-drv.c b/contiki-cpc/contiki-cpc/uip/rrnet-drv.c
new file mode 100644
index 0000000..0e3b4b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-drv.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-drv.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c b/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c
new file mode 100644
index 0000000..b19135e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: rrnet-dsc.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon rrnet_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(rrnet_dsc,
+    "RR-Net driver",
+    "rrnet.drv",
+    rrnet_init,
+    &rrnet_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char rrneticon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char rrneticon_textmap[9] = {
+  'R', 'R', '-',
+  'N', 'e', 't',
+  'D', 'R', 'V'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon rrnet_icon =
+  {CTK_ICON("RR-Net driver", rrneticon_bitmap, rrneticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c b/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c
new file mode 100644
index 0000000..2863457
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-dump-drv.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "RR-Net dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c b/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c
new file mode 100644
index 0000000..f9e900b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev-ss.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include "rs232silversurfer.h"
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c)  (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c)  while(rs232_put(c) == RS_ERR_OVERFLOW)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+#if MAX_SIZE > 255
+static u16_t len, tmplen;
+#else
+static u8_t len, tmplen;
+#endif /* MAX_SIZE > 255 */
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+#if MAX_SIZE > 255
+  u16_t i;
+#else
+  u8_t i;
+#endif /* MAX_SIZE > 255 */
+  u8_t *ptr;
+  u8_t c;
+
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == 40) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+#if MAX_SIZE > 255
+u16_t
+#else 
+u8_t
+#endif /* MAX_SIZE > 255 */
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  while(SIO_POLL(c)) {
+    /*    printf("c %x\n", c);*/
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+      
+      
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  
+  err = rs232_init(0);
+  rs232_err(err);
+  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);
+  rs232_err(err);
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev.c b/contiki-cpc/contiki-cpc/uip/rs232dev.c
new file mode 100644
index 0000000..cc89d52
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <serial.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(ser_get(&c) == SER_ERR_NO_DATA)
+#define SIO_POLL(c)  (ser_get(&c) != SER_ERR_NO_DATA)
+#define SIO_SEND(c)  ser_put(c)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+static char loaded = 0;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+/*static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+  
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == 40) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  if(loaded == 0) {
+    return 0;
+  }
+  
+  while(SIO_POLL(c)) {
+
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+            
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  struct ser_params p;
+  
+  err = ser_load_driver("c64-swlink.ser");
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+  p.baudrate = SER_BAUD_9600;
+  p.databits = SER_BITS_8;
+  p.stopbits = SER_STOP_1;
+  p.parity = SER_PAR_NONE;
+  p.handshake = SER_HS_HW;
+
+  err = ser_open(&p);
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+
+  loaded = 1;
+  
+  /*  err = rs232_init(0); */
+  /*  rs232_err(err);*/
+  /*  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);*/
+  /*  rs232_err(err);*/
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_unload(void)
+{
+  if(loaded){
+    ser_unload();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev.h b/contiki-cpc/contiki-cpc/uip/rs232dev.h
new file mode 100644
index 0000000..ddce6ef
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+
+u16_t rs232dev_poll(void);
+
+void rs232dev_unload(void);
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S
new file mode 100644
index 0000000..89bbf9d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S
@@ -0,0 +1,329 @@
+	;; The following code is written and is copyrighted by
+	;; Groepaz/Hitmen
+
+	;; Small changes by Adam Dunkels (renamed ss232 -> rs232)
+	
+;----------------------------------------------------------------------------------------------
+; silver surfer polling mode driver for cc65
+; - work from here to create a full featured driver with interupts.
+; gpz fixed 20020828: fatal bug fixed in _rs232_params
+;----------------------------------------------------------------------------------------------
+
+rs16550base             = $de08
+
+fifo_rxd     = rs16550base+$00 ;8  (r)
+fifo_txd     = rs16550base+$00 ;8 (w)
+
+fifo_dll     = rs16550base+$00 ;8 (r/w)
+fifo_dlm     = rs16550base+$01 ;9 (r/w)
+
+fifo_ier     = rs16550base+$01 ;9
+
+fifo_fcr     = rs16550base+$02 ;a (w)
+fifo_iir     = rs16550base+$02 ;a (r)
+fifo_lcr     = rs16550base+$03 ;b
+fifo_mcr     = rs16550base+$04 ;c
+fifo_lsr     = rs16550base+$05 ;d
+fifo_msr     = rs16550base+$06 ;e (r)
+fifo_scratch = rs16550base+$07 ;f (r/w)
+	
+
+
+                        .export _rs232_init
+                        .export _rs232_done
+                        .export _rs232_params
+                        .export _rs232_put
+                        .export _rs232_get
+
+                        .importzp ptr1, ptr2
+                        .import   popa, popax
+
+;----------------------------------------------------------------------------------------------
+; Error codes. Beware: The codes must match the codes in the C header file
+
+ErrNotInitialized       = $01
+ErrBaudTooFast    	= $02
+ErrBaudNotAvail   	= $03
+ErrNoData         	= $04
+ErrOverflow       	= $05
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_init (char hacked);
+;/* Initialize the serial port, install the interrupt handler. The parameter
+; * has no effect for now and should be set to 0.
+; */
+;----------------------------------------------------------------------------------------------
+
+         .code
+
+_rs232_init:
+         ; enable ssurfer-port
+         lda $de01
+         ora #$01
+         sta $de01
+
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; activate dtr
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_done (void);
+;/* Close the port, deinstall the interrupt hander. You MUST call this function
+; * before terminating the program, otherwise the machine may crash later. If
+; * in doubt, install an exit handler using atexit(). The function will do
+; * nothing, if it was already called.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_done:
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; deactivate dtr
+         sta fifo_mcr
+
+         ; disable ssurfer-port
+         lda $de01
+         and #$fe
+         sta $de01
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+;/* Set the port parameters. Use a combination of the #defined values above. */
+;----------------------------------------------------------------------------------------------
+
+         .data
+
+_rs232_baudrates:
+
+         .word          (7372800 / (      50 * 16))
+         .word          (7372800 / (     110 * 16))
+         .word          (7372800 / (     269 *  8))
+         .word          (7372800 / (     300 * 16))
+         .word          (7372800 / (     600 * 16))
+         .word          (7372800 / (    1200 * 16))
+         .word          (7372800 / (    2400 * 16))
+         .word          (7372800 / (    4800 * 16))
+         .word          (7372800 / (    9600 * 16))
+         .word          (7372800 / (   19200 * 16))
+         .word          (7372800 / (   38400 * 16))
+         .word          (7372800 / (   57600 * 16))
+         .word          (7372800 / (  115200 * 16))
+         .word          (7372800 / (  230400 * 16))
+
+         .bss
+
+_rs232_tmp1:
+         .res 1
+
+         .code
+
+_rs232_params:
+
+         sta _rs232_tmp1 ; save parity
+
+         ; reset fifo
+         lda #%10000111
+         sta fifo_fcr
+
+   ; that delay thing really needed ?!
+   ; (original datasheet mentions a delay here)
+   ;      ldy #$00
+   ;      dey
+   ;      bny *-1
+
+         ; set dlab
+         lda #%10000011 ; we assmume 8n1
+         sta fifo_lcr
+
+         jsr popa
+         tay             ; save param
+
+         ; set baudrate
+         clc
+         lsr a		
+         lsr a
+         lsr a
+         lsr a
+         asl a
+         tax
+         lda _rs232_baudrates,x
+         sta fifo_dll
+         lda _rs232_baudrates+1,x
+         sta fifo_dlm
+
+         tya             ; param
+         and #$0f
+         ora _rs232_tmp1 ; parity
+
+         ; reset dlab
+         sta fifo_lcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+; check if byte available, returns AKKU=0 if none
+
+ss_getlsr:
+         lda fifo_lsr
+         and #$01
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_get (char* b);
+;/* Get a character from the serial port. If no characters are available, the
+; * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+; */
+;----------------------------------------------------------------------------------------------
+; get byte (non blocking, returns byte in A or CARRY=1 - error)
+
+_rs232_get:
+         sta ptr1
+         stx ptr1+1
+
+         jsr ss_getlsr  ; check if byte available
+;         bne sk32 ; yes
+         bne sk33 ; yes
+
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+sk32:
+
+         ; deactivate rts
+;         lda #%00000001
+;         sta fifo_mcr
+
+	 jsr ss_getlsr  ; check if byte available
+         bne sk33 ; yes
+
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #ErrNoData      ; no data
+         ldx #0
+         rts
+sk33:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         ; get byte
+         ldy #$00
+         lda fifo_rxd
+         sta (ptr1),y
+
+         lda #0      ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_put (char b);
+;/* Send a character via the serial port. There is a transmit buffer, but
+; * transmitting is not done via interrupt. The function returns
+; * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_put:
+         tax
+         ; transmit buf ready?
+         lda fifo_lsr
+         and #%00100000
+         bne @sk1
+@sk2:
+         lda #ErrOverflow       ; overflow
+         ldx #$00
+         rts
+@sk1:
+         ; reciever ready?
+         lda fifo_msr
+         and #%00010000
+         beq @sk2
+
+         stx fifo_txd
+
+         lda #$00               ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_pause (void);
+;/* Assert flow control and disable interrupts. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_pause:
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_unpause (void);
+;/* Re-enable interrupts and release flow control */
+;----------------------------------------------------------------------------------------------
+
+_rs232_unpause:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_status (unsigned char* status,
+;                                         unsigned char* errors);
+;/* Return the serial port status. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_status:
+ 	sta    	ptr2
+ 	stx    	ptr2+1
+ 	jsr    	popax
+ 	sta    	ptr1
+ 	stx    	ptr1+1
+
+        ldy     #$00
+
+        ; Get status
+        lda     fifo_iir
+        and     #%00000001
+        sta     _rs232_tmp1
+        lda     fifo_msr
+        lsr     a
+        and     #%01010000
+        ora     _rs232_tmp1
+        sta     _rs232_tmp1
+        lda     fifo_lsr
+        and     #%00101110
+        ora     _rs232_tmp1
+ 	sta    	(ptr1),y
+
+        ; Get errors
+        lda     #$00    ; ok
+       	sta    	(ptr2),y
+
+        lda     #$00    ; ok
+        tax
+        rts
diff --git a/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h
new file mode 100644
index 0000000..9e9a49f
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2003, Groepaz/Hitmen.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * rs232silversurfer.h
+ *
+ * Groepaz/Hitmen, 16.12.2001
+ *
+ * This defines for the SilverSurver (16c550 UART) what Ullrichs rs232 module
+ * defines for the Swithlink/Turbo232
+ *
+ * this driver operates in polling mode only atm !
+ *
+ */
+
+#ifndef _RS232silversurfer_H
+#define _RS232silversurfer_H
+
+/*****************************************************************************/
+/*                   Data                                                    */
+/*****************************************************************************/
+
+/* Baudrate settings */
+#define RS_BAUD_50                0x00
+#define RS_BAUD_110               0x10
+#define RS_BAUD_134_5             0x20
+#define RS_BAUD_300               0x30
+#define RS_BAUD_600               0x40
+#define RS_BAUD_1200              0x50
+#define RS_BAUD_2400              0x60
+#define RS_BAUD_4800              0x70
+#define RS_BAUD_9600              0x80
+#define RS_BAUD_19200             0x90
+#define RS_BAUD_38400             0xa0
+#define RS_BAUD_57600             0xb0
+#define RS_BAUD_115200            0xc0
+#define RS_BAUD_230400            0xd0
+
+/* Stop bit settings */
+#define RS_STOP_1      	       		0x00
+#define RS_STOP_2      	       		0x04
+
+/* Data bit settings */
+#define RS_BITS_5      	       		0x00
+#define RS_BITS_6      	       		0x01
+#define RS_BITS_7      	       		0x02
+#define RS_BITS_8      	       		0x03
+
+/* Parity settings */
+#define RS_PAR_NONE    	       		0x00
+#define RS_PAR_ODD     	       		0x28
+#define RS_PAR_EVEN    	       		0x38
+#define RS_PAR_MARK    	       		0x48
+#define RS_PAR_SPACE   	       		0x48
+
+/* Bit masks to mask out things from the status returned by rs232_status */
+#define RS_STATUS_IRQ                   0x01    /* (iir) IRQ condition */
+#define RS_STATUS_OVERRUN               0x02    /* (lsr) Overrun error */
+#define RS_STATUS_PE                    0x04    /* (lsr) Parity error */
+#define RS_STATUS_FE                    0x08    /* (lsr) Framing error */
+#define RS_STATUS_DSR                   0x10    /* (msr>>1) NOT data set ready */
+#define RS_STATUS_THRE                  0x20    /* (lsr) Transmit holding reg. empty */
+#define RS_STATUS_DCD                   0x40    /* (msr>>1) NOT data carrier detect */
+#define RS_STATUS_RDRF                  0x80    /* Receiver data register full */
+
+/* Error codes returned by all functions */
+#define RS_ERR_OK                       0x00    /* Not an error - relax */
+#define RS_ERR_NOT_INITIALIZED 		0x01   	/* Module not initialized */
+#define RS_ERR_BAUD_TOO_FAST            0x02    /* Cannot handle baud rate */
+#define RS_ERR_BAUD_NOT_AVAIL           0x03    /* Baud rate not available */
+#define RS_ERR_NO_DATA                  0x04    /* Nothing to read */
+#define RS_ERR_OVERFLOW                 0x05    /* No room in send buffer */
+
+/*****************************************************************************/
+/*				     Code			                                               	     */
+/*****************************************************************************/
+
+unsigned char __fastcall__ rs232_init (char hacked);
+/* Initialize the serial port, install the interrupt handler. The parameter
+ * has no effect for now and should be set to 0.
+ */
+
+unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+/* Set the port parameters. Use a combination of the #defined values above. */
+
+unsigned char __fastcall__ rs232_done (void);
+/* Close the port, deinstall the interrupt hander. You MUST call this function
+ * before terminating the program, otherwise the machine may crash later. If
+ * in doubt, install an exit handler using atexit(). The function will do
+ * nothing, if it was already called.
+ */
+
+unsigned char __fastcall__ rs232_get (char* b);
+/* Get a character from the serial port. If no characters are available, the
+ * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+ */
+
+unsigned char __fastcall__ rs232_put (char b);
+/* Send a character via the serial port. There is a transmit buffer, but
+ * transmitting is not done via interrupt. The function returns
+ * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+ */
+
+unsigned char __fastcall__ rs232_pause (void);
+/* Assert flow control and disable interrupts. */
+
+unsigned char __fastcall__ rs232_unpause (void);
+/* Re-enable interrupts and release flow control */
+
+unsigned char __fastcall__ rs232_status (unsigned char* status,
+					 unsigned char* errors);
+/* Return the serial port status. */
+
+/* End of rs232silversurfer.h */
+#endif
+
+
+
diff --git a/contiki-cpc/contiki-cpc/uip/slip-drv.c b/contiki-cpc/contiki-cpc/uip/slip-drv.c
new file mode 100644
index 0000000..dc37f1b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-drv.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-drv.c,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tapdev_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/slip-dsc.c b/contiki-cpc/contiki-cpc/uip/slip-dsc.c
new file mode 100644
index 0000000..2cf7720
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: slip-dsc.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon slip_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(slip_dsc,
+    "SLIP driver",
+    "slip.drv",
+    slip_init,
+    &slip_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char slipicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char slipicon_textmap[9] = {
+  'R', 'S', ' ',
+  '2', '3', '2',
+  '/', 'I', 'P'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon slip_icon =
+  {CTK_ICON("SLIP driver", slipicon_bitmap, slipicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c b/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c
new file mode 100644
index 0000000..4741e74
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-dump-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(slip_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "SLIP dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S b/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S
new file mode 100644
index 0000000..d31c320
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de00
+	_cs8900a_txcmd		= $de04
+	_cs8900a_txlen		= $de06
+	_cs8900a_packetpp	= $de0a
+	_cs8900a_ppdata		= $de0c
+
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-drv.c b/contiki-cpc/contiki-cpc/uip/tfe-drv.c
new file mode 100644
index 0000000..ea807ac
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-dsc.c b/contiki-cpc/contiki-cpc/uip/tfe-dsc.c
new file mode 100644
index 0000000..24d9314
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: tfe-dsc.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon tfe_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+    "The Final Ethernet driver",
+    "tfe.drv",
+    tfe_init,
+    &tfe_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tfeicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tfeicon_textmap[9] = {
+  'T', 'C', 'P',
+  '/', 'I', 'P',
+  'T', 'F', 'E'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon tfe_icon =
+  {CTK_ICON("TFE driver", tfeicon_bitmap, tfeicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c b/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c
new file mode 100644
index 0000000..e572909
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-dump-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/uip_arch.c b/contiki-cpc/contiki-cpc/uip/uip_arch.c
new file mode 100644
index 0000000..3e07ef1
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/uip_arch.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.1 2006/04/17 15:12:03 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+#define IP_PROTO_UDP    17
+
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+#if 0
+  asm("ldy #3");
+  asm("jsr ldaxysp");
+  asm("sta ptr1");
+  asm("stx ptr1+1");
+  asm("ldy #0");
+  asm("lda (sp),y");
+  asm("ldy #3");
+  asm("clc");
+  asm("adc (ptr1),y");
+  asm("sta _uip_acc32+3");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("ldy #1");
+  asm("adc (sp),y");
+  asm("sta _uip_acc32+2");
+  asm("ldy #1");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+1");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+0");  
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u8_t chksum_protocol;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+u16_t
+chksum(void) {
+
+#if 0
+  asm("lda #0");
+  asm("sta tmp1");
+  asm("sta tmp1+1");
+  asm("lda _chksum_ptr");
+  asm("sta ptr1");
+  asm("lda _chksum_ptr+1");
+  asm("sta ptr1+1");
+
+
+  asm("lda _chksum_len+1");
+  asm("beq chksumlast");
+
+
+  /* If checksum is > 256, do the first runs. */
+  asm("ldy #0");
+  asm("clc");
+  asm("chksumloop_256:");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("iny");
+  asm("bne chksumloop_256");
+  asm("inc ptr1+1");
+  asm("dec _chksum_len+1");
+  asm("bne chksumloop_256");
+
+  asm("chksum_endloop_256:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop_256");
+  
+  asm("chksumlast:");
+  asm("lda _chksum_len");
+  asm("lsr");
+  asm("bcc chksum_noodd");  
+  asm("ldy _chksum_len");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("clc");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("bcc noinc1");
+  asm("inc tmp1+1");
+  asm("bne noinc1");
+  asm("inc tmp1");
+  asm("noinc1:");
+  asm("dec _chksum_len");
+
+  asm("chksum_noodd:");
+  asm("clc");
+  asm("php");
+  asm("ldy _chksum_len");
+  asm("chksum_loop1:");
+  asm("cpy #0");
+  asm("beq chksum_loop1_end");
+  asm("plp");
+  asm("dey");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("dey");
+  asm("php");
+  asm("jmp chksum_loop1");
+  asm("chksum_loop1_end:");
+  asm("plp");
+  
+  asm("chksum_endloop:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop");
+  
+  asm("lda tmp1");
+  asm("ldx tmp1+1");
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *buf, u16_t len)
+{
+  /*  unsigned long sum;
+
+  sum = 0;
+
+  chksum_ptr = (u16_t)buf;
+  while(len >= 256) {  
+    chksum_len = 256;
+    sum += chksum();
+    len -= 256;
+    chksum_ptr += 256;
+  }
+
+  if(len < 256) {
+    chksum_len = len;
+    sum += chksum();
+  }
+
+  while((sum >> 16) != 0) {
+    sum = (sum >> 16) + (sum & 0xffff);
+  }
+
+  return sum;*/
+
+  chksum_len = len;
+  chksum_ptr = (u16_t)buf;
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{  
+  chksum_ptr = (u16_t)uip_buf + UIP_LLH_LEN;
+  chksum_len = 20;  
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+static u16_t
+transport_chksum(u8_t protocol)
+{
+  chksum_protocol = protocol;
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+
+#if 0
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc %v", chksum_protocol);  
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+#endif
+
+  return chksum_tmp;
+}
+/*#pragma optimize(pop)*/
+
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  return transport_chksum(IP_PROTO_TCP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #6");  /* IP_PROTO_TCP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif 
+}
+
+/*-----------------------------------------------------------------------------------*/
+#if UIP_UDP_CHECKSUMS
+u16_t
+uip_udpchksum(void)
+{
+  return transport_chksum(IP_PROTO_UDP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #17");  /* IP_PROTO_UDP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif
+}
+#endif /* UIP_UDP_CHECKSUMS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/uip_arch.h b/contiki-cpc/contiki-cpc/uip/uip_arch.h
new file mode 100644
index 0000000..b850435
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/uip_arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.1 2006/04/17 15:12:03 kthacker Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki-cpc/ctk/conio.h b/contiki-cpc/ctk/conio.h
new file mode 100644
index 0000000..e8c3cdb
--- /dev/null
+++ b/contiki-cpc/ctk/conio.h
@@ -0,0 +1,66 @@
+/*
+ CONIO.H - Console I/O library for the Amsrad CPC
+ To use with the Small Devices C Compiler
+ CONIO.H is a implementation of the Contiki CONIO.H (Derived from the borland CONIO.H)
+
+ 2003 H. Hansen
+*/
+
+#ifndef  __conio_h__
+#define __conio_h__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "arch.h"
+
+#define CH_ULCORNER 0x096
+#define CH_URCORNER 0x09c
+#define CH_LLCORNER 0x093
+#define CH_LRCORNER 0x099
+
+void clrscr (void);
+
+unsigned char kbhit (void);
+
+void gotox (unsigned char x);
+
+void gotoy (unsigned char y);
+
+void gotoxy (unsigned char x, unsigned char y);
+
+unsigned char wherex (void);
+
+unsigned char wherey (void);
+
+void cputc (char c);
+
+void cputcxy (unsigned char x, unsigned char y, char c);
+
+void cputs (char* s);
+
+char cgetc (void);
+
+void  revers ();
+
+void textcolor (unsigned char color);
+
+void bgcolor (unsigned char color);
+
+void  bordercolor (unsigned char color);
+
+void chline (unsigned char length);
+
+void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cvline (unsigned char length);
+
+void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cclear (unsigned char length);
+
+void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+
+void screensize (unsigned char* x, unsigned char* y);
+
+#endif /* __conio_h__ */
+
diff --git a/contiki-cpc/ctk/ctk-arch.h b/contiki-cpc/ctk/ctk-arch.h
new file mode 100644
index 0000000..59d0641
--- /dev/null
+++ b/contiki-cpc/ctk/ctk-arch.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#if CTK_HIRES
+#include "ctk-hires.h"
+#endif 
+
+#if CTK_CONIO
+#include "ctk-conio.h"
+#endif 
+
+#if CTK_VNCSERVER
+#include "ctk-vncarch.h"
+#endif
+
+#include <ctype.h>
+
+//#define ctk_arch_isprint(c) isprint(c)
+
+#include "ctk-arch2.h"
+
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-cpc/ctk/ctk-arch2.h b/contiki-cpc/ctk/ctk-arch2.h
new file mode 100644
index 0000000..1d39254
--- /dev/null
+++ b/contiki-cpc/ctk/ctk-arch2.h
@@ -0,0 +1,39 @@
+/*#include "fire.h"*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//char *strncpy(char *, const char *, unsigned int);
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+// have to undefine because of it being defined in
+// ctk-conio.h
+#undef CH_ENTER
+#undef CH_F1
+#undef CH_F3
+#undef CH_CURS_LEFT
+#undef CH_CURS_RIGHT
+
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F2 0x032
+#define CH_F3 0x033
+#define CH_F4 0x034
+#define CH_F5 0x035
+#define CH_F6 0x036
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+#define CH_TAB 0x09
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC CH_STOP
+
diff --git a/contiki-cpc/ctk/ctk-conf.h.old b/contiki-cpc/ctk/ctk-conf.h.old
new file mode 100644
index 0000000..5b8df19
--- /dev/null
+++ b/contiki-cpc/ctk/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:02:27 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE  0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/ctk/ctk-conio-conf.h b/contiki-cpc/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..eebe228
--- /dev/null
+++ b/contiki-cpc/ctk/ctk-conio-conf.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.1 2006/04/17 15:02:28 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         0
+#define SCREENCOLOR         0
+
+#define BACKGROUNDCOLOR		0
+
+
+#define WINDOWCOLOR_FOCUS   1		/* colour of window which has focus */
+#define WINDOWCOLOR         2		/* colour of window which doesn't have focus */
+
+#define DIALOGCOLOR         1
+
+#define WIDGETCOLOR_HLINK   3
+#define WIDGETCOLOR_FWIN    2		/* colour of widget */
+#define WIDGETCOLOR         2
+#define WIDGETCOLOR_DIALOG  2
+#define WIDGETCOLOR_FOCUS   3		/* colour of widge which has focus */
+
+// 0 = blue
+// 1 = yellow
+// 2 = cyan
+// 3 = red
+
+#define MENUCOLOR           2
+#define OPENMENUCOLOR       1	
+#define ACTIVEMENUITEMCOLOR 3
+
+#endif
diff --git a/contiki-cpc/ctk/unused/ctk-80col-asm.S b/contiki-cpc/ctk/unused/ctk-80col-asm.S
new file mode 100644
index 0000000..4df6cad
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-80col-asm.S
@@ -0,0 +1,986 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		pushax
+	.import		incsp2
+
+	.import		_ctk_80col_screencolors
+	.import		_ctk_80col_screenpattern	
+		
+	.import		_ctk_80col_lefttab
+	.import		_ctk_80col_righttab
+	
+	.import		_ctk_80col_cursx
+	.import		_ctk_80col_cursy
+	.import		_ctk_80col_color
+	.import		_ctk_80col_underline	
+	.import		_ctk_80col_reversed
+
+	.import		_ctk_80col_yscreenaddr
+	.import		_ctk_80col_yhiresaddr
+
+	.import		_ctk_80col_windowparams
+	
+	.import		_ctk_80col_bitmapptr
+
+	.import		_ctk_80col_versionstring
+	.import		_ctk_80col_versionstring_len	
+	
+	.import		_ctk_80col_theme
+			
+	.export		_ctk_80col_cclear
+	.export		_ctk_80col_chline
+	.export		_ctk_80col_cputc
+	.export		_ctk_80col_cputsn
+	
+	.export		_ctk_80col_clear_line
+	.export		_ctk_80col_draw_bitmapline
+	
+	.export		_ctk_80col_draw_windowborders
+
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlecolor:  .res 1
+wptitlecolor = 6
+titlelen:    .res 1
+wptitlelen   = 7
+title:	.res 2
+wptitle      = 8
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_80col_cursx
+	asl
+	rol ptr1+1
+; 	asl	
+; 	rol ptr1+1	
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	and #$f8
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+	;; Find screen address. 
+	lda _ctk_80col_cursy
+	asl
+	tax
+	lda _ctk_80col_cursx
+	lsr
+	clc
+	adc _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+	
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_80col_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	ldy tmpl
+	lda _ctk_80col_color
+:		
+	sta (ptr1),y
+	dey
+	bpl :-
+	
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_80col_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf
+
+		
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_80col_cursx
+
+	dex
+	bpl @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_80col_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_80col_cputc:
+	sta tmpc
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+
+	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_80col_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+        jmp incsp2	
+:		
+
+	jsr setupptrs
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:		
+
+	
+	lda #0
+	sta ptr1+1		  	
+
+	ldy tmpc
+	lda (ptr3),y
+	bne :+
+	jmp @end
+:	
+			
+	;; Convert from PETSCII to screen encoding
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_80col_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	lda _ctk_80col_cursx
+	and #1
+	beq @left
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @rightnounderline
+	eor #$ff
+@rightnounderline:
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+@rightloop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$f0
+	ora _ctk_80col_righttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @rightloop	
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:	
+	
+	inc _ctk_80col_cursx	
+	
+	jmp @loopend
+	
+@left:		
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_80col_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	tax
+	lda (ptr2),y
+	and #$0f
+	ora _ctk_80col_lefttab,x	
+ 	sta (ptr2),y
+	dey
+	bpl @loop
+			
+	inc _ctk_80col_cursx	
+@loopend:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	beq :+
+	jmp @loop1
+:	
+	
+@end:
+	jsr restore01
+	
+        jmp incsp2	
+;---------------------------------------------------------------------
+_ctk_80col_clear_line:
+	sta tmpl
+	asl
+	tax
+	lda _ctk_80col_yscreenaddr,x
+	sta ptr1
+	lda _ctk_80col_yscreenaddr+1,x
+	sta ptr1+1	
+	lda _ctk_80col_yhiresaddr,x
+	sta ptr2
+	lda _ctk_80col_yhiresaddr+1,x
+	sta ptr2+1
+	
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+
+	ldy #39
+	ldx tmpl
+	lda _ctk_80col_screencolors,x
+:	
+	sta (ptr1),y
+	dey
+	bpl :-
+
+	lda tmpl
+	asl
+	asl
+	asl
+	tax
+	ldy #0
+:
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	bne :-
+
+	inc ptr2+1
+	
+:	
+	lda _ctk_80col_screenpattern,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+1,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+2,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+3,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+4,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+5,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+6,x
+	sta (ptr2),y
+	iny
+	lda _ctk_80col_screenpattern+7,x
+	sta (ptr2),y
+	iny
+	cpy #$40
+	bne :-
+
+	lda tmpl
+	cmp #24
+	bne :+			
+
+	sta _ctk_80col_cursy
+	lda #2
+	sta _ctk_80col_cursx
+
+	jsr restore01
+		
+	lda #<_ctk_80col_versionstring
+	ldx #>_ctk_80col_versionstring
+ 	jsr pushax		
+	lda _ctk_80col_versionstring_len
+	jmp _ctk_80col_cputsn
+:		
+	jmp restore01	
+;---------------------------------------------------------------------	
+_ctk_80col_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_80col_color
+:	
+	sta (ptr1),y	
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_80col_bitmapptr
+	sta ptr1
+	lda _ctk_80col_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_80col_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_80col_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	lda _ctk_80col_windowparams + wpw
+	sta tmpw	
+
+	
+	ldy #0
+	lda _ctk_80col_windowparams + wptitlecolor	
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	dec tmpw
+
+	;; Set color for upper right corner
+	sta (ptr1),y	
+	iny
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_80col_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+
+	
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_80col_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	bpl @titlebarloop
+
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_80col_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_80col_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_80col_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_80col_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_80col_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_80col_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_80col_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_80col_windowparams + wpw
+	lda _ctk_80col_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_80col_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_80col_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_80col_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_80col_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_80col_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_80col_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_80col_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_80col_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_80col_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+	
\ No newline at end of file
diff --git a/contiki-cpc/ctk/unused/ctk-80col-asm.h b/contiki-cpc/ctk/unused/ctk-80col-asm.h
new file mode 100644
index 0000000..210630f
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-80col-asm.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-80col-asm.h,v 1.1 2006/04/17 15:02:28 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_80COL_ASM_H__
+#define __CTK_80COL_ASM_H__
+
+void __fastcall__ ctk_80col_cclear(unsigned char len);
+void __fastcall__ ctk_80col_chline(unsigned char len);
+void __fastcall__ ctk_80col_cputc(unsigned char c);
+void __fastcall__ ctk_80col_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_80col_draw_buttonleft(void);
+void ctk_80col_draw_buttonright(void);
+
+struct ctk_80col_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlecolor;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_80col_windowparams ctk_80col_windowparams;
+void ctk_80col_draw_windowborders(void);
+
+extern unsigned char ctk_80col_cursx,
+  ctk_80col_cursy,
+  ctk_80col_color,
+  ctk_80col_reversed,
+  ctk_80col_underline;
+
+
+void __fastcall__ ctk_80col_draw_bitmapline(unsigned char len);
+
+void __fastcall__ ctk_80col_clear_line(unsigned char len);
+
+#endif /* __CTK_80COL_ASM_H__ */
diff --git a/contiki-cpc/ctk/unused/ctk-80col-theme.h b/contiki-cpc/ctk/unused/ctk-80col-theme.h
new file mode 100644
index 0000000..6141a40
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-80col-theme.h
@@ -0,0 +1,83 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-80col-theme.h,v 1.1 2006/04/17 15:02:28 kthacker Exp $
+ *
+ */
+#ifndef __CTK_80COL_THEME_H__
+#define __CTK_80COL_THEME_H__
+
+struct ctk_80col_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpattern[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+
+};
+
+extern struct ctk_80col_theme ctk_80col_theme;
+extern struct ctk_80col_theme *ctk_80col_theme_ptr;
+
+#endif /* __CTK_80COL_THEME_H__ */
diff --git a/contiki-cpc/ctk/unused/ctk-80col.c b/contiki-cpc/ctk/unused/ctk-80col.c
new file mode 100644
index 0000000..a0f5e9c
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-80col.c
@@ -0,0 +1,1200 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-80col.c,v 1.2 2006/05/28 20:41:03 oliverschmidt Exp $
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+
+#include "ctk-80col-asm.h"
+
+#include "ctk-80col-theme.h"
+
+#include <string.h>
+
+unsigned char ctk_80col_cursx, ctk_80col_cursy;
+unsigned char ctk_80col_reversed;
+unsigned char ctk_80col_color;
+unsigned char *ctk_80col_bitmapptr;
+unsigned char ctk_80col_underline = 0;
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  80
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+unsigned char ctk_80col_lefttab[256];
+unsigned char ctk_80col_righttab[256];
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define COLOR_DIALOG            0x01
+#define COLOR_FOCUS_WINDOW      0xbf
+#define COLOR_BACKGROUND_WINDOW 0x0c
+
+#define color(c) ctk_80col_color = c
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+unsigned char ctk_80col_screencolors[25] =
+  {COLOR(BGCOLOR4,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+   COLOR(BGCOLOR4,1)};
+
+unsigned char ctk_80col_screenpattern[25*8] =
+  {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+   0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+unsigned short ctk_80col_yscreenaddr[25] =
+  {0 * 40 + SCREENADDR, 1 * 40 + SCREENADDR,
+   2 * 40 + SCREENADDR, 3 * 40 + SCREENADDR,
+   4 * 40 + SCREENADDR, 5 * 40 + SCREENADDR,
+   6 * 40 + SCREENADDR, 7 * 40 + SCREENADDR,
+   8 * 40 + SCREENADDR, 9 * 40 + SCREENADDR,
+   10 * 40 + SCREENADDR, 11 * 40 + SCREENADDR,
+   12 * 40 + SCREENADDR, 13 * 40 + SCREENADDR,
+   14 * 40 + SCREENADDR, 15 * 40 + SCREENADDR,
+   16 * 40 + SCREENADDR, 17 * 40 + SCREENADDR,
+   18 * 40 + SCREENADDR, 19 * 40 + SCREENADDR,
+   20 * 40 + SCREENADDR, 21 * 40 + SCREENADDR,
+   22 * 40 + SCREENADDR, 23 * 40 + SCREENADDR,
+   24 * 40 + SCREENADDR};
+
+unsigned short ctk_80col_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+
+
+struct ctk_80col_theme ctk_80col_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xc0,0x80,0xbf,0x80,0xbf,0x80,0x80},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x03,0x01,0xfd,0x01,0xfd,0x01,0x01},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x01,0x01,0x01,0x01,0x01,0x01,0x03,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0x0f,0x3f,0x3f,0x7f,0x7f,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xf0,0xfc,0xfc,0xfe,0xfe,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_WHITE),
+    
+  };
+char ctk_80col_versionstring[] = CONTIKI_VERSION_STRING;
+char ctk_80col_versionstring_len = sizeof(CONTIKI_VERSION_STRING) - 1;
+
+struct ctk_80col_windowparams ctk_80col_windowparams;
+
+/*---------------------------------------------------------------------------*/
+/*void
+ctk_arch_draw_char(char c,
+		   unsigned char xpos,
+		   unsigned char ypos,
+		   unsigned char reversedflag,
+		   unsigned char color)
+{
+  ctk_80col_cursx = xpos;
+  ctk_80col_cursy = ypos;
+  ctk_80col_reversed = reversedflag;
+  ctk_80col_color = color;
+  
+  ctk_80col_cputc(c);
+}*/
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+void reset(void);
+void
+quit(void)
+{
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+  VIC.bordercolor = 0x0e; /* $D020 */
+  VIC.bgcolor0 = 0x06; /* $D021 */
+
+  memset((char *)0xd800, 0x0e, 40*25);
+
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+ctk_80col_init(void)
+{
+  int i;
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = 0x06; /* $D020 */
+  VIC.bgcolor0 = 0x0b; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  memset((char *)0xe000, 0, 8000);
+
+  for(i = 0; i < 256; ++i) {
+#if 0
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x20) << 1) |
+      ((i & 0x08) << 2) |
+      ((i & 0x02) << 3);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x20) >> 3) |
+      ((i & 0x08) >> 2) |
+      ((i & 0x02) >> 1);
+#else
+    ctk_80col_lefttab[i] =
+      ((i & 0x40) << 1) |
+      ((i & 0x10) << 2) |
+      ((i & 0x04) << 3) |
+      ((i & 0x01) << 4);
+    ctk_80col_righttab[i] =
+      ((i & 0x40) >> 3) |
+      ((i & 0x10) >> 2) |
+      ((i & 0x04) >> 1) |
+      ((i & 0x01));
+#endif
+  }
+  
+#if 0
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_80col_theme,
+      offsetof(struct ctk_80col_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_80col_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+#endif
+  return;
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+/*static unsigned char cursx, cursy;
+  static unsigned char reversed;*/
+
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+cputc(char c) 
+{
+  /*  ctk_arch_draw_char(c, cursx, cursy, reversed, 0);*/
+  ctk_80col_cputc(c);
+  /*  ++cursx;*/
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+  return ctk_80col_cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+  return ctk_80col_cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+/*void
+clrscr(void)
+{
+  unsigned char x, y;
+
+  for(x = 0; x < SCREEN_WIDTH; ++x) {
+    for(y = 0; y < SCREEN_HEIGHT; ++y) {
+      gotoxy(x, y);
+      cputc(' ');
+    }
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+#define revers(c) ctk_80col_reversed = c
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+_cputs(char *str)
+{
+  char *ptr = str;
+  
+  while(*ptr != 0) {
+    cputc(*ptr++);
+  }
+
+  /*  int i;
+  for(i = 0; i < strlen(str); ++i) {
+    cputc(str[i]);
+    }*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+cclear(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc(' ');
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('-');
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('|');
+    --ctk_80col_cursx;
+    ++ctk_80col_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_80col_cursx = x;
+  ctk_80col_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+_cputsxy(unsigned char x, unsigned char y, char *str)
+{
+  gotoxy(x, y);
+  _cputs(str);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cputcxy(unsigned char x, unsigned char y, char c)
+{
+  gotoxy(x, y);
+  cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+/*void CC_FASTCALL
+screensize(unsigned char *x, unsigned char *y)
+{
+  *x = SCREEN_WIDTH;
+  *y = SCREEN_HEIGHT;
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*static unsigned char sizex, sizey;*/
+/*-----------------------------------------------------------------------------------*/
+static void
+_cputsn(char *str, unsigned char len)
+{
+  /*  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+    }*/  
+  ctk_80col_cputsn(str, len);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_init(void)
+{
+  ctk_80col_init();
+
+  /*  screensize(&sizex, &sizey);*/
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    if(focus & CTK_FOCUS_WIDGET) {
+      wfocus = 1;
+    }
+  } else {
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	_cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      cputcxy(xpos, ypos, '[');
+      _cputsn(w->widget.button.text, w->w);
+      cputc(']');
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(wfocus != 0) {
+	revers(0);
+      } else {
+	revers(1);
+      }
+      gotoxy(xpos, ypos);
+      _cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    if(wfocus != 0) {
+      revers(1);
+    } else {
+      revers(0);
+    }
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      revers(1);
+	    } else {
+	      revers(0);
+	    }
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	    revers(0);
+	  }
+	  cputc('<');
+	} else {
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  _cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      color(ctk_80col_theme.iconcolors[focus]);
+      
+      /*      if(focus & 1) {
+	
+	revers(1);
+      } else {
+	revers(0);
+	}*/
+      /*      gotoxy(xpos, ypos);*/
+      if(xpos >= 73) {
+	xpos = 73;
+      }
+      if(xpos <= 2) {
+	xpos = 2;
+      }
+      if(w->widget.icon.textmap != NULL) {
+	ctk_80col_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    gotoxy(xpos, ypos);
+	    ctk_80col_draw_bitmapline(3);	    
+	  }
+	  ctk_80col_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+      }
+      x = xpos;
+  
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      if(ypos >= clipy1 && ypos < clipy2) {
+	len = strlen(w->widget.icon.title);
+	gotoxy((x & 0xfe) + 1, ypos);
+	ctk_80col_cclear((len - 1)/ 2);
+	gotoxy(x, ypos);
+	ctk_80col_cputsn(w->widget.icon.title, len);
+      }
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		  unsigned char focus,
+		  unsigned char clipy1,
+		  unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = (win->x & 0xfe) + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+  
+  if(focus & CTK_FOCUS_WINDOW) {
+    color(COLOR_FOCUS_WINDOW);
+  } else {
+    color(COLOR_BACKGROUND_WINDOW);
+  }
+    
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      gotoxy((window->x & 0xfe) + 1, i);
+      ctk_80col_cclear((window->w + 1)/2);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		  unsigned char clipy1, unsigned char clipy2)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+
+  
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x & 0xfe;
+  y = window->y + 1;
+  
+/*  if(focus & CTK_FOCUS_WINDOW) {
+  } else {
+  }*/
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  /* Draw window frame. */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (window->w-1)/2;
+  ctk_80col_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_80col_windowparams.clipy1 = 0;
+  } else {
+    ctk_80col_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_80col_windowparams.clipy2 = clipy2 - y + 1;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[focus];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[focus+1];
+  ctk_80col_windowparams.title = window->title;
+  ctk_80col_windowparams.titlelen = window->titlelen/2;
+
+  if(ctk_80col_windowparams.clipy1 < ctk_80col_windowparams.clipy2 &&
+     ctk_80col_windowparams.clipy2 > 0) {
+    ctk_80col_draw_windowborders();
+  }
+  /*  
+  if(y >= clipy1) {
+    cputcxy(x, y, CH_ULCORNER);
+    gotoxy(wherex() + window->titlelen + 2, wherey());
+    chline(window->w - (wherex() - x) - 2);
+    cputcxy(x2, y, CH_URCORNER);
+  }
+
+  h = window->h;
+  
+  if(clipy1 > y1) {
+    if(clipy1 - y1 < h) {
+      h = clipy1 - y1;
+            y1 = clipy1;
+    } else {
+      h = 0;
+    }
+  }
+
+  if(clipy2 < y1 + h) {
+    if(y1 >= clipy2) {
+      h = 0;
+    } else {
+      h = clipy2 - y1;
+    }
+  }
+
+  cvlinexy(x, y1, h);
+  cvlinexy(x2, y1, h);  
+
+  if(y + window->h >= clipy1 &&
+     y + window->h < clipy2) {
+    cputcxy(x, y2, CH_LLCORNER);
+    chlinexy(x1, y2, window->w);
+    cputcxy(x2, y2, CH_LRCORNER);
+  }
+  */
+  if(ctk_mode_get() != CTK_MODE_WINDOWMOVE) {
+    draw_window_contents(window, focus & CTK_FOCUS_WINDOW, clipy1, clipy2,
+			 x1, x2, y + 1, y2);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  
+  x = dialog->x & 0xfe;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  /*  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  */
+  gotoxy(x, y);
+  ctk_80col_windowparams.w = (dialog->w-1)/2;
+  ctk_80col_windowparams.h = dialog->h;
+  ctk_80col_windowparams.clipy1 = 0;
+  ctk_80col_windowparams.clipy2 = SCREEN_HEIGHT;
+  ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[4];
+  ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[5];
+
+  ctk_80col_draw_windowborders();  
+  
+  /* Clear dialog contents. */
+  color(COLOR_DIALOG);
+  for(i = y1; i < y2; ++i) {
+    gotoxy((x1 & 0xfe) + 2, i);
+    ctk_80col_cclear((dialog->w + 1)/2 - 2);
+    /*    cclearxy(x1, i, dialog->w);*/
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, SCREEN_HEIGHT,
+		       x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+
+  
+  for(i = y1; i < y2; ++i) {
+    
+    ctk_80col_clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  
+  color(ctk_80col_theme.openmenucolor);
+  
+  revers(0);
+  x = wherex();
+  _cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH - 2;
+  }
+    
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      color(ctk_80col_theme.activemenucolor);
+    } else {
+      color(ctk_80col_theme.openmenucolor);
+    }
+    gotoxy(x, y + 1);
+    ctk_80col_cclear(CTK_CONF_MENUWIDTH/2);
+
+    gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      /*      _cputs(m->items[y].title);*/
+      ctk_80col_cputsn(m->items[y].title, m->items[y].titlelen);
+    }
+    /*    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear(x + CTK_CONF_MENUWIDTH - wherex());
+      }*/
+  
+  }
+  gotoxy(x2, 0);
+  revers(1);
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+  
+  memcpy((char *)0xe000, ctk_80col_theme.menuleftpattern, 8);
+  /* Draw menus */
+  gotoxy(2, 0);
+
+  revers(1); 
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    color(ctk_80col_theme.menucolor);
+    if(m != menus->open) {
+      /*      _cputs(m->title);*/
+      ctk_80col_cputsn(m->title, m->titlelen);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+  color(ctk_80col_theme.menucolor);
+    
+  if(wherex() + strlen(menus->desktopmenu->title) + 2 >= SCREEN_WIDTH) {
+    gotoxy(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 2, 0);
+  } else {
+    cclear(SCREEN_WIDTH - wherex() -
+	   strlen(menus->desktopmenu->title) - 2);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    ctk_80col_cputsn(menus->desktopmenu->title, menus->desktopmenu->titlelen);
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  /*  gotoxy(78, 0);
+  color(ctk_80col_screencolors[0]);
+  cputc(' ');
+  cputc(' ');    */
+  
+  revers(0);
+  memcpy((char *)0xe138, ctk_80col_theme.menurightpattern, 8);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 4;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": 80col", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_80col_service_init, arg)
+{ 
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    quit();
+    ek_exit();
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/ctk/unused/ctk-hires-asm.S b/contiki-cpc/ctk/unused/ctk-hires-asm.S
new file mode 100644
index 0000000..8d52510
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-asm.S
@@ -0,0 +1,934 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		incsp2
+
+	
+	.import		_ctk_hires_cursx
+	.import		_ctk_hires_cursy
+	.import		_ctk_hires_color
+	.import		_ctk_hires_underline
+	.import		_ctk_hires_reversed
+
+	.import		_ctk_hires_yscreenaddr
+	.import		_ctk_hires_yhiresaddr
+
+	.import		_ctk_hires_windowparams
+	
+	.import		_ctk_hires_bitmapptr
+
+	.import		_ctk_hires_theme
+			
+	.export		_ctk_hires_cclear
+	.export		_ctk_hires_chline
+	.export		_ctk_hires_cputc
+	.export		_ctk_hires_cputsn
+
+	.export		_ctk_hires_draw_buttonleft
+	.export		_ctk_hires_draw_buttonright
+	
+	.export		_ctk_hires_draw_windowborders
+
+	.export		_ctk_hires_draw_bitmapline
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+	;; Offsets in the theme struct
+
+	ulcornerpattern =	8
+	titlebarpattern =	ulcornerpattern+8
+	urcornerpattern =	titlebarpattern+8
+	rborderpattern  =	urcornerpattern+8
+	lrcornerpattern =	rborderpattern+8
+	lowerborderpattern =	lrcornerpattern+8
+	llcornerpattern =	lowerborderpattern+8
+	lborderpattern =	llcornerpattern+8
+
+	
+	buttonleftpattern =	lborderpattern+8
+	buttonrightpattern =	buttonleftpattern+8
+
+				
+.bss
+tmp01:	.res 1
+tmpl:	.res 1
+tmpf:	.res 1
+tmpc:	.res 1
+tmpw:	.res 1	
+tmpptr:	.res 2
+
+tmpy:	.res 1
+tmph:	.res 1
+
+	;; Window border parameters	
+w:	.res 1
+wpw          = 0
+h:	.res 1
+wph          = 1	
+clipy1:	.res 1
+wpclipy1     = 2
+clipy2:	.res 1
+wpclipy2     = 3	
+color1:	.res 1
+wpcolor1     = 4	
+color2:	.res 1
+wpcolor2     = 5	
+titlelen:	.res 1
+wptitlelen   = 6
+title:	.res 2
+wptitle      = 7	
+	
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_hires_cursy
+	asl
+	tax
+	lda _ctk_hires_yhiresaddr,x
+	sta ptr2
+	lda _ctk_hires_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_hires_cursx
+	asl
+	rol ptr1+1
+	asl	
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	clc
+	adc ptr2
+	sta ptr2
+	lda ptr2+1
+	adc ptr1+1
+	sta ptr2+1
+
+
+	;; Find screen address. 
+	lda _ctk_hires_cursy
+	asl
+	tax	
+	lda _ctk_hires_yscreenaddr,x
+	clc
+	adc _ctk_hires_cursx
+	sta ptr1
+	lda _ctk_hires_yscreenaddr+1,x
+	adc #0
+	sta ptr1+1
+
+	;; Turn off interrupts, prepare $01 to store color data in RAM
+	;; under I/O area.		
+	sei
+	lda $01
+	sta tmp01
+	and #$f8
+	sta $01
+	rts
+;---------------------------------------------------------------------	
+restore01:	
+	lda tmp01
+	sta $01
+	cli
+	rts		
+;---------------------------------------------------------------------
+_ctk_hires_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store either $00 or $ff in hires memory, depending on the
+	;; reversed flag		
+	
+	ldx tmpl
+	lda _ctk_hires_reversed
+	beq @noff
+	lda #$ff
+@noff:		
+	sta tmpf	
+@loop1:
+	ldy #7
+	lda tmpf
+@loop2:
+	sta (ptr2),y
+	dey
+	bpl @loop2
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:		
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+
+	;; Store horizontal line pattern in hires memory
+	ldx tmpl
+@loop1:
+	ldy #0
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$ff
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+	iny
+	lda #$00
+	sta (ptr2),y
+
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc @noinc
+	inc ptr2+1
+@noinc:	
+
+	inc _ctk_hires_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_cputc:
+	sta tmpc
+
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+	
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	lda #0
+	sta ptr1+1		  
+	
+	;; Convert from PETSCII to screen encoding
+	lda tmpc
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_hires_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+	
+	jsr setupptrs
+
+	ldy tmpl
+	dey
+	lda _ctk_hires_color
+@loop0:
+	sta (ptr1),y
+	dey
+	bpl @loop0
+			
+	;; Turn on font ROM
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	
+	;; Output each character from the string
+	lda #0
+	sta tmpc
+	ldy #0
+	lda (sp),y
+	sta ptr3
+	iny
+	lda (sp),y
+	sta ptr3+1	
+	
+@loop1:	
+	
+	lda #0
+	sta ptr1+1		  
+		
+	ldy tmpc
+	lda (ptr3),y
+	beq @end
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	ldx _ctk_hires_reversed
+	beq :+
+	eor #$80
+:		
+
+	;; Convert to address in character ROM
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	asl
+	rol ptr1+1
+	sta ptr1
+	lda #$d8
+	adc ptr1+1
+	sta ptr1+1
+
+	;; Print on hires screen, bottom-up. If we should underline,
+	;; we do this by eor:ing the bottom line with #$ff
+	ldy #7
+	lda (ptr1),y
+	ldx _ctk_hires_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_hires_cursx
+
+	lda ptr2
+	clc
+	adc #8
+	sta ptr2
+	bcc :+
+	inc ptr2+1
+:
+	inc tmpc
+	lda tmpc
+	cmp tmpl
+	bne @loop1
+	
+@end:		
+	jsr restore01
+	
+        jmp incsp2
+	
+;---------------------------------------------------------------------
+_ctk_hires_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_hires_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y	
+	dey
+	dey
+	dey
+	sty tmpw	
+
+	ldy _ctk_hires_windowparams + wptitlelen
+	iny
+	iny
+	iny
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	inc tmpw
+
+	;; Set color for upper left corner
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+		
+	
+	;; Turn on font ROM for drawing the title
+	lda tmp01
+	and #$f8
+	ora #$01
+	sta $01
+
+	;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+	;; reuse it later.
+	lda ptr2
+	sta ptr3
+	lda ptr2+1
+	sta ptr3+1
+		
+	;; Draw upper left corner
+	ldy #7
+:	
+	lda _ctk_hires_theme+ulcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	;; Draw first empty char left of the title
+	ldy #8
+	lda #0
+:		
+; 	sta (ptr3),y		
+	iny
+	cpy #$10
+	bne :-
+
+	lda ptr3
+	clc
+	adc #$10
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;;  Draw the title
+	lda _ctk_hires_windowparams + wptitle
+	sta ptr4
+	lda _ctk_hires_windowparams + wptitle+1
+	sta ptr4+1
+	
+
+	lda #0
+	sta tmpc
+@titleloop:
+	lda #0
+	sta ptr5+1
+
+	ldy tmpc
+	lda (ptr4),y
+
+	
+	;; Convert from PETSCII to screen encoding		
+	eor #$e0
+	clc
+	adc #$20
+	bpl @cont
+	adc #$40
+	bpl @cont
+	eor #$a0
+@cont:
+	;; Convert to address in character ROM
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	asl
+	rol ptr5+1
+	sta ptr5
+	lda #$d8
+	adc ptr5+1
+	sta ptr5+1
+
+	;; Print on hires screen, character by character, bottom-up.
+	ldy #7
+:
+	lda (ptr5),y
+; 	sta (ptr3),y		
+	dey
+	bpl :-
+	
+	lda ptr3
+	clc
+	adc #8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+	
+	inc tmpc
+	lda tmpc
+	cmp _ctk_hires_windowparams + wptitlelen
+	bne @titleloop
+
+	;; Draw empty char after the title
+	ldy #7
+	lda #0
+:		
+; 	sta (ptr3),y
+	dey	
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	dec tmpw
+
+	;; Draw window title bar pattern
+@titlebarloop:	
+	ldy #7
+:
+	lda _ctk_hires_theme+titlebarpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	clc
+	adc #$8
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:
+	;; Loop until we are three characters away from right border
+	;; to avoid flickering since we would be overwriting the close
+	;; button.
+	dec tmpw
+	lda tmpw
+	cmp #3
+	bcs @titlebarloop
+
+	lda ptr3
+	clc
+	adc #$18
+	sta ptr3
+	bcc :+
+	inc ptr3+1
+:		
+	;; Draw upper right corner piece
+	ldy #7
+:
+	lda _ctk_hires_theme+urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_hires_windowparams + wph
+	inx
+	stx tmph
+
+	;; Draw left and right borders
+
+	;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+	;; First check how much we actually should draw by inspecting
+	;; the clipy1 and clipy2 fields in the _ctk_hires_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_hires_windowparams + wpclipy1
+@clipy1loop:
+	cpx #0
+	beq @clipy1loopend
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	inc tmpy
+	
+	dex
+	jmp @clipy1loop
+@clipy1loopend:	
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+		
+	ldx tmpy
+	ldy _ctk_hires_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @bordercloopend
+	
+	ldy tmpw
+	lda _ctk_hires_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_hires_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_hires_windowparams + wpw
+	lda _ctk_hires_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	cpx _ctk_hires_windowparams + wpclipy2
+	beq @rborderloopend
+
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda _ctk_hires_theme+rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_hires_windowparams + wpclipy2 
+ 	beq @norbordercorner
+	
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+	
+	;; Draw lower right corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_hires_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_hires_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:	
+	lda _ctk_hires_theme+lowerborderpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+@nolowerborder:	
+		
+	dex
+	bne @lowerborderloop
+
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+
+	ldx tmpy
+ 	cpx tmph
+ 	bne @nolbordercorner
+	
+	;; Draw lower left corner, if clipy2 allows it
+	ldy #7
+:		
+	lda _ctk_hires_theme+llcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+
+@nolbordercorner:	
+				
+	;; Draw left border
+
+	
+		
+@lborderloop:
+	cpx #1
+	beq @lborderloopend
+	cpx _ctk_hires_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda _ctk_hires_theme+lborderpattern,y	
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	lda ptr3
+	sec
+	sbc #$40
+	sta ptr3
+	lda ptr3+1
+	sbc #1
+	sta ptr3+1
+	
+	dex
+	jmp @lborderloop
+	
+@lborderloopend:		
+
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonleft:
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonleftpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_hires_draw_buttonright:
+	jsr setupptrs
+	ldy #0
+	lda _ctk_hires_color
+	sta (ptr1),y
+
+:		
+	lda _ctk_hires_theme+buttonrightpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+_ctk_hires_draw_bitmapline:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+
+	jsr setupptrs
+	
+	ldy #0	
+	lda _ctk_hires_color
+:	
+ 	sta (ptr1),y
+	iny
+	cpy tmpl
+	bne :-
+
+	lda _ctk_hires_bitmapptr
+	sta ptr1
+	lda _ctk_hires_bitmapptr+1
+	sta ptr1+1
+	
+	ldy #0
+	ldx #0
+:		
+	lda (ptr1),y
+ 	sta (ptr2),y		
+	iny
+	inx
+	cpx #8
+	bne :-
+
+	ldx #0
+	
+	dec tmpl
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+	
\ No newline at end of file
diff --git a/contiki-cpc/ctk/unused/ctk-hires-asm.h b/contiki-cpc/ctk/unused/ctk-hires-asm.h
new file mode 100644
index 0000000..374eb74
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-asm.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-asm.h,v 1.1 2006/04/17 15:02:30 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_ASM_H__
+#define __CTK_HIRES_ASM_H__
+
+void __fastcall__ ctk_hires_cclear(unsigned char len);
+void __fastcall__ ctk_hires_chline(unsigned char len);
+void __fastcall__ ctk_hires_cputc(unsigned char c);
+void __fastcall__ ctk_hires_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_hires_draw_buttonleft(void);
+void ctk_hires_draw_buttonright(void);
+
+struct ctk_hires_windowparams {
+  unsigned char w;
+  unsigned char h;
+  unsigned char clipy1;
+  unsigned char clipy2;
+  unsigned char color1;
+  unsigned char color2;
+  unsigned char titlelen;
+  char *title;
+};
+extern struct ctk_hires_windowparams ctk_hires_windowparams;
+void ctk_hires_draw_windowborders(void);
+
+extern unsigned char ctk_hires_cursx,
+  ctk_hires_cursy,
+  ctk_hires_color,
+  ctk_hires_reversed,
+  ctk_hires_underline;
+
+
+void __fastcall__ ctk_hires_draw_bitmapline(unsigned char len);
+
+#endif /* __CTK_HIRES_ASM_H__ */
diff --git a/contiki-cpc/ctk/unused/ctk-hires-service.c b/contiki-cpc/ctk/unused/ctk-hires-service.c
new file mode 100644
index 0000000..a9018f8
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-service.c
@@ -0,0 +1,931 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-service.c,v 1.1 2006/04/17 15:02:31 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+/*unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;*/
+
+static void s_ctk_draw_clear(unsigned char y1, unsigned char y2);
+
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+s_ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+  
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  s_ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  focus = focus & CTK_FOCUS_WINDOW;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": hires", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_conio_service_init, arg)
+{
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    VIC.ctrl1 = 0x1b;  /* $D011 */
+    VIC.addr  = 0x17;  /* $D018 */
+    VIC.ctrl2 = 0xc8;  /* $D016 */
+    CIA2.pra  = 0x03;  /* $DD00 */
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c b/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
new file mode 100644
index 0000000..b7ea8ed
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
@@ -0,0 +1,313 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-blueround.c,v 1.1 2006/04/17 15:02:31 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x06
+#define BGCOLOR2 0x00
+#define BGCOLOR3 0x06
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_CYAN)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_CYAN),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLACK, COLOR_CYAN),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLUE, COLOR_BLACK),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+     COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+     COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_CYAN, COLOR_BLUE),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    /*unsigned char pointermaskcolor,*/
+    3,
+
+    /* Pointer sprite 1 color */
+    /*     pointercolor; */
+    6,
+
+    
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+     
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+     0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+     0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+     0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+     0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+     0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+     0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+    },
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+       COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+       COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+
+      COLOR(BGCOLOR4,BGCOLOR4)},
+      
+    
+
+  };
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme-default.c b/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
new file mode 100644
index 0000000..0a1fae6
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-default.c,v 1.1 2006/04/17 15:02:32 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+    
+    /* buttonright[8]; */
+    {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY3)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_YELLOW, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_YELLOW),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    6,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c b/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
new file mode 100644
index 0000000..0037128
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-enabler.c,v 1.1 2006/04/17 15:02:32 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x0f
+#define BGCOLOR2 0x0c
+#define BGCOLOR3 0x0b
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0xff,0xfc,0xf0,0xf0,0xe0,0xe0,0xe0,0xe0},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0xff,0x3f,0x0f,0x0f,0x07,0x07,0x07,0x07},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},    
+    
+    /* buttonright[8]; */
+    {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_GRAY2),
+     COLOR(COLOR_WHITE, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_WHITE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY3, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY3),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_GRAY3),
+     COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GRAY3, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_GRAY1, COLOR_GRAY3),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_WHITE, COLOR_BLACK),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    0,
+
+    /* Pointer sprite 1 color */
+    1,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+       0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+       0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+       0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+       0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+       0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+       0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+       0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+       0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+       COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+      
+    
+
+  };
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c b/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
new file mode 100644
index 0000000..d57cb05
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
@@ -0,0 +1,288 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-ravenpine.c,v 1.1 2006/04/17 15:02:33 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x00
+#define BGCOLOR2 0x05
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xfc,0xfc,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x0c,0x0c,0x0c,0x0c,0x0c,0xfc,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x3e,0x30,0x30,0x30,0x30,0x30,0x30,0x3c},
+    
+    /* buttonright[8]; */
+    {0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c},
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_BLACK, COLOR_BLUE),
+     COLOR(COLOR_GREEN, COLOR_LIGHTBLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+        
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+        
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GRAY1),
+     COLOR(COLOR_BLACK, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_GREEN, COLOR_BLACK),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_LIGHTGREEN, COLOR_GREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    0,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_LIGHTGREEN,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+    {
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+      0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,      
+    },
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c b/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
new file mode 100644
index 0000000..88e5f1e
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
@@ -0,0 +1,284 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-springlight.c,v 1.1 2006/04/17 15:02:33 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x05
+#define BGCOLOR2 0x0d
+
+
+struct ctk_hires_theme ctk_hires_theme =
+  {
+    /* Version string. */
+    /*    char version[8]; */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+    /* Window borders patterns. */
+    /* unsigned char ulcorner[8], */ /* Upper left corner. */
+    {0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40},
+    
+    /* titlebar[8], */            /* Title bar pattern. */
+    {0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00},
+    
+    /* urcorner[8],       */       /* Upper right corner. */
+    {0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00},
+    
+    /* rightborder[8],     */      /* Right border. */
+    {0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
+    
+    /* lrcorner[8],      */        /* Lower right corner. */
+    {0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00},
+    
+    /* lowerborder[8], */          /* Lower border. */
+    {0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00},
+    
+    /* llcorner[8],  */            /* Lower left corner. */
+    {0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00},
+    
+    /* leftborder[8]; */          /* Left border. */
+    {0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40},
+
+    /* Button corner patterns. */
+    /*    unsigned char buttonleft[8], */
+    {0x0f,0x18,0x10,0x10,0x10,0x10,0x10,0x00},    
+    
+    /* buttonright[8]; */
+    {0x00,0x08,0x08,0x08,0x08,0x08,0x18,0xf0},    
+    
+      /* Menu border patterns. */
+    /*    unsigned char menuleftpattern[8], */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* menurightpatterns[8]; */
+    {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+    
+    /* Window and widget colors. */
+    /*    unsigned char windowcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* separatorcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GRAY1, COLOR_GRAY2),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1)},
+    
+    /* labelcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+    
+    /* buttoncolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+    
+    /* hyperlinkcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+     COLOR(COLOR_GREEN, COLOR_CYAN),
+     COLOR(COLOR_GREEN, COLOR_BLUE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+     COLOR(COLOR_BLUE, COLOR_LIGHTGREEN)},
+    
+    /* textentrycolors[6],  */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* bitmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_GRAY1),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK),
+     COLOR(COLOR_GRAY3, COLOR_BLACK)},
+    
+    /* textmapcolors[6], */
+    {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_GRAY2, COLOR_GRAY1),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_WHITE, COLOR_BLACK)},
+    
+    /* iconcolors[6]; */
+    {COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+     COLOR(COLOR_GRAY1, COLOR_LIGHTGREEN),
+     COLOR(COLOR_WHITE, COLOR_BLACK),
+     COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+    /* Button corner colors. */
+    /* unsigned char buttonleftcolors[6], */
+    {COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2)},
+    
+    /* buttonrightcolors[6]; */
+    {COLOR(COLOR_GRAY1, COLOR_BLACK),
+     COLOR(COLOR_GRAY1, COLOR_GREEN),
+     COLOR(COLOR_GREEN, COLOR_GRAY1),
+     COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+     COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+     COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+    
+    /* Menu colors. */
+    /*    unsigned char menucolor,*/
+    COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+    
+    /*    openmenucolor, */
+    COLOR(COLOR_BLACK, COLOR_GREEN),
+    
+    /* activemenucolor; */
+    COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+    
+    /* Border and screen colors. */
+    /*    unsigned char bordercolor,*/
+    5,
+    
+    /* screencolor; */
+    0,
+
+    /* Pointer sprite 0 color */
+    COLOR_WHITE,
+
+    /* Pointer sprite 1 color */
+    COLOR_GREEN,
+
+
+    /* Pointer sprite. */
+    /* unsigned char pointer[128]; */
+    {0x00, 0x00, 0x00,
+    0x40, 0x00, 0x00,
+    0x60, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x78, 0x00, 0x00,
+    0x7c, 0x00, 0x00,
+    0x70, 0x00, 0x00,
+    0x58, 0x00, 0x00,
+    0x18, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00,
+    
+    0xc0, 0x00, 0x00,
+    0xe0, 0x00, 0x00,
+    0xf0, 0x00, 0x00,
+    0xf8, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0xfc, 0x00, 0x00,
+    0x3c, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00,
+     0x00 },
+    
+
+
+    /* Background pattern fill. */
+    /*    unsigned char backgroundpattern[8*25]; */
+      {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 223, 255, 255, 247, 255, 255, 191, 247, 255, 255, 219, 255, 255, 187,
+255, 239, 251, 191, 239, 253, 223, 251, 223, 253, 183, 255, 213, 127, 237, 191,
+245, 95, 245, 223, 181, 255, 85, 255, 85, 219, 118, 219, 109, 219, 182, 109, 219, 182, 109, 219, 170, 109, 219, 170, 181, 173, 85, 218, 85, 173, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 146, 85, 146, 170, 82, 138, 50, 74, 164, 73,
+146, 84, 137, 82, 4, 169, 18, 164, 2, 168, 18, 68, 18, 160, 10, 32, 74, 0, 42, 128, 18, 64, 20, 0, 82, 0, 4, 80, 4, 0, 72, 2, 0, 16, 132, 0, 0, 72, 0, 0, 4, 64, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+
+    /* Background colors. */
+    /*    unsigned char backgroundpatterncolors[25]; */
+      {COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+       COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+      
+    
+
+  };
diff --git a/contiki-cpc/ctk/unused/ctk-hires-theme.h b/contiki-cpc/ctk/unused/ctk-hires-theme.h
new file mode 100644
index 0000000..6bebb2c
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires-theme.h
@@ -0,0 +1,105 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme.h,v 1.1 2006/04/17 15:02:33 kthacker Exp $
+ *
+ */
+#ifndef __CTK_HIRES_THEME_H__
+#define __CTK_HIRES_THEME_H__
+
+struct ctk_hires_theme {
+  /* Version string. */
+  char version[8];
+  
+  /* Window borders patterns. */
+  unsigned char ulcorner[8], /* Upper left corner. */
+    titlebar[8],             /* Title bar pattern. */
+    urcorner[8],             /* Upper right corner. */
+    rightborder[8],          /* Right border. */
+    lrcorner[8],             /* Lower right corner. */
+    lowerborder[8],          /* Lower border. */
+    llcorner[8],             /* Lower left corner. */
+    leftborder[8];           /* Left border. */
+
+  /* Button corner patterns. */
+  unsigned char buttonleftpattern[8],
+    buttonrightpattern[8];
+
+  /* Menu border patterns. */
+  unsigned char menuleftpattern[8],
+    menurightpatterns[8];
+  
+
+
+  /* Window and widget colors. */
+  unsigned char windowcolors[6],
+    separatorcolors[6],
+    labelcolors[6],
+    buttoncolors[6],
+    hyperlinkcolors[6],
+    textentrycolors[6],
+    bitmapcolors[6],
+    textmapcolors[6],
+    iconcolors[6];
+
+  
+  /* Button corner colors. */
+  unsigned char buttonleftcolors[6],
+    buttonrightcolors[6];
+
+  /* Menu colors. */
+  unsigned char menucolor,
+    openmenucolor,
+    activemenucolor;
+ 
+  /* Border and screen colors. */
+  unsigned char bordercolor,
+    screencolor;
+
+  /* Pointer sprite colors. */
+  unsigned char pointermaskcolor,
+    pointercolor;
+  
+  /* Pointer sprite. */
+  unsigned char pointer[128];
+
+  /* Background pattern fill. */
+  unsigned char backgroundpattern[8*25];
+
+  /* Background colors. */
+  unsigned char backgroundpatterncolors[25];
+
+};
+
+extern struct ctk_hires_theme ctk_hires_theme;
+extern struct ctk_hires_theme *ctk_hires_theme_ptr;
+
+#endif /* __CTK_HIRES_THEME_H__ */
diff --git a/contiki-cpc/ctk/unused/ctk-hires.c b/contiki-cpc/ctk/unused/ctk-hires.c
new file mode 100644
index 0000000..6f33aa6
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires.c
@@ -0,0 +1,872 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.c,v 1.1 2006/04/17 15:02:34 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH  40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR  0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+  {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+   2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+   4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+   6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+   8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+   10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+   12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+   14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+   16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+   18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+   20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+   22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+   24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+  {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+   2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+   4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+   6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+   8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+   10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+   12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+   14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+   16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+   18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+   20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+   22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+   24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c)   ctk_hires_reversed = c
+#define hires_color(c)   ctk_hires_color = c
+#define hires_underline(c)   ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+  static unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_hires_cputc('|');
+    --ctk_hires_cursx;
+    ++ctk_hires_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_hires_cursx = x;
+  ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void 
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda %v", lineptr);
+  asm("asl");
+  asm("tax");
+  asm("lda %v,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2");
+  asm("lda %v+1,x", ctk_hires_yhiresaddr);
+  asm("sta ptr2+1");
+  asm("lda %v,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1");
+  asm("lda %v+1,x", ctk_hires_yscreenaddr);
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx %v", lineptr);
+  asm("lda %v+%w,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda %v", lineptr);
+  /*  asm("and #7");*/
+  asm("asl");
+  asm("asl");
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda %v+%w+0,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+1,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+2,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+3,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+4,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+5,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+6,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda %v+%w+7,x", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, backgroundpattern));
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+
+  
+  if(lineptr == 24) {
+    hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+    hires_gotoxy(0, 24);
+    ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+		     sizeof(CONTIKI_VERSION_STRING) - 1);
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+  asm("sei");
+  asm("pha");
+  asm("inc $d020");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$36");
+  asm("sta $01");
+  asm("lda #>_nmi2");
+  asm("pha");
+  asm("lda #<_nmi2");
+  asm("pha");
+  asm("php");
+  asm("jmp ($0318)");
+
+  nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_draw_init(void)
+{
+  unsigned char i, *ptr1, *ptr2;
+
+  
+  setup_nmi();
+  
+  /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+     hires/colors. */
+  VIC.ctrl1 = 0x3b;  /* $D011 */
+  VIC.addr  = 0x78;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+  VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */  
+
+  /* Fill color memory. */
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldx #0");
+  asm("lda #$c0");
+  asm("fillcolorloop:");
+  asm("sta $dc00,x");
+  asm("sta $dd00,x");
+  asm("sta $de00,x");
+  asm("sta $df00,x");
+  asm("inx");
+  asm("bne fillcolorloop");
+
+  /* Setup sprite pointers */
+  asm("ldx #$fd");
+  asm("stx $dff8");
+  asm("inx");
+  asm("stx $dff9");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+  /* Fill hires memory with 0. */
+
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+  asm("lda #0");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+  asm("ldy #0");
+  asm("lda #0");
+  asm("clrscrnloop:");
+  asm("lda #$55");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne clrscrnloop");
+  asm("inc $fe");
+  asm("lda $fe");
+  asm("cmp #$ff");
+  asm("bne clrscrnloop");
+
+  asm("ldy #$00");
+  asm("clrscrnloop2:");
+  asm("lda #$55");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("lda #$aa");
+  asm("sta $ff00,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne clrscrnloop2");
+
+  
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+
+  
+  ctk_draw_clear(0, SCREEN_HEIGHT);
+
+  /* Setup mouse pointer sprite. */
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointermaskcolor));
+  asm("sta $d027");
+  asm("lda %v+%w", ctk_hires_theme,
+      offsetof(struct ctk_hires_theme, pointercolor));
+  asm("sta $d028");
+
+  ptr1 = ctk_hires_theme.pointer;
+  ptr2 = (unsigned char *)0xff40;
+  
+  for(i = 0; i < 0x80; ++i) {
+    *ptr2++ = *ptr1++;
+  }
+
+  return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char afocus)
+{
+  static unsigned char xpos, ypos, xscroll;
+  static unsigned char i;
+  static char c;
+  static unsigned char len;
+  static unsigned char tmp;
+  static unsigned char yclipped;
+  static unsigned char focus;
+  char *text;
+  
+  xpos = x + w->x;
+  ypos = y + w->y;  
+
+  yclipped = 0;  
+  if(ypos >= clipy1 && ypos < clipy2) {
+    yclipped = 1;
+  }
+  focus = afocus;
+  
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    hires_color(ctk_hires_theme.separatorcolors[focus]);
+    if(yclipped) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    hires_color(ctk_hires_theme.labelcolors[focus]);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_cputsn(text, w->w);
+	tmp = w->w - (hires_wherex() - xpos);
+	if(tmp > 0) {
+	  ctk_hires_cclear(tmp);
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_draw_buttonleft();
+      hires_color(ctk_hires_theme.buttoncolors[focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+      ctk_hires_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_hires_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.textentrycolors[focus]);
+      
+      if((focus & CTK_FOCUS_WIDGET) &&
+	 w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+	hires_revers(1);
+      } else {
+	hires_revers(0);
+      }
+      xscroll = 0;
+      tmp = w->w - 1;
+      if(w->widget.textentry.xpos >= tmp) {
+	xscroll = w->widget.textentry.xpos - tmp;
+      }
+      text = w->widget.textentry.text;
+      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	hires_revers(0);
+	hires_cputcxy(xpos, ypos, '>');
+	text += xscroll;
+	for(i = 0; i < w->w; ++i) {
+	  c = *text;
+	  if(i == w->widget.textentry.xpos - xscroll) {
+	    hires_revers(1);
+	  } else {
+	    hires_revers(0);
+	  }
+	  if(c == 0) {
+	    ctk_hires_cputc(' ');
+	  } else {
+	    ctk_hires_cputc(c);
+	  }
+	  hires_revers(0);
+	  ++text;
+	}
+	ctk_hires_cputc('<');
+      } else {
+	hires_cputcxy(xpos, ypos, '|');
+	/*	  hires_gotoxy(xpos + 1, ypos);          */
+	ctk_hires_cputsn(text, w->w);
+	i = hires_wherex();
+	tmp = i - xpos - 1;
+	if(tmp < w->w) {
+	  ctk_hires_cclear(w->w - tmp);
+	}
+	ctk_hires_cputc('|');
+      }
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(yclipped) {
+      hires_color(ctk_hires_theme.iconcolors[focus]);
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+
+      tmp = ypos + 3;
+	
+      if(tmp < clipy2) {
+	hires_gotoxy(x, tmp);
+	ctk_hires_cputsn(w->widget.icon.title, len);
+      }
+
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	ctk_hires_bitmapptr = w->widget.icon.bitmap;
+	for(i = 0; i < 3; ++i) {
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    hires_gotoxy(xpos, ypos);
+	    ctk_hires_draw_bitmapline(3);
+	  }
+	  ctk_hires_bitmapptr += 3 * 8;
+	  ++ypos;
+	}
+	
+	/*	draw_bitmap_icon(w->widget.icon.bitmap);*/
+      }
+
+    }
+    break;
+  case CTK_WIDGET_BITMAP:
+    hires_color(ctk_hires_theme.bitmapcolors[focus]);
+    ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_hires_draw_bitmapline(w->w);
+      }
+      ctk_hires_bitmapptr += w->w * 8;
+      ++ypos;
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(register struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  static unsigned char h;
+
+  hires_color(ctk_hires_theme.windowcolors[focus]);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i <= clipy2) {
+      hires_cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(register struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2)
+{
+  register struct ctk_widget *w;
+
+  x = window->x;
+  y = window->y + 1;
+  
+  ++clipy2;
+  
+  if(clipy2 <= y) {
+    return;
+  }
+  
+  /*  hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  /*  x2 = x1 + window->w;
+      y2 = y1 + window->h;*/
+    
+  hires_gotoxy(x, y);
+  ctk_hires_windowparams.w = window->w;
+  ctk_hires_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_hires_windowparams.clipy1 = 0;
+  } else {
+    ctk_hires_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_hires_windowparams.clipy2 = clipy2 - y;
+  ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+  ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+  ctk_hires_windowparams.title = window->title;
+  ctk_hires_windowparams.titlelen = window->titlelen;
+
+  if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+     ctk_hires_windowparams.clipy2 > 0) {
+    ctk_hires_draw_windowborders();
+  }
+  
+  focus = focus & CTK_FOCUS_WINDOW;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1,
+		clipy1, clipy2,
+		wfocus);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(register struct ctk_window *dialog)
+{
+  register struct ctk_widget *w;
+
+  hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+  /*  x = (SCREEN_WIDTH - dialog->w) / 2;
+      y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  hires_cvlinexy(x, y1, dialog->h);
+  hires_cvlinexy(x2, y1, dialog->h);
+
+  hires_chlinexy(x1, y, dialog->w);
+  hires_chlinexy(x1, y2, dialog->w);
+
+  hires_cputcxy(x, y, CH_ULCORNER);
+  hires_cputcxy(x, y2, CH_LLCORNER);
+  hires_cputcxy(x2, y, CH_URCORNER);
+  hires_cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2; ++i) {
+    hires_cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1,
+		0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+  }
+
+
+  /* Draw active widgets. */
+  for(w = dialog->active; w != NULL; w = w->next) {
+    wfocus = CTK_FOCUS_DIALOG;
+    if(w == dialog->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+    draw_widget(w, x1, y1, 
+		0, SCREEN_HEIGHT, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  for(i = y1; i < y2; ++i) {
+    clear_line(i);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+  static unsigned char x, x2, y;
+  
+  hires_color(ctk_hires_theme.openmenucolor);
+  x = hires_wherex();
+  ctk_hires_cputsn(m->title, m->titlelen);
+  ctk_hires_cputc(' ');
+  x2 = hires_wherex();
+  if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+    x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+  }      
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      hires_color(ctk_hires_theme.activemenucolor);
+    } else {
+      hires_color(ctk_hires_theme.menucolor);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_hires_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_hires_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(ctk_hires_theme.menucolor);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  hires_color(ctk_hires_theme.menucolor); 
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  ctk_hires_cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      ctk_hires_cputsn(m->title, m->titlelen);
+      ctk_hires_cputc(' ');
+    } else {     
+      draw_menu(m);
+    }
+  }
+  ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_hires_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_hires_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+/*unsigned char
+ctk_arch_isprint(char c)
+{
+  return isprint(c);
+}*/
diff --git a/contiki-cpc/ctk/unused/ctk-hires.h b/contiki-cpc/ctk/unused/ctk-hires.h
new file mode 100644
index 0000000..a395899
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.h,v 1.1 2006/04/17 15:02:34 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_H__
+#define __CTK_HIRES_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey   cgetc
+
+#define CH_ENTER '\n'
+
+#endif /* __CTK_HIRES_H__ */
diff --git a/contiki-cpc/ctk/unused/ctk-hires2.c b/contiki-cpc/ctk/unused/ctk-hires2.c
new file mode 100644
index 0000000..d3e8f03
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-hires2.c
@@ -0,0 +1,30 @@
+void ctk_hires_cputc(unsigned char ch)
+{
+}
+
+void ctk_hires_cclear(unsigned char len)
+{
+}
+
+void ctk_hires_chline(unsigned char len)
+{
+}
+void ctk_hires_cputsn(unsigned char *str, unsigned char len)
+{
+}
+
+void ctk_hires_draw_buttonleft()
+{
+}
+
+void ctk_hires_draw_buttonright()
+{
+}
+
+void ctk_hires_draw_bitmapline(unsigned char len)
+{
+}
+
+void ctk_hires_draw_windowborders()
+{
+}
diff --git a/contiki-cpc/ctk/unused/ctk-mouse-1351.S b/contiki-cpc/ctk/unused/ctk-mouse-1351.S
new file mode 100644
index 0000000..eeef7b5
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-mouse-1351.S
@@ -0,0 +1,149 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_1351
+;---------------------------------------------------------------------
+.bss
+OldValue:       .res    1               ; Temp for MoveCheck routine
+NewValue:       .res    1               ; Temp for MoveCheck routine
+YCorr:          .res    1               ; Correction for Y coordinate
+	
+OldPotX:        .res    1               ; Old hw counter values
+OldPotY:        .res    1
+ 
+SID_ADConv1     = $D419
+SID_ADConv2     = $D41A
+CIA1_PRA        = $DC00	
+CIA1_PRB        = $DC01	
+CIA1_DDRB       = $DC03	
+
+
+;---------------------------------------------------------------------
+.data
+XMin:           .word    0               ; X1 value of bounding box
+YMin:           .word    0               ; Y1 value of bounding box
+XMax:           .word    319             ; X2 value of bounding box
+YMax:           .word    199             ; Y2 value of bounding box
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+;---------------------------------------------------------------------
+	;; Most of the mouse code is taken from the CC65 libraries written by
+	;; Ullrich von Bassewitz
+MoveCheck:
+        sty     OldValue
+        sta     NewValue
+        ldx     #$00
+ 
+        sub     OldValue                ; a = mod64 (new - old)
+        and     #%01111111
+        cmp     #%01000000              ; if (a > 0)
+        bcs     @L1                     ;
+        lsr     a                       ;   a /= 2;
+        beq     @L2                     ;   if (a != 0)
+        ldy     NewValue                ;     y = NewValue
+        rts                             ;   return
+ 
+@L1:    ora     #%11000000              ; else or in high order bits
+        cmp     #$FF                    ; if (a != -1)
+        beq     @L2
+        sec
+        ror     a                       ;   a /= 2
+        dex                             ;   high byte = -1 (X = $FF)
+        ldy     NewValue
+        rts
+                                                                               
+@L2:    txa                             ; A = $00
+        rts
+                                                                               
+;---------------------------------------------------------------------	
+_ctk_mouse_1351:
+        lda     SID_ADConv1             ; Get mouse X movement
+        ldy     OldPotX
+        jsr     MoveCheck               ; Calculate movement vector
+        sty     OldPotX
+ 
+; Calculate the new X coordinate (--> a/y)
+ 
+        add     _ctk_mouse_joyx
+        tay                             ; Remember low byte
+        txa
+        adc     _ctk_mouse_joyx+1
+        tax
+ 
+; Limit the X coordinate to the bounding box
+ 
+        cpy     XMin
+        sbc     XMin+1
+        bpl     @L1
+        ldy     XMin
+        ldx     XMin+1
+        jmp     @L2
+@L1:    txa
+ 
+        cpy     XMax
+        sbc     XMax+1
+        bmi     @L2
+        ldy     XMax
+        ldx     XMax+1
+@L2:    sty     _ctk_mouse_joyx
+        stx     _ctk_mouse_joyx+1
+; Calculate the Y movement vector
+ 
+        lda     SID_ADConv2             ; Get mouse Y movement
+        ldy     OldPotY
+        jsr     MoveCheck               ; Calculate movement
+        sty     OldPotY
+ 
+; Calculate the new Y coordinate (--> a/y)
+ 
+        sta     OldValue
+        lda     _ctk_mouse_joyy
+        sub     OldValue
+        tay
+        stx     OldValue
+        lda     _ctk_mouse_joyy+1
+        sbc     OldValue
+        tax
+ 
+        cpy     YMin
+        sbc     YMin+1
+        bpl     @L3
+        ldy     YMin
+        ldx     YMin+1
+        jmp     @L4
+@L3:    txa
+                                                                               
+        cpy     YMax
+        sbc     YMax+1
+        bmi     @L4
+        ldy     YMax
+        ldx     YMax+1
+@L4:    sty     _ctk_mouse_joyy
+        stx     _ctk_mouse_joyy+1
+
+	;; Get mouse button
+        lda     #$7F
+        sta     CIA1_PRA
+        lda     CIA1_PRB                ; Read joystick #0
+        ldx     #0
+        and     #$1F
+        eor     #$1F
+	
+	ora     _ctk_mouse_firebutton
+	sta	_ctk_mouse_firebutton
+	
+	lda	#0
+	sta	CIA1_PRA
+	sta	CIA1_DDRB	
+	rts	
+;---------------------------------------------------------------------			
diff --git a/contiki-cpc/ctk/unused/ctk-mouse-asm.S b/contiki-cpc/ctk/unused/ctk-mouse-asm.S
new file mode 100644
index 0000000..6aa53b4
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-mouse-asm.S
@@ -0,0 +1,48 @@
+
+;---------------------------------------------------------------------
+	;; The 1351 mouse code was taken from the CC65 libraries,
+	;; written by Ullrich von Bassewitz 
+;---------------------------------------------------------------------	
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton
+	.export		_ctk_mouse_asm_irq
+	.import		_ctk_mouse_joy, _ctk_mouse_1351
+;---------------------------------------------------------------------
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------			
+_ctk_mouse_asm_irq:
+	lda #0
+	sta _ctk_mouse_firebutton
+	
+	jsr _ctk_mouse_joy
+	;; jsr_ctk_mouse_1351
+
+ ; 	lda _ctk_mouse_joybutton
+ ; 	ora _ctk_mouse_1351button
+ ; 	sta _ctk_mouse_firebutton
+	
+	  lda _ctk_mouse_joyy
+	  clc
+	  adc #$32
+	  sta $d001
+	  sta $d003	
+
+	  lda _ctk_mouse_joyx
+	  clc
+	  adc #$18
+	  sta $d000
+	  sta $d002	
+	  lda #0
+	  adc _ctk_mouse_joyx+1
+	  and #1
+	  beq :+
+	  lda #3
+:		
+	  sta $d010                                                                                       
+	  jmp $ea31
diff --git a/contiki-cpc/ctk/unused/ctk-mouse-joy.S b/contiki-cpc/ctk/unused/ctk-mouse-joy.S
new file mode 100644
index 0000000..963ca36
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-mouse-joy.S
@@ -0,0 +1,135 @@
+
+;---------------------------------------------------------------------
+
+        .macpack        generic
+
+	.import		_ctk_mouse_joyx, _ctk_mouse_joyy
+	.import		_ctk_mouse_firebutton	
+	.export		_ctk_mouse_joy	
+;---------------------------------------------------------------------
+.bss
+lastjoydy:	.res 1
+lastjoydx:	.res 1
+joydycnt:	.res 1
+joydxcnt:	.res 1
+	
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+_ctk_mouse_joy:
+	  ldy $dc02
+	  lda #0
+          sta $dc02
+          lda $dc00
+          sty $dc02
+	  ldy #0
+	  ldx #0
+	  lsr
+	  bcs nodey
+	  dey
+nodey:
+	  lsr
+	  bcs noiny
+	  iny
+noiny:
+	  lsr
+	  bcs nodex
+	  dex
+nodex:
+	  lsr
+	  bcs noinx
+	  inx
+noinx:
+	  and #1
+	  eor #1
+	  ora _ctk_mouse_firebutton
+	  sta _ctk_mouse_firebutton
+
+	  cpy lastjoydy
+	  sty lastjoydy
+	  bne noydy
+	  tya
+	  pha
+	  inc joydycnt
+	  lda joydycnt
+          cmp #$1f
+          bmi nostajoydycnt
+          lda #$20
+	  sta joydycnt
+nostajoydycnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tay
+	  pla
+asldeyloop:
+	  asl
+	  dey
+	  bpl asldeyloop
+	  tay
+	  jmp ydy
+noydy:
+	  lda #0
+	  sta joydycnt
+ydy:
+
+	  tya
+	  clc
+	  adc _ctk_mouse_joyy
+
+	  cmp #240
+	  bcc :+
+	  lda #0
+:	
+		
+ 	  cmp #200
+ 	  bcc :+
+ 	  lda #199		
+:
+	  sta _ctk_mouse_joyy
+	
+	  cpx lastjoydx
+	  stx lastjoydx
+	  bne noxdx
+	  txa
+	  pha
+	  inc joydxcnt
+	  lda joydxcnt
+          cmp #$1f
+          bmi nostajoydxcnt
+          lda #$20
+	  sta joydxcnt
+nostajoydxcnt:
+	  lsr
+	  lsr
+	  lsr
+	  lsr
+	  tax
+	  pla
+asldexloop:
+	  asl
+	  dex
+	  bpl asldexloop
+	  tax
+	  jmp xdx
+noxdx:
+	  lda #0
+	  sta joydxcnt
+xdx:
+	                                                                                       
+	  txa
+	  clc
+	  adc _ctk_mouse_joyx
+	  sta _ctk_mouse_joyx
+	  php
+	  lda #$ff
+	  cpx #0
+	  bmi nolda02
+	  lda #0
+nolda02:
+	  plp
+	  adc _ctk_mouse_joyx+1
+	  sta _ctk_mouse_joyx+1
+	  rts	                                                                                       
diff --git a/contiki-cpc/ctk/unused/ctk-mouse.c b/contiki-cpc/ctk/unused/ctk-mouse.c
new file mode 100644
index 0000000..aaa0970
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-mouse.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.c,v 1.1 2006/04/17 15:02:34 kthacker Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+unsigned short ctk_mouse_joyy, ctk_mouse_joyx;
+unsigned char ctk_mouse_firebutton;
+
+extern void ctk_mouse_asm_irq(void);
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_init(void)
+{
+  /* Place mouse pointer at the middle of the screen. */
+  ctk_mouse_joyx = 160;
+  ctk_mouse_joyy = 100;
+  
+  /* Setup and start IRQ */
+  asm("sei");
+  asm("lda #<%v", ctk_mouse_asm_irq);
+  asm("sta $0314");
+  asm("lda #>%v", ctk_mouse_asm_irq);
+  asm("sta $0315");   
+  asm("cli");
+  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+  if(ctk_mouse_joyx >= 342) {
+    ctk_mouse_joyx = 0;
+  } else if(ctk_mouse_joyx >= 320) {
+    ctk_mouse_joyx = 319;
+  }
+  return ctk_mouse_joyx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+  return ctk_mouse_joyy;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+  return ctk_mouse_firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_hide(void)
+{
+  /* Turn off sprites 0 and 1 */
+  asm("lda #0");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_show(void)
+{  
+  /* Turn on sprites 0 and 1 */
+  asm("lda #3");
+  asm("sta $d015"); 
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki-cpc/lib/lc-asm.s b/contiki-cpc/lib/lc-asm.s
new file mode 100644
index 0000000..05f773d
--- /dev/null
+++ b/contiki-cpc/lib/lc-asm.s
@@ -0,0 +1,30 @@
+;---------------------------------------------------------------------
+;;	.globl ptr1
+;---------------------------------------------------------------------
+_lc_set::
+;;	sta ptr1
+;;	stx ptr1+1
+;;	tsx
+;;	lda $0102,x
+;;	ldy #$01
+;;	sta (ptr1),y
+;;	lda $0101,x
+;;	dey
+;;	sta (ptr1),y
+
+	ret
+;---------------------------------------------------------------------
+_lc_resume::
+;;	sta ptr1
+;;	stx ptr1+1
+;;	ldy #$01
+;;	lda (ptr1),y
+;;	beq :+
+;;	tsx
+;;	sta $0102,x
+;;	dey
+;;	lda (ptr1),y
+;;	sta $0101,x
+
+	ret
+;---------------------------------------------------------------------	
diff --git a/contiki-cpc/lib/lc.h b/contiki-cpc/lib/lc.h
new file mode 100644
index 0000000..827a840
--- /dev/null
+++ b/contiki-cpc/lib/lc.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and Oliver Schmidt
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>, Oliver Schmidt <ol.sc0web.de>
+ *
+ * $Id: lc.h,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ */
+/* Local continuations: a form of continuation that only works locally
+   within a function.
+*/
+
+#ifndef __LC_H__
+#define __LC_H__
+
+#include "cc.h"
+
+typedef void * lc_t;
+
+void __fastcall__ lc_set(lc_t *lc);
+void __fastcall__ lc_resume(lc_t *lc);
+
+#define LC_SET(lc)    lc_set(&(lc))
+#define LC_RESUME(lc) lc_resume(&(lc))
+#define LC_INIT(lc)   (lc) = NULL
+#define LC_END(lc)
+
+#endif /* __LC_H__ */
diff --git a/contiki-cpc/lib/mtarch-asm.S b/contiki-cpc/lib/mtarch-asm.S
new file mode 100644
index 0000000..22ab609
--- /dev/null
+++ b/contiki-cpc/lib/mtarch-asm.S
@@ -0,0 +1,245 @@
+;---------------------------------------------------------------------       
+	.importzp       ptr1
+	.importzp	sp
+	.import		__ZP_START__
+
+	
+	.import		_mtarch_asm_threadstack
+	.import		_mtarch_asm_threadsp
+	.import		_mtarch_asm_threadspreg
+	.import		_mtarch_asm_threadzp	
+	
+	.export		_mtarch_asm_exec
+	.export		_mtarch_yield
+	.export		_mtarch_asm_start
+	.export		_mtarch_pstart, _mtarch_pstop
+	
+;---------------------------------------------------------------------
+.bss
+kernelsp:	.res 2
+kernelspreg:	.res 1		
+	
+oldirq:		.res 2
+
+	zpsize = 32
+.code
+;---------------------------------------------------------------------	
+	;; Switch to thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped onto the threadstack, and the
+	;; sp and spreg are saved to the local variables "kernelsp" and
+	;; "kernelspreg". Also, the zeropage variables are saved.
+	
+_mtarch_asm_exec:
+	sei
+	;; Save current stack pointer
+	lda sp
+	sta kernelsp
+	lda sp+1
+	sta kernelsp+1
+	
+	tsx
+	stx kernelspreg
+	
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda _mtarch_asm_threadsp
+	sta sp
+	lda _mtarch_asm_threadsp+1
+	sta sp+1
+	
+	ldx _mtarch_asm_threadspreg
+	txs
+
+; 	jsr _mtarch_pstart	
+
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315
+
+	
+	pla
+	tay
+	pla
+	tax
+	pla
+	
+	rti
+
+	;; Switch from thread defined by threadsp, threadstack and threadspreg.
+	;; The kernel stack is swapped back from the threadstack, and the
+	;; sp and spreg are restored from the local variables "kernelsp" and
+	;; "kernelspreg".
+yield:
+	sei
+	lda sp
+	sta _mtarch_asm_threadsp
+	lda sp+1
+	sta _mtarch_asm_threadsp+1
+
+	tsx
+	stx _mtarch_asm_threadspreg
+
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy kernelspreg                  ; determine the smallest of the two stack pointers,
+        cpy _mtarch_asm_threadspreg              ; as we only need to swap the used part of the stack
+        bcc :+
+        ldy _mtarch_asm_threadspreg
+
+:		
+	lda <__ZP_START__,y
+	tax
+	lda (ptr1),y
+	sta <__ZP_START__,y
+	txa
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+
+	lda _mtarch_asm_threadstack
+	sta ptr1
+	lda _mtarch_asm_threadstack+1
+	sta ptr1+1
+
+	ldy #0
+:
+	lda $0100,y
+	tax	
+	lda (ptr1),y
+	sta $0100,y
+	txa
+	sta (ptr1),y
+	iny
+	bne :-
+
+	lda kernelsp
+	sta sp
+	lda kernelsp+1
+	sta sp+1
+	
+	ldx kernelspreg
+	txs
+
+	cli
+	
+	rts
+;---------------------------------------------------------------------
+	;; Simulate an IRQ by pushing CPU status and CPu registers
+	;; onto the stack. Then call the yield function to yield the
+	;; process.		
+_mtarch_yield:	
+	php
+	pha
+	txa
+	pha
+	tya
+	pha
+
+        tsx
+         
+                                ; the rts adds 1 to the PC
+                                ; saved on the stack. We want
+        lda $0105,x             ; the stack to look like is would
+        clc                     ; do inside of an interrupt.
+        adc #1                  ; (this is what the 'rts' does,
+        sta $0105,x             ;  but not the 'rti')
+        lda $0106,x
+        adc #0
+        sta $0106,x
+ 
+	
+	jmp yield		
+;---------------------------------------------------------------------
+_mtarch_asm_start:
+	lda _mtarch_asm_threadzp
+	sta ptr1
+	lda _mtarch_asm_threadzp+1
+	sta ptr1+1
+
+	ldy #0
+:		
+	lda <__ZP_START__,y
+	sta (ptr1),y	
+	iny
+	cpy #zpsize
+	bne :-
+	rts
+
+;---------------------------------------------------------------------
+irq:
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	jmp yield
+;---------------------------------------------------------------------	
+	;; Setup preemption IRQ
+_mtarch_pstart:
+	sei
+	lda $0314
+	sta oldirq
+	lda $0315
+	sta oldirq+1
+
+	lda #<irq
+ 	sta $0314
+	lda #>irq
+	sta $0315		
+	cli
+	rts
+;---------------------------------------------------------------------
+_mtarch_pstop:
+	sei
+	lda oldirq
+	sta $0314
+	lda oldirq+1
+	sta $0315
+	cli
+	rts	
+;---------------------------------------------------------------------
+
diff --git a/contiki-cpc/lib/mtarch.c b/contiki-cpc/lib/mtarch.c
new file mode 100644
index 0000000..cb6ef68
--- /dev/null
+++ b/contiki-cpc/lib/mtarch.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.c,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ */
+#include "mtarch.h"
+#include <string.h>
+
+unsigned char  mtarch_asm_threadspreg;
+unsigned char *mtarch_asm_threadsp;
+unsigned char *mtarch_asm_threadzp;
+unsigned char *mtarch_asm_threadstack;
+
+void mtarch_asm_start(void);
+void mtarch_asm_exec(void);
+
+
+/*--------------------------------------------------------------------------*/
+void
+mtarch_start(struct mtarch_thread *thread,
+	     void (* function)(void *data),
+	     void *data)
+{
+  memset(thread->cpustack, 0, sizeof(thread->cpustack));
+  memset(thread->cstack, 0, sizeof(thread->cstack));
+  
+  /* Create a CPU stack frame with the appropriate values... */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((unsigned short)function) >> 8; /* high byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((unsigned short)function) & 0xff; /* low byte of return address. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21; /* processor flags. */
+  thread->cpustack[MTARCH_CPUSTACKSIZE - 5] =       /* a register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 6] =     /* x register */
+    thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0;  /* y register */
+  thread->spreg = MTARCH_CPUSTACKSIZE - 8;
+
+  /* Setup the C stack with the data pointer. */
+  thread->sp = &thread->cstack[MTARCH_CSTACKSIZE - 1];
+  
+  mtarch_asm_threadzp    = &(thread->zp);  
+  mtarch_asm_start();
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_exec(struct mtarch_thread *thread)
+{
+  /* Switch processor stack. The call to mtarch_asm_switch() will not
+     return until the process that we switch to calls yield(). */
+  mtarch_asm_threadspreg = thread->spreg;
+  mtarch_asm_threadsp    = thread->sp;
+
+  mtarch_asm_threadstack = &(thread->cpustack[0]);  
+  mtarch_asm_threadzp    = &(thread->zp[0]);
+  
+  mtarch_asm_exec();
+
+  thread->sp = mtarch_asm_threadsp;
+  thread->spreg = mtarch_asm_threadspreg;  
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_init(void) {
+
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_remove(void)
+{
+
+}
diff --git a/contiki-cpc/lib/mtarch.h b/contiki-cpc/lib/mtarch.h
new file mode 100644
index 0000000..afef9af
--- /dev/null
+++ b/contiki-cpc/lib/mtarch.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.h,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ */
+#ifndef __MTARCH_H__
+#define __MTARCH_H__
+
+#define MTARCH_CPUSTACKSIZE 256
+#define MTARCH_CSTACKSIZE 256
+#define MTARCH_ZPSIZE 32
+
+struct mtarch_thread {
+  unsigned char  spreg;
+  unsigned char *sp;
+  unsigned char  cpustack[MTARCH_CPUSTACKSIZE];
+  unsigned char  cstack[MTARCH_CSTACKSIZE];
+  unsigned char  zp[MTARCH_ZPSIZE];
+};
+
+#endif /* __MTARCH_H__ */
+	
diff --git a/contiki-cpc/loader/cfs-cpc.c b/contiki-cpc/loader/cfs-cpc.c
new file mode 100644
index 0000000..a3fa655
--- /dev/null
+++ b/contiki-cpc/loader/cfs-cpc.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.c,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+extern void _readdir(void *);
+
+struct cpc_dir 
+{
+	char *buffer; 
+	char *ptr;
+};
+
+//#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+           cpc_cfs_eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_cpc_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    log_message("Starting KERNAL CFS", "");
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+ // if(cbm_open(2, 8, f, n) == 0) {
+ //   return 2;
+ // }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+ // cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return 0; //return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return 0; //  return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+	struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+
+	char *buffer = malloc(2048);
+	
+	if (buffer)
+	{
+		cpcdir->buffer = buffer;
+		cpcdir->ptr = buffer;	
+		_readdir(buffer);
+		return 0;
+	}
+	return 1;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  int i;
+  int size;
+  int npos;
+  struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+  char *ptr = cpcdir->ptr;
+
+  if (ptr[0]!=0xff)
+	return 1;
+  
+  ptr++;
+
+  npos = 0;
+  for (i=0; i<8; i++)
+  {  
+    char ch = ptr[0]&0x07f;
+    ptr++;
+    e->name[npos] = ch;
+    npos++;    
+  }
+  e->name[npos] = '.';
+  npos++;
+  for (i=0; i<3; i++)
+  {
+    char ch = ptr[0]&0x07f;
+    ptr++;
+    e->name[npos] = ch;
+    npos++;
+  }
+  e->name[npos] = '\0';
+ 
+  size = (ptr[0]&0x0ff) + ((ptr[1]&0x0ff)<<8);  
+  size = size*1024;
+  ptr+=2;
+  e->size = size;
+  cpcdir->ptr = ptr;
+
+  return 0;
+
+/* 1 = if no more dir entries
+ 0 = more dir entries */
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+	struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+	free(cpcdir->buffer);
+	return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/loader/cfs-cpc.h b/contiki-cpc/loader/cfs-cpc.h
new file mode 100644
index 0000000..18f94e8
--- /dev/null
+++ b/contiki-cpc/loader/cfs-cpc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.h,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ */
+#ifndef __CFS_CPC_H__
+#define __CFS_CPC_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cpc_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/loader/dir.s b/contiki-cpc/loader/dir.s
new file mode 100644
index 0000000..2de266a
--- /dev/null
+++ b/contiki-cpc/loader/dir.s
@@ -0,0 +1,99 @@
+;; This example shows how to perform a directory of a disc
+;; and extract the filenames. 
+;;
+;; This code is public domain and can freely be used in your
+;; own programs.
+;;
+;; Written by Kevin Thacker. 2002
+
+
+
+;;------------------------------------------------------------------
+
+;; firmware function to catalog a disc or cassette
+cas_catalog == 0xbc9b
+;; firmware function to disable text output
+txt_vdu_enable == 0xbb54
+;; firmware function to enable text output
+txt_vdu_disable == 0xbb57
+;; firmware function to find a RSX 
+kl_find_command == 0xbcd4
+
+		.globl __readdir
+		.area _CODE
+
+;;------------------------------------------------------------------
+;; find BIOS SET MESSAGE command
+;; this is used to disable disc messages.
+;; this is compatible with other DOSs that also provide this command
+__readdir::
+
+ld hl,#cmd_bios_set_message
+call kl_find_command
+ret nc
+
+;; command found
+
+;; store address of command
+ld (bios_set_message),hl
+ld a,c
+;; store "rom select" of command
+ld (bios_set_message+2),a
+
+;;------------------------------------------------------------------
+
+;; do CAT
+ld hl,#2
+add hl,sp
+ld e,(hl)
+inc hl
+ld d,(hl)
+call fetch_directory
+ret
+
+
+;;------------------------------------------------------------------
+;; display files from data generated by CAS CATALOG function
+
+;; perform a CAT command
+
+fetch_directory::
+push de
+;; disable disc messages. Error messages will not be displayed.
+ld a,#0xff
+rst 0x018						;; KL FAR CALL
+.dw bios_set_message
+
+;; disable text output
+call txt_vdu_disable
+
+pop de
+
+;; initialise in case of an error
+xor a
+ld (de),a
+
+;; do catalog
+call cas_catalog
+
+;; enable text output
+call txt_vdu_enable
+
+;; enable disc messages. Error messages will be displayed
+ld a,#0x0
+rst 0x018						;; KL FAR CALL
+.dw bios_set_message
+ret
+
+
+;;------------------------------------------------------------------
+
+;; this is initialised when the "BIOS SET MESSAGE" RSX has been found.
+bios_set_message:
+.dw 0                    ;; address of function
+.db 0                    ;; "rom select" for function
+
+
+cmd_bios_set_message:
+.db #0x01+#0x80				;; this is the "BIOS SET MESSAGE" RSX
+
diff --git a/contiki-cpc/loader/loader-arch-cpc.c b/contiki-cpc/loader/loader-arch-cpc.c
new file mode 100644
index 0000000..84d12be
--- /dev/null
+++ b/contiki-cpc/loader/loader-arch-cpc.c
@@ -0,0 +1,93 @@
+#include "loader-arch.h"
+#include "rel.h"
+#include <stddef.h>
+#include <malloc.h>
+
+extern void *progend;
+
+struct prg_hdr {
+	char *relocatedata;
+	char arch[8];
+	char version[8];
+	char initfunc[1];
+};
+
+struct dsc_hdr {
+	char *relocatedata;
+	struct dsc dscdata;
+};
+
+unsigned char loader_arch_load(const char *name, char *arg)
+{
+	char *loadaddr;	
+	struct prg_hdr *prghdr;
+	int length;
+
+	/* get length of file */
+	length = get_file_length(name);
+	if (length==0)
+		return LOADER_ERR_OPEN;
+
+	/* allocate memory */
+	loadaddr = malloc(length);
+	if (loadaddr==NULL)
+		return LOADER_ERR_MEM;
+	
+	/* load the file */
+	load_file(name,loadaddr);
+
+	prghdr = (struct prg_hdr *)loadaddr;
+
+	/* relocate it */
+	relocate(prghdr->relocatedata,loadaddr);
+
+	((void (*)(char *))prghdr->initfunc)(arg);
+
+	return LOADER_OK;
+}
+
+struct dsc *loader_arch_load_dsc(const char *name)
+{
+	char *loadaddr;
+	struct dsc_hdr *dschdr;
+	int length;
+
+	/* get length of file */
+	length = get_file_length(name);
+	if (length==0)
+		return NULL;
+
+	/* allocate memory */
+	loadaddr = malloc(length);
+	if (loadaddr==NULL)
+		return NULL;
+
+	/* load the file */
+	load_file(name, loadaddr);
+	
+	dschdr = (struct dsc_hdr *)loadaddr;
+	/* relocate it */
+	relocate(dschdr->relocatedata, loadaddr);
+
+	return &dschdr->dscdata;
+}
+
+void loader_arch_free(void *loadaddr)
+{
+	/* free module */
+	/* we're given the start of 'arch' member of the prg_hdr,
+	calculate the real start address and then free the block */
+	void *header = (void *)((char *)loadaddr - offsetof(struct prg_hdr,arch));
+	free(header);
+}
+
+void loader_arch_free_dsc(struct dsc *dscdata)
+{
+	/* we're given the start of 'dsc' member of the dsc_hdr,
+	calculate the real start address and then free the block */
+	void *header = (void *)((char *)dscdata - 2);
+//offsetof(struct 
+//dsc_hdr,dscdata));
+	free(header);
+}
+
diff --git a/contiki-cpc/loader/loader-arch-module.s b/contiki-cpc/loader/loader-arch-module.s
new file mode 100644
index 0000000..2539b86
--- /dev/null
+++ b/contiki-cpc/loader/loader-arch-module.s
@@ -0,0 +1,16 @@
+;; This is the header for Contiki program files
+;;
+;; This must always be at at the start of the file
+;; The order of the data must not change.
+;;
+.globl _loader_appinit
+		.area _CODE
+
+_loader_arch_loadaddr::
+arch:		.byte	0,0,0,0,0,1,1,1
+version:	.byte	0,0,0,0,0,1,1,1
+
+;; The position of the init function can be anywhere in the file.
+;; This jump is always in the same place, and points to the actual init function.
+	call gsinit
+	jp _loader_appinit
diff --git a/contiki-cpc/loader/loader-arch.h b/contiki-cpc/loader/loader-arch.h
new file mode 100644
index 0000000..ad970a0
--- /dev/null
+++ b/contiki-cpc/loader/loader-arch.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.1 2006/04/17 15:02:35 kthacker Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+#include "dsc.h"
+
+unsigned char loader_arch_load(const char *name, char *arg);
+struct dsc *loader_arch_load_dsc(const char *name);
+void loader_arch_free(void *addr);
+void loader_arch_free_dsc(struct dsc *);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD_DSC(name) loader_arch_load_dsc(name)
+#define LOADER_LOAD(name, arg) loader_arch_load(name, arg)
+#define LOADER_UNLOAD() loader_arch_free(&loader_arch_loadaddr)
+#define LOADER_UNLOAD_DSC(dsc) loader_arch_free_dsc(dsc)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-cpc/loader/rel.h b/contiki-cpc/loader/rel.h
new file mode 100644
index 0000000..fd3c264
--- /dev/null
+++ b/contiki-cpc/loader/rel.h
@@ -0,0 +1,3 @@
+int get_file_length(const char *);
+void load_file(const char *, void *);
+void relocate(void *relocate_data, void *base);
diff --git a/contiki-cpc/loader/rel.s b/contiki-cpc/loader/rel.s
new file mode 100644
index 0000000..be8f085
--- /dev/null
+++ b/contiki-cpc/loader/rel.s
@@ -0,0 +1,219 @@
+	.area _CODE
+	.globl _get_file_length
+	.globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+	ld hl,#2
+	add hl,sp
+	ld a,(hl)
+	inc hl
+	ld h,(hl)
+	ld l,a
+
+	;; HL = address of null terminated string
+	call count_string_length
+	ld de,#0x0c000		;; points to unused 2k buffer
+	call 0x0bc77		;; cas in open
+	push bc			;; BC = length of file
+	call 0x0bc7d		;; cas in abandon
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+	push hl
+	ld b,#0
+csl:	ld a,(hl)
+	or a
+	jr z,csl2
+	inc hl
+	inc b
+	jr csl
+csl2:
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+	ld hl,#5
+	add hl,sp
+	ld d,(hl)
+	dec hl
+	ld e,(hl)
+	dec hl
+
+	push de
+	ld a,(hl)
+	dec hl
+	ld l,(hl)
+	ld h,a
+
+	call count_string_length
+	ld de,#0x0c000
+	call 0x0bc77		;; cas in open
+	pop hl			;; load address
+	call 0x0bc83		;; cas in direct
+	call 0x0bc7a		;; cas in close
+	ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+	ld hl,#5
+	add hl,sp
+	push ix
+	ld b,(hl)			;; base address
+	dec hl
+	ld c,(hl)
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld h,a	
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld l,a				;; IX is offset of table from start of loaded file
+	add ix,bc			;; relocate IX to give absolute address of table.
+
+	push bc
+	pop hl
+	call relocate_16bit
+	push bc
+	pop hl
+	call relocate_8bitl	;; lower byte
+	push bc
+	pop hl
+	call relocate_8bith	;; upper byte
+	pop ix
+	ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;; 
+relocate_8bith:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bh
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bith
+
+r8bh:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get low byte of address
+ld e,0(ix)
+inc ix
+
+;; get high byte to relocate
+ld d,(hl)
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),d
+jr relocate_8bith
+
+relocate_8bitl:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bl
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bitl
+
+r8bl:
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+ld e,(hl)
+ld d,#0x0
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),e
+jr relocate_8bitl
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit 
+;; value to relocate. 
+;;
+;; BC = base address
+;; 
+;; NOTE: 
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix)		;; number of items to relocate
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r16
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_16bit
+
+r16:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+jr relocate_16bit
+
diff --git a/contiki-cpc/loader/unused/c64-dio-asm.S b/contiki-cpc/loader/unused/c64-dio-asm.S
new file mode 100644
index 0000000..86b9639
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-dio-asm.S
@@ -0,0 +1,505 @@
+
+	
+	.export _c64_dio_asm_init
+	.export _c64_dio_asm_read_block
+	.export _c64_dio_asm_write_block	
+
+	.export _c64_dio_asm_track, _c64_dio_asm_sector
+
+	.export _c64_dio_asm_ptr
+	
+	.importzp ptr1, ptr2
+		
+	;; job code $80 read, $90 write
+	
+
+ciout    = $ffa8
+listen   = $ffb1
+second   = $ff93
+unlsn    = $ffae
+
+nbytes   = 34
+esc      = $42
+
+blockread = 1
+blockwrite = 2
+
+errok    = 0
+errerr   = 1
+
+.data
+_c64_dio_asm_track: .byte 0
+_c64_dio_asm_sector: .byte 0
+_c64_dio_asm_ptr: .byte 0,0			
+
+.code
+;---------------------------------------
+_c64_dio_asm_read_block:		
+
+  	lda #blockread
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+	 lda _c64_dio_asm_sector
+         jsr send
+
+
+         jsr recv
+         cmp #errok
+         bne readerr
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+readl:	
+         jsr recv
+         sta (ptr1),y
+         iny
+         bne readl
+         clc
+	 lda #0
+         tax	
+         rts
+readerr:	
+	;          sta $07c0	
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_write_block:		
+
+ 	lda #blockwrite
+         jsr send
+
+         lda _c64_dio_asm_track
+         jsr send
+         lda _c64_dio_asm_sector
+         jsr send
+
+
+	 lda _c64_dio_asm_ptr
+	 sta ptr1 
+	 lda _c64_dio_asm_ptr+1
+	 sta ptr1+1
+        ldy #0
+writel:
+         lda (ptr1),y	
+         jsr send
+         iny
+         bne writel
+
+         jsr recv
+         cmp #errok
+         bne writeerr
+         lda #0
+	 tax
+         rts
+
+writeerr:	
+	;          sta $07c0
+	 jsr recv
+	; 	 sta $07c1
+         ldx #0
+         rts
+;---------------------------------------
+_c64_dio_asm_init:		
+         sta devnr
+         lda #$00
+         sta drvmem
+         lda #$05
+         sta drvmem+1
+
+         lda #<drive
+         sta ptr1
+         lda #>drive
+         sta ptr1+1
+
+       ; lda devnr
+       ; ldx #<icmd
+       ; ldy #>icmd
+       ; jsr drvcmd
+       ; jsr unlsn
+
+mwl:	
+         lda devnr
+         ldx #<mwcmd
+         ldy #>mwcmd
+         jsr drvcmd
+
+         ldy #0
+         lda (ptr1),y
+         jsr ciout
+         iny
+         cpy #nbytes
+         bne *-8
+
+         jsr unlsn
+
+         lda drvmem
+         clc
+         adc #nbytes
+         sta drvmem
+         lda drvmem+1
+         adc #0
+         sta drvmem+1
+
+         lda ptr1
+         clc
+         adc #nbytes
+         sta ptr1
+         tax
+         lda ptr1+1
+         adc #0
+         sta ptr1+1
+         cpx #<driveend
+         sbc #>driveend
+         bcc mwl
+
+         lda devnr
+         ldx #<mecmd
+         ldy #>mecmd
+         jsr drvcmd
+         jsr unlsn
+
+         rts
+;---------------------------------------
+drvcmd:	
+         stx ptr2
+         sty ptr2+1
+         jsr listen
+         lda #$6f
+         jsr second
+
+         ldy #0
+         lda (ptr2),y
+         sta drvcmdcmp+1
+         inc ptr2
+         bne *+4
+         inc ptr2+1
+
+         ldy #0
+         lda (ptr2),y
+         jsr ciout
+         iny
+drvcmdcmp:	 cpy #0
+         bne *-8
+         rts
+;---------------------------------------
+devnr:	    .byte 8
+mwcmd:	    .byte 6
+	.byte $4d, $2d, $57
+drvmem:	   .word $0500
+         .byte nbytes
+         .byte 0
+mecmd:	    .byte 2
+	 .byte $55, $33
+         .byte 0
+;---------------------------------------
+send:
+
+         sta ptr2
+         ldx #7
+sendl:	
+         lsr ptr2
+
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcc *+4
+         eor #$30
+         sta $dd00
+
+         lda #$c0
+         bit $dd00
+         bne *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         lda $dd00
+         and #$c0
+         eor #$c0
+         bne *-7
+
+         dex
+         bpl sendl
+
+	 ldx $d020
+	 lda #1
+	 sta $d020
+	 stx $d020
+		
+         rts
+;---------------------------------------
+recv:
+	 ldx $d020
+	 lda #0
+	 sta $d020
+	 stx $d020
+	
+         ldx #7
+recvl:	
+         lda $dd00
+         and #$c0
+         eor #$c0
+         beq *-7
+         asl a
+
+         lda $dd00
+         and #$df
+         ora #$10
+         bcs *+4
+         eor #$30
+         sta $dd00
+         ror ptr2
+
+         lda #$c0
+         bit $dd00
+         beq *-3
+
+         lda $dd00
+         and #$cf
+         sta $dd00
+
+         dex
+         bpl recvl
+         lda ptr2
+         rts
+;---------------------------------------
+
+;---------------------------------------
+;the code residing in the drive:
+;---------------------------------------
+dtmp     = $46
+dtmp2    = $97
+dbuf     = $0300
+dbufcmd  = $00
+dbuftrack = $06
+dbufsect = $07
+
+retries  = 10
+bretries = 2
+;---------------------------------------
+drive  :		
+	.org $0500
+
+
+
+         cld
+         tsx
+         stx dstack
+         sei
+         jsr ledoff
+
+drivel:	
+         jsr dload
+         jsr ledoff
+         cli
+         jmp drivel
+;---------------------------------------
+ledon:	
+         lda $1c00
+         ora #$08
+         sta $1c00
+         rts
+ledoff:	
+         lda $1c00
+         and #$f7
+         sta $1c00
+         rts
+;---------------------------------------
+drecv:	
+         ldx #7
+drecvl:	
+         lda $1800
+         bmi atn
+         and #5
+         beq *-7
+         lsr a
+         lda #2
+         bcc *+4
+         lda #8
+         sta $1800
+         ror dtmp
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         beq *-9
+         lda #0
+         sta $1800
+         dex
+         bpl drecvl
+         lda dtmp
+         rts
+;---------------------------------------
+atn:	
+         ldx dstack
+         txs
+         cli
+         rts
+;---------------------------------------
+dsend:	
+         sta dtmp
+         ldx #7
+dsendl:	
+         lsr dtmp
+         lda #2
+         bcs *+4
+         lda #8
+         sta $1800
+
+         lda $1800
+         bmi atn
+         and #5
+         eor #5
+         bne *-9
+
+         sta $1800
+
+         lda #5
+         bit $1800
+         bne *-3
+         dex
+         bpl dsendl
+         rts
+;---------------------------------------
+dload:
+         ldy #0
+
+         jsr drecv
+         sta dcmd
+	
+         jsr ledon
+	
+         jsr drecv
+         sta dbuftrack
+
+         jsr drecv
+         sta dbufsect
+
+	 lda dcmd
+	 cmp #blockwrite
+	 bne dblockread
+dblockwrite:
+         ldy #0
+drecvpl:	
+         jsr drecv
+         sta dbuf,y	
+         iny
+         bne drecvpl
+	
+	 jmp dputsect
+
+dblockread:		
+         jsr dgetsect
+
+dsendpage:	
+         ldy #0
+dsendpl:	
+         lda dbuf,y
+         jsr dsend
+         iny
+         bne dsendpl
+         rts
+;---------------------------------------
+dgetsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dgetsectl:	
+         lda #$80
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dgsnoerr
+
+         cpx #0
+         beq dgsserr
+         dex
+         cpx #bretries
+         bcs dgetsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dgetsectl
+
+dgsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dgsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+dputsect:	
+       ; stx dbuftrack
+       ; sty dbufsect
+         ldx #retries
+dputsectl:	
+         lda #$90
+         sta dbufcmd
+
+         cli
+:
+         lda dbufcmd
+         bmi :-
+         sei
+         cmp #1
+         beq dpsnoerr
+
+         cpx #0
+         beq dpsserr
+         dex
+         cpx #bretries
+         bcs dputsectl
+         pha
+         lda #$c0
+         sta dbufcmd
+         cli
+:		
+         lda dbufcmd
+         bmi :-
+         pla
+         cpx #0
+         bne dputsectl
+
+dpsserr:	
+         pha
+         lda #errerr
+         jsr dsend
+         pla
+         jsr dsend
+         rts
+dpsnoerr:	
+         lda #errok
+         jsr dsend
+         rts
+;---------------------------------------
+led:	      .byte 0,0
+dstack:	   .byte 0
+dcmd:	     .byte 0
+.RELOC
+driveend:	
+
diff --git a/contiki-cpc/loader/unused/c64-dio-asm.h b/contiki-cpc/loader/unused/c64-dio-asm.h
new file mode 100644
index 0000000..5f4b076
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-dio-asm.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio-asm.h,v 1.1 2006/04/17 15:02:36 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_ASM_H__
+#define __C64_DIO_ASM_H__
+
+extern unsigned char c64_dio_asm_track,
+  c64_dio_asm_sector;
+
+extern unsigned char *c64_dio_asm_ptr;
+
+void __fastcall__ c64_dio_asm_init(unsigned char drive);
+unsigned char c64_dio_asm_read_block(void);
+unsigned char c64_dio_asm_write_block(void);
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/loader/unused/c64-dio.c b/contiki-cpc/loader/unused/c64-dio.c
new file mode 100644
index 0000000..99161d9
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-dio.c
@@ -0,0 +1,119 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * C64 direct disk I/O.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */ 
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.c,v 1.1 2006/04/17 15:02:36 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read a block of data (256 bytes) from the disk.
+ *
+ * \param track The track of the disk block to be read.
+ *
+ * \param sector The sector of the disk block to be read.
+ *
+ * \param ptr A pointer to a buffer than must be able to accomodate
+ * 256 bytes of data.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * read.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_read_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_read_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write a block of data (256 bytes) to the disk.
+ *
+ * \param track The track of the disk block to be written.
+ *
+ * \param sector The sector of the disk block to be written.
+ *
+ * \param ptr A pointer to a buffer containing the 256 bytes of data
+ * to be written.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * written.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_write_block(unsigned char track,
+		   unsigned char sector,
+		   unsigned char *ptr)
+{
+  c64_dio_asm_track = track;
+  c64_dio_asm_sector = sector;
+  c64_dio_asm_ptr = ptr;
+  return c64_dio_asm_write_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the direct disk I/O routines for a particular disk drive.
+ *
+ * This function must be called before any of the other direct disk
+ * I/O functions can be used.
+ *
+ * \param drive The drive number of the disk drive for which the
+ * direct disk I/O should be enabled.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_dio_init(unsigned char drive)
+{
+  c64_dio_asm_init(drive);
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/loader/unused/c64-dio.h b/contiki-cpc/loader/unused/c64-dio.h
new file mode 100644
index 0000000..328f092
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-dio.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.h,v 1.1 2006/04/17 15:02:36 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_H__
+#define __C64_DIO_H__
+
+void c64_dio_init(unsigned char drive);
+
+unsigned char c64_dio_read_block(unsigned char track,
+				 unsigned char sector,
+				 unsigned char *buf);
+
+unsigned char c64_dio_write_block(unsigned char track,
+				  unsigned char sector,
+				  unsigned char *buf);
+
+#define C64_DIO_OK 0
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/loader/unused/c64-fs-raw.c b/contiki-cpc/loader/unused/c64-fs-raw.c
new file mode 100644
index 0000000..939812c
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-fs-raw.c
@@ -0,0 +1,205 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * "Raw" C64 file system access.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file provides functions that allow reading data from files
+ * without updating the file descriptor pointer. The functions are not
+ * automatically included in the core Contiki code and therefore
+ * application programs that use tham must manually link with this
+ * file.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.c,v 1.1 2006/04/17 15:02:37 kthacker Exp $
+ *
+ */
+
+#include "c64-fs-raw.h"
+
+#include <string.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+
+extern unsigned char _c64_fs_dirbuf[256];
+extern unsigned char _c64_fs_dirbuftrack, _c64_fs_dirbufsect;
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack, _c64_fs_filebufsect;
+
+void _c64_fs_readdirbuf(unsigned char track, unsigned char sect);
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from a file without updating the file descriptor pointer.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller, but does not update the file
+ * description pointer like the c64_fs_read() function does.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_read_raw(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+  unsigned char fptr, ftrack, fsect;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  fptr = f->ptr;
+  ftrack = f->track;
+  fsect = f->sect;
+  
+  for(i = 0; i < len; ++i) {
+    *buf = _c64_fs_filebuf[fptr];
+    
+    ++fptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(fptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(fptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = ftrack = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = fsect = _c64_fs_filebuf[1];
+      fptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the file descriptior pointer forward in the file.
+ *
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param len The number of bytes the pointer should be moved forward.
+ *
+ * \return The number of bytes that the pointer actually was moved, or
+ * 0 if an end of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_read_next(register struct c64_fs_file *f, int len)
+{
+  int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect, _c64_fs_filebuf);
+  }
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+    
+    ++f->ptr;
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }    
+  }
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/loader/unused/c64-fs-raw.h b/contiki-cpc/loader/unused/c64-fs-raw.h
new file mode 100644
index 0000000..7364452
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-fs-raw.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-raw.h,v 1.1 2006/04/17 15:02:37 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_RAW_H__
+#define __C64_FS_RAW_H__
+
+#include "c64-fs.h"
+
+int __fastcall__ c64_fs_read_raw(struct c64_fs_file *f,
+				 char *buf, int len);
+
+int c64_fs_read_next(struct c64_fs_file *f, int len);
+
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/loader/unused/c64-fs-write.c b/contiki-cpc/loader/unused/c64-fs-write.c
new file mode 100644
index 0000000..ce67f51
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-fs-write.c
@@ -0,0 +1,121 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of C64 file writes.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The functions in this file are not included in the core Contiki
+ * code, but must be explicitly linked by an application that that
+ * wishes to be able to write to files.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs-write.c,v 1.1 2006/04/17 15:02:37 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-fs.h"
+#include <string.h>
+
+/* An *UGLY* implementation of c64_fs_write that only can be used to
+   overwrite a single block file. */
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack,
+  _c64_fs_filebufsect;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write data to an open file.
+ *
+ * \note This function currently does not support writing to other than a single block file (cannot be more than 254 bytes long).
+ *
+ * \param f A pointer to a file descriptor previously opened with c64_fs_open().
+ *
+ * \param buf A pointer to a buffer with data that should be written
+ * to the file.
+ *
+ * \param len The length of the data that should be written.
+ *
+ * \return The number of bytes actually written.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_write(register struct c64_fs_file *f, char *buf, int len)
+{
+  int i;
+
+  if(len <= 0) {
+    return 0;
+  }
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+  if(_c64_fs_filebuftrack != f->track ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack,
+		       _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+
+  i = 256 - f->ptr;
+  if(len < i) {
+    i = len;
+  }
+
+  memcpy(&_c64_fs_filebuf[f->ptr], buf, i);
+
+  f->ptr += i;
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr > _c64_fs_filebuf[1]) {
+    _c64_fs_filebuf[1] = f->ptr;    
+  }
+
+  c64_dio_write_block(_c64_fs_filebuftrack,
+		      _c64_fs_filebufsect,
+		      _c64_fs_filebuf);
+  
+  return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/loader/unused/c64-fs.c b/contiki-cpc/loader/unused/c64-fs.c
new file mode 100644
index 0000000..139e6ef
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-fs.c
@@ -0,0 +1,411 @@
+/**
+ * \defgroup c64fs C64 file system and disk functions.
+ * @{
+ *
+ * The C64 file system functions are divided into two categories:
+ * those that deal with C64 files and the C64 disk directory, and
+ * those that allow direct block access to the disk. The former
+ * functions can be used for accessing regular files, whereas the
+ * latter functions are used e.g. to download D64 files onto 1541
+ * disks.
+ *
+ * \note The C64 filesystem functions currently only work with the
+ * 1541/1541-II/1571 and compatible drives, and not with the IDE64
+ * hard disks or the 1581/FD2000 3.5" drives.
+ *
+ * 
+ */
+
+/**
+ * \file
+ * C64 file system operations interface for Contiki.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.c,v 1.1 2006/04/17 15:02:37 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+#include "c64-fs.h"
+
+#include <string.h>
+#include <stdio.h>
+
+struct directory_entry {
+  unsigned char type;
+  unsigned char track, sect;
+  unsigned char name[16];
+  unsigned char reltrack, relsect, relreclen;
+  unsigned char unused1, unused2, unused3, unused4;
+  unsigned char tmptrack, tmpsect;
+  unsigned char blockslo, blockshi;
+};
+
+unsigned char _c64_fs_dirbuf[256];
+unsigned char _c64_fs_dirbuftrack = 0, _c64_fs_dirbufsect = 0;
+
+unsigned char _c64_fs_filebuf[256];
+unsigned char _c64_fs_filebuftrack = 0, _c64_fs_filebufsect = 0;
+
+static struct c64_fs_dirent lastdirent;
+
+static struct c64_fs_dir opendir;
+static struct c64_fs_dirent opendirent;
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a file.
+ *
+ * The file description must be allocated by the caller and a pointer
+ * to it is passed to this function.
+ *
+ * \param name A pointer to the name of the file to be opened.
+ * \param f A pointer to the file descriptor struct.
+ *
+ * \retval 0 If the file was successfully opened.
+ * \retval -1 If the file does not exist.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_open(const char *name, register struct c64_fs_file *f)
+{
+  /* First check if we already have the file cached. If so, we don't
+     need to do an expensive directory lookup. */
+  if(strncmp(lastdirent.name, name, 16) == 0) {
+    f->track = lastdirent.track;
+    f->sect = lastdirent.sect;
+    f->ptr = 2;
+    return 0;
+  }
+
+  /* Not in cache, so we walk through directory instead. */
+  c64_fs_opendir(&opendir);
+
+  do {
+    c64_fs_readdir_dirent(&opendir, &opendirent);
+    if(strncmp(opendirent.name, name, 16) == 0) {
+      f->track = opendirent.track;
+      f->sect = opendirent.sect;
+      f->ptr = 2;
+      return 0;
+    }
+  } while(c64_fs_readdir_next(&opendir) == 0);
+
+  /* The file was not found in the directory. We flush the directory
+     buffer cache now in order to prevent a nasty problem from
+     happening: If the first directory block of an empty disk was
+     cached, *all* subsequent file opens would return "file not
+     found". */
+  _c64_fs_dirbuftrack = 0; /* There are no disk blocks on track 0. */
+  return -1;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from an open file.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if !NOASM
+#pragma optimize(push, off)
+#endif /* !NOASM */
+int __fastcall__
+c64_fs_read(register struct c64_fs_file *f, char *buf, int len)
+{
+  static int i;
+
+  /* Check if current block is already in buffer, and if not read it
+     from disk. */
+
+#if NOASM
+  if(f->track != _c64_fs_filebuftrack ||
+     _c64_fs_filebufsect != f->sect) {
+    _c64_fs_filebuftrack = f->track;
+    _c64_fs_filebufsect = f->sect;
+    c64_dio_read_block(_c64_fs_filebuftrack, _c64_fs_filebufsect,
+		       _c64_fs_filebuf);
+  }
+#else /* NOASM */
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebuftrack);
+  asm("bne doblock");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("cmp %v", _c64_fs_filebufsect);
+  asm("bne doblock");
+
+  asm("jmp noblock");
+
+  asm("doblock:");
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, track));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebuftrack);
+  asm("sta %v", c64_dio_asm_track);
+  
+  asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+  asm("lda (regbank+%b),y", 4);
+  asm("sta %v", _c64_fs_filebufsect);
+  asm("sta %v", c64_dio_asm_sector);
+
+  asm("lda #<(%v)", _c64_fs_filebuf);
+  asm("sta %v", c64_dio_asm_ptr);
+  asm("lda #>(%v)", _c64_fs_filebuf);
+  asm("sta %v+1", c64_dio_asm_ptr);
+
+  asm("jsr %v", c64_dio_asm_read_block);
+
+  asm("noblock:");
+
+#endif /* NOASM */
+
+  if(_c64_fs_filebuf[0] == 0 &&
+     f->ptr == _c64_fs_filebuf[1]) {
+    return 0; /* EOF */
+  }
+
+  for(i = 0; i < len; ++i) {
+#if NOASM    
+    *buf = _c64_fs_filebuf[f->ptr];
+    ++f->ptr;
+#else /* NOASM */	
+    asm("ldy #%o+1", buf);
+    asm("jsr ldaxysp");
+    asm("sta ptr2");
+    asm("stx ptr2+1");
+
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("lda (regbank+%b),y", 4);    
+    asm("tax");
+
+    asm("ldy #0");
+    asm("lda %v,x", _c64_fs_filebuf);
+    asm("sta (ptr2),y");
+
+    asm("inx");
+    asm("txa");
+    asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+    asm("sta (regbank+%b),y", 4);    
+#endif /* NOASM */
+
+    
+    if(_c64_fs_filebuf[0] == 0) {
+      if(f->ptr == _c64_fs_filebuf[1]) {
+	/* End of file reached, we return the amount of bytes read so
+	   far. */
+	return i + 1;
+      }
+    } else if(f->ptr == 0) {
+
+      /* Read new block into buffer and set buffer state
+	 accordingly. */
+      _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+      _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+      f->ptr = 2;
+      c64_dio_read_block(_c64_fs_filebuftrack,
+			 _c64_fs_filebufsect, _c64_fs_filebuf);
+    }
+    
+    ++buf;
+  }
+  return i;
+}
+#if !NOASM    
+#pragma optimize(pop)
+#endif /* !NOASM */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close an open file.
+ *
+ * \param f A pointer to a file descriptor struct that previously has
+ * been opened with c64_fs_open().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_close(struct c64_fs_file *f)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Read a directory buffer into the _c64_fs_dirbuf buffer.
+ *
+ * This function is shared between this and  the c64-fs-raw module.
+ *
+ * \param track The track of the directory block.
+ * \param sect The sector of the directory block.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+_c64_fs_readdirbuf(unsigned char track, unsigned char sect)
+{
+  if(_c64_fs_dirbuftrack == track &&
+     _c64_fs_dirbufsect == sect) {
+    /* Buffer already contains requested block, return. */
+    return;
+  }
+  c64_dio_read_block(track, sect, _c64_fs_dirbuf);
+  _c64_fs_dirbuftrack = track;
+  _c64_fs_dirbufsect = sect;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open the disk directory for reading.
+ *
+ * The caller must supply a pointer to a directory descriptor.
+ *
+ * \param d A pointer to a directory description that must be
+ * allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_opendir(register struct c64_fs_dir *d)
+{
+  d->track = 18;
+  d->sect = 1;
+  d->ptr = 2;
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read the current directory entry.
+ *
+ * This function reads the directory entry to which the directory
+ * descriptor currently points into a struct c64_fs_dirent supplied by
+ * the caller.
+ *
+ * The function c64_fs_readdir_next() is used to move the directory
+ * entry pointer forward in the directory.
+ *
+ * \param d A pointer to a directory descriptor previously opened with c64_fs_opendir().
+ *
+ * \param f A pointer to a directory entry that must have been
+ * previously allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_readdir_dirent(register struct c64_fs_dir *d,
+		      register struct c64_fs_dirent *f)
+{
+  struct directory_entry *de;
+  int i;
+  register char *nameptr;
+  
+  _c64_fs_readdirbuf(d->track, d->sect);
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  nameptr = de->name;
+  for(i = 0; i < 16; ++i) {
+    if(*nameptr == 0xa0) {
+      *nameptr = 0;
+      break;
+    }
+    ++nameptr;
+  }
+  strncpy(f->name, de->name, 16);
+  f->track = de->track;
+  f->sect = de->sect;
+  f->size = de->blockslo + (de->blockshi >> 8);
+  memcpy(&lastdirent, f, sizeof(struct c64_fs_dirent));
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the directory pointer forward.
+ *
+ * This function moves the directory entry pointer in the directory
+ * descriptor forward so that it points to the next file.
+ *
+ * \param d A pointer to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ *
+ * \retval 1 If there are no more directory entried in the directory.
+ * \retval 0 There were more directory entries and the pointer has
+ * been moved to point to the next one.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_readdir_next(struct c64_fs_dir *d)
+{
+  struct directory_entry *de;
+ again:
+  _c64_fs_readdirbuf(d->track, d->sect);
+  if(d->ptr == 226) {
+    if(_c64_fs_dirbuf[0] == 0) {
+      return 1;
+    }
+    d->track = _c64_fs_dirbuf[0];
+    d->sect = _c64_fs_dirbuf[1];
+    d->ptr = 2;
+  } else {
+    d->ptr += 32;
+  }
+
+  de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+  if(de->type == 0) {
+    goto again;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close a directory descriptor previously opened by c64_fs_opendir().
+ *
+ * \param d A poitner to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_closedir(struct c64_fs_dir *d)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/loader/unused/c64-fs.h b/contiki-cpc/loader/unused/c64-fs.h
new file mode 100644
index 0000000..b4346c1
--- /dev/null
+++ b/contiki-cpc/loader/unused/c64-fs.h
@@ -0,0 +1,97 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the C64 filesystem functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: c64-fs.h,v 1.1 2006/04/17 15:02:37 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_H__
+#define __C64_FS_H__
+
+#include "c64-dio.h"
+
+/**
+ * An opaque structure with no user visible elements that represents
+ * an open file.
+ */
+struct c64_fs_file {
+  unsigned char track, sect, ptr;
+};
+
+int c64_fs_open(const char *name, struct c64_fs_file *f);
+void c64_fs_close(struct c64_fs_file *f);
+int __fastcall__ c64_fs_read(struct c64_fs_file *f,
+			     char *buf, int len);
+
+int __fastcall__ c64_fs_write(struct c64_fs_file *f,
+			      char *buf, int len);
+
+/**
+ * An opaque structure with no user visible elements that represents a
+ * directory descriptor.
+ */
+struct c64_fs_dir {
+  unsigned char track, sect, ptr;
+};
+
+/**
+ * A C64 directory entry.
+ */
+struct c64_fs_dirent {
+  char name[17];        /**< The name of the directory entry. */
+  unsigned short size;  /**< The size of the directory entry in 256 byte blocks. */
+  unsigned char track,  
+    sect;
+};
+
+
+unsigned char c64_fs_opendir(struct c64_fs_dir *d);
+
+void c64_fs_readdir_dirent(struct c64_fs_dir *d,
+			   struct c64_fs_dirent *f);
+unsigned char c64_fs_readdir_next(struct c64_fs_dir *d);
+
+void c64_fs_closedir(struct c64_fs_dir *d);
+
+/** @} */
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/loader/unused/cfs-cbm.c b/contiki-cpc/loader/unused/cfs-cbm.c
new file mode 100644
index 0000000..5f3b45c
--- /dev/null
+++ b/contiki-cpc/loader/unused/cfs-cbm.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.c,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cfs_cbm_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    log_message("Starting KERNAL CFS", "");
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, f, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+  return cbm_opendir(4, 8);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  struct cbm_dirent ce;
+  int ret;
+  ret = cbm_readdir(4, &ce);
+  strncpy(e->name, ce.name, sizeof(ce.name));
+  e->size = ce.size;
+  return ret;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+  cbm_closedir(4);
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/loader/unused/cfs-cbm.h b/contiki-cpc/loader/unused/cfs-cbm.h
new file mode 100644
index 0000000..174137a
--- /dev/null
+++ b/contiki-cpc/loader/unused/cfs-cbm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.h,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ */
+#ifndef __CFS_CBM_H__
+#define __CFS_CBM_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cbm_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/loader/unused/cfs-init.c b/contiki-cpc/loader/unused/cfs-init.c
new file mode 100644
index 0000000..450d22a
--- /dev/null
+++ b/contiki-cpc/loader/unused/cfs-init.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.c,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l) {return -1;}
+static int  s_opendir(struct cfs_dir *p, const char *n) {return -1;}
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;}
+static int  s_closedir(struct cfs_dir *p) {return -1;}
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": init", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_init_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  if(cbm_open(2, 8, CBM_READ, n) == 0) {
+    return 2;
+  }
+  return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/loader/unused/cfs-init.h b/contiki-cpc/loader/unused/cfs-init.h
new file mode 100644
index 0000000..4d3326d
--- /dev/null
+++ b/contiki-cpc/loader/unused/cfs-init.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.h,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ */
+#ifndef __CFS_INIT_H__
+#define __CFS_INIT_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_init_init, arg);
+
+#endif /* __CFS_INIT_H__ */
diff --git a/contiki-cpc/loader/unused/loader-arch-cpc.h b/contiki-cpc/loader/unused/loader-arch-cpc.h
new file mode 100644
index 0000000..9a2a22e
--- /dev/null
+++ b/contiki-cpc/loader/unused/loader-arch-cpc.h
@@ -0,0 +1,19 @@
+int cpc_load(char *name, char *arg);
+void cpc_unload();
+struct dsc *cpc_load_dsc(char *name);
+void cpc_unload_dsc(struct dsc *dsc);
+
+#define LOADER_LOAD(name,arg) \
+	cpc_load(name, arg)
+
+#define LOADER_UNLOAD() \
+	cpc_unload()
+
+#define LOADER_LOAD_DSC(name) \
+	cpc_load_dsc(name)
+
+#define LOADER_UNLOAD_DSC(dsc) \
+	cpc_unload_dsc(dsc)
+
+
+
diff --git a/contiki-cpc/loader/unused/loader-arch.c b/contiki-cpc/loader/unused/loader-arch.c
new file mode 100644
index 0000000..d1a7807
--- /dev/null
+++ b/contiki-cpc/loader/unused/loader-arch.c
@@ -0,0 +1,185 @@
+/**
+ * \file
+ * File loader implementation.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file implements dynamically loadable files for Contiki using
+ * the cc65 module loading system. The actual file operations are
+ * implemented in other files.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include "modload.h" 
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cfs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+static int __fastcall__
+do_read(int f, char *buf, unsigned int len)
+{
+  return cfs_read(f, buf, len);
+}
+
+static struct mod_ctrl ctrl = {
+  (void *)do_read            /* Read from disk */
+};
+
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Load a program from disk and execute it.
+ *
+ * Code originally written by Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  
+  /* Now open the file */
+  ctrl.callerdata = cfs_open(name, 0);
+  if(ctrl.callerdata < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+  
+  /* Load the module */
+  res = mod_load(&ctrl);
+  
+  /* Close the input file */
+  cfs_close(ctrl.callerdata);
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load and start a program.
+ *
+ * \param name The name of the program file.
+ * \param arg A pointer that will be passed to the new process.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load a DSC file into memory.
+ *
+ * The memory must be deallocated with the loader_arch_free() function
+ * after is has been used.
+ *
+ * \param name The name of the DSC file.
+ *
+ * \return A pointer to the struct dsc or NULL if the DSC file could
+ * not be loaded.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+  unsigned char r;
+
+  r = load(name);
+  if(r == MLOAD_OK) {
+    return (struct dsc *)ctrl.module;
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Deallocate memory previously allocated by the loader.
+ *
+ * The loader allocates memory when it loads programs or DSC
+ * files. All such memory must be deallocated with this function. Memory for programs is automatically deallocated when calling the LOADER_UNLOAD() function, but memory for DSCs must be explicitly deallcated with this function.
+ *
+ * \param addr A pointer to memory allocated by the loader.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+  mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/loader/unused/loader-arch.c.old b/contiki-cpc/loader/unused/loader-arch.c.old
new file mode 100644
index 0000000..c6fcbeb
--- /dev/null
+++ b/contiki-cpc/loader/unused/loader-arch.c.old
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c.old,v 1.1 2006/04/17 15:02:38 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <modload.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cpc-fs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+struct loader_arch_hdr {
+  char arch[8];
+  char version[8];
+
+  char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+  unsigned char res;
+  int ret;
+  
+  /* Now open the file */
+  ret = cpc_fs_open(name);
+  if(ret < 0) {
+    /* Could not open the file, display an error and return */
+    /* ### */
+    return LOADER_ERR_OPEN;
+  }
+/*  ctrl.callerdata = (int)&file; */
+  
+  /* Load the module */
+  res = cpc_fs_read();
+  
+  /* Close the input file */
+  cpc_fs_close();
+  
+  /* Check the return code */
+  if(res != MLOAD_OK) {
+    /* Wrong module, out of memory or whatever. Print an error
+     * message and return.
+     */
+    /* ### */
+    return res;
+  }
+  
+  /* We've successfully loaded the module. */
+  
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+  unsigned char r;
+  struct loader_arch_hdr *hdr;
+  
+  r = load(name);
+  if(r != MLOAD_OK) {
+    return r;
+  }
+//  hdr = (struct loader_arch_hdr *)ctrl.module;
+  
+  /* Check the program header and see that version and architecture
+     matches. */
+  
+  /* Call the init function. */
+
+  ((void (*)(char *))hdr->initfunc)(arg);
+
+  return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+  unsigned char r;
+
+  r = load(name);
+  if(r == MLOAD_OK) {
+    return (struct dsc *)ctrl.module;    
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+  mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/loader/unused/modload.c b/contiki-cpc/loader/unused/modload.c
new file mode 100644
index 0000000..9c33b16
--- /dev/null
+++ b/contiki-cpc/loader/unused/modload.c
@@ -0,0 +1,12 @@
+#include "modload.h"
+
+void mod_free(struct dsc *d)
+{
+
+
+}
+
+int mod_load(struct mod_ctrl *ctrl)
+{
+	return MLOAD_OK;
+}
diff --git a/contiki-cpc/loader/unused/modload.h b/contiki-cpc/loader/unused/modload.h
new file mode 100644
index 0000000..ff0dc41
--- /dev/null
+++ b/contiki-cpc/loader/unused/modload.h
@@ -0,0 +1,13 @@
+void mod_free(struct dsc *);
+
+struct mod_ctrl
+{ 
+	void *read;
+	void *module;
+	int callerdata;
+}; 
+
+#define MLOAD_OK 0
+
+int mod_load(struct mod_ctrl *);
+
diff --git a/contiki-cpc/loader/unused/rel-old.s b/contiki-cpc/loader/unused/rel-old.s
new file mode 100644
index 0000000..8b03baa
--- /dev/null
+++ b/contiki-cpc/loader/unused/rel-old.s
@@ -0,0 +1,167 @@
+	.area _CODE
+	.globl _get_file_length
+	.globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+	ld hl,#2
+	add hl,sp
+	ld a,(hl)
+	inc hl
+	ld h,(hl)
+	ld l,a
+
+	;; HL = address of null terminated string
+	call count_string_length
+	ld de,#0x0c000		;; points to unused 2k buffer
+	call 0x0bc77		;; cas in open
+	push bc			;; BC = length of file
+	call 0x0bc7d		;; cas in abandon
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+	push hl
+	ld b,#0
+csl:	ld a,(hl)
+	or a
+	jr z,csl2
+	inc hl
+	inc b
+	jr csl
+csl2:
+	pop hl
+	ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+	ld hl,#5
+	add hl,sp
+	ld d,(hl)
+	dec hl
+	ld e,(hl)
+	dec hl
+
+	push de
+	ld a,(hl)
+	dec hl
+	ld l,(hl)
+	ld h,a
+
+	call count_string_length
+	ld de,#0x0c000
+	call 0x0bc77		;; cas in open
+	pop hl			;; load address
+	call 0x0bc83		;; cas in direct
+	call 0x0bc7a		;; cas in close
+	ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+	ld hl,#5
+	add hl,sp
+	push ix
+	ld b,(hl)			;; base address
+	dec hl
+	ld c,(hl)
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld h,a	
+	dec hl
+	ld a,(hl)
+	.db #0x0dd
+	ld l,a				;; IX is offset of table from start of loaded file
+	add ix,bc			;; relocate IX to give absolute address of table.
+	call relocate_16bit
+	ld e,c
+	call relocate_8bit	;; lower byte
+	ld e,b
+	call relocate_8bit	;; upper byte
+	pop ix
+	ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;; 
+relocate_8bit:
+	ld a,0(ix)
+	or a
+	ret z
+	inc ix
+rel8bit: push af
+	ld l,0(ix)
+	inc ix
+	ld h,0(ix)
+inc ix
+add hl,bc
+ld a,(hl)
+add e
+ld (hl),a
+pop af
+dec a
+jr nz,rel8bit
+ret
+
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit 
+;; value to relocate. 
+;;
+;; BC = base address
+;; 
+;; NOTE: 
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix)		;; number of items to relocate
+or a
+ret z
+
+inc ix
+
+rel16bit:
+push af
+;; get offset (from start of file) of 16-bit value to relocate
+ld l,0(ix)
+inc ix
+ld h,0(ix)
+inc ix
+add hl,bc
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+pop af
+dec a
+jr nz,rel16bit
+ret
+
diff --git a/contiki-cpc/readme.txt b/contiki-cpc/readme.txt
new file mode 100644
index 0000000..2fc791a
--- /dev/null
+++ b/contiki-cpc/readme.txt
@@ -0,0 +1,22 @@
+What I did to make contiki for CPC:
+
+1. I took the contiki sources and made it compile with gcc on linux.
+2. Next I made it compile with sdcc
+3. Next I added cpc version of some files.
+4. Then I prayed.
+
+About contiki:
+
+contiki is both the initial program to run to start the operating system 
+AND contains a library of functions to use by the other programs. 
+
+Compile contiki executable to generate the executable and to generate a 
+list of symbols.
+
+These symbols are used to compile the other programs. When they are run 
+they will automatically call the appropiate functions.
+
+This is not as good as referencing a fixed location jumptable, because 
+each utility has to be recompiled if the contiki executable is recompiled 
+:(
+
diff --git a/contiki-cpc/uip/cs8900a.c b/contiki-cpc/uip/cs8900a.c
new file mode 100644
index 0000000..44915eb
--- /dev/null
+++ b/contiki-cpc/uip/cs8900a.c
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.1 2006/04/17 15:02:39 kthacker Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+   written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+/*#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x00
+#define UIP_ETHADDR2 0x00
+#define UIP_ETHADDR3 0x64
+#define UIP_ETHADDR4 0x64
+#define UIP_ETHADDR5 0x64*/
+
+extern u8_t *cs8900a_rxtxreg,
+  *cs8900a_txcmd,
+  *cs8900a_txlen,
+  *cs8900a_packetpp,
+  *cs8900a_ppdata;
+
+static u16_t len;
+static u8_t r;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+  /* Turn on transmission and reception of frames. */
+  /* PACKETPP = 0x0112;
+     PPDATA   = 0x00c0; */
+  asm("lda #$12");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Accept valid unicast+broadcast frames. */
+  /* PACKETPP = 0x0104;
+     PPDATA   = 0x0d05; */
+  asm("lda #$04");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda #$05");
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda #$0d");
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* Set MAC address. */
+  /* PACKETPP = 0x0158;
+     PPDATA   = (ETHADDR1 << 8) | (ETHADDR0); */
+  asm("lda #$58");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+1", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015a;
+     PPDATA   = (ETHADDR3 << 8) | (ETHADDR2); */
+  asm("lda #$5a");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+2", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+3", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+  /* PACKETPP = 0x015c;
+     PPDATA   = (ETHADDR5 << 8) | (ETHADDR4); */
+  asm("lda #$5c");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+4", uip_ethaddr);
+  asm("sta %v", cs8900a_ppdata);
+  asm("lda %v+5", uip_ethaddr);
+  asm("sta %v+1", cs8900a_ppdata);
+
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+  if(uip_len > UIP_BUFSIZE) {
+    asm("inc $d020");
+    return;
+  }
+    
+  /* Transmit command. */
+  asm("lda #$c0");
+  asm("sta %v", cs8900a_txcmd);
+  asm("lda #$00");
+  asm("sta %v+1", cs8900a_txcmd);
+  asm("lda _uip_len");
+  asm("sta %v", cs8900a_txlen);
+#if UIP_BUFSIZE > 255  
+  asm("lda _uip_len+1");
+#else
+  asm("lda #0");
+#endif      
+  asm("sta %v+1", cs8900a_txlen);
+
+  asm("ldx #8");
+  asm("tryagain:");
+  /* Check for avaliable buffer space. */
+  asm("lda #$38");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #1");
+  asm("bne send");
+
+  /* No space avaliable, skip a received frame and try again. */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+
+  asm("dex");
+  asm("bne tryagain");
+  
+  asm("bailout:");
+  return;
+
+  /* Send the frame. */
+  asm("send:");
+
+  
+  /* First, send 40+14=54 bytes of header. */
+  
+  asm("ldx #54");
+  asm("ldy #0");
+  asm("sendloop1:");
+  asm("lda _uip_buf,y");
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("lda _uip_buf+1,y");
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("iny");
+  asm("dex");
+  asm("dex");
+  asm("bne sendloop1");
+
+  if(uip_len <= 54) {
+    return;
+  }
+
+  /* Next, send rest of the packet. */
+
+  uip_len -= 54;
+
+
+  asm("lda ptr1");
+  asm("pha");
+  asm("lda ptr1+1");
+  asm("pha");
+  
+  asm("lda _uip_appdata");
+  asm("sta ptr1");
+  asm("lda _uip_appdata+1");
+  asm("sta ptr1+1");  
+
+  asm("sendloop2:");
+  asm("lda _uip_len");  
+  asm("tax");
+  asm("and #1");
+  asm("beq noinc");
+  asm("inx");
+  asm("noinc:");
+#if UIP_BUFSIZE > 255
+  asm("lda _uip_len+1");
+#else
+  asm("lda #0");
+#endif
+  asm("beq nozero");
+  asm("ldx #0");
+  asm("nozero:");
+  asm("ldy #0");
+  asm("sendloop:");
+  asm("lda (ptr1),y");
+  asm("sta %v", cs8900a_rxtxreg);
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("sta %v+1", cs8900a_rxtxreg);
+  asm("iny");
+  asm("dex");
+  asm("dex");
+  asm("bne sendloop");
+  asm("inc ptr1+1");
+#if UIP_BUFSIZE > 255
+  asm("dec _uip_len+1");
+  asm("bpl sendloop2");
+#endif
+
+  asm("pla");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("sta ptr1");  
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+  /* PACKETPP = 0x0102;
+     PPDATA   = PPDATA | 0x0040; */
+  asm("lda #$02");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v", cs8900a_ppdata);
+  asm("ora #$40");
+  asm("sta %v", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u8_t
+cs8900a_poll(void)
+{
+  /* Check receiver event register to see if there are any valid
+     unicast frames avaliable.  */
+  /* PACKETPP = 0x0124;
+     if(PPDATA & 0x000d == 0x0000) {
+       return 0;
+     }
+  */
+  asm("lda #$24");
+  asm("sta %v", cs8900a_packetpp);
+  asm("lda #$01");
+  asm("sta %v+1", cs8900a_packetpp);
+  asm("lda %v+1", cs8900a_ppdata);
+  asm("and #$0d");
+  asm("cmp #$00");
+  asm("bne noreturn");
+  /* No frame ready. */
+  return 0;
+  
+  asm("noreturn:");
+  /* Process the incoming frame. */
+  
+  /* Read receiver event and discard it. */
+  /* dummy = RXTXREG; */
+     
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta _len+1");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta _len");
+  
+  /* Read frame length. */
+  /* len = uip_len = RXTXREG; */
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta _len+1");
+  asm("sta _uip_len+1");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta _len");
+  asm("sta _uip_len");
+
+  
+  if(len > UIP_BUFSIZE) {
+    skip_frame();
+    return 0;
+  }
+  
+  /* Read bytes into uip_buf. */
+  asm("lda ptr1");
+  asm("pha");
+  asm("lda ptr1+1");
+  asm("pha");
+  
+  asm("lda #<_uip_buf");
+  asm("sta ptr1");
+  asm("lda #>_uip_buf");
+  asm("sta ptr1+1");  
+  
+  asm("lda _len+1");
+  asm("beq read256");
+  
+    /* Read first 256*n bytes. */
+  asm("ldy #0");
+  asm("read256loop:");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne read256loop");
+  asm("inc ptr1+1");
+  
+  asm("dec _len+1");
+  asm("bne read256loop");
+  
+  /* Read last 255 or less bytes. */
+  asm("read256:");
+  asm("lda _len");
+  asm("lsr");
+  asm("bcc noinc");
+  asm("inc _len");
+  asm("noinc:");
+  asm("ldy #$0");
+  asm("readloop:");
+  asm("lda %v", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda %v+1", cs8900a_rxtxreg);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("cpy _len");
+  asm("bne readloop");
+
+  asm("pla");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("sta ptr1");
+  return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-cpc/uip/cs8900a.h b/contiki-cpc/uip/cs8900a.h
new file mode 100644
index 0000000..dab0ea6
--- /dev/null
+++ b/contiki-cpc/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.1 2006/04/17 15:02:39 kthacker Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u8_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-cpc/uip/eth64-drv.c b/contiki-cpc/uip/eth64-drv.c
new file mode 100644
index 0000000..db79c85
--- /dev/null
+++ b/contiki-cpc/uip/eth64-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-drv.c,v 1.1 2006/04/17 15:02:39 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(eth64_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/eth64-dsc.c b/contiki-cpc/uip/eth64-dsc.c
new file mode 100644
index 0000000..4c11d7e
--- /dev/null
+++ b/contiki-cpc/uip/eth64-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: eth64-dsc.c,v 1.1 2006/04/17 15:02:39 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lan91c96_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(lan91c96_dsc,
+    "IDE64/ETH64 driver",
+    "lan91c96.drv",
+    lan91c96_init,
+    &lan91c96_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lan91c96icon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lan91c96icon_textmap[9] = {
+  'I', 'D', 'E',
+  ' ', '6', '4',
+  'E', 'T', 'H'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon lan91c96_icon =
+  {CTK_ICON("ETH64 driver", lan91c96icon_bitmap, lan91c96icon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/eth64-dump-drv.c b/contiki-cpc/uip/eth64-dump-drv.c
new file mode 100644
index 0000000..af1243e
--- /dev/null
+++ b/contiki-cpc/uip/eth64-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-dump-drv.c,v 1.1 2006/04/17 15:02:39 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  lan91c96_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    lan91c96_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = lan91c96_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      dump_packet();
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        lan91c96_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/lan91c96.c b/contiki-cpc/uip/lan91c96.c
new file mode 100644
index 0000000..d830eb0
--- /dev/null
+++ b/contiki-cpc/uip/lan91c96.c
@@ -0,0 +1,486 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Ethernet card for Commodore 64, based on lan91c96 chip
+ * is a device created by IDE64 Project team.
+ * More information: http://ide64.come.to
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.1 2006/04/17 15:02:40 kthacker Exp $
+ *
+ */
+
+#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x0d
+#define UIP_ETHADDR2 0x60
+#define UIP_ETHADDR3 0x80
+#define UIP_ETHADDR4 0x3d
+#define UIP_ETHADDR5 0xb9
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+// #define DEBUG
+
+#define ETHBASE 0xde10
+
+#define ETHBSR     ETHBASE+0x0e  //Bank select register             R/W (2B)
+
+/* Register bank 0 */
+
+#define ETHTCR     ETHBASE       //Transmition control register     R/W (2B)
+#define ETHEPHSR   ETHBASE+2     //EPH status register              R/O (2B)
+#define ETHRCR     ETHBASE+4     //Receive control register         R/W (2B)
+#define ETHECR     ETHBASE+6     //Counter register                 R/O (2B)
+#define ETHMIR     (ETHBASE+8)     //Memory information register      R/O (2B)
+#define ETHMCR     ETHBASE+0x0a  //Memory Config. reg.    +0 R/W +1 R/O (2B)
+
+/* Register bank 1 */
+
+#define ETHCR      ETHBASE       //Configuration register           R/W (2B)
+#define ETHBAR     ETHBASE+2     //Base address register            R/W (2B)
+#define ETHIAR     ETHBASE+4     //Individual address register      R/W (6B)
+#define ETHGPR     ETHBASE+0x0a  //General address register         R/W (2B)
+#define ETHCTR     ETHBASE+0x0c  //Control register                 R/W (2B)
+
+/* Register bank 2 */
+
+#define ETHMMUCR   ETHBASE       //MMU command register             W/O (1B)
+#define ETHAUTOTX  ETHBASE+1     //AUTO TX start register           R/W (1B)
+#define ETHPNR     ETHBASE+2     //Packet number register           R/W (1B)
+#define ETHARR     ETHBASE+3     //Allocation result register       R/O (1B)
+#define ETHFIFO    ETHBASE+4     //FIFO ports register              R/O (2B)
+#define ETHPTR     ETHBASE+6     //Pointer register                 R/W (2B)
+#define ETHDATA    ETHBASE+8     //Data register                    R/W (4B)
+#define ETHIST     (ETHBASE+0x0c)  //Interrupt status register        R/O (1B)
+#define ETHACK     ETHBASE+0x0c  //Interrupt acknowledge register   W/O (1B)
+#define ETHMSK     ETHBASE+0x0d  //Interrupt mask register          R/W (1B)
+
+/* Register bank 3 */
+
+#define ETHMT      ETHBASE       //Multicast table                  R/W (8B)
+#define ETHMGMT    ETHBASE+8     //Management interface             R/W (2B)
+#define ETHREV     ETHBASE+0x0a  //Revision register                R/W (2B)
+#define ETHERCV    ETHBASE+0x0c  //Early RCV register               R/W (2B)
+
+#define BANK(num) asm("lda #%b",num); asm("sta %w",ETHBSR);
+
+#ifdef DEBUG
+static void print_packet(u8_t *, u16_t);
+#endif
+
+static u8_t packet_status;
+static u16_t packet_length;
+
+extern u16_t uip_len;
+
+
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+  /* Check if high byte is 0x33 */
+  asm("lda %w", ETHBSR+1);
+  asm("cmp #$33");
+  asm("beq @L1");
+
+  asm("inc $d021");              // Error
+
+  asm("@L1:");
+
+  /* Reset ETH card */
+  BANK(0);
+  asm("lda #%%10000000");        //Software reset
+  asm("sta %w", ETHRCR+1);
+
+  asm("lda #0");
+  asm("sta %w", ETHRCR);
+  asm("sta %w", ETHRCR+1);
+
+  /* delay */
+  asm("ldx #0");
+  asm("@L2:");
+  asm("cmp ($ff,x)");            //6 cycles
+  asm("cmp ($ff,x)");            //6 cycles
+  asm("dex");                    //2 cycles
+  asm("bne @L2");                //3 cycles
+                                 //17*256=4352 => 4,4 ms
+
+  /* Enable transmit and receive */
+  asm("lda #%%10000001");        //Enable transmit TXENA, PAD_EN
+  asm("sta %w", ETHTCR);
+  asm("lda #%%00000011");        //Enable receive, strip CRC ???
+  asm("sta %w", ETHRCR+1);
+
+  BANK(1);
+  asm("lda %w", ETHCR+1);
+  asm("ora #%%00010000");        //No wait (IOCHRDY)
+  asm("sta %w", ETHCR+1);
+
+  asm("lda #%%00001001");        //Auto release
+  asm("sta %w", ETHCTR+1);
+  
+  /* Set MAC address */
+  asm("lda #%b", (unsigned)UIP_ETHADDR0);
+  asm("sta %w", ETHIAR);
+  asm("lda #%b", (unsigned)UIP_ETHADDR1);
+  asm("sta %w", ETHIAR+1);
+  asm("lda #%b", (unsigned)UIP_ETHADDR2);
+  asm("sta %w", ETHIAR+2);
+  asm("lda #%b", (unsigned)UIP_ETHADDR3);
+  asm("sta %w", ETHIAR+3);
+  asm("lda #%b", (unsigned)UIP_ETHADDR4);
+  asm("sta %w", ETHIAR+4);
+  asm("lda #%b", (unsigned)UIP_ETHADDR5);
+  asm("sta %w", ETHIAR+5);
+
+  BANK(2);
+  asm("lda #%%00001111");               //RCV INT, ALLOC INT, TX INT, TX EMPTY 
+  asm("sta %w", ETHMSK);
+}
+#pragma optimize(pop)
+
+
+#pragma optimize(push, off)
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void)
+#else
+u8_t lan91c96_poll(void)
+#endif
+{
+  // #######
+//  BANK(0);
+//  printf("RAM: %d ", ((*(unsigned int *)ETHMIR) & 0xff00));
+//  BANK(2);
+  // #######
+
+  asm("lda %w", ETHIST);
+  asm("and #%%00000001");                //RCV INT
+  asm("bne @L1");
+
+  /* No packet available */
+  return 0;
+
+  asm("@L1:");
+
+  #ifdef DEBUG
+  printf("RCV: IRQ\n");
+  #endif
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%11100000");               //RCV,AUTO INCR.,READ
+  asm("sta %w", ETHPTR+1);
+
+  asm("lda %w", ETHDATA);               //Status word
+  asm("lda %w", ETHDATA);
+  asm("sta _packet_status");            //High byte only
+
+  asm("lda %w", ETHDATA);               //Total number of bytes
+  asm("sta _packet_length");
+  asm("lda %w", ETHDATA);
+  asm("sta _packet_length+1");
+
+  /* Last word contain 'last data byte' and 0x60 */
+  /* or 'fill byte' and 0x40 */
+
+  packet_length -= 6;            //The packet contains 3 extra words
+
+  asm("lda _packet_status");
+  asm("and #$10");
+  asm("beq @L2");
+
+  packet_length++;
+
+  #ifdef DEBUG
+  printf("RCV: odd number of bytes\n");
+  #endif
+
+  asm("@L2:");
+                    
+  #ifdef DEBUG
+  printf("RCV: L:%d ST-HIGH:0x%02x ",packet_length,packet_status);
+  #endif
+
+  if (packet_length > UIP_BUFSIZE)
+  {
+    /* Remove and release RX packet from FIFO*/ 
+    asm("lda #%%10000000");
+    asm("sta %w", ETHMMUCR);
+
+    #ifdef DEBUG
+    printf("RCV: UIP_BUFSIZE exceeded - packet dropped!\n");
+    #endif
+
+    return 0;
+  }
+
+  asm("lda #<_uip_buf");
+  asm("sta ptr1");
+  asm("lda #>_uip_buf");
+  asm("sta ptr1+1");
+
+  asm("ldy #0");
+  asm("ldx _packet_length+1");
+  asm("beq @RE1");               //packet_length < 256
+
+  asm("@RL1:");
+  asm("lda %w", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("bne @RL1");
+  asm("inc ptr1+1");
+  asm("dex");
+  asm("bne @RL1");
+
+  asm("@RE1:");
+  asm("lda %w", ETHDATA);
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("cpy _packet_length");
+  asm("bne @RE1");
+
+  /* Remove and release RX packet from FIFO*/ 
+  asm("lda #%%10000000");
+  asm("sta %w", ETHMMUCR);
+
+  #ifdef DEBUG
+//  print_packet(uip_buf, packet_length);
+  #endif
+
+  return packet_length;
+}
+#pragma optimize(pop)
+
+/* First 40+14 (IP nad TCP header) is send from uip_buf */
+/* than data from uip_appdata                           */
+
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+  #ifdef DEBUG
+  printf("SND: send packet\n");
+  #endif
+
+  #if UIP_BUFSIZE > 255
+  asm("lda _uip_len+1");  
+  #else
+  asm("lda #0");
+  #endif
+  asm("ora #%%00100000");        //Allocate memory for TX
+  asm("sta %w", ETHMMUCR);
+
+  asm("ldx #8");                 //Wait...
+  asm("@L1:");                   //Wait for allocation ready
+  asm("lda %w", ETHIST);
+  asm("and #%%00001000");        //ALLOC INT
+  asm("bne @X1");
+  asm("dex");
+  asm("bne @L1");
+
+    #ifdef DEBUG
+    printf("SND: ERR: memory alloc timeout\n");
+    #endif
+
+    return;
+
+  asm("@X1:");
+  #ifdef DEBUG
+  printf("SND: packet memory allocated\n");
+  #endif
+
+  asm("lda #%%00001000");        //Acknowledge int, is it necessary ???
+  asm("sta %w", ETHACK);
+
+  asm("lda %w", ETHARR);
+  asm("sta %w", ETHPNR);         //Set packet address
+
+  asm("lda #0");
+  asm("sta %w", ETHPTR);
+  asm("lda #%%01000000");        //AUTO INCR.
+  asm("sta %w", ETHPTR+1);
+
+  #ifdef DEBUG
+  printf("SND: L:%d ", uip_len);
+  #endif
+
+  asm("lda #0");                 //Status written by CSMA
+  asm("sta %w", ETHDATA);
+  asm("sta %w", ETHDATA);
+
+  asm("lda _uip_len");
+  asm("and #$01");
+  asm("beq @SD1");
+
+    packet_length=uip_len+5;
+    asm("jmp @LC1");
+
+  asm("@SD1:");
+
+    packet_length=uip_len+6;       //+6 for status word, length and ctl byte
+
+  asm("@LC1:");
+
+//  printf("SND: L:%d ", packet_length);
+
+  asm("lda _packet_length");
+  asm("sta %w", ETHDATA);
+  asm("lda _packet_length+1");
+  asm("sta %w", ETHDATA);
+
+  #ifdef DEBUG
+//  print_packet(uip_buf, uip_len);
+  #endif
+
+  /* Send 40+14=54 bytes of header */
+
+  if(uip_len <= 54) {
+
+    #ifdef DEBUG
+    printf("SND: short packet sent.\n");
+    #endif
+
+    asm("ldx _uip_len");
+    asm("ldy #0");
+    asm("@WL1:");
+    asm("lda _uip_buf,y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("dex");
+    asm("bne @WL1");
+
+  } else {
+
+    asm("ldx #54");
+    asm("ldy #0");
+    asm("@WL2:");
+    asm("lda _uip_buf,y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("dex");
+    asm("bne @WL2");
+
+    uip_len -= 54;
+
+    asm("lda _uip_appdata");       //uip_appdata is pointer
+    asm("sta ptr1");
+    asm("lda _uip_appdata+1");
+    asm("sta ptr1+1");
+
+    asm("ldy #0");
+    #if UIP_BUFSIZE > 255
+    asm("ldx _uip_len+1");
+    #else
+    asm("ldx #0");
+    #endif
+    asm("beq @RE1");               //packet_length < 256
+
+    asm("@RL1:");
+    asm("lda (ptr1),y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("bne @RL1");
+    asm("inc ptr1+1");
+    asm("dex");
+    asm("bne @RL1");
+
+    asm("@RE1:");
+    asm("lda (ptr1),y");
+    asm("sta %w", ETHDATA);
+    asm("iny");
+    asm("cpy _uip_len");
+    asm("bne @RE1");
+
+  }
+
+  asm("lda _uip_len");
+  asm("and #$01");
+  asm("beq @R3");
+
+  asm("lda #%%00100000");
+  asm("sta %w", ETHDATA);        //Control byte
+
+  asm("lda #%%11000000");        //ENQUEUE PACKET - transmit packet
+  asm("sta %w", ETHMMUCR);
+
+//  printf("\n## %02x", *(unsigned char *)ETHIST);
+
+  return;
+
+  asm("@R3:");
+
+  asm("lda #0");
+  asm("sta %w", ETHDATA);        //Fill byte
+  asm("sta %w", ETHDATA);        //Control byte
+
+  asm("lda #%%11000000");        //ENQUEUE PACKET - transmit packet
+  asm("sta %w", ETHMMUCR);
+
+//  printf("\n## %02x\n", *(unsigned char *)ETHIST);
+  return;
+}
+#pragma optimize(pop)
+
+#ifdef DEBUG
+static void print_packet(u8_t *buf, u16_t length)
+{
+  int i;
+  int remainder;
+  int lines;
+  u8_t a;
+  int cur;
+  int address=0;
+
+  printf("\nPacket of length %d \n", length );
+
+  lines = length / 8;
+  remainder = length % 8;
+
+  for ( i = 0; i < lines ; i ++ ) {
+    printf(":%04x ", address=i*8);
+
+    for ( cur = 0; cur < 8; cur ++ ) {
+      a = *(buf ++ );
+      printf("%02x ", a);
+    }
+    printf("\n");
+  }
+
+  printf(":%04x ", address+8);
+
+  for ( i = 0; i < remainder ; i++ ) {
+    a = *(buf ++ );
+    printf("%02x ", a);
+  }
+  printf("\n");
+}
+#endif /* DEBUG */
+
diff --git a/contiki-cpc/uip/lan91c96.h b/contiki-cpc/uip/lan91c96.h
new file mode 100644
index 0000000..774e182
--- /dev/null
+++ b/contiki-cpc/uip/lan91c96.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.1 2006/04/17 15:02:40 kthacker Exp $
+ */
+
+#ifndef _LAN91C96_H
+#define _LAN91C96_H
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_done(void);
+void lan91c96_send(void);
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void);
+#else
+u8_t lan91c96_poll(void);
+#endif
+
+/* End of lan91c96.h */
+#endif
+
diff --git a/contiki-cpc/uip/rrnet-drv-asm.S b/contiki-cpc/uip/rrnet-drv-asm.S
new file mode 100644
index 0000000..595c00c
--- /dev/null
+++ b/contiki-cpc/uip/rrnet-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de08
+	_cs8900a_txcmd		= $de0c
+	_cs8900a_txlen		= $de0e
+	_cs8900a_packetpp	= $de02
+	_cs8900a_ppdata		= $de04
+
diff --git a/contiki-cpc/uip/rrnet-drv.c b/contiki-cpc/uip/rrnet-drv.c
new file mode 100644
index 0000000..0d800ca
--- /dev/null
+++ b/contiki-cpc/uip/rrnet-drv.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-drv.c,v 1.1 2006/04/17 15:02:40 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/rrnet-dsc.c b/contiki-cpc/uip/rrnet-dsc.c
new file mode 100644
index 0000000..b8f6875
--- /dev/null
+++ b/contiki-cpc/uip/rrnet-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: rrnet-dsc.c,v 1.1 2006/04/17 15:02:40 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon rrnet_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(rrnet_dsc,
+    "RR-Net driver",
+    "rrnet.drv",
+    rrnet_init,
+    &rrnet_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char rrneticon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char rrneticon_textmap[9] = {
+  'R', 'R', '-',
+  'N', 'e', 't',
+  'D', 'R', 'V'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon rrnet_icon =
+  {CTK_ICON("RR-Net driver", rrneticon_bitmap, rrneticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/rrnet-dump-drv.c b/contiki-cpc/uip/rrnet-dump-drv.c
new file mode 100644
index 0000000..4748cde
--- /dev/null
+++ b/contiki-cpc/uip/rrnet-dump-drv.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-dump-drv.c,v 1.1 2006/04/17 15:02:40 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "RR-Net dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    asm("lda #1");
+    asm("ora $de01");
+    asm("sta $de01");
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/rs232dev-ss.c b/contiki-cpc/uip/rs232dev-ss.c
new file mode 100644
index 0000000..7800bb1
--- /dev/null
+++ b/contiki-cpc/uip/rs232dev-ss.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev-ss.c,v 1.1 2006/04/17 15:02:41 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include "rs232silversurfer.h"
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c)  (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c)  while(rs232_put(c) == RS_ERR_OVERFLOW)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+#if MAX_SIZE > 255
+static u16_t len, tmplen;
+#else
+static u8_t len, tmplen;
+#endif /* MAX_SIZE > 255 */
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+#if MAX_SIZE > 255
+  u16_t i;
+#else
+  u8_t i;
+#endif /* MAX_SIZE > 255 */
+  u8_t *ptr;
+  u8_t c;
+
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == 40) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+#if MAX_SIZE > 255
+u16_t
+#else 
+u8_t
+#endif /* MAX_SIZE > 255 */
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  while(SIO_POLL(c)) {
+    /*    printf("c %x\n", c);*/
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+      
+      
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  
+  err = rs232_init(0);
+  rs232_err(err);
+  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);
+  rs232_err(err);
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/uip/rs232dev.c b/contiki-cpc/uip/rs232dev.c
new file mode 100644
index 0000000..2e2db52
--- /dev/null
+++ b/contiki-cpc/uip/rs232dev.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.1 2006/04/17 15:02:41 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <serial.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(ser_get(&c) == SER_ERR_NO_DATA)
+#define SIO_POLL(c)  (ser_get(&c) != SER_ERR_NO_DATA)
+#define SIO_SEND(c)  ser_put(c)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+static char loaded = 0;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+/*static void
+rs232_err(char err)
+{
+  switch(err) {
+  case RS_ERR_OK:
+    printf("RS232 OK\n");
+    break;
+  case RS_ERR_NOT_INITIALIZED:
+    printf("RS232 not initialized\n");
+    break;
+  case RS_ERR_BAUD_TOO_FAST:
+    printf("RS232 baud too fast\n");
+    break;
+  case RS_ERR_BAUD_NOT_AVAIL:
+    printf("RS232 baud rate not available\n");
+    break;
+  case RS_ERR_NO_DATA:
+    printf("RS232 nothing to read\n");
+    break;
+  case RS_ERR_OVERFLOW:
+    printf("RS232 overflow\n");
+    break;
+  }
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+  
+  SIO_SEND(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == 40) {
+      ptr = uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      SIO_SEND(SLIP_ESC);
+      SIO_SEND(SLIP_ESC_ESC);
+      break;
+    default:
+      SIO_SEND(c);
+      break;
+    }
+  }
+  SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+  u8_t c;
+  static u8_t lastc;
+  
+  if(loaded == 0) {
+    return 0;
+  }
+  
+  while(SIO_POLL(c)) {
+
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+            
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > MAX_SIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+  char err;
+  struct ser_params p;
+  
+  err = ser_load_driver("c64-swlink.ser");
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+  p.baudrate = SER_BAUD_9600;
+  p.databits = SER_BITS_8;
+  p.stopbits = SER_STOP_1;
+  p.parity = SER_PAR_NONE;
+  p.handshake = SER_HS_HW;
+
+  err = ser_open(&p);
+
+  if(err != SER_ERR_OK) {
+    asm("inc $d020");
+    return;
+  }
+  
+
+  loaded = 1;
+  
+  /*  err = rs232_init(0); */
+  /*  rs232_err(err);*/
+  /*  err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);*/
+  /*  rs232_err(err);*/
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_unload(void)
+{
+  if(loaded){
+    ser_unload();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/uip/rs232dev.h b/contiki-cpc/uip/rs232dev.h
new file mode 100644
index 0000000..af71b33
--- /dev/null
+++ b/contiki-cpc/uip/rs232dev.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.1 2006/04/17 15:02:41 kthacker Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+
+u16_t rs232dev_poll(void);
+
+void rs232dev_unload(void);
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-cpc/uip/rs232silversurfer.S b/contiki-cpc/uip/rs232silversurfer.S
new file mode 100644
index 0000000..89bbf9d
--- /dev/null
+++ b/contiki-cpc/uip/rs232silversurfer.S
@@ -0,0 +1,329 @@
+	;; The following code is written and is copyrighted by
+	;; Groepaz/Hitmen
+
+	;; Small changes by Adam Dunkels (renamed ss232 -> rs232)
+	
+;----------------------------------------------------------------------------------------------
+; silver surfer polling mode driver for cc65
+; - work from here to create a full featured driver with interupts.
+; gpz fixed 20020828: fatal bug fixed in _rs232_params
+;----------------------------------------------------------------------------------------------
+
+rs16550base             = $de08
+
+fifo_rxd     = rs16550base+$00 ;8  (r)
+fifo_txd     = rs16550base+$00 ;8 (w)
+
+fifo_dll     = rs16550base+$00 ;8 (r/w)
+fifo_dlm     = rs16550base+$01 ;9 (r/w)
+
+fifo_ier     = rs16550base+$01 ;9
+
+fifo_fcr     = rs16550base+$02 ;a (w)
+fifo_iir     = rs16550base+$02 ;a (r)
+fifo_lcr     = rs16550base+$03 ;b
+fifo_mcr     = rs16550base+$04 ;c
+fifo_lsr     = rs16550base+$05 ;d
+fifo_msr     = rs16550base+$06 ;e (r)
+fifo_scratch = rs16550base+$07 ;f (r/w)
+	
+
+
+                        .export _rs232_init
+                        .export _rs232_done
+                        .export _rs232_params
+                        .export _rs232_put
+                        .export _rs232_get
+
+                        .importzp ptr1, ptr2
+                        .import   popa, popax
+
+;----------------------------------------------------------------------------------------------
+; Error codes. Beware: The codes must match the codes in the C header file
+
+ErrNotInitialized       = $01
+ErrBaudTooFast    	= $02
+ErrBaudNotAvail   	= $03
+ErrNoData         	= $04
+ErrOverflow       	= $05
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_init (char hacked);
+;/* Initialize the serial port, install the interrupt handler. The parameter
+; * has no effect for now and should be set to 0.
+; */
+;----------------------------------------------------------------------------------------------
+
+         .code
+
+_rs232_init:
+         ; enable ssurfer-port
+         lda $de01
+         ora #$01
+         sta $de01
+
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; activate dtr
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_done (void);
+;/* Close the port, deinstall the interrupt hander. You MUST call this function
+; * before terminating the program, otherwise the machine may crash later. If
+; * in doubt, install an exit handler using atexit(). The function will do
+; * nothing, if it was already called.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_done:
+         ; disable nmi's from ssurfer
+         lda #%00000000
+         sta fifo_ier
+
+         ; deactivate dtr
+         sta fifo_mcr
+
+         ; disable ssurfer-port
+         lda $de01
+         and #$fe
+         sta $de01
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+;/* Set the port parameters. Use a combination of the #defined values above. */
+;----------------------------------------------------------------------------------------------
+
+         .data
+
+_rs232_baudrates:
+
+         .word          (7372800 / (      50 * 16))
+         .word          (7372800 / (     110 * 16))
+         .word          (7372800 / (     269 *  8))
+         .word          (7372800 / (     300 * 16))
+         .word          (7372800 / (     600 * 16))
+         .word          (7372800 / (    1200 * 16))
+         .word          (7372800 / (    2400 * 16))
+         .word          (7372800 / (    4800 * 16))
+         .word          (7372800 / (    9600 * 16))
+         .word          (7372800 / (   19200 * 16))
+         .word          (7372800 / (   38400 * 16))
+         .word          (7372800 / (   57600 * 16))
+         .word          (7372800 / (  115200 * 16))
+         .word          (7372800 / (  230400 * 16))
+
+         .bss
+
+_rs232_tmp1:
+         .res 1
+
+         .code
+
+_rs232_params:
+
+         sta _rs232_tmp1 ; save parity
+
+         ; reset fifo
+         lda #%10000111
+         sta fifo_fcr
+
+   ; that delay thing really needed ?!
+   ; (original datasheet mentions a delay here)
+   ;      ldy #$00
+   ;      dey
+   ;      bny *-1
+
+         ; set dlab
+         lda #%10000011 ; we assmume 8n1
+         sta fifo_lcr
+
+         jsr popa
+         tay             ; save param
+
+         ; set baudrate
+         clc
+         lsr a		
+         lsr a
+         lsr a
+         lsr a
+         asl a
+         tax
+         lda _rs232_baudrates,x
+         sta fifo_dll
+         lda _rs232_baudrates+1,x
+         sta fifo_dlm
+
+         tya             ; param
+         and #$0f
+         ora _rs232_tmp1 ; parity
+
+         ; reset dlab
+         sta fifo_lcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+; check if byte available, returns AKKU=0 if none
+
+ss_getlsr:
+         lda fifo_lsr
+         and #$01
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_get (char* b);
+;/* Get a character from the serial port. If no characters are available, the
+; * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+; */
+;----------------------------------------------------------------------------------------------
+; get byte (non blocking, returns byte in A or CARRY=1 - error)
+
+_rs232_get:
+         sta ptr1
+         stx ptr1+1
+
+         jsr ss_getlsr  ; check if byte available
+;         bne sk32 ; yes
+         bne sk33 ; yes
+
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+sk32:
+
+         ; deactivate rts
+;         lda #%00000001
+;         sta fifo_mcr
+
+	 jsr ss_getlsr  ; check if byte available
+         bne sk33 ; yes
+
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #ErrNoData      ; no data
+         ldx #0
+         rts
+sk33:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         ; get byte
+         ldy #$00
+         lda fifo_rxd
+         sta (ptr1),y
+
+         lda #0      ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_put (char b);
+;/* Send a character via the serial port. There is a transmit buffer, but
+; * transmitting is not done via interrupt. The function returns
+; * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_put:
+         tax
+         ; transmit buf ready?
+         lda fifo_lsr
+         and #%00100000
+         bne @sk1
+@sk2:
+         lda #ErrOverflow       ; overflow
+         ldx #$00
+         rts
+@sk1:
+         ; reciever ready?
+         lda fifo_msr
+         and #%00010000
+         beq @sk2
+
+         stx fifo_txd
+
+         lda #$00               ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_pause (void);
+;/* Assert flow control and disable interrupts. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_pause:
+         ; activate rts
+         lda #%00000011
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_unpause (void);
+;/* Re-enable interrupts and release flow control */
+;----------------------------------------------------------------------------------------------
+
+_rs232_unpause:
+         ; deactivate rts
+         lda #%00000001
+         sta fifo_mcr
+
+         lda #$00       ; ok
+         tax
+         rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_status (unsigned char* status,
+;                                         unsigned char* errors);
+;/* Return the serial port status. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_status:
+ 	sta    	ptr2
+ 	stx    	ptr2+1
+ 	jsr    	popax
+ 	sta    	ptr1
+ 	stx    	ptr1+1
+
+        ldy     #$00
+
+        ; Get status
+        lda     fifo_iir
+        and     #%00000001
+        sta     _rs232_tmp1
+        lda     fifo_msr
+        lsr     a
+        and     #%01010000
+        ora     _rs232_tmp1
+        sta     _rs232_tmp1
+        lda     fifo_lsr
+        and     #%00101110
+        ora     _rs232_tmp1
+ 	sta    	(ptr1),y
+
+        ; Get errors
+        lda     #$00    ; ok
+       	sta    	(ptr2),y
+
+        lda     #$00    ; ok
+        tax
+        rts
diff --git a/contiki-cpc/uip/rs232silversurfer.h b/contiki-cpc/uip/rs232silversurfer.h
new file mode 100644
index 0000000..9e9a49f
--- /dev/null
+++ b/contiki-cpc/uip/rs232silversurfer.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2003, Groepaz/Hitmen.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * rs232silversurfer.h
+ *
+ * Groepaz/Hitmen, 16.12.2001
+ *
+ * This defines for the SilverSurver (16c550 UART) what Ullrichs rs232 module
+ * defines for the Swithlink/Turbo232
+ *
+ * this driver operates in polling mode only atm !
+ *
+ */
+
+#ifndef _RS232silversurfer_H
+#define _RS232silversurfer_H
+
+/*****************************************************************************/
+/*                   Data                                                    */
+/*****************************************************************************/
+
+/* Baudrate settings */
+#define RS_BAUD_50                0x00
+#define RS_BAUD_110               0x10
+#define RS_BAUD_134_5             0x20
+#define RS_BAUD_300               0x30
+#define RS_BAUD_600               0x40
+#define RS_BAUD_1200              0x50
+#define RS_BAUD_2400              0x60
+#define RS_BAUD_4800              0x70
+#define RS_BAUD_9600              0x80
+#define RS_BAUD_19200             0x90
+#define RS_BAUD_38400             0xa0
+#define RS_BAUD_57600             0xb0
+#define RS_BAUD_115200            0xc0
+#define RS_BAUD_230400            0xd0
+
+/* Stop bit settings */
+#define RS_STOP_1      	       		0x00
+#define RS_STOP_2      	       		0x04
+
+/* Data bit settings */
+#define RS_BITS_5      	       		0x00
+#define RS_BITS_6      	       		0x01
+#define RS_BITS_7      	       		0x02
+#define RS_BITS_8      	       		0x03
+
+/* Parity settings */
+#define RS_PAR_NONE    	       		0x00
+#define RS_PAR_ODD     	       		0x28
+#define RS_PAR_EVEN    	       		0x38
+#define RS_PAR_MARK    	       		0x48
+#define RS_PAR_SPACE   	       		0x48
+
+/* Bit masks to mask out things from the status returned by rs232_status */
+#define RS_STATUS_IRQ                   0x01    /* (iir) IRQ condition */
+#define RS_STATUS_OVERRUN               0x02    /* (lsr) Overrun error */
+#define RS_STATUS_PE                    0x04    /* (lsr) Parity error */
+#define RS_STATUS_FE                    0x08    /* (lsr) Framing error */
+#define RS_STATUS_DSR                   0x10    /* (msr>>1) NOT data set ready */
+#define RS_STATUS_THRE                  0x20    /* (lsr) Transmit holding reg. empty */
+#define RS_STATUS_DCD                   0x40    /* (msr>>1) NOT data carrier detect */
+#define RS_STATUS_RDRF                  0x80    /* Receiver data register full */
+
+/* Error codes returned by all functions */
+#define RS_ERR_OK                       0x00    /* Not an error - relax */
+#define RS_ERR_NOT_INITIALIZED 		0x01   	/* Module not initialized */
+#define RS_ERR_BAUD_TOO_FAST            0x02    /* Cannot handle baud rate */
+#define RS_ERR_BAUD_NOT_AVAIL           0x03    /* Baud rate not available */
+#define RS_ERR_NO_DATA                  0x04    /* Nothing to read */
+#define RS_ERR_OVERFLOW                 0x05    /* No room in send buffer */
+
+/*****************************************************************************/
+/*				     Code			                                               	     */
+/*****************************************************************************/
+
+unsigned char __fastcall__ rs232_init (char hacked);
+/* Initialize the serial port, install the interrupt handler. The parameter
+ * has no effect for now and should be set to 0.
+ */
+
+unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+/* Set the port parameters. Use a combination of the #defined values above. */
+
+unsigned char __fastcall__ rs232_done (void);
+/* Close the port, deinstall the interrupt hander. You MUST call this function
+ * before terminating the program, otherwise the machine may crash later. If
+ * in doubt, install an exit handler using atexit(). The function will do
+ * nothing, if it was already called.
+ */
+
+unsigned char __fastcall__ rs232_get (char* b);
+/* Get a character from the serial port. If no characters are available, the
+ * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+ */
+
+unsigned char __fastcall__ rs232_put (char b);
+/* Send a character via the serial port. There is a transmit buffer, but
+ * transmitting is not done via interrupt. The function returns
+ * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+ */
+
+unsigned char __fastcall__ rs232_pause (void);
+/* Assert flow control and disable interrupts. */
+
+unsigned char __fastcall__ rs232_unpause (void);
+/* Re-enable interrupts and release flow control */
+
+unsigned char __fastcall__ rs232_status (unsigned char* status,
+					 unsigned char* errors);
+/* Return the serial port status. */
+
+/* End of rs232silversurfer.h */
+#endif
+
+
+
diff --git a/contiki-cpc/uip/slip-drv.c b/contiki-cpc/uip/slip-drv.c
new file mode 100644
index 0000000..4eb0205
--- /dev/null
+++ b/contiki-cpc/uip/slip-drv.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-drv.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tapdev_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/slip-dsc.c b/contiki-cpc/uip/slip-dsc.c
new file mode 100644
index 0000000..60b0fc5
--- /dev/null
+++ b/contiki-cpc/uip/slip-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: slip-dsc.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon slip_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(slip_dsc,
+    "SLIP driver",
+    "slip.drv",
+    slip_init,
+    &slip_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char slipicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char slipicon_textmap[9] = {
+  'R', 'S', ' ',
+  '2', '3', '2',
+  '/', 'I', 'P'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon slip_icon =
+  {CTK_ICON("SLIP driver", slipicon_bitmap, slipicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/slip-dump-drv.c b/contiki-cpc/uip/slip-dump-drv.c
new file mode 100644
index 0000000..63b4def
--- /dev/null
+++ b/contiki-cpc/uip/slip-dump-drv.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-dump-drv.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+	   eventhandler, pollhandler, (void *)&state);
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(slip_service_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  rs232dev_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "SLIP dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    rs232dev_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    rs232dev_unload();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{  
+  uip_len = rs232dev_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    tcpip_input();
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/tfe-drv-asm.S b/contiki-cpc/uip/tfe-drv-asm.S
new file mode 100644
index 0000000..d31c320
--- /dev/null
+++ b/contiki-cpc/uip/tfe-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------       
+	.export		_cs8900a_rxtxreg
+	.export		_cs8900a_txcmd
+	.export		_cs8900a_txlen
+	.export		_cs8900a_packetpp
+	.export		_cs8900a_ppdata
+	
+
+;---------------------------------------------------------------------
+
+	_cs8900a_rxtxreg	= $de00
+	_cs8900a_txcmd		= $de04
+	_cs8900a_txlen		= $de06
+	_cs8900a_packetpp	= $de0a
+	_cs8900a_ppdata		= $de0c
+
diff --git a/contiki-cpc/uip/tfe-drv.c b/contiki-cpc/uip/tfe-drv.c
new file mode 100644
index 0000000..d7255b0
--- /dev/null
+++ b/contiki-cpc/uip/tfe-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-drv.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x0d,0x60,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/tfe-dsc.c b/contiki-cpc/uip/tfe-dsc.c
new file mode 100644
index 0000000..4170400
--- /dev/null
+++ b/contiki-cpc/uip/tfe-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: tfe-dsc.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon tfe_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+    "The Final Ethernet driver",
+    "tfe.drv",
+    tfe_init,
+    &tfe_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tfeicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tfeicon_textmap[9] = {
+  'T', 'C', 'P',
+  '/', 'I', 'P',
+  'T', 'F', 'E'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon tfe_icon =
+  {CTK_ICON("TFE driver", tfeicon_bitmap, tfeicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/tfe-dump-drv.c b/contiki-cpc/uip/tfe-dump-drv.c
new file mode 100644
index 0000000..e992141
--- /dev/null
+++ b/contiki-cpc/uip/tfe-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-dump-drv.c,v 1.1 2006/04/17 15:02:42 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+  {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+  {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+  memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+  tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+  CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_arp_out();
+  cs8900a_send();
+  dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+    CTK_WIDGET_ADD(&window, &dumplabel);
+    ctk_window_open(&window);
+    uip_setethaddr(addr);
+    cs8900a_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ctk_window_close(&window);
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  
+  /* Poll Ethernet device to see if there is a frame avaliable. */
+  uip_len = cs8900a_poll();
+  if(uip_len > 0) {
+    dump_packet();
+    /* A frame was avaliable (and is now read into the uip_buf), so
+       we process it. */
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_len -= sizeof(struct uip_eth_hdr);
+      tcpip_input();
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      /* If the above function invocation resulted in data that
+         should be sent out on the network, the global variable
+         uip_len is set to a value > 0. */
+      if(uip_len > 0) {
+        cs8900a_send();
+      }
+    }
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/uip_arch.c b/contiki-cpc/uip/uip_arch.c
new file mode 100644
index 0000000..5edd6c2
--- /dev/null
+++ b/contiki-cpc/uip/uip_arch.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.1 2006/04/17 15:02:43 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+#define IP_PROTO_UDP    17
+
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+#if 0
+  asm("ldy #3");
+  asm("jsr ldaxysp");
+  asm("sta ptr1");
+  asm("stx ptr1+1");
+  asm("ldy #0");
+  asm("lda (sp),y");
+  asm("ldy #3");
+  asm("clc");
+  asm("adc (ptr1),y");
+  asm("sta _uip_acc32+3");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("ldy #1");
+  asm("adc (sp),y");
+  asm("sta _uip_acc32+2");
+  asm("ldy #1");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+1");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+0");  
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u8_t chksum_protocol;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+u16_t
+chksum(void) {
+
+#if 0
+  asm("lda #0");
+  asm("sta tmp1");
+  asm("sta tmp1+1");
+  asm("lda _chksum_ptr");
+  asm("sta ptr1");
+  asm("lda _chksum_ptr+1");
+  asm("sta ptr1+1");
+
+
+  asm("lda _chksum_len+1");
+  asm("beq chksumlast");
+
+
+  /* If checksum is > 256, do the first runs. */
+  asm("ldy #0");
+  asm("clc");
+  asm("chksumloop_256:");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("iny");
+  asm("bne chksumloop_256");
+  asm("inc ptr1+1");
+  asm("dec _chksum_len+1");
+  asm("bne chksumloop_256");
+
+  asm("chksum_endloop_256:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop_256");
+  
+  asm("chksumlast:");
+  asm("lda _chksum_len");
+  asm("lsr");
+  asm("bcc chksum_noodd");  
+  asm("ldy _chksum_len");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("clc");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("bcc noinc1");
+  asm("inc tmp1+1");
+  asm("bne noinc1");
+  asm("inc tmp1");
+  asm("noinc1:");
+  asm("dec _chksum_len");
+
+  asm("chksum_noodd:");
+  asm("clc");
+  asm("php");
+  asm("ldy _chksum_len");
+  asm("chksum_loop1:");
+  asm("cpy #0");
+  asm("beq chksum_loop1_end");
+  asm("plp");
+  asm("dey");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("dey");
+  asm("php");
+  asm("jmp chksum_loop1");
+  asm("chksum_loop1_end:");
+  asm("plp");
+  
+  asm("chksum_endloop:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop");
+  
+  asm("lda tmp1");
+  asm("ldx tmp1+1");
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *buf, u16_t len)
+{
+  /*  unsigned long sum;
+
+  sum = 0;
+
+  chksum_ptr = (u16_t)buf;
+  while(len >= 256) {  
+    chksum_len = 256;
+    sum += chksum();
+    len -= 256;
+    chksum_ptr += 256;
+  }
+
+  if(len < 256) {
+    chksum_len = len;
+    sum += chksum();
+  }
+
+  while((sum >> 16) != 0) {
+    sum = (sum >> 16) + (sum & 0xffff);
+  }
+
+  return sum;*/
+
+  chksum_len = len;
+  chksum_ptr = (u16_t)buf;
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{  
+  chksum_ptr = (u16_t)uip_buf + UIP_LLH_LEN;
+  chksum_len = 20;  
+  return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+static u16_t
+transport_chksum(u8_t protocol)
+{
+  chksum_protocol = protocol;
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+
+#if 0
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc %v", chksum_protocol);  
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+#endif
+
+  return chksum_tmp;
+}
+/*#pragma optimize(pop)*/
+
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+  return transport_chksum(IP_PROTO_TCP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #6");  /* IP_PROTO_TCP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif 
+}
+
+/*-----------------------------------------------------------------------------------*/
+#if UIP_UDP_CHECKSUMS
+u16_t
+uip_udpchksum(void)
+{
+  return transport_chksum(IP_PROTO_UDP);
+#if 0
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+  asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+  asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+  asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #17");  /* IP_PROTO_UDP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+#endif
+}
+#endif /* UIP_UDP_CHECKSUMS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/uip/uip_arch.h b/contiki-cpc/uip/uip_arch.h
new file mode 100644
index 0000000..9d1c03b
--- /dev/null
+++ b/contiki-cpc/uip/uip_arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.1 2006/04/17 15:02:43 kthacker Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki-devel-environment/Makefile b/contiki-devel-environment/Makefile
new file mode 100644
index 0000000..7c7a8d8
--- /dev/null
+++ b/contiki-devel-environment/Makefile
@@ -0,0 +1,54 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.3 2003/04/10 07:01:30 adamdunkels Exp $
+#
+
+all: hello.prg
+
+include Makefile.cfg
+
+CC=cc65
+AS=ca65
+LD=ld65
+CFLAGS=-I include -I include-$(SYS) -t $(SYS) --add-source -DWITH_LOADER_ARCH 
+OPT=-Or
+
+%.prg:  %.o $(SYS)/contiki-labels.o
+	cl65 --module -t $(SYS) -o $(SYS)/$@ $(SYS)/loader-arch-module.o $^
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+#clean:
+#	rm *.s *.o 
\ No newline at end of file
diff --git a/contiki-devel-environment/Makefile.cfg b/contiki-devel-environment/Makefile.cfg
new file mode 100644
index 0000000..38413ea
--- /dev/null
+++ b/contiki-devel-environment/Makefile.cfg
@@ -0,0 +1,5 @@
+# These values are intended to be changed:
+
+# SYS is the target system for which the programs should be compiled.
+SYS=c64
+
diff --git a/contiki-devel-environment/hello.c b/contiki-devel-environment/hello.c
new file mode 100644
index 0000000..c30ca3a
--- /dev/null
+++ b/contiki-devel-environment/hello.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This an example program for the Contiki desktop OS
+ *
+ * $Id: hello.c,v 1.3 2003/04/10 07:02:05 adamdunkels Exp $
+ *
+ */
+
+/* This is an example of how to write programs for Contiki. It
+   displays a window with the famous message "Hello world" and two
+   buttons; one which changes the message slightly and one which quits
+   the application. */
+
+#include "ctk.h"
+#include "dispatcher.h"
+#include "loader.h"
+
+static struct ctk_window window;
+
+static struct ctk_label hellolabel =
+  {CTK_LABEL(0, 0, 8, 1, "Hello")};
+static struct ctk_label worldlabel =
+  {CTK_LABEL(8, 1, 6, 1, "world!")};
+
+static struct ctk_button updatebutton =
+  {CTK_BUTTON(0, 3, 6, "Update")};
+static struct ctk_button closebutton =
+  {CTK_BUTTON(8, 3, 5, "Close")};
+
+static DISPATCHER_SIGHANDLER(hello_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Hello world", NULL, hello_sighandler, NULL)};
+static ek_id_t id;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(hello_init)
+{
+  if(id == EK_ID_NONE) {
+    id = dispatcher_start(&p);
+    
+    ctk_window_new(&window, 15, 4, "Hello");
+
+    CTK_WIDGET_ADD(&window, &hellolabel);
+    CTK_WIDGET_ADD(&window, &worldlabel);
+
+    CTK_WIDGET_ADD(&window, &updatebutton);
+    CTK_WIDGET_ADD(&window, &closebutton);
+
+    CTK_WIDGET_FOCUS(&window, &updatebutton);
+        
+    dispatcher_listen(ctk_signal_button_activate);
+    dispatcher_listen(ctk_signal_window_close);
+  }
+  ctk_window_open(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hello_quit(void)
+{
+  dispatcher_exit(&p);
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+  ctk_redraw();
+}
+/*-----------------------------------------------------------------------------------*/
+static DISPATCHER_SIGHANDLER(hello_sighandler, s, data)
+{
+  DISPATCHER_SIGHANDLER_ARGS(s, data);
+    
+  if(s == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&updatebutton) {
+      ctk_label_set_text(&hellolabel, "Good bye");
+      CTK_WIDGET_REDRAW(&hellolabel);
+    } else if(data == (ek_data_t)&closebutton) {
+      ctk_window_close(&window);
+      hello_quit();
+    }
+  } else if(s == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) {
+    hello_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-devel-environment/include-c64/cc-conf.h b/contiki-devel-environment/include-c64/cc-conf.h
new file mode 100644
index 0000000..6c834e1
--- /dev/null
+++ b/contiki-devel-environment/include-c64/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/10 07:00:22 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-devel-environment/include-c64/ctk-conf.h b/contiki-devel-environment/include-c64/ctk-conf.h
new file mode 100644
index 0000000..87c2e2e
--- /dev/null
+++ b/contiki-devel-environment/include-c64/ctk-conf.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.2 2004/06/27 12:46:51 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        1
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-devel-environment/include-c64/ek-conf.h b/contiki-devel-environment/include-c64/ek-conf.h
new file mode 100644
index 0000000..ab96bb2
--- /dev/null
+++ b/contiki-devel-environment/include-c64/ek-conf.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2003/04/10 07:00:27 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   32    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  32    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_UNLISTEN 0
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-devel-environment/include-c64/loader-arch.h b/contiki-devel-environment/include-c64/loader-arch.h
new file mode 100644
index 0000000..b8dc33d
--- /dev/null
+++ b/contiki-devel-environment/include-c64/loader-arch.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.1 2003/04/10 07:00:29 adamdunkels Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+unsigned char loader_arch_load(const char *name);
+void loader_arch_free(void *addr);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD(name) loader_arch_load(name)
+#define LOADER_UNLOAD() loader_arch_free(&loader_arch_loadaddr)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-devel-environment/include-vic20/cc-conf.h b/contiki-devel-environment/include-vic20/cc-conf.h
new file mode 100644
index 0000000..6485a82
--- /dev/null
+++ b/contiki-devel-environment/include-vic20/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/10 07:00:32 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS          1
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+#define CC_CONF_FASTCALL               fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-devel-environment/include-vic20/ctk-conf.h b/contiki-devel-environment/include-vic20/ctk-conf.h
new file mode 100644
index 0000000..0fb8a7d
--- /dev/null
+++ b/contiki-devel-environment/include-vic20/ctk-conf.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.2 2004/06/27 12:47:21 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-devel-environment/include-vic20/ek-conf.h b/contiki-devel-environment/include-vic20/ek-conf.h
new file mode 100644
index 0000000..c1f26da
--- /dev/null
+++ b/contiki-devel-environment/include-vic20/ek-conf.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2003/04/10 07:00:35 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   32    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  32    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_UNLISTEN 0
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-devel-environment/include-vic20/loader-arch.h b/contiki-devel-environment/include-vic20/loader-arch.h
new file mode 100644
index 0000000..5297c5c
--- /dev/null
+++ b/contiki-devel-environment/include-vic20/loader-arch.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.1 2003/04/10 07:00:36 adamdunkels Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+unsigned char loader_arch_load(const char *name);
+void loader_arch_free(void *addr);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD(name) loader_arch_load(name)
+#define LOADER_UNLOAD() loader_arch_free(&loader_arch_loadaddr)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-devel-environment/include/ctk-draw.h b/contiki-devel-environment/include/ctk-draw.h
new file mode 100644
index 0000000..9791612
--- /dev/null
+++ b/contiki-devel-environment/include/ctk-draw.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-draw.h,v 1.3 2005/03/15 15:56:51 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_DRAW_H__
+#define __CTK_DRAW_H__
+
+#include "ctk.h"
+
+#include "ctk-arch.h"
+
+
+/* See the file doc/ctk.txt for documentation on these function
+   declarations. */
+
+void ctk_draw_init(void);
+
+void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2);
+void ctk_draw_clear_window(struct ctk_window *window,
+			   unsigned char focus,
+			   unsigned char clipy1, unsigned char clipy2);
+
+void ctk_draw_widget(struct ctk_widget *w,
+		     unsigned char focus,
+		     unsigned char clipy1,
+		     unsigned char clipy2);
+
+void ctk_draw_window(struct ctk_window *window,
+		     unsigned char focus,
+		     unsigned char clipy1,
+		     unsigned char clipy2,
+		     unsigned char draw_borders);
+
+void ctk_draw_dialog(struct ctk_window *dialog);
+
+void ctk_draw_menus(struct ctk_menus *menus);
+
+
+
+/* Returns width and height of screen. */
+unsigned char ctk_draw_width(void);
+unsigned char ctk_draw_height(void);
+
+
+#endif /* __CTK_DRAW_H__ */
diff --git a/contiki-devel-environment/include/ctk-mouse.h b/contiki-devel-environment/include/ctk-mouse.h
new file mode 100644
index 0000000..391e7e7
--- /dev/null
+++ b/contiki-devel-environment/include/ctk-mouse.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.h,v 1.2 2003/04/09 19:15:26 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_MOUSE_H__
+#define __CTK_MOUSE_H__
+
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+void ctk_mouse_init(void);
+
+unsigned short ctk_mouse_x(void);
+unsigned short ctk_mouse_y(void);
+
+unsigned char ctk_mouse_xtoc(unsigned short x);
+unsigned char ctk_mouse_ytoc(unsigned short y);
+
+unsigned char ctk_mouse_button(void);
+
+#else
+
+#define ctk_mouse_init()
+#define ctk_mouse_x() 0
+#define ctk_mouse_y() 0
+#define ctk_mouse_xtoc(x) 0
+#define ctk_mouse_ytoc(y) 0
+
+#define ctk_mouse_button() 0
+
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+
+#endif /* __CTK_MOUSE_H__ */
diff --git a/contiki-devel-environment/include/ctk.h b/contiki-devel-environment/include/ctk.h
new file mode 100644
index 0000000..bb0da8e
--- /dev/null
+++ b/contiki-devel-environment/include/ctk.h
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk.h,v 1.2 2003/04/09 19:15:27 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_H__
+#define __CTK_H__
+
+#include "ctk-conf.h"
+#include "ek.h"
+
+#include "cc.h"
+
+/* Defintions for the CTK widget types. */
+#define CTK_WIDGET_SEPARATOR 1
+#define CTK_WIDGET_LABEL     2
+#define CTK_WIDGET_BUTTON    3
+#define CTK_WIDGET_HYPERLINK 4
+#define CTK_WIDGET_TEXTENTRY 5
+#define CTK_WIDGET_BITMAP    6
+#define CTK_WIDGET_ICON      7
+
+struct ctk_widget;
+
+#define CTK_SEPARATOR(x, y, w) \
+ NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w
+struct ctk_separator {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+};
+
+#define CTK_BUTTON(x, y, w, text) \
+ NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, text
+struct ctk_button {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  char *text;
+};
+
+#define CTK_LABEL(x, y, w, h, text) \
+ NULL, NULL, x, y, CTK_WIDGET_LABEL, w, text, h
+struct ctk_label {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  char *text;
+  unsigned char h;
+};
+
+#define CTK_HYPERLINK(x, y, w, text, url) \
+ NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, text, url
+struct ctk_hyperlink {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  char *text;
+  char *url;
+};
+
+/* Editing modes of the CTK textentry widget. */
+#define CTK_TEXTENTRY_NORMAL 0
+#define CTK_TEXTENTRY_EDIT   1
+
+
+#define CTK_TEXTENTRY(x, y, w, h, text, len) \
+  NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, text, h, len, \
+  CTK_TEXTENTRY_NORMAL, 0, 0
+struct ctk_textentry {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  char *text;
+  unsigned char h;
+  unsigned char len;
+  unsigned char state;
+  unsigned char xpos, ypos;
+};
+
+
+#define CTK_ICON(title, bitmap, textmap) \
+ NULL, NULL, 0, 0, CTK_WIDGET_ICON, 0, title, 4, 0, bitmap, textmap
+struct ctk_icon {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  char *title;
+  unsigned char h;
+  ek_id_t owner;
+  unsigned char *bitmap;
+  char *textmap;
+};
+
+#define CTK_BITMAP(x, y, w, h, bitmap) \
+  NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, bitmap, h
+struct ctk_bitmap {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  unsigned char *bitmap;
+  unsigned char h;
+};
+
+
+
+struct ctk_widget_button {
+  char *text;
+};
+
+struct ctk_widget_label {
+  char *text;
+  unsigned char h;
+};
+
+struct ctk_widget_hyperlink {
+  char *text;
+  char *url;
+};
+
+struct ctk_widget_textentry {
+  char *text;
+  unsigned char h;
+  unsigned char len;
+  unsigned char state;
+  unsigned char xpos, ypos;
+};
+
+struct ctk_widget_icon {
+  char *title;
+  unsigned char h;
+  ek_id_t owner;
+  unsigned char *bitmap;
+  char *textmap;
+};
+
+struct ctk_widget_bitmap {
+  unsigned char *bitmap;
+  unsigned char h;
+};
+
+struct ctk_widget {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w;
+  union {
+    struct ctk_widget_label label;
+    struct ctk_widget_button button;
+    struct ctk_widget_hyperlink hyperlink;
+    struct ctk_widget_textentry textentry;
+    struct ctk_widget_icon icon;
+    struct ctk_widget_bitmap bitmap;
+  } widget;
+};
+
+/* Definition of the CTK window structure. */
+struct ctk_window {
+  struct ctk_window *next, *prev;
+  ek_id_t owner;
+
+  char *title;
+  unsigned char titlelen;
+
+#if CTK_CONF_WINDOWCLOSE
+  struct ctk_button closebutton;
+#else /* CTK_CONF_WINDOWCLOSE */
+  struct ctk_label closebutton;
+#endif /* CTK_CONF_WINDOWCLOSE */
+  
+#if CTK_CONF_WINDOWMOVE
+  struct ctk_button titlebutton;
+#else /* CTK_CONF_WINDOWMOVE */
+  struct ctk_label titlebutton;
+#endif /* CTK_CONF_WINDOWMOVE */
+
+  unsigned char x, y;
+  unsigned char w, h;
+
+
+  struct ctk_widget *inactive;
+  struct ctk_widget *active;
+  struct ctk_widget *focused;
+};
+
+struct ctk_menuitem {
+  char *title;
+  unsigned char titlelen;
+};
+
+struct ctk_menu {
+  struct ctk_menu *next;
+  char *title;
+  unsigned char titlelen;
+#if CC_UNSIGNED_CHAR_BUGS
+  unsigned char nitems;
+  unsigned char active;
+#else /* CC_UNSIGNED_CHAR_BUGS */
+  unsigned char nitems;
+  unsigned char active;
+#endif /* CC_UNSIGNED_CHAR_BUGS */
+  struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS];
+};
+
+struct ctk_menus {
+  struct ctk_menu *menus;
+  struct ctk_menu *open;
+  struct ctk_menu *desktopmenu;
+};
+
+/* Global CTK modes. */
+#define CTK_MODE_NORMAL      0
+#define CTK_MODE_WINDOWMOVE  1
+#define CTK_MODE_SCREENSAVER 2
+#define CTK_MODE_EXTERNAL    3
+
+/* General ctk functions. */
+void ctk_init(void);
+void ctk_mode_set(unsigned char mode);
+unsigned char ctk_mode_get(void);
+void ctk_redraw(void);
+
+/* Functions for manipulating windows. */
+void ctk_window_new(struct ctk_window *window,
+		    unsigned char w, unsigned char h,
+		    char *title);
+void ctk_window_clear(struct ctk_window *w);
+void ctk_window_open(struct ctk_window *w);
+#define ctk_window_move(w,xpos,ypos) do {(w)->x=xpos; (w)->y=ypos;}while(0)
+void ctk_window_close(struct ctk_window *w);
+void ctk_window_redraw(struct ctk_window *w);
+#define ctk_window_isopen(w) ((w)->next != NULL)
+
+
+/* Functions for manipulating dialogs. */
+void ctk_dialog_new(struct ctk_window *window,
+		    unsigned char w, unsigned char h);
+void ctk_dialog_open(struct ctk_window *d);
+void ctk_dialog_close(void);
+
+/* Functions for manipulating menus. */
+void ctk_menu_new(struct ctk_menu *menu, char *title);
+void ctk_menu_add(struct ctk_menu *menu);
+void ctk_menu_remove(struct ctk_menu *menu);
+unsigned char ctk_menuitem_add(struct ctk_menu *menu, char *name);
+
+/* Functions for icons. */
+#define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id)
+void ctk_icon_add(struct ctk_widget *icon, ek_id_t id);
+
+/* Functions for manipulating widgets. */
+#define CTK_WIDGET_ADD(win, widg) \
+ ctk_widget_add(win, (struct ctk_widget *)widg)
+void ctk_widget_add(struct ctk_window *window,
+		    struct ctk_widget *widget);
+
+#define CTK_WIDGET_FOCUS(win, widg) \
+  (win)->focused = (struct ctk_widget *)(widg)
+#define CTK_WIDGET_REDRAW(widg) \
+ ctk_widget_redraw((struct ctk_widget *)widg)
+void ctk_widget_redraw(struct ctk_widget *w);
+
+#define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y)
+
+#define ctk_textentry_set_height(w, height) \
+                           (w)->widget.textentry.h = (height)
+#define ctk_label_set_height(w, height) \
+                           (w)->widget.label.h = (height)
+#define ctk_label_set_text(l, t) (l)->text = (t)
+
+#define ctk_button_set_text(b, t) (b)->text = (t)
+
+#define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \
+ (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_BUTTON; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->text = (buttontext)
+
+#define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \
+ (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_LABEL; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->h = (height); \
+ (widg)->text = (labeltext)
+
+#define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \
+ (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_TEXTENTRY; \
+ (widg)->x = (xxpos); \
+ (widg)->y = (yypos); \
+ (widg)->w = (width); \
+ (widg)->h = (height); \
+ (widg)->text = (textptr); \
+ (widg)->len = (textlen); \
+ (widg)->state = CTK_TEXTENTRY_NORMAL; \
+ (widg)->xpos = 0; \
+ (widg)->ypos = 0
+
+
+
+#define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \
+ (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_HYPERLINK; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->text = (linktext); \
+ (widg)->url = (linkurl)
+
+/* Signals. */
+extern ek_signal_t ctk_signal_keypress,
+  ctk_signal_timer,
+  ctk_signal_button_activate,
+  ctk_signal_button_hover,
+  ctk_signal_hyperlink_activate,
+  ctk_signal_hyperlink_hover,
+  ctk_signal_menu_activate,
+  ctk_signal_window_close,
+  ctk_signal_pointer_move,
+  ctk_signal_pointer_down,
+  ctk_signal_pointer_up;
+		       
+/* Focus flags */
+#define CTK_FOCUS_NONE     0
+#define CTK_FOCUS_WIDGET   1
+#define CTK_FOCUS_WINDOW   2
+#define CTK_FOCUS_DIALOG   4
+
+
+
+#endif /* __CTK_H__ */
diff --git a/contiki-devel-environment/include/dispatcher.h b/contiki-devel-environment/include/dispatcher.h
new file mode 100644
index 0000000..9ec74d9
--- /dev/null
+++ b/contiki-devel-environment/include/dispatcher.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: dispatcher.h,v 1.2 2003/04/09 19:15:27 adamdunkels Exp $
+ *
+ */
+#ifndef __DISPATCHER_H__
+#define __DISPATCHER_H__
+
+#include "ek.h"
+#include "cc.h"
+
+void dispatcher_init(void);
+
+#define DISPATCHER_BROADCAST EK_ID_ALL
+
+#define DISPATCHER_PROC(name, idle, signal, uip) \
+ NULL, 0, name, idle, signal, uip
+struct dispatcher_proc {
+  struct dispatcher_proc *next;
+  ek_id_t id;
+  char *name;
+  void (* idle)(void);
+#if CC_FUNCTION_POINTER_ARGS  
+  void (* signalhandler)(ek_signal_t s, ek_data_t data);
+#else /* CC_FUNCTION_POINTER_ARGS */
+  void (* signalhandler)(void);
+#endif /* CC_FUNCTION_POINTER_ARGS */
+  void (* uiphandler)(void *state);
+};
+
+#define DISPATCHER_CURRENT() dispatcher_current
+
+ek_signal_t dispatcher_sigalloc(void);
+
+ek_id_t dispatcher_start(struct dispatcher_proc *p);
+void dispatcher_exit(struct dispatcher_proc *p);
+
+void dispatcher_listen(ek_signal_t s);
+void dispatcher_timer(ek_signal_t s, ek_data_t data, ek_ticks_t t);
+#define dispatcher_emit ek_emit
+
+struct dispatcher_proc *dispatcher_process(ek_id_t id);
+
+struct dispatcher_uipstate {
+  ek_id_t id;  
+  void *state;
+};
+
+/* We must do some C macro trickery to make things work with sdcc,
+   which doesn't support passing arguments to functions called as
+   function pointers. */
+#if CC_FUNCTION_POINTER_ARGS
+#define DISPATCHER_SIGHANDLER(name, s, data) \
+        void name(ek_signal_t s, ek_data_t data)
+
+#define DISPATCHER_SIGHANDLER_ARGS(s, data)
+
+#else /* CC_FUNCTION_POINTER_ARGS */
+#define DISPATCHER_SIGHANDLER(name, s, data) \
+        void name(void)
+
+#define DISPATCHER_SIGHANDLER_ARGS(s, data) ek_signal_t s = dispatcher_sighandler_s; \
+                                            ek_data_t data = dispatcher_sighandler_data
+
+extern ek_signal_t dispatcher_sighandler_s;
+extern ek_data_t dispatcher_sighandler_data;
+#endif /* CC_FUNCTION_POINTER_ARGS */
+
+#define UIP_APPCALL dispatcher_uipcall
+#define UIP_APPSTATE_SIZE sizeof(struct dispatcher_uipstate)
+
+
+#include "uip.h"
+
+struct uip_conn;
+
+void dispatcher_uipcall(void);
+
+void dispatcher_markconn(struct uip_conn *conn,
+			 void *appstate);
+void dispatcher_uiplisten(u16_t port);
+
+extern ek_id_t dispatcher_current;
+
+
+#endif /* __DISPATCHER_H__ */
diff --git a/contiki-devel-environment/include/ek.h b/contiki-devel-environment/include/ek.h
new file mode 100644
index 0000000..b8c19ad
--- /dev/null
+++ b/contiki-devel-environment/include/ek.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek.h,v 1.1 2003/04/09 12:55:06 adamdunkels Exp $
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+#ifndef __EK_H__
+#define __EK_H__
+
+#include "ek-conf.h"
+
+/* Signals defined by ek: */
+#define EK_SIGNAL_NONE 0
+
+/* Errors: */
+#define EK_ERR_OK        0
+#define EK_ERR_FULL      1
+#define EK_ERR_NOTUNIQUE 2
+#define EK_ERR_NOTFOUND  3
+
+/* Special IDs defined by ek: */
+#define EK_ID_NONE 0
+#define EK_ID_ALL  0
+
+typedef unsigned char ek_err_t;
+
+/* Callback functions (must be implemented by the system/application
+   program using ek): */
+
+/* ek_idle:
+ *
+ * Is called repeatedly by ek when there is nothing else to do. This
+ * function can be used to implement polling operations by the
+ * system/application program using ek.
+ */
+void ek_idle(void);
+
+/* ek_dispatcher:
+ *
+ * Is called by ek when a signal has been omitted. The "id" parameter
+ * can be used to distinguish listeners.
+ *
+ * Return values: TBA
+ */
+ek_err_t ek_dispatcher(ek_signal_t s, ek_data_t data, ek_id_t id);
+
+/* ek_clock:
+ *
+ * Should return the current value of the system clock.
+ */
+ek_clock_t ek_clock(void);
+
+
+/* API functions (are used by programs using ek): */
+
+/* ek_listen:
+ *
+ * Registers the listener identified by "id" with the signal "s". When
+ * the signal "s" is emitted, the ek dispatcher callback will be
+ * invoked for the listener "id".
+ *
+ * The meaning of the identifier "id" is defined by the caller (i.e.,
+ * the application program using the ek kernel).
+ *
+ * Return values: TBA
+ */
+ek_err_t ek_listen(ek_signal_t s, ek_id_t id);
+
+/* ek_unlisten:
+ *
+ * Unregisters a previously registered listener.
+ *
+ * Return values: TBA
+ */
+ek_err_t ek_unlisten(ek_signal_t s, ek_id_t id);
+
+/* ek_emit:
+ *
+ * Emits the signal "s". When control returns to ek, the ek signal
+ * dispatcher will be called for each of the registered listeners for
+ * the signal. If no listeners are registered, the signal is
+ * dropped.
+ *
+ * Return values: TBA
+ */
+ek_err_t ek_emit(ek_signal_t s, ek_data_t data, ek_id_t id);
+
+/* ek_timer:
+ *
+ * Sets a timer that will make the signal "s" to be emitted after "t"
+ * number of clock ticks. The granularity of the clock ticks is
+ * determined by the underlying system on which ek is run.
+ *
+ * Return values: TBA
+ */ 
+ek_err_t ek_timer(ek_signal_t s, ek_data_t data, ek_id_t id,
+		  ek_ticks_t t);
+
+/* ek_init:
+ *
+ * Initializes ek.
+ */
+void ek_init(void);
+
+/* ek_signals:
+ *
+ * Called internally by ek_run(). Processes signals. 
+ */
+void ek_signals(void);
+
+/* ek_run:
+ *
+ * The main function in ek that is called to start ek. This function
+ * never returns.
+ */
+void ek_run(void);
+
+#endif /* __EK_H__ */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-devel-environment/include/loader.h b/contiki-devel-environment/include/loader.h
new file mode 100644
index 0000000..995cff2
--- /dev/null
+++ b/contiki-devel-environment/include/loader.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader.h,v 1.1 2003/04/09 12:55:06 adamdunkels Exp $
+ *
+ */
+#ifndef __LOADER_H__
+#define __LOADER_H__
+
+#ifdef WITH_LOADER_ARCH
+#include "loader-arch.h"
+#define LOADER_INIT_FUNC(name) void init(void)
+#else /* WITH_LOADER_ARCH */
+#define LOADER_INIT_FUNC(name) void name(void)
+#endif /* WITH_LOADER_ARCH */
+
+#ifndef LOADER_LOAD
+#define LOADER_LOAD(name) LOADER_OK
+#endif /* LOADER_LOAD */
+
+#ifndef LOADER_UNLOAD
+#define LOADER_UNLOAD()
+#endif /* LOADER_UNLOAD */
+
+
+
+#define LOADER_OK 0
+
+#endif /* __LOADER_H__ */
diff --git a/contiki-devel-environment/include/petsciiconv.h b/contiki-devel-environment/include/petsciiconv.h
new file mode 100644
index 0000000..d9607d5
--- /dev/null
+++ b/contiki-devel-environment/include/petsciiconv.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: petsciiconv.h,v 1.1 2003/04/09 12:55:06 adamdunkels Exp $
+ *
+ */
+#ifndef __PETSCIICONV_H__
+#define __PETSCIICONV_H__
+
+#ifdef WITH_ASCII
+
+#define petsciiconv_toascii(buf, len)
+#define petsciiconv_topetscii(buf, len)
+
+#else /* WITH_ASCII */
+
+void petsciiconv_toascii(char *buf, unsigned int len);
+void petsciiconv_topetscii(char *buf, unsigned int len);
+
+#endif /* WITH_ASCII */
+
+#endif /* __PETSCIICONV_H__ */
diff --git a/contiki-devel-environment/include/resolv.h b/contiki-devel-environment/include/resolv.h
new file mode 100644
index 0000000..802de18
--- /dev/null
+++ b/contiki-devel-environment/include/resolv.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: resolv.h,v 1.1 2003/04/09 12:55:06 adamdunkels Exp $
+ *
+ */
+#ifndef __RESOLV_H__
+#define __RESOLV_H__
+
+#include "uip.h"
+#include "ek.h"
+
+/* Signals */
+extern ek_signal_t resolv_signal_found;
+
+/* Callbacks. */
+void resolv_found(char *name, u16_t *ipaddr);
+
+/* Functions. */
+void resolv_conf(u16_t *dnsserver);
+void resolv_init(void);
+u16_t *resolv_lookup(char *name);
+void resolv_query(char *name);
+
+#endif /* __RESOLV_H__ */
diff --git a/contiki-devel-environment/include/uip.h b/contiki-devel-environment/include/uip.h
new file mode 100644
index 0000000..1d5a70a
--- /dev/null
+++ b/contiki-devel-environment/include/uip.h
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2001-2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip.h,v 1.2 2005/01/26 23:36:23 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIP_H__
+#define __UIP_H__
+
+#include "uipopt.h"
+
+#ifndef UIP_IPV6
+#define UIP_IPV6 0
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+/* First, the functions that should be called from the
+ * system. Initialization, the periodic timer and incoming packets are
+ * handled by the following three functions.
+ */
+
+/* uip_init(void):
+ *
+ * Must be called at boot up to configure the uIP data structures.
+ */
+void uip_init(void);
+
+/* uip_periodic(conn):
+ *
+ * Should be called when the periodic timer has fired. Should be
+ * called once per connection (0 - UIP_CONNS).
+ */
+#define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
+                                uip_process(UIP_TIMER); } while (0)
+
+/* uip_input(void):
+ *
+ * Is called when the network device driver has received new data.
+ */
+#define uip_input()        uip_process(UIP_DATA)
+
+/* uip_sethostaddr(addr):
+ *
+ * Is used to set the IP address.
+ */
+#define uip_sethostaddr(addr) do { uip_hostaddr[0] = addr[0]; \
+                              uip_hostaddr[1] = addr[1]; } while(0)
+
+#if UIP_UDP
+/* uip_udp_periodic(conn):
+ */
+#define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
+                                uip_process(UIP_UDP_TIMER); } while (0)
+#endif /* UIP_UDP */
+/*-----------------------------------------------------------------------------------*/
+/* Functions that are used by the uIP application program. Opening and
+ * closing connections, sending and receiving data, etc. is all
+ * handled by the functions below.
+*/
+
+/* uip_listen(port):
+ *
+ * Starts listening to the specified port.
+ */
+void uip_listen(u16_t port);
+
+/* uip_connect(ripaddr, port):
+ *
+ * Returns a connection identifier that connects to a port on the
+ * specified host (given in ripaddr). If no connections are avaliable,
+ * the function returns NULL. This function is avaliable only if
+ * support for active open has been configured (#define
+ * UIP_ACTIVE_OPEN 1 in uipopt.h)
+ */
+struct uip_conn *uip_connect(u16_t *ripaddr, u16_t port);
+
+#if UIP_UDP
+/* uip_udp_new(ripaddr, rport):
+ *
+ * Sets up a new UDP "connection" with the specified parameters.
+ */
+struct uip_udp_conn *uip_udp_new(u16_t *ripaddr, u16_t rport);
+
+/* uip_udp_remove(conn):
+ *
+ * Removes the UDP "connection".
+ */
+#define uip_udp_remove(conn) (conn)->lport = 0
+
+/* uip_udp_send(len):
+ *
+ * Sends a UDP datagram of length len. The data must be present in the
+ * uip_buf buffer (pointed to by uip_appdata).
+ */
+#define uip_udp_send(len) uip_slen = (len)
+#endif /* UIP_UDP */
+
+
+/* uip_outstanding(conn):
+ *
+ * Checks whether a connection has outstanding (i.e., unacknowledged)
+ * data.
+ */
+#define uip_outstanding(conn) ((conn)->len)
+
+/* uip_send(data, len):
+ *
+ * Send data on the current connection. The length of the data must
+ * not exceed the maxium segment size (MSS) for the connection.
+ */
+#define uip_send(data, len) do { uip_appdata = (data); uip_slen = (len);} while(0)   
+
+/* uip_datalen():
+ *
+ * The length of the data that is currently avaliable (if avaliable)
+ * in the uip_appdata buffer. The test function uip_data() is
+ * used to check if data is avaliable.
+ */
+#define uip_datalen()       uip_len
+
+#define uip_urgdatalen()    uip_urglen
+
+/* uip_close():
+ *
+ * Close the current connection.
+ */
+#define uip_close()         (uip_flags = UIP_CLOSE)
+
+/* uip_abort():
+ *
+ * Abort the current connection.
+ */
+#define uip_abort()         (uip_flags = UIP_ABORT)
+
+/* uip_stop():
+ *
+ * Close our receiver's window so that we stop receiving data for the
+ * current connection.
+ */
+#define uip_stop()          (uip_conn->tcpstateflags |= UIP_STOPPED)
+
+/* uip_stopped():
+ *
+ * Find out if the current connection has been previously stopped.
+ */
+#define uip_stopped(conn)   ((conn)->tcpstateflags & UIP_STOPPED)
+
+/* uip_restart():
+ *
+ * Open the window again so that we start receiving data for the
+ * current connection.
+ */
+#define uip_restart()         do { uip_flags |= UIP_NEWDATA; \
+                                   uip_conn->tcpstateflags &= ~UIP_STOPPED; \
+                              } while(0)
+
+
+/* uIP tests that can be made to determine in what state the current
+   connection is, and what the application function should do. */
+
+/* uip_newdata():
+ *
+ * Will reduce to non-zero if there is new data for the application
+ * present at the uip_appdata pointer. The size of the data is
+ * avaliable through the uip_len variable.
+ */
+#define uip_newdata()   (uip_flags & UIP_NEWDATA)
+
+/* uip_acked():
+ *
+ * Will reduce to non-zero if the previously sent data has been
+ * acknowledged by the remote host. This means that the application
+ * can send new data. uip_reset_acked() can be used to reset the acked
+ * flag.
+ */
+#define uip_acked()   (uip_flags & UIP_ACKDATA)
+#define uip_reset_acked() (uip_flags &= ~UIP_ACKDATA)
+
+/* uip_connected():
+ *
+ * Reduces to non-zero if the current connection has been connected to
+ * a remote host. This will happen both if the connection has been
+ * actively opened (with uip_connect()) or passively opened (with
+ * uip_listen()).
+ */
+#define uip_connected() (uip_flags & UIP_CONNECTED)
+
+/* uip_closed():
+ *
+ * Is non-zero if the connection has been closed by the remote
+ * host. The application may do the necessary clean-ups.
+ */
+#define uip_closed()    (uip_flags & UIP_CLOSE)
+
+/* uip_aborted():
+ *
+ * Non-zero if the current connection has been aborted (reset) by the
+ * remote host.
+ */
+#define uip_aborted()    (uip_flags & UIP_ABORT)
+
+/* uip_timedout():
+ *
+ * Non-zero if the current connection has been aborted due to too many
+ * retransmissions.
+ */
+#define uip_timedout()    (uip_flags & UIP_TIMEDOUT)
+
+/* uip_rexmit():
+ *
+ * Reduces to non-zero if the previously sent data has been lost in
+ * the network, and the application should retransmit it. The
+ * application should set the uip_appdata buffer and the uip_len
+ * variable just as it did the last time this data was to be
+ * transmitted.
+ */
+#define uip_rexmit()     (uip_flags & UIP_REXMIT)
+
+/* uip_poll():
+ *
+ * Is non-zero if the reason the application is invoked is that the
+ * current connection has been idle for a while and should be
+ * polled.
+ */ 
+#define uip_poll()       (uip_flags & UIP_POLL)
+
+/* uip_mss():
+ *
+ * Gives the current maxium segment size (MSS) of the current
+ * connection.
+ */
+#define uip_mss()             (uip_conn->mss)
+
+
+/* uIP convenience and converting functions. */
+
+/* uip_ipaddr(&ipaddr, addr0,addr1,addr2,addr3):
+ *
+ * Packs an IP address into a two element 16-bit array. Such arrays
+ * are used to represent IP addresses in uIP.
+ */
+#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
+                     (addr)[0] = HTONS(((addr0) << 8) | (addr1)); \
+                     (addr)[1] = HTONS(((addr2) << 8) | (addr3)); \
+                  } while(0)
+
+/* HTONS():
+ *
+ * Macros for converting 16-bit quantities between host and network
+ * byte order.
+ */
+#ifndef HTONS
+#   if BYTE_ORDER == BIG_ENDIAN
+#      define HTONS(n) (n)
+#   else /* BYTE_ORDER == BIG_ENDIAN */
+#      define HTONS(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
+#   endif /* BYTE_ORDER == BIG_ENDIAN */
+#endif /* HTONS */
+
+#ifndef htons
+u16_t htons(u16_t val);
+#endif /* htons */
+
+/*-----------------------------------------------------------------------------------*/
+/* The following global variables are used for passing parameters
+ * between uIP, the network device driver and the application. */
+/*-----------------------------------------------------------------------------------*/
+
+/* u8_t uip_buf[UIP_BUFSIZE]:
+ *
+ * The uip_buf array is used to hold incoming and outgoing
+ * packets. The device driver fills this with incoming packets.
+ */
+extern u8_t uip_buf[UIP_BUFSIZE];
+
+/* u8_t *uip_appdata:
+ *
+ * This pointer points to the application data when the application is
+ * called. If the application wishes to send data, this is where the
+ * application should write it. The application can also point this to
+ * another location.
+ */
+extern volatile u8_t *uip_appdata; 
+
+#if UIP_URGDATA > 0 
+/* u8_t *uip_urgdata:
+ *
+ * This pointer points to any urgent data that has been received. Only
+ * present if compiled with support for urgent data (UIP_URGDATA).
+ */
+extern volatile u8_t *uip_urgdata; 
+#endif /* UIP_URGDATA > 0 */
+
+
+/* u[8|16]_t uip_len:
+ *
+ * When the application is called, uip_len contains the length of any
+ * new data that has been received from the remote host. The
+ * application should set this variable to the size of any data that
+ * the application wishes to send. When the network device driver
+ * output function is called, uip_len should contain the length of the
+ * outgoing packet.
+ */
+extern volatile u16_t uip_len, uip_slen;
+
+#if UIP_URGDATA > 0 
+extern volatile u8_t uip_urglen, uip_surglen;
+#endif /* UIP_URGDATA > 0 */
+
+extern volatile u8_t uip_acc32[4];
+
+/* struct uip_conn:
+ *
+ * The uip_conn structure is used for identifying a connection. All
+ * but one field in the structure are to be considered read-only by an
+ * application. The only exception is the appstate field whos purpose
+ * is to let the application store application-specific state (e.g.,
+ * file pointers) for the connection. The size of this field is
+ * configured in the "uipopt.h" header file.
+ */
+struct uip_conn {
+#if UIP_IPV6
+  u16_t ripaddr[8];   /* The IP address of the remote peer. */
+#else /* UIP_IPV6 */
+  u16_t ripaddr[2];   /* The IP address of the remote peer. */
+#endif /* UIP_IPV6 */
+  
+  u16_t lport, rport; /* The local and the remote port. */
+  
+  u8_t rcv_nxt[4];    /* The sequence number that we expect to receive
+			 next. */
+  u8_t snd_nxt[4];    /* The sequence number that was last sent by
+                         us. */
+#if UIP_TCP_MSS > 255
+  u16_t len;
+  u16_t mss;          /* Maximum segment size for the connection. */
+#else
+  u8_t len;
+  u8_t mss;
+#endif /* UIP_TCP_MSS */
+  u8_t sa, sv, rto;
+  u8_t tcpstateflags; /* TCP state and flags. */
+  u8_t timer;         /* The retransmission timer. */
+  u8_t nrtx;          /* Counts the number of retransmissions for a
+                         particular segment. */
+  
+  u8_t appstate[UIP_APPSTATE_SIZE];
+};
+
+/* struct uip_conn *uip_conn:
+ *
+ * When the application is called, uip_conn will point to the current
+ * conntection, the one that should be processed by the
+ * application. The uip_conns[] array is a list containing all
+ * connections.
+ */
+extern struct uip_conn *uip_conn;  
+extern struct uip_conn uip_conns[UIP_CONNS];
+
+#if UIP_UDP
+/* struct uip_udp_conn:
+ *
+ * The uip_udp_conn structure is used for identifying UDP
+ * "connections".
+ */
+struct uip_udp_conn {
+#if UIP_IPV6
+  u16_t ripaddr[8];   /* The IP address of the remote peer. */
+#else /* UIP_IPV6 */
+  u16_t ripaddr[2];   /* The IP address of the remote peer. */
+#endif /* UIP_IPV6 */
+  u16_t lport, rport;
+};
+
+extern struct uip_udp_conn *uip_udp_conn;
+extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
+#endif /* UIP_UDP */
+
+/* struct uip_stats:
+ *
+ * Contains statistics about the TCP/IP stack.
+ */
+struct uip_stats {
+  struct {
+    uip_stats_t drop;
+    uip_stats_t recv;
+    uip_stats_t sent;
+    uip_stats_t vhlerr;   /* Number of packets dropped due to wrong IP version
+			     or header length. */
+    uip_stats_t hblenerr; /* Number of packets dropped due to wrong IP length,
+			     high byte. */
+    uip_stats_t lblenerr; /* Number of packets dropped due to wrong IP length,
+			     low byte. */
+    uip_stats_t fragerr;  /* Number of packets dropped since they were IP
+			     fragments. */
+    uip_stats_t chkerr;   /* Number of packets dropped due to IP checksum errors. */
+    uip_stats_t protoerr; /* Number of packets dropped since they were neither
+			     ICMP nor TCP. */
+  } ip;
+  struct {
+    uip_stats_t drop;
+    uip_stats_t recv;
+    uip_stats_t sent;
+    uip_stats_t typeerr;
+  } icmp;
+  struct {
+    uip_stats_t drop;
+    uip_stats_t recv;
+    uip_stats_t sent;
+    uip_stats_t chkerr;
+    uip_stats_t ackerr;
+    uip_stats_t rst;
+    uip_stats_t rexmit;
+    uip_stats_t syndrop;  /* Number of dropped SYNs due to too few
+			     connections was avaliable. */
+    uip_stats_t synrst;   /* Number of SYNs for closed ports, triggering a
+			     RST. */
+  } tcp;
+};
+
+extern struct uip_stats uip_stat;
+
+
+/*-----------------------------------------------------------------------------------*/
+/* All the stuff below this point is internal to uIP and should not be
+ * used directly by an application or by a device driver.
+ */
+/*-----------------------------------------------------------------------------------*/
+/* u8_t uip_flags:
+ *
+ * When the application is called, uip_flags will contain the flags
+ * that are defined in this file. Please read below for more
+ * infomation.
+ */
+extern volatile u8_t uip_flags;
+
+/* The following flags may be set in the global variable uip_flags
+   before calling the application callback. The UIP_ACKDATA and
+   UIP_NEWDATA flags may both be set at the same time, whereas the
+   others are mutualy exclusive. Note that these flags should *NOT* be
+   accessed directly, but through the uIP functions/macros. */
+
+#define UIP_ACKDATA   1     /* Signifies that the outstanding data was
+			       acked and the application should send
+			       out new data instead of retransmitting
+			       the last data. */
+#define UIP_NEWDATA   2     /* Flags the fact that the peer has sent
+			       us new data. */
+#define UIP_REXMIT    4     /* Tells the application to retransmit the
+			       data that was last sent. */
+#define UIP_POLL      8     /* Used for polling the application, to
+			       check if the application has data that
+			       it wants to send. */
+#define UIP_CLOSE     16    /* The remote host has closed the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to close the
+			       connection. */
+#define UIP_ABORT     32    /* The remote host has aborted the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to abort the
+			       connection. */
+#define UIP_CONNECTED 64    /* We have got a connection from a remote
+                               host and have set up a new connection
+                               for it, or an active connection has
+                               been successfully established. */
+
+#define UIP_TIMEDOUT  128   /* The connection has been aborted due to
+			       too many retransmissions. */
+
+
+/* uip_process(flag):
+ *
+ * The actual uIP function which does all the work.
+ */
+void uip_process(u8_t flag);
+
+/* The following flags are passed as an argument to the uip_process()
+   function. They are used to distinguish between the two cases where
+   uip_process() is called. It can be called either because we have
+   incoming data that should be processed, or because the periodic
+   timer has fired. */
+
+#define UIP_DATA    1     /* Tells uIP that there is incoming data in
+                             the uip_buf buffer. The length of the
+                             data is stored in the global variable
+                             uip_len. */
+#define UIP_TIMER   2     /* Tells uIP that the periodic timer has
+                             fired. */
+#if UIP_UDP
+#define UIP_UDP_TIMER 3
+#endif /* UIP_UDP */
+
+/* The TCP states used in the uip_conn->tcpstateflags. */
+#define CLOSED      0
+#define SYN_RCVD    1
+#define SYN_SENT    2
+#define ESTABLISHED 3
+#define FIN_WAIT_1  4
+#define FIN_WAIT_2  5
+#define CLOSING     6
+#define TIME_WAIT   7
+#define LAST_ACK    8
+#define TS_MASK     15
+  
+#define UIP_STOPPED      16
+
+#if UIP_IPV6
+#define UIP_TCPIP_HLEN 60
+#else /* UIP_IPV6 */
+#define UIP_TCPIP_HLEN 40
+#endif /* UIP_IPV6 */
+
+/* The TCP and IP headers. */
+typedef struct {
+  /* IP header. */
+#if UIP_IPV6
+  u8_t vtc,
+    tcfl;
+  u16_t fl;
+  u8_t len[2];
+  u8_t nxthdr, hoplim;
+  u16_t srcipaddr[8],
+    destipaddr[8];
+#else /* UIP_IPV6 */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+#endif /* UIP_IPV6 */
+  
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],  
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];     
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+} uip_tcpip_hdr;
+
+/* The ICMP and IP headers. */
+typedef struct {
+  /* IP header. */
+#if UIP_IPV6
+  u16_t vtcfl;
+  u16_t fl;
+  u8_t len[2];
+  u8_t nxthdr, hoplim;
+  u16_t srcipaddr[8],
+    destipaddr[8];
+#else /* UIP_IPV6 */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+#endif /* UIP_IPV6 */
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+  u16_t id, seqno;  
+} uip_icmpip_hdr;
+
+
+/* The UDP and IP headers. */
+typedef struct {
+  /* IP header. */
+#if UIP_IPV6
+  u8_t vtc,
+    tcfl;
+  u16_t fl;
+  u8_t len[2];
+  u8_t nxthdr, hoplim;
+  u16_t srcipaddr[8],
+    destipaddr[8];
+#else /* UIP_IPV6 */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+#endif /* UIP_IPV6 */
+  
+  /* UDP header. */
+  u16_t srcport,
+    destport;
+  u16_t udplen;
+  u16_t udpchksum;
+} uip_udpip_hdr;
+
+#define UIP_PROTO_ICMP  1
+#define UIP_PROTO_TCP   6
+#define UIP_PROTO_UDP   17
+
+#if UIP_FIXEDADDR
+#if UIP_IPV6
+extern const u16_t uip_hostaddr[8];
+#else /* UIP_IPV6 */
+extern const u16_t uip_hostaddr[2];
+#endif /* UIP_IPV6 */
+#else /* UIP_FIXEDADDR */
+#if UIP_IPV6
+extern u16_t uip_hostaddr[8];
+#else /* UIP_IPV6 */
+extern u16_t uip_hostaddr[2];
+#endif /* UIP_IPV6 */
+#endif /* UIP_FIXEDADDR */
+
+#endif /* __UIP_H__ */
+
+
+
+
+
+
+
diff --git a/contiki-devel-environment/include/uip_main.h b/contiki-devel-environment/include/uip_main.h
new file mode 100644
index 0000000..bc94b94
--- /dev/null
+++ b/contiki-devel-environment/include/uip_main.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: uip_main.h,v 1.1 2003/04/09 12:55:06 adamdunkels Exp $
+ *
+ */
+#ifndef __UIP_MAIN_H__
+#define __UIP_MAIN_H__
+
+void uip_main_init(void);
+unsigned char uip_main_ipaddrconv(char *addrstr, unsigned char *addr);
+
+#endif /* __UIP_MAIN_H__ */
diff --git a/contiki-devel-environment/include/uipopt.h b/contiki-devel-environment/include/uipopt.h
new file mode 100644
index 0000000..1ebe071
--- /dev/null
+++ b/contiki-devel-environment/include/uipopt.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uipopt.h,v 1.2 2005/02/23 22:43:53 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIPOPT_H__
+#define __UIPOPT_H__
+
+/* This file is used for tweaking various configuration options for
+   uIP. You should make a copy of this file into one of your project's
+   directories instead of editing this example "uipopt.h" file that
+   comes with the uIP distribution. */
+
+/*-----------------------------------------------------------------------------------*/
+/* First, two typedefs that may have to be tweaked for your particular
+   compiler. The uX_t types are unsigned integer types, where the X is
+   the number of bits in the integer type. Most compilers use
+   "unsigned char" and "unsigned short" for those two,
+   respectively. */
+typedef unsigned char u8_t;
+typedef unsigned short u16_t;
+typedef unsigned long u32_t;
+typedef unsigned long uip_stats_t;
+
+#include <string.h>
+#define bcopy(s,d,l) memcpy(d,s,l)
+
+/*-----------------------------------------------------------------------------------*/
+/* The configuration options for a specific node. This includes IP
+ * address, netmask and default router as well as the Ethernet
+ * address. The netmask, default router and Ethernet address are
+ * appliciable only if uIP should be run over Ethernet.
+ *
+ * All of these should be changed to suit your project.
+*/
+#define UIP_URGDATA 0
+#define UIP_PINGADDRCONF 0
+
+#define UIP_UDP 1
+#define UIP_UDP_CHECKSUMS 0
+#define UIP_UDP_CONNS 1
+#define UIP_UDP_APPCALL udp_appcall
+void udp_appcall(void);
+
+#define UIP_FIXEDADDR 0
+/* UIP_IPADDR: The IP address of this uIP node. */
+/*#define UIP_IPADDR0     192
+#define UIP_IPADDR1     168
+#define UIP_IPADDR2     0
+#define UIP_IPADDR3     2*/
+
+/* UIP_NETMASK: The netmask. */
+#define UIP_NETMASK0    255
+#define UIP_NETMASK1    255
+#define UIP_NETMASK2    255
+#define UIP_NETMASK3    0
+
+/* UIP_DRIPADDR: IP address of the default router. */
+#define UIP_DRIPADDR0   192
+#define UIP_DRIPADDR1   168
+#define UIP_DRIPADDR2   1
+#define UIP_DRIPADDR3   1
+
+/* UIP_ETHADDR: The Ethernet address. */
+#define UIP_ETHADDR0    0x00
+#define UIP_ETHADDR1    0x00
+#define UIP_ETHADDR2    0x00
+#define UIP_ETHADDR3    0x64
+#define UIP_ETHADDR4    0x64
+#define UIP_ETHADDR5    0x64
+
+
+/*-----------------------------------------------------------------------------------*/
+/* The following options are used to configure application specific
+ * setting such as how many TCP ports that should be avaliable and if
+ * the uIP should be configured to support active opens.
+ *
+ * These should probably be tweaked to suite your project.
+ */
+
+/* Include the header file for the application program that should be
+   used. If you don't use the example web server, you should change
+   this. */
+#include "dispatcher.h"
+
+/* UIP_ACTIVE_OPEN: Determines if support for opening connections from
+   uIP should be compiled in. If this isn't needed for your
+   application, don't turn it on. (A web server doesn't need this, for
+   instance.) */
+#define UIP_ACTIVE_OPEN 1
+
+/* UIP_CONNS: The maximum number of simultaneously active
+   connections. */
+#define UIP_CONNS       6
+
+/* UIP_LISTENPORTS: The maximum number of simultaneously listening TCP
+   ports. For a web server, 1 is enough here. */
+#define UIP_LISTENPORTS 6
+
+/* UIP_BUFSIZE: The size of the buffer that holds incoming and
+   outgoing packets. */
+#ifdef WITH_ETHERNET
+#define UIP_BUFSIZE     360
+#else /* WITH_ETHERNET */
+#define UIP_BUFSIZE     300
+#endif /* WITH_ETHERNET */
+
+/* UIP_STATISTICS: Determines if statistics support should be compiled
+   in. The statistics is useful for debugging and to show the user. */
+#define UIP_STATISTICS  0
+
+/* UIP_LOGGING: Determines if logging of certain events should be
+   compiled in. Useful mostly for debugging. The function uip_log(char
+   *msg) must be implemented to suit your architecture if logging is
+   turned on. */
+#define UIP_LOGGING     0
+
+/* UIP_LLH_LEN: The link level header length; this is the offset into
+   the uip_buf where the IP header can be found. For Ethernet, this
+   should be set to 14. For SLIP, this should be set to 0. */
+#ifdef WITH_ETHERNET
+#define UIP_LLH_LEN     14
+#else /* WITH_ETHERNET */
+#define UIP_LLH_LEN     0
+#endif /* WITH_ETHERNET */
+
+/*-----------------------------------------------------------------------------------*/
+/* The following configuration options can be tweaked for your
+ * project, but you are probably safe to use the default values. The
+ * options are listed in order of tweakability.
+ */
+
+/* UIP_ARPTAB_SIZE: The size of the ARP table - use a larger value if
+   this uIP node will have many connections from the local network. */
+#define UIP_ARPTAB_SIZE 8
+
+/* The maxium age of ARP table entries measured in 10ths of
+   seconds. An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
+   default). */
+#define UIP_ARP_MAXAGE 120
+
+/* UIP_RTO: The retransmission timeout counted in timer pulses (i.e.,
+   the speed of the periodic timer, usually one second). */
+#define UIP_RTO         3
+
+/* UIP_MAXRTX: The maximum number of times a segment should be
+   retransmitted before the connection should be aborted. */
+#define UIP_MAXSYNRTX   8
+#define UIP_MAXRTX      8
+
+/* UIP_TCP_MSS: The TCP maximum segment size. This should be set to
+   at most UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN. */
+#define UIP_TCP_MSS     (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN - 2)
+
+/* UIP_TTL: The IP TTL (time to live) of IP packets sent by uIP. */
+#define UIP_TTL         255
+
+/* UIP_TIME_WAIT_TIMEOUT: How long a connection should stay in the
+   TIME_WAIT state. Has no real implication, so it should be left
+   untouched. */
+#define UIP_TIME_WAIT_TIMEOUT 120
+/*-----------------------------------------------------------------------------------*/
+/* This is where you configure if your CPU architecture is big or
+ * little endian. Most CPUs today are little endian. The most notable
+ * exception are the Motorolas which are big endian. Tweak the
+ * definition of the BYTE_ORDER macro to configure uIP for your
+ * project.
+ */
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN  3412
+#endif /* LITTLE_ENDIAN */
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN     1234
+#endif /* BIGE_ENDIAN */
+
+#ifndef BYTE_ORDER
+#define BYTE_ORDER     LITTLE_ENDIAN
+#endif /* BYTE_ORDER */
+
+#endif /* __UIPOPT_H__ */
diff --git a/contiki/Makefile.common b/contiki/Makefile.common
new file mode 100644
index 0000000..12ca89c
--- /dev/null
+++ b/contiki/Makefile.common
@@ -0,0 +1,27 @@
+UIP=uip.o uip_arch.o uiplib.o resolv.o tcpip.o
+
+DHCP=dhcp.o dhcpc.o
+
+DIRECTORY=directory.o loader-arch-dsc.o
+
+EDITOR=editor.o memb.o ctk-filedialog.o
+
+EMAIL=email.o smtp-socket.o smtp-strings.o ctk-textentry-multiline.o psock.o uipbuf.o memb.o
+
+FTP=ftp.o ftpc.o memb.o
+
+IRC=irc.o ircc.o psock.o uipbuf.o ircc-strings.o ctk-textentry-cmdline.o
+
+SHELL_=shell-gui.o shell.o ctk-textentry-cmdline.o
+
+TELNET=simpletelnet.o telnet.o
+
+TELNETD=telnetd.o shell.o memb.o telnetd-gui.o
+
+VNCVIEWER=vnc.o vnc-viewer.o vnc-draw.o
+
+WEBSERVER=webserver.o httpd.o http-strings.o psock.o uipbuf.o memb.o httpd-fs.o httpd-cgi.o
+
+WGET=wget.o webclient.o http-strings.o http-user-agent-string.o 
+
+WWW=www.o webclient.o http-strings.o http-user-agent-string.o htmlparser.o html-strings.o 
diff --git a/contiki/README b/contiki/README
new file mode 100644
index 0000000..9c71711
--- /dev/null
+++ b/contiki/README
@@ -0,0 +1,31 @@
+Contiki is an open source, highly portable, networked, multi-tasking
+operating system for memory-constrained systems.
+
+Contiki runs on a variety of tiny systems ranging from embedded 8-bit
+microcontrollers to old homecomputers such the Commodore 64. Code
+footprint is on the order of kilobytes and memory usage can be
+configured to be as low as tens of bytes.
+
+Contiki provides a simple event-driven kernel with per-process
+optional preemptive multi-threading, interprocess communication using
+message passing through events, a dynamic process structure with
+support for loading and unloading programs, native TCP/IP support
+using the uIP TCP/IP stack, and a GUI subsystem with either direct
+graphic support for locally connected terminals or networked virtual
+display with VNC or over Telnet.
+
+The Contiki source code is split into the following directories:
+
+  apps/ - Applications
+  conf/ - Example configuration files
+  ctk/  - CTK, the Contiki GUI toolkit
+  doc/  - Files for building documentation from the sources
+  ek/   - Event kernel, multitasking, protothreads
+  lib/  - Libraries 
+  uip/  - The uIP TCP/IP stack
+
+To build a Contiki system, you also need a Contiki port. This contains
+all the architecture specific files needed to build an actual
+system. For most ports, the build procedure is simple: place the
+port's directory in the same directory as the contiki/ directory and
+run "make" (or "gmake" under FreeBSD) in the port's directory.
diff --git a/contiki/apps/FILES b/contiki/apps/FILES
new file mode 100644
index 0000000..167bd5e
--- /dev/null
+++ b/contiki/apps/FILES
@@ -0,0 +1,73 @@
+The contiki/apps/ directory contains source code for a number of
+Contiki application programs.
+
+about*.[ch]
+
+  A program showing an "About Contiki" dialog box.
+
+calc*.[ch]
+
+  A simple desktop calculator.
+
+dhcp.[ch]
+
+  A simple frontend for the DHCP client.
+
+email*.[ch], smtp*.[ch], pop*.[ch]
+
+  An email program with network protocols SMTP and POP3.
+
+ftp*.[ch], ftpc*.[ch]
+
+  An FTP client.
+
+htmlparser.[ch], http-*[ch], webclient.[ch], www.[ch]
+
+  A simple web browser with an HTML parser and an HTTP client
+  implementation.
+
+httpd*.[ch], webserver.[ch]
+
+  A simple web server (HTTP server implementation).
+
+irc*.[ch], ircc*.[ch]
+
+  An IRC client.
+
+netconf*.[ch]
+
+  A program for changing network settings.
+
+processes*.[ch]
+
+  A program that shows currently running processes.
+
+shell*.[ch]
+
+  A command shell
+
+telnet*.[ch]
+
+  A simple telnet-like program
+
+telnetd*.[ch]
+
+  A telnet server.
+
+vnc*.[ch]
+
+  A VNC client.  
+  
+makestrings
+
+  Creates .c and .h files from the -strings files.
+
+httpd-fs/
+
+  Directory containing static files for the web server.  
+  
+makefsdata
+
+  Creates the httpd-fsdata.c file from the httpd-fs/ directory
+             
+  
\ No newline at end of file
diff --git a/contiki/apps/about-dsc.c b/contiki/apps/about-dsc.c
new file mode 100644
index 0000000..c47c921
--- /dev/null
+++ b/contiki/apps/about-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: about-dsc.c,v 1.6 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon about_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(about_dsc,
+    "About Contiki",
+    "about.prg",
+    about_init,
+    &about_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char abouticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char abouticon_textmap[9] = {
+  ' ', ' ', 'c',
+  ' ', '?', ' ',
+  '.', ' ', ' '
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon about_icon =
+  {CTK_ICON("About Contiki", abouticon_bitmap, abouticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/about-dsc.h b/contiki/apps/about-dsc.h
new file mode 100644
index 0000000..6b405c8
--- /dev/null
+++ b/contiki/apps/about-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: about-dsc.h,v 1.1 2003/04/17 19:00:00 adamdunkels Exp $
+ *
+ */
+#ifndef __ABOUT_DSC_H__
+#define __ABOUT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(about_dsc);
+
+#endif /* __ABOUT_DSC_H__ */
diff --git a/contiki/apps/about.c b/contiki/apps/about.c
new file mode 100644
index 0000000..283464c
--- /dev/null
+++ b/contiki/apps/about.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: about.c,v 1.14 2004/09/12 17:52:58 adamdunkels Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ek.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "petsciiconv.h"
+
+#include "loader.h"
+
+static struct ctk_window aboutdialog;
+static struct ctk_label aboutlabel1 =
+  {CTK_LABEL(2, 0, 28, 1, "The Contiki Operating System")};
+static struct ctk_label aboutlabel2 =
+  {CTK_LABEL(3, 2, 28, 1, "A modern, Internet-enabled")};
+static struct ctk_label aboutlabel3 =
+  {CTK_LABEL(6, 3, 20, 1, "operating system and")};
+static struct ctk_label aboutlabel4 =
+  {CTK_LABEL(6, 4, 20, 1, "desktop environment.")};
+
+static char abouturl_petscii[] = "http://www.sics.se/~adam/contiki/";
+static char abouturl_ascii[40];
+static struct ctk_hyperlink abouturl = 
+  {CTK_HYPERLINK(0, 6, 32, "http://www.sics.se/~adam/contiki/",
+		 abouturl_ascii)};
+static struct ctk_button aboutclose =
+  {CTK_BUTTON(12, 8, 5, "Close")};
+
+EK_EVENTHANDLER(about_eventhandler, ev, data);
+
+EK_PROCESS(p, "About Contiki", EK_PRIO_NORMAL, about_eventhandler, NULL, NULL);
+/*static DISPATCHER_SIGHANDLER(about_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("About Contiki", NULL, about_sighandler, NULL)};
+  static ek_id_t id;*/
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(about_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    /*    id = dispatcher_start(&p); */
+    id = ek_start(&p);
+  }
+  /*  ctk_desktop_redraw(aboutdialog.desktop);*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+about_quit(void)
+{
+  ctk_dialog_close();
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(about_sighandler, s, data)*/
+EK_EVENTHANDLER(about_eventhandler, ev, data)
+{
+  unsigned char width;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    width = ctk_desktop_width(NULL);
+    
+    strcpy(abouturl_ascii, abouturl_petscii);
+    petsciiconv_toascii(abouturl_ascii, sizeof(abouturl_ascii));
+
+    if(width > 34) {
+      ctk_dialog_new(&aboutdialog, 32, 9);
+    } else {
+      ctk_dialog_new(&aboutdialog, width - 2, 9);
+    }
+    CTK_WIDGET_ADD(&aboutdialog, &aboutlabel1);
+    CTK_WIDGET_ADD(&aboutdialog, &aboutlabel2);
+    CTK_WIDGET_ADD(&aboutdialog, &aboutlabel3);
+    CTK_WIDGET_ADD(&aboutdialog, &aboutlabel4);
+    if(width > 34) {
+      CTK_WIDGET_ADD(&aboutdialog, &abouturl);
+      CTK_WIDGET_SET_FLAG(&abouturl, CTK_WIDGET_FLAG_MONOSPACE);
+    } else {
+      CTK_WIDGET_SET_XPOS(&aboutlabel1, 0);
+      CTK_WIDGET_SET_XPOS(&aboutlabel2, 0);
+      CTK_WIDGET_SET_XPOS(&aboutlabel3, 0);
+      CTK_WIDGET_SET_XPOS(&aboutlabel4, 0);
+      
+      CTK_WIDGET_SET_XPOS(&aboutclose, 0);
+    }
+    CTK_WIDGET_ADD(&aboutdialog, &aboutclose);
+    CTK_WIDGET_FOCUS(&aboutdialog, &aboutclose);
+    
+    /*    dispatcher_listen(ctk_signal_button_activate);
+	  dispatcher_listen(ctk_signal_hyperlink_activate);*/
+    ctk_dialog_open(&aboutdialog);
+    
+  } else if(ev == EK_EVENT_REQUEST_EXIT) {
+    about_quit();
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&aboutclose) {
+      about_quit();
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    if((struct ctk_widget *)data == (struct ctk_widget *)&abouturl) {
+      about_quit();
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/calc-dsc.c b/contiki/apps/calc-dsc.c
new file mode 100644
index 0000000..aedec22
--- /dev/null
+++ b/contiki/apps/calc-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: calc-dsc.c,v 1.3 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon calc_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(calc_dsc,
+    "Simple calculator",
+    "calc.prg",
+    calc_init,
+    &calc_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char calcicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char calcicon_textmap[9] = {
+  '+', ' ', '-',
+  ' ', '*', ' ',
+  '=', ' ', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon calc_icon =
+  {CTK_ICON("Calculator", calcicon_bitmap, calcicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/calc-dsc.h b/contiki/apps/calc-dsc.h
new file mode 100644
index 0000000..db821ee
--- /dev/null
+++ b/contiki/apps/calc-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: calc-dsc.h,v 1.1 2003/05/29 19:15:37 adamdunkels Exp $
+ *
+ */
+#ifndef __CALC_DSC_H__
+#define __CALC_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(calc_dsc);
+
+#endif /* __CALC_DSC_H__ */
diff --git a/contiki/apps/calc.c b/contiki/apps/calc.c
new file mode 100644
index 0000000..603e610
--- /dev/null
+++ b/contiki/apps/calc.c
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This an example program for the Contiki desktop OS
+ *
+ * $Id: calc.c,v 1.8 2005/02/07 23:13:00 oliverschmidt Exp $
+ *
+ */
+
+/* This is an example of how to write programs for Contiki. It
+   displays a window with the famous message "Hello world" and two
+   buttons; one which changes the message slightly and one which quits
+   the application. */
+
+#include "ek.h"
+#include "ctk.h"
+#include "loader.h"
+
+static struct ctk_window window;
+
+static char input[16];
+static struct ctk_label inputlabel =
+  {CTK_LABEL(0, 0, 12, 1, input)};
+
+static struct ctk_button button7 =
+  {CTK_BUTTON(0, 3, 1, "7")};
+static struct ctk_button button8 =
+  {CTK_BUTTON(3, 3, 1, "8")};
+static struct ctk_button button9 =
+  {CTK_BUTTON(6, 3, 1, "9")};
+static struct ctk_button button4 =
+  {CTK_BUTTON(0, 4, 1, "4")};
+static struct ctk_button button5 =
+  {CTK_BUTTON(3, 4, 1, "5")};
+static struct ctk_button button6 =
+  {CTK_BUTTON(6, 4, 1, "6")};
+static struct ctk_button button1 =
+  {CTK_BUTTON(0, 5, 1, "1")};
+static struct ctk_button button2 =
+  {CTK_BUTTON(3, 5, 1, "2")};
+static struct ctk_button button3 =
+  {CTK_BUTTON(6, 5, 1, "3")};
+static struct ctk_button button0 =
+  {CTK_BUTTON(0, 6, 3, " 0 ")};
+
+static struct ctk_button cbutton =
+  {CTK_BUTTON(0, 2, 1, "C")};
+
+static struct ctk_button divbutton =
+  {CTK_BUTTON(9, 2, 1, "/")};
+static struct ctk_button mulbutton =
+  {CTK_BUTTON(9, 3, 1, "*")};
+
+static struct ctk_button subbutton =
+  {CTK_BUTTON(9, 4, 1, "-")};
+static struct ctk_button addbutton =
+  {CTK_BUTTON(9, 5, 1, "+")};
+static struct ctk_button calcbutton =
+  {CTK_BUTTON(9, 6, 1, "=")};
+
+EK_EVENTHANDLER(calc_eventhandler, ev, data);
+EK_PROCESS(p, "Calculator", EK_PRIO_NORMAL,
+	   calc_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*
+static DISPATCHER_SIGHANDLER(calc_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Calculator", NULL, calc_sighandler, NULL)};
+static ek_id_t id;
+*/
+
+static unsigned long operand1, operand2;
+static unsigned char op;
+#define OP_ADD 1
+#define OP_SUB 2
+#define OP_MUL 3
+#define OP_DIV 4
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(calc_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+calc_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+add_to_input(char c)
+{
+  unsigned char i;
+    
+  for(i = 0; i < 11; ++i) {
+    input[i] = input[i + 1];
+  }
+  input[11] = c;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+clear_input(void)
+{
+  unsigned char i;
+  
+  for(i = 0; i < sizeof(input); ++i) {
+    input[i] = ' ';
+  }      
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+input_to_operand1(void)
+{
+  unsigned int m;
+  unsigned char i;
+
+  operand1 = 0;
+  for(m = 1, i = 11;
+      i > 7; --i, m *= 10) {
+    if(input[i] >= '0' &&
+       input[i] <= '9') {
+      operand1 += (input[i] - '0') * m;
+    }
+  }
+  clear_input();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+operand2_to_input(void)
+{
+  unsigned char i;
+  
+  input[7] = (operand2/10000) % 10 + '0';
+  input[8] = (operand2/1000) % 10 + '0';
+  input[9] = (operand2/100) % 10 + '0';
+  input[10] = (operand2/10) % 10 + '0';
+  input[11] = operand2 % 10 + '0';
+
+  for(i = 0; i < 4; ++i) {
+    if(input[7 + i] == '0') {
+      input[7 + i] = ' ';
+    } else {
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+calculate(void)
+{
+  operand2 = operand1;
+  input_to_operand1();
+  switch(op) {
+  case OP_ADD:
+    operand2 = operand2 + operand1;
+    break;
+  case OP_SUB:
+    operand2 = operand2 - operand1;
+    break;
+  case OP_MUL:
+    operand2 = operand2 * operand1;
+    break;
+  case OP_DIV:
+    operand2 = operand2 / operand1;
+    break;
+  }
+  operand2_to_input();      
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(calc_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 12, 7, "Calc");
+
+    CTK_WIDGET_ADD(&window, &inputlabel);
+    CTK_WIDGET_SET_FLAG(&inputlabel, CTK_WIDGET_FLAG_MONOSPACE);
+
+    CTK_WIDGET_ADD(&window, &cbutton);
+    
+    CTK_WIDGET_ADD(&window, &divbutton);
+	    
+    CTK_WIDGET_ADD(&window, &button7);
+    CTK_WIDGET_ADD(&window, &button8);
+    CTK_WIDGET_ADD(&window, &button9);
+
+    CTK_WIDGET_ADD(&window, &mulbutton);
+
+   
+
+    CTK_WIDGET_ADD(&window, &button4);
+    CTK_WIDGET_ADD(&window, &button5);
+    CTK_WIDGET_ADD(&window, &button6);
+
+    CTK_WIDGET_ADD(&window, &subbutton);
+
+    CTK_WIDGET_ADD(&window, &button1);
+    CTK_WIDGET_ADD(&window, &button2);
+    CTK_WIDGET_ADD(&window, &button3);
+    
+    CTK_WIDGET_ADD(&window, &addbutton);
+    
+    CTK_WIDGET_ADD(&window, &button0);
+
+    CTK_WIDGET_ADD(&window, &calcbutton);
+	
+    clear_input();
+    
+    ctk_window_open(&window);
+
+  } else if(ev == ctk_signal_keypress) {
+    if((char)data >= '0' &&
+       (char)data <= '9') {
+      add_to_input((char)data);
+    } else if((char)data == ' ') {
+      clear_input();
+    } else if((char)data == '+') {
+      input_to_operand1();
+      op = OP_ADD;
+    } else if((char)data == '-') {
+      input_to_operand1();
+      op = OP_SUB;
+    } else if((char)data == '*') {
+      input_to_operand1();
+      op = OP_MUL;
+    } else if((char)data == '/') {
+      input_to_operand1();
+      op = OP_DIV;
+    } else if((char)data == '=' ||
+	      (char)data == CH_ENTER) {
+      calculate();
+    }
+
+    CTK_WIDGET_REDRAW(&inputlabel);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&button0) {
+      add_to_input('0');
+    } else if(data == (ek_data_t)&button1) {
+      add_to_input('1');
+    } else if(data == (ek_data_t)&button2) {
+      add_to_input('2');
+    } else if(data == (ek_data_t)&button3) {
+      add_to_input('3');
+    } else if(data == (ek_data_t)&button4) {
+      add_to_input('4');
+    } else if(data == (ek_data_t)&button5) {
+      add_to_input('5');
+    } else if(data == (ek_data_t)&button6) {
+      add_to_input('6');
+    } else if(data == (ek_data_t)&button7) {
+      add_to_input('7');
+    } else if(data == (ek_data_t)&button8) {
+      add_to_input('8');
+    } else if(data == (ek_data_t)&button9) {
+      add_to_input('9');
+    } else if(data == (ek_data_t)&cbutton) {
+      clear_input();
+    } else if(data == (ek_data_t)&calcbutton) {
+      calculate();
+    } else if(data == (ek_data_t)&addbutton) {
+      input_to_operand1();
+      op = OP_ADD;
+    } else if(data == (ek_data_t)&subbutton) {
+      input_to_operand1();
+      op = OP_SUB;
+    } else if(data == (ek_data_t)&mulbutton) {
+      input_to_operand1();
+      op = OP_MUL;
+    } else if(data == (ek_data_t)&divbutton) {
+      input_to_operand1();
+      op = OP_DIV;
+    }
+    CTK_WIDGET_REDRAW(&inputlabel);
+  } else if(ev == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) {
+    calc_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/dhcp-dsc.c b/contiki/apps/dhcp-dsc.c
new file mode 100644
index 0000000..a9bd423
--- /dev/null
+++ b/contiki/apps/dhcp-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: dhcp-dsc.c,v 1.2 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon dhcp_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(dhcp_dsc,
+    "Obtain IP address automatically",
+    "dhcp.prg",
+    dhcp_init,
+    &dhcp_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+  'T', 'C', 'P',
+  '/', 'I', 'P',
+  'C', 'f', 'g'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon dhcp_icon =
+  {CTK_ICON("DHCP client", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/dhcp-dsc.h b/contiki/apps/dhcp-dsc.h
new file mode 100644
index 0000000..b7e39f9
--- /dev/null
+++ b/contiki/apps/dhcp-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: dhcp-dsc.h,v 1.1 2004/09/17 20:42:08 adamdunkels Exp $
+ *
+ */
+#ifndef __DHCP_DSC_H__
+#define __DHCP_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(dhcp_dsc);
+
+#endif /* __DHCP_DSC_H__ */
diff --git a/contiki/apps/dhcp.c b/contiki/apps/dhcp.c
new file mode 100644
index 0000000..8d5617a
--- /dev/null
+++ b/contiki/apps/dhcp.c
@@ -0,0 +1,150 @@
+#include "contiki.h"
+#include "ctk.h"
+#include "dhcpc.h"
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "DHCP", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static struct ctk_window window;
+static struct ctk_button getbutton =
+  {CTK_BUTTON(0, 0, 16, "Request address")};
+static struct ctk_label statuslabel =
+  {CTK_LABEL(0, 1, 16, 1, "")};
+
+
+static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 3, 10, 1, "IP address")};
+static char ipaddr[17];
+static struct ctk_textentry ipaddrentry =
+  {CTK_LABEL(11, 3, 16, 1, ipaddr)};
+static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 4, 10, 1, "Netmask")};
+static char netmask[17];
+static struct ctk_textentry netmaskentry =
+  {CTK_LABEL(11, 4, 16, 1, netmask)};
+static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 5, 10, 1, "Gateway")};
+static char gateway[17];
+static struct ctk_textentry gatewayentry =
+  {CTK_LABEL(11, 5, 16, 1, gateway)};
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 6, 10, 1, "DNS server")};
+static char dnsserver[17];
+static struct ctk_textentry dnsserverentry =
+  {CTK_LABEL(11, 6, 16, 1, dnsserver)};
+
+enum {
+  SHOWCONFIG
+};
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(dhcp_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+set_statustext(char *text)
+{
+  ctk_label_set_text(&statuslabel, text);
+  CTK_WIDGET_REDRAW(&statuslabel);
+}
+/*---------------------------------------------------------------------------*/
+static char *
+makebyte(u8_t byte, char *str)
+{
+  if(byte >= 100) {
+    *str++ = (byte / 100 ) % 10 + '0';
+  }
+  if(byte >= 10) {
+    *str++ = (byte / 10) % 10 + '0';
+  }
+  *str++ = (byte % 10) + '0';
+
+  return str;
+}
+/*---------------------------------------------------------------------------*/
+static void
+makeaddr(u16_t *addr, char *str)
+{
+  str = makebyte(HTONS(addr[0]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[0]) & 0xff, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) & 0xff, str);
+  *str++ = 0;
+}
+/*---------------------------------------------------------------------------*/
+static void
+makestrings(void)
+{
+  u16_t addr[2], *addrptr;
+
+  uip_gethostaddr(addr);
+  makeaddr(addr, ipaddr);
+  
+  uip_getnetmask(addr);
+  makeaddr(addr, netmask);
+  
+  uip_getdraddr(addr);
+  makeaddr(addr, gateway);
+
+  addrptr = resolv_getserver();
+  if(addrptr != NULL) {
+    makeaddr(addrptr, dnsserver);
+  }
+ 
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 28, 7, "DHCP");
+
+    CTK_WIDGET_ADD(&window, &getbutton);
+    CTK_WIDGET_ADD(&window, &statuslabel);
+    CTK_WIDGET_ADD(&window, &ipaddrlabel);
+    CTK_WIDGET_ADD(&window, &ipaddrentry);
+    CTK_WIDGET_ADD(&window, &netmasklabel);
+    CTK_WIDGET_ADD(&window, &netmaskentry);
+    CTK_WIDGET_ADD(&window, &gatewaylabel);
+    CTK_WIDGET_ADD(&window, &gatewayentry);
+    CTK_WIDGET_ADD(&window, &dnsserverlabel);
+    CTK_WIDGET_ADD(&window, &dnsserverentry);
+    
+    CTK_WIDGET_FOCUS(&window, &getbutton);
+
+    ctk_window_open(&window);
+    dhcpc_init();
+  } else if(ev == ctk_signal_widget_activate) {
+    if(data == (ek_data_t)&getbutton) {
+      dhcpc_request();
+      set_statustext("Requesting...");
+    }
+  } else if(ev == tcpip_event) {
+    dhcpc_appcall(data);
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_window_close) {
+    ctk_window_close(&window);
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  } else if(ev == SHOWCONFIG) {
+    makestrings();
+    ctk_window_redraw(&window);  
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_configured(void)
+{
+  set_statustext("Configured.");
+  ek_post(EK_PROC_ID(EK_CURRENT()), SHOWCONFIG, NULL);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/dhcp.h b/contiki/apps/dhcp.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contiki/apps/dhcp.h
diff --git a/contiki/apps/directory-dsc.c b/contiki/apps/directory-dsc.c
new file mode 100644
index 0000000..eaf4382
--- /dev/null
+++ b/contiki/apps/directory-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.c,v 1.1 2005/04/18 23:17:55 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon directory_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(directory_dsc,
+    "Directory reader",
+    "directory.prg",
+    directory_init,
+    &directory_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char directoryicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char directoryicon_textmap[9] = {
+  '+', '-', '+',
+  '|', 'o', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon directory_icon =
+  {CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/directory-dsc.h b/contiki/apps/directory-dsc.h
new file mode 100644
index 0000000..9875d26
--- /dev/null
+++ b/contiki/apps/directory-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.h,v 1.1 2005/04/18 23:17:55 oliverschmidt Exp $
+ *
+ */
+#ifndef __DIRECTORY_DSC_H__
+#define __DIRECTORY_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(directory_dsc);
+
+#endif /* __DIRECTORY_DSC_H__ */
diff --git a/contiki/apps/directory.c b/contiki/apps/directory.c
new file mode 100644
index 0000000..62b4f25
--- /dev/null
+++ b/contiki/apps/directory.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory.c,v 1.3 2006/05/24 19:34:39 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "loader.h"
+
+#include "cfs.h"
+
+#include "program-handler.h"
+
+#define FILENAMELEN 24
+#define MAX_NUMFILES 40
+#define WIDTH 36
+#define HEIGHT 22
+
+static char (filenames[FILENAMELEN + 1])[MAX_NUMFILES];
+static struct dsc *dscs[MAX_NUMFILES];
+static unsigned char numfiles, morestart, filenameptr;
+
+static struct ctk_window window;
+
+static struct ctk_label description =
+  {CTK_LABEL(0, HEIGHT - 1, WIDTH, 1, "")};
+
+static char autoexit = 1;
+static struct ctk_button autoexitbutton =
+  {CTK_BUTTON(WIDTH/2 - 9, 20, 9, "Auto-exit")};
+static char autoexiton[] = "is On ";
+static char autoexitoff[] = "is Off";
+static struct ctk_label autoexitlabel =
+  {CTK_LABEL(WIDTH/2 - 9 + 12, 20, 6, 1, autoexiton)};
+
+static struct ctk_button morebutton =
+  {CTK_BUTTON(0, 20, 4, "More")};
+
+static struct ctk_button backbutton =
+  {CTK_BUTTON(0, 20, 4, "Back")};
+
+static struct ctk_button reloadbutton =
+  {CTK_BUTTON(30, 20, 6, "Reload")};
+
+EK_EVENTHANDLER(directory_eventhandler, ev, data);
+EK_PROCESS(p, "Directory browser", EK_PRIO_NORMAL,
+	   directory_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char width, height;
+
+#define LOADING_DIR 1
+#define LOADING_DSC 2
+static char loading = 0;
+static struct cfs_dir dir;
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&description, text);
+  CTK_WIDGET_REDRAW(&description);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+startloading(void)
+{
+  if(cfs_opendir(&dir, "/") != 0) {
+    show_statustext("Cannot open directory");
+    loading = 0;
+  } else {
+    loading = LOADING_DIR;
+    ek_post(id, EK_EVENT_CONTINUE, NULL);
+    numfiles = 0;
+  }
+}    
+/*-----------------------------------------------------------------------------------*/
+static void
+makewindow(unsigned char i)
+{
+  unsigned char x, y;
+
+  ctk_window_clear(&window);
+  CTK_WIDGET_SET_YPOS(&description, height - 3);
+  CTK_WIDGET_SET_WIDTH(&description, width);
+  CTK_WIDGET_ADD(&window, &description);
+
+  morestart = i;
+  
+  x = 0; y = 1;
+  for(; dscs[i] != NULL; ++i) {
+
+    if(x + strlen(dscs[i]->icon->title) >= width) {
+      y += 5;
+      x = 0;
+      if(y >= height - 2 - 4) {
+	morestart = i;
+	break;
+      }
+    }
+    CTK_WIDGET_SET_XPOS(dscs[i]->icon, x);
+    CTK_WIDGET_SET_YPOS(dscs[i]->icon, y);
+    CTK_WIDGET_ADD(&window, dscs[i]->icon);
+
+    x += strlen(dscs[i]->icon->title) + 2;
+  }
+  CTK_WIDGET_SET_YPOS(&autoexitbutton, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitbutton);
+  CTK_WIDGET_SET_YPOS(&autoexitlabel, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitlabel);
+  CTK_WIDGET_FOCUS(&window, &autoexitbutton);
+
+  if(i != morestart) {
+    CTK_WIDGET_SET_YPOS(&backbutton, height - 1);
+    CTK_WIDGET_ADD(&window, &backbutton);
+  } else {
+    CTK_WIDGET_SET_YPOS(&morebutton, height - 1);
+    CTK_WIDGET_ADD(&window, &morebutton);
+  }
+  CTK_WIDGET_SET_XPOS(&reloadbutton, width - 8);
+  CTK_WIDGET_SET_YPOS(&reloadbutton, height - 1);
+  CTK_WIDGET_ADD(&window, &reloadbutton);    
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(directory_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+    width = ctk_draw_width() - 2;
+    height = ctk_draw_height() - 3;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  unsigned char i;
+
+  if(loading == LOADING_DIR) {
+    cfs_closedir(&dir);
+  }
+  ctk_window_close(&window);
+  for(i = 0; dscs[i] != NULL; ++i) {
+    LOADER_UNLOAD_DSC(dscs[i]);
+  }
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+read_dirent(void)
+{
+  static struct cfs_dirent dirent;
+  static char message[40];
+    
+  if(loading == LOADING_DIR) {
+    if(cfs_readdir(&dir, &dirent)) {
+      cfs_closedir(&dir);
+      loading = LOADING_DSC;
+      filenameptr = 0;
+    } else if(strcasecmp(&dirent.name[strlen(dirent.name) - 4], ".dsc") == 0) {
+      strncpy(filenames[numfiles], dirent.name, FILENAMELEN);
+      ++numfiles;
+      if(numfiles == MAX_NUMFILES) {
+	cfs_closedir(&dir);	
+	loading = LOADING_DSC;
+	filenameptr = 0;
+	return;
+      }      
+      strcpy(message, "Found \"");
+      strcpy(message + 7, dirent.name);
+      strcpy(message + 7 + strlen(dirent.name), "\"...");
+      show_statustext(message);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+load_dirent(void)
+{
+  static char message[40];
+  char *name;
+    
+  if(loading == LOADING_DSC) {
+
+    name = filenames[filenameptr];
+    dscs[filenameptr] = LOADER_LOAD_DSC(name);
+    if(dscs[filenameptr] == NULL || filenameptr + 1 >= numfiles) {
+      loading = 0;
+      makewindow(0);
+      show_statustext("Directory loaded");
+      ctk_window_redraw(&window);
+      return;
+    }
+    ++filenameptr;
+    strcpy(message, "Loading \"");
+    strcpy(message + 9, name);
+    strcpy(message + 9 + strlen(name), "\"...");
+    show_statustext(message);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(directory_eventhandler, ev, data)
+{
+  unsigned char i;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, width, height, "Directory");
+
+    /*    loaddirectory();*/
+    makewindow(0);
+    show_statustext("Loading directory...");
+    startloading();
+    
+    ctk_window_open(&window);
+
+  } else if(ev == EK_EVENT_CONTINUE) {
+    read_dirent();
+    load_dirent();
+    if(loading != 0) {
+      ek_post(id, EK_EVENT_CONTINUE, NULL);
+    }
+  } else if(ev == ctk_signal_widget_activate) {
+    if(data == (ek_data_t)&reloadbutton) {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	LOADER_UNLOAD_DSC(dscs[i]);
+	dscs[i] = NULL;
+      }     
+      /*      loaddirectory();*/
+      startloading();
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&morebutton) {
+      makewindow(morestart);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&backbutton) {
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      autoexit = 1 - autoexit;
+      if(autoexit == 1) {
+	ctk_label_set_text(&autoexitlabel, autoexiton);
+      } else {
+	ctk_label_set_text(&autoexitlabel, autoexitoff);
+      }
+      CTK_WIDGET_REDRAW(&autoexitlabel);
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  program_handler_load(dscs[i]->prgname, NULL);
+	  if(autoexit) {
+	    ctk_window_close(&window);
+	    quit();
+	  }
+	  break;
+	}
+      }
+    }
+  } else if(ev == ctk_signal_widget_select) {
+    if(data == (ek_data_t)&reloadbutton) {
+      show_statustext("Reload directory");
+    } else if(data == (ek_data_t)&morebutton) {
+      show_statustext("Show more files");
+    } else if(data == (ek_data_t)&backbutton) {
+      show_statustext("Show first files");
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      show_statustext("Exit when loading program");
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  show_statustext(dscs[i]->description);
+	  break;
+	}
+      }
+    }
+  } else if(ev == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) {
+    quit();
+  } else if(ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&window);
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/editor-dsc.c b/contiki/apps/editor-dsc.c
new file mode 100644
index 0000000..1865a85
--- /dev/null
+++ b/contiki/apps/editor-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: editor-dsc.c,v 1.3 2005/04/19 22:00:53 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon editor_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(editor_dsc,
+    "A simple text editor",
+    "editor.prg",
+    editor_init,
+    &editor_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char editoricon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char editoricon_textmap[9] = {
+  't', 'x', 't',
+  'e', 'd', 'i',
+  't', 'o', 'r'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon editor_icon =
+  {CTK_ICON("Editor", editoricon_bitmap, editoricon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/editor-dsc.h b/contiki/apps/editor-dsc.h
new file mode 100644
index 0000000..6ab77c8
--- /dev/null
+++ b/contiki/apps/editor-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: editor-dsc.h,v 1.1 2004/08/09 20:08:10 adamdunkels Exp $
+ *
+ */
+#ifndef __EDITOR_DSC_H__
+#define __EDITOR_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(editor_dsc);
+
+#endif /* __EDITOR_DSC_H__ */
diff --git a/contiki/apps/editor.c b/contiki/apps/editor.c
new file mode 100644
index 0000000..35defb1
--- /dev/null
+++ b/contiki/apps/editor.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: editor.c,v 1.4 2005/04/24 13:37:42 oliverschmidt Exp $
+ */
+#define EDITOR_CONF_WIDTH 32
+#define EDITOR_CONF_HEIGHT 16
+#define EDITOR_CONF_MAX_FILENAME_LEN 16
+
+#include "contiki.h"
+#include "ctk.h"
+#include "cfs.h"
+
+#include "ctk-filedialog.h"
+
+#define ISO_nl 0x0a
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Editor", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static struct ctk_window window;
+
+#define LINE_LEN 60
+#define NUM_LINES EDITOR_CONF_HEIGHT
+
+struct line {
+  struct line *next, *prev;
+  char text[LINE_LEN];
+};
+MEMB(linesmem, sizeof(struct line), NUM_LINES);
+
+static struct line *lines;
+
+static struct {
+  unsigned char x, y;
+  struct ctk_label labels[NUM_LINES];
+
+} editor_state;
+
+static struct ctk_button openbutton =
+  {CTK_BUTTON(0, 0, 4, "Open")};
+static char statustext[EDITOR_CONF_WIDTH + 1];
+static struct ctk_label statuslabel =
+  {CTK_LABEL(0, EDITOR_CONF_HEIGHT + 2, EDITOR_CONF_WIDTH, 1, statustext)};
+
+static struct ctk_menu menu;
+static unsigned char menuitem_new, menuitem_open, menuitem_save;
+
+static char filename[EDITOR_CONF_MAX_FILENAME_LEN];
+
+
+static struct ctk_filedialog_state filedialog;
+
+enum {
+  OPEN_EVENT
+};
+
+/*---------------------------------------------------------------------------*/
+static void
+show_statustext(char *text1, char *text2)
+{
+  int len;
+
+  len = strlen(text1);
+  if(len < sizeof(statustext)) {
+    strncpy(statustext, text1, sizeof(statustext));
+    strncpy(statustext + len, text2, sizeof(statustext) - len);
+    CTK_WIDGET_REDRAW(&statuslabel);
+  }  
+  
+}
+/*---------------------------------------------------------------------------*/
+static void
+editor_start(void)
+{
+  unsigned char i;
+  register struct ctk_label *label;
+  struct line *l, *m;
+
+  m = NULL;
+  
+  for(i = 0; i < NUM_LINES; ++i) {
+    label = &editor_state.labels[i];
+    l = (struct line *)memb_alloc(&linesmem);
+    
+    if(l != NULL) {
+      l->next = NULL;
+      l->prev = m;
+      if(m == NULL) {
+	/* First line */
+	lines = l;
+      } else {
+	m->next = l;
+      }
+      CTK_LABEL_NEW(label, 0, i + 1, EDITOR_CONF_WIDTH, 1, l->text);
+      CTK_WIDGET_SET_FLAG(label, CTK_WIDGET_FLAG_MONOSPACE);
+      CTK_WIDGET_ADD(&window, label);
+    }
+    m = l;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+editor_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  char *textptr, *textptr2;
+  unsigned char len;
+  
+  if(ev == ctk_signal_keypress) {
+    /*    CTK_WIDGET_FOCUS(t->label.window, &t->label);*/
+    textptr = &(editor_state.labels[editor_state.y].text[editor_state.x]);
+    *textptr &= 0x7f;
+    CTK_WIDGET_REDRAW(&(editor_state.labels[editor_state.y]));
+    
+    switch((ctk_arch_key_t)data) {
+    case CH_CURS_DOWN:
+      ++editor_state.y;
+      if(editor_state.y >= EDITOR_CONF_HEIGHT) {
+	editor_state.y = EDITOR_CONF_HEIGHT - 1;
+      }
+      break; 
+    case CH_CURS_UP:
+      if(editor_state.y > 0) {
+	--editor_state.y;
+      }
+      break; 
+    case CH_CURS_RIGHT:
+      if(editor_state.x < strlen(editor_state.labels[editor_state.y].text)) {
+	++editor_state.x;
+      }
+      break; 
+    case CH_CURS_LEFT:
+      if(editor_state.x > 0) {
+	--editor_state.x;
+      } else {
+	if(editor_state.y > 0) {
+	  --editor_state.y;
+	  editor_state.x = strlen(editor_state.labels[editor_state.y].text);
+	}       
+      }
+      break;
+    case CH_ENTER:
+      editor_state.x = 0;
+      ++editor_state.y;
+      if(editor_state.y >= EDITOR_CONF_HEIGHT) {
+	editor_state.y = EDITOR_CONF_HEIGHT - 1;
+      }
+      break;
+    case CH_DEL:
+      /*      len = t->label.w - t->xpos;
+      if(t->xpos > 0 && len > 0) {
+	strncpy(textptr - 1, textptr,
+		len);
+	*(textptr + len - 1) = 0;
+	--t->xpos;
+	}*/
+      break;      
+    default:
+      len = EDITOR_CONF_WIDTH - editor_state.x;
+      if(len > 0) {
+	textptr2 = textptr + len - 1;
+	while(textptr2 + 1 > textptr) {
+	  *(textptr2 + 1) = *textptr2;
+	  --textptr2;
+	}
+	
+	*textptr = (char)data;
+	++editor_state.x;
+	if(editor_state.x == EDITOR_CONF_WIDTH) {
+	  editor_state.x = 0;
+	  if(editor_state.y < EDITOR_CONF_HEIGHT - 1) {
+	    ++editor_state.y;
+	  }
+	}
+      }
+      break;
+    }
+    textptr = &(editor_state.labels[editor_state.y].text[editor_state.x]);
+    *textptr |= 0x80;
+    CTK_WIDGET_REDRAW(&(editor_state.labels[editor_state.y]));
+    /*  } else if(s == ctk_signal_widget_activate &&
+	    data == (ek_data_t)t) {
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr &= 0x7f;
+    t->xpos = 0;
+    if(t->ypos < t->label.h - 1) {
+      ++t->ypos;
+    }
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr |= 0x80;
+    CTK_WIDGET_REDRAW(&t->label);*/ 
+  
+
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+open_file(char *name)
+{
+  int fd;
+  struct line *l;
+  char line[LINE_LEN];
+  char *cptr;
+  int i, len, clen;
+  
+  fd = cfs_open(name, 0);
+  if(fd < 0) {
+    show_statustext("Could not open file ", name);
+    return;
+  }
+
+  l = lines; 
+  cptr = l->text;
+  clen = LINE_LEN;
+  
+  do {
+    /* Read a portion of the input file */
+    len = cfs_read(fd, line, LINE_LEN);  
+    
+    /* Split the input into lines. */
+    for(i = 0; i < len; ++i) {
+      if(line[i] == ISO_nl ||
+	 clen == 0) {
+	*cptr = 0;
+	l = l->next;
+	if(l != NULL) {
+	  cptr = l->text;
+	  clen = LINE_LEN;
+	} else {
+	  len = -1;
+	  break;
+	}
+      } else {
+	*cptr++ = line[i];
+	--clen;
+      }
+    }
+  } while(len > 0);
+
+
+  cfs_close(fd);
+}
+/*---------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ctk_window_close(&window);
+  ek_exit();
+  LOADER_UNLOAD();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+
+  if(ctk_filedialog_eventhandler(&filedialog, ev, data)) {
+    return;
+  }
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+
+    memb_init(&linesmem);
+   
+    ctk_window_new(&window,
+		   EDITOR_CONF_WIDTH + 2,
+		   EDITOR_CONF_HEIGHT + 3,
+		   "Editor");
+
+    CTK_WIDGET_ADD(&window, &openbutton);
+    CTK_WIDGET_ADD(&window, &statuslabel);
+
+    CTK_WIDGET_FOCUS(&window, &openbutton);
+
+    editor_start();
+    
+    ctk_window_open(&window);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    quit();
+    break;
+  case OPEN_EVENT:
+    /*    printf("Open file '%s'\n", (char *)data);*/
+    open_file((char *)data);
+    ctk_window_redraw(&window);
+    break;
+  default:
+    if(ev == ctk_signal_window_close &&
+       data == (ek_data_t)&window) {
+      quit();
+    } else if(ev == ctk_signal_widget_activate) {
+      if(data == (ek_data_t)&openbutton) {
+	ctk_filedialog_open(&filedialog, "Open", OPEN_EVENT);
+      }      
+    } else {
+      editor_eventhandler(ev, data);
+    }
+  };
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(editor_init, arg)
+{
+  arg_free(arg);
+  id = ek_start(&p);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/email-dsc.c b/contiki/apps/email-dsc.c
new file mode 100644
index 0000000..afb092a
--- /dev/null
+++ b/contiki/apps/email-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: email-dsc.c,v 1.4 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon email_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(email_dsc,
+    "Unfinished e-mail client",
+    "email.prg",
+    email_init,
+    &email_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+  '+', '-', '+',
+  '|', 'v', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon email_icon =
+  {CTK_ICON("E-mail", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/email-dsc.h b/contiki/apps/email-dsc.h
new file mode 100644
index 0000000..21198aa
--- /dev/null
+++ b/contiki/apps/email-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: email-dsc.h,v 1.1 2003/08/11 22:23:39 adamdunkels Exp $
+ *
+ */
+#ifndef __EMAIL_DSC_H__
+#define __EMAIL_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(email_dsc);
+
+#endif /* __EMAIL_DSC_H__ */
diff --git a/contiki/apps/email.c b/contiki/apps/email.c
new file mode 100644
index 0000000..a792e84
--- /dev/null
+++ b/contiki/apps/email.c
@@ -0,0 +1,360 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: email.c,v 1.21 2005/05/05 22:15:49 oliverschmidt Exp $
+ *
+ */
+
+
+#include "ek.h"
+#include "ctk.h"
+#include "smtp.h"
+#include "uiplib.h"
+#include "resolv.h"
+#include "petsciiconv.h"
+#include "loader.h"
+#include "tcpip.h"
+
+#include "ctk-textentry-multiline.h"
+
+#include "email-conf.h"
+
+#include <string.h>
+
+#define MAIL_WIDTH EMAIL_CONF_WIDTH
+#define MAIL_HEIGHT EMAIL_CONF_HEIGHT
+/*
+#define MAIL_WIDTH 37
+#define MAIL_HEIGHT 17
+*/
+
+#if (MAIL_WIDTH - 9) < 39
+#define TEXTENTRY_WIDTH (MAIL_WIDTH - 9)
+#else
+#define TEXTENTRY_WIDTH 39
+#endif
+
+static struct ctk_menu menu;
+unsigned char menuitem_compose, menuitem_setup, menuitem_quit;
+
+/* The main window. */
+static struct ctk_window composewindow;
+
+static struct ctk_separator sep1 =
+ {CTK_SEPARATOR(0, MAIL_HEIGHT + 3, MAIL_WIDTH + 1)};
+static struct ctk_label statuslabel =
+ {CTK_LABEL(7, MAIL_HEIGHT + 4, MAIL_WIDTH - 14, 1, "")};
+
+
+static struct ctk_label tolabel =
+  {CTK_LABEL(0, 0, 3, 1, "To:")};
+static char to[40];
+static struct ctk_textentry totextentry =
+  {CTK_TEXTENTRY(8, 0, TEXTENTRY_WIDTH, 1, to, 39)};
+
+static struct ctk_label cclabel =
+  {CTK_LABEL(0, 1, 3, 1, "Cc:")};
+static char cc[40];
+static struct ctk_textentry cctextentry =
+  {CTK_TEXTENTRY(8, 1, TEXTENTRY_WIDTH, 1, cc, 39)};
+
+static struct ctk_label subjectlabel =
+  {CTK_LABEL(0, 2, 8, 1, "Subject:")};
+static char subject[40];
+static struct ctk_textentry subjecttextentry =
+  {CTK_TEXTENTRY(8, 2, TEXTENTRY_WIDTH, 1, subject, 39)};
+
+static char mail[MAIL_WIDTH * MAIL_HEIGHT];
+struct ctk_textentry mailtextentry =
+  {CTK_TEXTENTRY_INPUT(0, 3, MAIL_WIDTH - 1, MAIL_HEIGHT, mail, MAIL_WIDTH - 1, \
+		       ctk_textentry_multiline_input)};
+
+
+static struct ctk_button sendbutton =
+  {CTK_BUTTON(0, MAIL_HEIGHT + 4, 4, "Send")};
+static struct ctk_button erasebutton =
+  {CTK_BUTTON(MAIL_WIDTH - 6, MAIL_HEIGHT + 4, 5, "Erase")};
+
+/* The "Really erase message?" dialog. */
+static struct ctk_window erasedialog;
+static struct ctk_label erasedialoglabel1 =
+  {CTK_LABEL(2, 1, 22, 1, "Really erase message?")};
+static struct ctk_label erasedialoglabel2 =
+  {CTK_LABEL(0, 2, 26, 1, "All contents will be lost.")};
+static struct ctk_button eraseyesbutton =
+  {CTK_BUTTON(4, 4, 3, "Yes")};
+static struct ctk_button erasenobutton =
+  {CTK_BUTTON(18, 4, 2, "No")};
+
+/* The setup window. */
+static struct ctk_window setupwindow;
+static struct ctk_label fromaddresslabel =
+  {CTK_LABEL(0, 0, 25, 1, "Name and e-mail address")};
+static char fromaddress[40];
+static struct ctk_textentry fromaddresstextentry =
+  {CTK_TEXTENTRY(0, 1, 26, 1, fromaddress, 39)};
+
+static struct ctk_label smtpserverlabel =
+  {CTK_LABEL(0, 3, 20, 1, "Outgoing mailserver")};
+static char smtpserver[40];
+static struct ctk_textentry smtpservertextentry =
+  {CTK_TEXTENTRY(0, 4, 26, 1, smtpserver, 39)};
+
+static struct ctk_label pop3serverlabel =
+  {CTK_LABEL(0, 6, 20, 1, "Incoming mailserver")};
+static char pop3server[40];
+static struct ctk_textentry pop3servertextentry =
+  {CTK_TEXTENTRY(0, 7, 26, 1, pop3server, 39)};
+
+static struct ctk_label pop3userlabel =
+  {CTK_LABEL(0, 9, 20, 1, "Mailserver username")};
+static char pop3user[40];
+static struct ctk_textentry pop3usertextentry =
+  {CTK_TEXTENTRY(0, 10, 26, 1, pop3user, 39)};
+  
+static struct ctk_label pop3passwordlabel =
+  {CTK_LABEL(0, 12, 20, 1, "Mailserver password")};
+static char pop3password[40];
+static struct ctk_textentry pop3passwordtextentry =
+  {CTK_TEXTENTRY(0, 13, 26, 1, pop3password, 39)};
+
+
+static struct ctk_button setupokbutton =
+  {CTK_BUTTON(24, 15, 2, "Ok")};
+
+/*
+static DISPATCHER_SIGHANDLER(email_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("E-mail client", NULL, email_sighandler, smtp_appcall)};
+static ek_id_t id;
+*/
+EK_EVENTHANDLER(email_eventhandler, ev, data);
+EK_PROCESS(p, "E-mail client", EK_PRIO_NORMAL,
+	   email_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+email_quit(void)
+{
+  ctk_window_close(&setupwindow);
+  ctk_window_close(&composewindow);
+  ctk_menu_remove(&menu);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(email_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  } else {
+    ctk_window_open(&composewindow);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+applyconfig(void)
+{
+  u16_t addr[2], *addrptr;
+  char *cptr;
+
+  for(cptr = smtpserver; *cptr != ' ' && *cptr != 0; ++cptr);
+  *cptr = 0;
+  
+  addrptr = &addr[0];
+  if(uiplib_ipaddrconv(smtpserver, (unsigned char *)addr) == 0) {
+    addrptr = resolv_lookup(smtpserver);
+    if(addrptr == NULL) {
+      resolv_query(smtpserver);
+      ctk_label_set_text(&statuslabel, "Resolving host...");
+      return;
+    }
+  }
+  smtp_configure("contiki", addrptr);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+prepare_message(void)
+{
+  /* Convert fields to ASCII. */
+  petsciiconv_toascii(to, sizeof(to));
+  petsciiconv_toascii(cc, sizeof(cc));
+  petsciiconv_toascii(subject, sizeof(subject));  
+  petsciiconv_toascii(mail, sizeof(mail));
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+erase_message(void)
+{
+  CTK_TEXTENTRY_CLEAR(&totextentry);
+  CTK_TEXTENTRY_CLEAR(&cctextentry);
+  CTK_TEXTENTRY_CLEAR(&subjecttextentry);
+  CTK_TEXTENTRY_CLEAR(&mailtextentry);
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(email_sighandler, s, data)*/
+EK_EVENTHANDLER(email_eventhandler, ev, data)
+{
+  struct ctk_widget *w;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == tcpip_event) {
+    smtp_appcall(data);
+  } else if(ev == EK_EVENT_INIT) {
+
+    /* Create the "Really erase message?" dialog. */
+    ctk_dialog_new(&erasedialog, 26, 6);
+    CTK_WIDGET_ADD(&erasedialog, &erasedialoglabel1);
+    CTK_WIDGET_ADD(&erasedialog, &erasedialoglabel2);
+    CTK_WIDGET_ADD(&erasedialog, &eraseyesbutton);
+    CTK_WIDGET_ADD(&erasedialog, &erasenobutton);
+    CTK_WIDGET_FOCUS(&erasedialog, &erasenobutton);
+    
+    /* Create setup window. */
+    ctk_window_new(&setupwindow, 28, 16, "E-mail setup");
+    
+    CTK_WIDGET_ADD(&setupwindow, &fromaddresslabel);
+    CTK_WIDGET_ADD(&setupwindow, &fromaddresstextentry);
+    CTK_WIDGET_ADD(&setupwindow, &smtpserverlabel);
+    CTK_WIDGET_ADD(&setupwindow, &smtpservertextentry);
+    /*	  CTK_WIDGET_ADD(&setupwindow, &pop3serverlabel);*/
+    /*    CTK_WIDGET_ADD(&setupwindow, &pop3servertextentry);*/
+    /*	  CTK_WIDGET_ADD(&setupwindow, &pop3userlabel);*/
+    /*    CTK_WIDGET_ADD(&setupwindow, &pop3usertextentry);*/
+    /*    CTK_WIDGET_ADD(&setupwindow, &pop3passwordlabel);*/
+    /*    CTK_WIDGET_ADD(&setupwindow, &pop3passwordtextentry);*/
+    CTK_WIDGET_ADD(&setupwindow, &setupokbutton);
+
+    CTK_WIDGET_FOCUS(&setupwindow, &fromaddresstextentry);
+    
+
+    /* Create compose window. */
+
+    ctk_window_new(&composewindow, MAIL_WIDTH + 1, MAIL_HEIGHT + 5, "Compose e-mail");
+    
+    CTK_WIDGET_ADD(&composewindow, &tolabel);
+    CTK_WIDGET_ADD(&composewindow, &cclabel);
+    CTK_WIDGET_ADD(&composewindow, &subjectlabel);
+    
+    CTK_WIDGET_ADD(&composewindow, &totextentry);
+    CTK_WIDGET_FOCUS(&composewindow, &totextentry);  
+    CTK_WIDGET_ADD(&composewindow, &cctextentry);  
+    CTK_WIDGET_ADD(&composewindow, &subjecttextentry);
+    
+    CTK_WIDGET_ADD(&composewindow, &mailtextentry);
+    
+    CTK_WIDGET_ADD(&composewindow, &sep1);
+    CTK_WIDGET_ADD(&composewindow, &statuslabel);
+    
+    CTK_WIDGET_ADD(&composewindow, &sendbutton);
+    CTK_WIDGET_ADD(&composewindow, &erasebutton);
+    
+    erase_message();
+
+    /* Create and add the menu */
+    ctk_menu_new(&menu, "E-mail");
+    menuitem_setup = ctk_menuitem_add(&menu, "Setup");
+    menuitem_compose = ctk_menuitem_add(&menu, "Compose");
+    menuitem_quit = ctk_menuitem_add(&menu, "Quit");
+    ctk_menu_add(&menu);
+
+    /* Attach listeners to signals. */
+    /*    dispatcher_listen(ctk_signal_widget_activate);
+    dispatcher_listen(ctk_signal_menu_activate);
+    dispatcher_listen(ctk_signal_window_close);
+
+    dispatcher_listen(ctk_signal_keypress);*/
+    
+    /* Open setup window */
+    ctk_window_open(&setupwindow);
+
+  } else if(ev == ctk_signal_widget_activate) {
+    w = (struct ctk_widget *)data;
+    if(w == (struct ctk_widget *)&sendbutton) {
+      prepare_message();
+      smtp_send(to, cc, fromaddress, subject, mail, MAIL_WIDTH, MAIL_HEIGHT);
+      ctk_label_set_text(&statuslabel, "Sending message...");
+      CTK_WIDGET_REDRAW(&statuslabel);
+    } else if(w == (struct ctk_widget *)&erasebutton) {
+      ctk_dialog_open(&erasedialog);      
+    } else if(w == (struct ctk_widget *)&eraseyesbutton) {
+      erase_message();
+      ctk_dialog_close();
+    } else if(w == (struct ctk_widget *)&erasenobutton) {
+      ctk_dialog_close();
+    } else if(w == (struct ctk_widget *)&setupokbutton) {
+      applyconfig();
+      ctk_window_close(&setupwindow);
+      ctk_window_open(&composewindow);
+    }
+  } else if(ev == ctk_signal_menu_activate) {
+    if((struct ctk_menu *)data == &menu) {
+      if(menu.active == menuitem_compose) {
+	ctk_window_open(&composewindow);
+      } else if(menu.active == menuitem_setup) {
+	ctk_window_open(&setupwindow);
+      } else if(menu.active == menuitem_quit) {
+	email_quit();
+      }
+    }
+  } else if(ev == resolv_event_found) {
+    if(strcmp(data, smtpserver) == 0) {
+      if(resolv_lookup(smtpserver) != NULL) {
+	applyconfig();
+	ctk_label_set_text(&statuslabel, "");
+      } else {
+	ctk_label_set_text(&statuslabel, "Host not found");
+      }
+      CTK_WIDGET_REDRAW(&statuslabel);  
+    }
+  } else if(ev == EK_EVENT_REQUEST_EXIT) {
+    email_quit();
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+smtp_done(unsigned char error)
+{
+  if(error == SMTP_ERR_OK) {
+    ctk_label_set_text(&statuslabel, "Mail sent");
+    erase_message();
+    ctk_window_open(&composewindow);
+  } else {
+    ctk_label_set_text(&statuslabel, "Mail error");
+  }
+  CTK_WIDGET_REDRAW(&statuslabel);  
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/email.h b/contiki/apps/email.h
new file mode 100644
index 0000000..bc0d771
--- /dev/null
+++ b/contiki/apps/email.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: email.h,v 1.2 2004/06/06 05:59:21 adamdunkels Exp $
+ *
+ */
+#ifndef __EMAIL_H__
+#define __EMAIL_H__
+
+void email_init(void);
+
+#endif /* __EMAIL_H__ */
diff --git a/contiki/apps/ftp-dsc.c b/contiki/apps/ftp-dsc.c
new file mode 100644
index 0000000..cf3fdeb
--- /dev/null
+++ b/contiki/apps/ftp-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ftp-dsc.c,v 1.4 2005/04/19 22:00:53 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ftp_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ftp_dsc,
+    "FTP client",
+    "ftp.prg",
+    ftp_init,
+    &ftp_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ftpicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ftpicon_textmap[9] = {
+  'F', 'T', 'P',
+  ' ', ' ', ' ',
+  'F', 'T', 'P'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon ftp_icon =
+  {CTK_ICON("FTP client", ftpicon_bitmap, ftpicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/ftp-dsc.h b/contiki/apps/ftp-dsc.h
new file mode 100644
index 0000000..7803823
--- /dev/null
+++ b/contiki/apps/ftp-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ftp-dsc.h,v 1.1 2004/08/09 20:09:27 adamdunkels Exp $
+ *
+ */
+#ifndef __FTP_DSC_H__
+#define __FTP_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(ftp_dsc);
+
+#endif /* __FTP_DSC_H__ */
diff --git a/contiki/apps/ftp.c b/contiki/apps/ftp.c
new file mode 100644
index 0000000..3203970
--- /dev/null
+++ b/contiki/apps/ftp.c
@@ -0,0 +1,587 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ftp.c,v 1.8 2005/05/08 10:39:08 oliverschmidt Exp $
+ */
+/* Note to self: It would be nice to have a "View" option in the download dialog. */
+
+#include "ftpc.h"
+#include "contiki.h"
+#include "ctk.h"
+#include "cfs.h"
+#include <string.h>
+
+#define MAX_USERNAMELEN 16
+#define MAX_PASSWORDLEN 16
+#define MAX_HOSTNAMELEN 32
+#define MAX_FILENAMELEN 16
+#define FILES_WIDTH 17
+#define FILES_HEIGHT 18
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "FTP client", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static void *connection;
+
+/*  ---  The main window --- */
+
+static struct ctk_window window;
+
+static struct ctk_label localtextlabel =
+  {CTK_LABEL(1, 0, FILES_WIDTH, 1, "Local files")};
+static struct ctk_label remotetextlabel =
+  {CTK_LABEL(1 + FILES_WIDTH + 1, 0,
+	     FILES_WIDTH, 1, "Remote files")};
+
+static char leftptr[FILES_HEIGHT];
+static struct ctk_label leftptrlabel =
+  {CTK_LABEL(0, 1, 1, FILES_HEIGHT, leftptr)};
+static char midptr[FILES_HEIGHT];
+static struct ctk_label midptrlabel =
+  {CTK_LABEL(1 + FILES_WIDTH, 1, 1, FILES_HEIGHT, midptr)};
+static char rightptr[FILES_HEIGHT];
+static struct ctk_label rightptrlabel =
+   {CTK_LABEL(1 + FILES_WIDTH + 1 + FILES_WIDTH, 1,
+	      1, FILES_HEIGHT, rightptr)};
+
+static char localfiles[FILES_WIDTH * FILES_HEIGHT];
+static struct ctk_label localfileslabel =
+  {CTK_LABEL(1, 1,
+	     FILES_WIDTH, FILES_HEIGHT, localfiles)};
+static char remotefiles[FILES_WIDTH * FILES_HEIGHT];
+static struct ctk_label remotefileslabel =
+  {CTK_LABEL(FILES_WIDTH + 1 + 1, 1,
+	     FILES_WIDTH, FILES_HEIGHT, remotefiles)};
+
+static struct ctk_button reloadbutton =
+  {CTK_BUTTON(0, 1 + FILES_HEIGHT, 6, "Reload")};
+
+static struct ctk_button connectionbutton =
+  {CTK_BUTTON(8, 1 + FILES_HEIGHT, 13, "Connection...")};
+static struct ctk_button quitbutton =
+  {CTK_BUTTON(1 + FILES_WIDTH + 1 + FILES_WIDTH - 5,
+	      1 + FILES_HEIGHT, 4, "Quit")};
+
+static char statustext[3 + FILES_WIDTH * 2 + 1];
+static struct ctk_label statuslabel =
+  {CTK_LABEL(0, FILES_HEIGHT + 2, 3 + FILES_WIDTH * 2, 1, statustext)};
+
+
+
+/*  ---  The download/upload dialogs --- */
+static char remotefilename[MAX_FILENAMELEN + 1];
+static char localfilename[MAX_FILENAMELEN + 1];
+
+static struct ctk_window dialog;
+static struct ctk_label downloadlabel =
+  {CTK_LABEL(6, 1, 13, 1, "Download file")};
+static struct ctk_label uploadlabel =
+  {CTK_LABEL(7, 1, 11, 1, "Upload file")};
+static struct ctk_label localfilenametextlabel =
+  {CTK_LABEL(2, 3, 15, 1, "Local filename")};
+static struct ctk_label localfilenamelabel =
+  {CTK_LABEL(3, 5, 16, 1, localfilename)};
+static struct ctk_textentry localfilenameentry =
+  {CTK_TEXTENTRY(2, 5, 16, 1, localfilename, sizeof(localfilename) - 1)};
+static struct ctk_label remotefilenametextlabel =
+  {CTK_LABEL(2, 7, 15, 1, "Remote filename")};
+static struct ctk_label remotefilenamelabel =
+  {CTK_LABEL(3, 9, 16, 1, remotefilename)};
+static struct ctk_textentry remotefilenameentry =
+  {CTK_TEXTENTRY(2, 9, 16, 1, remotefilename, sizeof(remotefilename) - 1)};
+static struct ctk_button downloadbutton =
+  {CTK_BUTTON(0, 11, 13, "Download file")};
+static struct ctk_button uploadbutton =
+  {CTK_BUTTON(0, 11, 11, "Upload file")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(16, 11, 6, "Cancel")};
+  
+/*  ---  The connection window --- */
+static char hostname[MAX_HOSTNAMELEN + 1];
+static char username[MAX_USERNAMELEN + 1];
+static char password[MAX_PASSWORDLEN + 1];
+
+static struct ctk_window connectionwindow;
+static struct ctk_label serverlabel =
+  {CTK_LABEL(0, 1, 10, 1, "FTP server")};
+static struct ctk_textentry serverentry =
+  {CTK_TEXTENTRY(0, 2, 16, 1, hostname, MAX_HOSTNAMELEN)};
+
+static struct ctk_button anonymousbutton =
+  {CTK_BUTTON(10, 4, 9, "Anonymous")};
+static struct ctk_label userlabel =
+  {CTK_LABEL(0, 4, 8, 1, "Username")};
+static struct ctk_textentry userentry =
+  {CTK_TEXTENTRY(0, 5, 16, 1, username, sizeof(username) - 1)};
+static struct ctk_label passwordlabel =
+  {CTK_LABEL(0, 7, 8, 1, "Password")};
+static struct ctk_textentry passwordentry =
+  {CTK_TEXTENTRY(0, 8, 16, 1, password, sizeof(password) - 1)};
+
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(0, 10, 7, "Connect")};
+static struct ctk_button closeconnectionbutton =
+  {CTK_BUTTON(0, 10, 16, "Close connection")};
+
+static struct ctk_button closebutton =
+  {CTK_BUTTON(18, 10, 5, "Close")};
+
+static struct cfs_dir dir;
+static struct cfs_dirent dirent;
+static unsigned char localfileptr = 0;
+
+static unsigned char remotefileptr = 0;
+
+static unsigned char ptrstate;
+#define PTRSTATE_LOCALFILES 0
+#define PTRSTATE_REMOTEFILES 1
+static unsigned char localptr, remoteptr;
+
+static int fd = -1;
+
+/*---------------------------------------------------------------------------*/
+static void
+make_uploaddialog(void)
+{
+  ctk_dialog_new(&dialog, 24, 13);
+
+  CTK_WIDGET_ADD(&dialog, &uploadlabel);
+  CTK_WIDGET_ADD(&dialog, &localfilenametextlabel);
+  CTK_WIDGET_ADD(&dialog, &localfilenamelabel);
+  CTK_WIDGET_ADD(&dialog, &remotefilenametextlabel);
+  CTK_WIDGET_ADD(&dialog, &remotefilenameentry);
+  CTK_WIDGET_ADD(&dialog, &uploadbutton);
+  CTK_WIDGET_ADD(&dialog, &cancelbutton);  
+
+  CTK_WIDGET_FOCUS(&dialog, &uploadbutton);
+}
+/*---------------------------------------------------------------------------*/
+static void
+make_downloaddialog(void)
+{
+  ctk_dialog_new(&dialog, 24, 13);
+
+  CTK_WIDGET_ADD(&dialog, &downloadlabel);
+  CTK_WIDGET_ADD(&dialog, &localfilenametextlabel);
+  CTK_WIDGET_ADD(&dialog, &localfilenameentry);
+  CTK_WIDGET_ADD(&dialog, &remotefilenametextlabel);
+  CTK_WIDGET_ADD(&dialog, &remotefilenamelabel);
+  CTK_WIDGET_ADD(&dialog, &downloadbutton);
+  CTK_WIDGET_ADD(&dialog, &cancelbutton);
+
+  CTK_WIDGET_FOCUS(&dialog, &downloadbutton);
+}
+/*---------------------------------------------------------------------------*/
+static void
+show_statustext(char *text1, char *text2)
+{
+  int len;
+
+  len = strlen(text1);
+  if(len < sizeof(statustext)) {
+    strncpy(statustext, text1, sizeof(statustext));
+    strncpy(statustext + len, text2, sizeof(statustext) - len);
+    CTK_WIDGET_REDRAW(&statuslabel);
+  }  
+  
+}
+/*---------------------------------------------------------------------------*/
+static void
+close_file(void)
+{
+  if(fd != -1) {
+    cfs_close(fd);
+    fd = -1;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  close_file();
+  ctk_window_close(&window);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*---------------------------------------------------------------------------*/
+static void
+clearptr(void)
+{
+  rightptr[remoteptr] = ' ';
+  midptr[remoteptr] = ' ';
+  leftptr[localptr] = ' ';
+  midptr[localptr] = ' ';    
+}
+/*---------------------------------------------------------------------------*/
+static void
+showptr(void)
+{
+  if(ptrstate == PTRSTATE_LOCALFILES) {
+    rightptr[remoteptr] = ' ';
+    midptr[remoteptr] = ' ';
+    leftptr[localptr] = '>';
+    midptr[localptr] = '<';
+  } else {
+    leftptr[localptr] = ' ';
+    midptr[localptr] = ' ';    
+    rightptr[remoteptr] = '<';
+    midptr[remoteptr] = '>';
+  }
+
+  CTK_WIDGET_REDRAW(&leftptrlabel);
+  CTK_WIDGET_REDRAW(&midptrlabel);
+  CTK_WIDGET_REDRAW(&rightptrlabel);
+}
+/*---------------------------------------------------------------------------*/
+static void
+start_loaddir(void)
+{
+  memset(localfiles, 0, sizeof(localfiles));
+  localfileptr = 0;
+  cfs_opendir(&dir, ".");
+  ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+}
+/*---------------------------------------------------------------------------*/
+static void
+start_loadremote(void)
+{
+  memset(remotefiles, 0, sizeof(remotefiles));
+  remotefileptr = 0;
+  clearptr();
+  remoteptr = 0;
+  showptr();
+  ftpc_list(connection);
+}
+/*---------------------------------------------------------------------------*/
+static void
+make_connectionwindow(void)
+{
+  ctk_dialog_new(&connectionwindow, 25, 11);
+  
+  CTK_WIDGET_ADD(&connectionwindow, &serverlabel);
+  CTK_WIDGET_ADD(&connectionwindow, &serverentry);
+  
+  CTK_WIDGET_ADD(&connectionwindow, &userlabel);
+  CTK_WIDGET_ADD(&connectionwindow, &anonymousbutton);
+  CTK_WIDGET_ADD(&connectionwindow, &userentry);
+  CTK_WIDGET_ADD(&connectionwindow, &passwordlabel);
+  CTK_WIDGET_ADD(&connectionwindow, &passwordentry);
+  
+  if(connection == NULL) {
+    CTK_WIDGET_ADD(&connectionwindow, &connectbutton);
+  } else {
+    CTK_WIDGET_ADD(&connectionwindow, &closeconnectionbutton);
+  }
+  CTK_WIDGET_ADD(&connectionwindow, &closebutton);
+
+  CTK_WIDGET_FOCUS(&connectionwindow, &serverentry);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t ipaddr[2], *ipaddrptr;
+  
+  switch(ev) {
+    
+  case EK_EVENT_INIT:
+    ftpc_init();
+
+    memset(statustext, 0, sizeof(statustext));
+    memset(remotefiles, 0, sizeof(remotefiles));
+    memset(localfiles, 0, sizeof(localfiles));
+    memset(leftptr, 0, sizeof(leftptr));
+    memset(midptr, 0, sizeof(midptr));	    
+    memset(rightptr, 0, sizeof(rightptr));
+
+    ptrstate = PTRSTATE_REMOTEFILES;
+    localptr = remoteptr = 0;
+
+    connection = NULL;
+    
+    ctk_window_new(&window,
+		   3 + FILES_WIDTH * 2, 3 + FILES_HEIGHT,
+		   "FTP Client");
+
+    CTK_WIDGET_ADD(&window, &localtextlabel);
+    CTK_WIDGET_ADD(&window, &remotetextlabel);
+    
+    CTK_WIDGET_ADD(&window, &leftptrlabel);
+    CTK_WIDGET_ADD(&window, &localfileslabel);
+    CTK_WIDGET_ADD(&window, &midptrlabel);
+    CTK_WIDGET_ADD(&window, &remotefileslabel);
+    CTK_WIDGET_ADD(&window, &rightptrlabel);
+
+    CTK_WIDGET_ADD(&window, &reloadbutton);
+    CTK_WIDGET_ADD(&window, &connectionbutton);
+    CTK_WIDGET_ADD(&window, &quitbutton);
+    
+    CTK_WIDGET_ADD(&window, &statuslabel);
+
+    CTK_WIDGET_FOCUS(&window, &connectionbutton);
+    ctk_window_open(&window);
+
+    showptr();
+
+    start_loaddir();
+    
+    break;
+  case EK_EVENT_CONTINUE:
+    if(cfs_readdir(&dir, &dirent) == 0 &&
+       localfileptr < FILES_HEIGHT) {
+      strncpy(&localfiles[localfileptr * FILES_WIDTH],
+	      dirent.name, FILES_WIDTH);
+      CTK_WIDGET_REDRAW(&localfileslabel);
+      ++localfileptr;
+      ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+    } else{
+      cfs_closedir(&dir);
+    }   
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    quit();
+    break;
+  default:
+    if(ev == tcpip_event) {
+      ftpc_appcall(data);
+    } else if(ev == resolv_event_found) {
+      /* Either found a hostname, or not. */
+      if((char *)data != NULL &&
+	 (ipaddrptr = resolv_lookup((char *)data)) != NULL) {
+	connection = ftpc_connect(ipaddrptr, HTONS(21));
+	show_statustext("Connecting to ", hostname);
+      } else {
+	show_statustext("Host not found: ", hostname);
+      }
+      
+    } else if(ev == ctk_signal_window_close &&
+	      data == (ek_data_t)&window) {
+      quit();
+    } else if(ev == ctk_signal_widget_activate) {
+      if((struct ctk_button *)data == &quitbutton) {
+	quit();
+      } else if((struct ctk_button *)data == &cancelbutton) {
+	ctk_dialog_close();
+      } else if((struct ctk_button *)data == &downloadbutton) {
+	ctk_dialog_close();
+	close_file();
+	fd = cfs_open(localfilename, CFS_WRITE);
+	if(fd != -1) {
+	  show_statustext("Downloading ", remotefilename);
+	  ftpc_get(connection, remotefilename);
+	} else {
+	  show_statustext("Could not create ", localfilename);
+	}
+      } else if((struct ctk_button *)data == &reloadbutton) {	
+	start_loaddir();
+      } else if((struct ctk_button *)data == &connectionbutton) {	
+	make_connectionwindow();
+	ctk_dialog_open(&connectionwindow);
+      } else if((struct ctk_button *)data == &closebutton) {
+	ctk_dialog_close();
+      } else if((struct ctk_button *)data == &anonymousbutton) {
+	strcpy(username, "ftp");
+	strcpy(password, "contiki@ftp");
+	CTK_WIDGET_REDRAW(&userentry);
+	CTK_WIDGET_REDRAW(&passwordentry);
+      } else if((struct ctk_button *)data == &closeconnectionbutton) {
+	ctk_dialog_close();
+	ftpc_close(connection);
+      } else if((struct ctk_button *)data == &connectbutton) {
+	ctk_dialog_close();
+	if(uiplib_ipaddrconv(hostname, (unsigned char *)ipaddr) == 0) {
+	  ipaddrptr = resolv_lookup(hostname);
+	  if(ipaddrptr == NULL) {
+	    resolv_query(hostname);
+	    show_statustext("Resolving host ", hostname);
+	    break;
+	  }
+	  connection = ftpc_connect(ipaddrptr, HTONS(21));
+	  show_statustext("Connecting to ", hostname);
+	} else {
+	  connection = ftpc_connect(ipaddr, HTONS(21));
+	  show_statustext("Connecting to ", hostname);
+	}       	
+      } 
+      /*      if((struct ctk_button *)data == &closebutton) {
+	ftpc_close(connection);
+	}*/
+    } else if(ev == ctk_signal_keypress) {
+      /* if((ctk_arch_key_t)data == ' ') {
+	if(ptrstate == PTRSTATE_LOCALFILES) {
+	  ptrstate = PTRSTATE_REMOTEFILES;
+	} else {
+	  ptrstate = PTRSTATE_LOCALFILES;
+	}
+      } else */ if((ctk_arch_key_t)data == CH_CURS_UP) {
+	clearptr();
+	if(ptrstate == PTRSTATE_LOCALFILES) {
+	  if(localptr > 0) {
+	    --localptr;
+	  }
+	} else {
+	  if(remoteptr > 0) {
+	    --remoteptr;
+	  }
+	}
+      } else if((ctk_arch_key_t)data == CH_CURS_DOWN) {
+	clearptr();
+	if(ptrstate == PTRSTATE_LOCALFILES) {
+	  if(localptr < FILES_HEIGHT - 1) {
+	    ++localptr;
+	  }
+	} else {
+	  if(remoteptr < FILES_HEIGHT - 1) {
+	    ++remoteptr;
+	  }
+	}
+      } else if((ctk_arch_key_t)data == CH_ENTER) {	
+	if(ptrstate == PTRSTATE_LOCALFILES) {
+	  strncpy(localfilename,
+		  &localfiles[localptr * FILES_WIDTH], FILES_WIDTH);
+	  strncpy(remotefilename,
+		  &localfiles[localptr * FILES_WIDTH], FILES_WIDTH);
+	  make_uploaddialog();
+	  ctk_dialog_open(&dialog);
+	} else {
+	  strncpy(localfilename,
+		  &remotefiles[remoteptr * FILES_WIDTH], FILES_WIDTH);
+	  strncpy(remotefilename,
+		  &remotefiles[remoteptr * FILES_WIDTH], FILES_WIDTH);
+	  ftpc_cwd(connection, remotefilename);
+	  /*	  make_downloaddialog();
+		  ctk_dialog_open(&dialog);*/
+	}
+      } else if((ctk_arch_key_t)data == 'u') {
+	ftpc_cdup(connection);
+      }
+
+      showptr();
+    }
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ftp_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_closed(void)
+{
+  strcpy(statustext, "Connection closed");
+  CTK_WIDGET_REDRAW(&statuslabel);
+  connection = NULL;
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_aborted(void)
+{
+  strcpy(statustext, "Connection reset");
+  CTK_WIDGET_REDRAW(&statuslabel);
+  connection = NULL;
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_timedout(void)
+{
+  strcpy(statustext, "Connection timed out");
+  CTK_WIDGET_REDRAW(&statuslabel);
+  connection = NULL;
+}
+/*---------------------------------------------------------------------------*/
+char *
+ftpc_username(void)
+{
+  return username;
+}
+/*---------------------------------------------------------------------------*/
+char *
+ftpc_password(void)
+{
+  return password;
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_list_file(char *filename)
+{
+  if(remotefileptr < FILES_HEIGHT && filename != NULL) {
+    strncpy(&remotefiles[remotefileptr * FILES_WIDTH], filename, FILES_WIDTH);
+    CTK_WIDGET_REDRAW(&remotefileslabel);
+    ++remotefileptr;
+  }
+
+  if(filename == NULL) {
+    strcpy(statustext, "Connected");
+    CTK_WIDGET_REDRAW(&statuslabel);  
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_cwd_done(unsigned short status)
+{
+  if(status == FTPC_COMPLETED ||
+     status == FTPC_OK) {
+    start_loadremote();
+  } else {
+    make_downloaddialog();
+    ctk_dialog_open(&dialog);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_connected(void *connection)
+{
+  strcpy(statustext, "Loading remote directory");
+  CTK_WIDGET_REDRAW(&statuslabel);
+
+  start_loadremote();
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_data(u8_t *data, u16_t len)
+{
+  if(data == NULL) {
+    show_statustext("Download complete", "");
+    close_file();
+    start_loaddir();
+  } else {
+    cfs_write(fd, data, len);
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/ftpc.c b/contiki/apps/ftpc.c
new file mode 100644
index 0000000..92e50fb
--- /dev/null
+++ b/contiki/apps/ftpc.c
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ftpc.c,v 1.3 2005/04/17 22:42:33 oliverschmidt Exp $
+ */
+#include "contiki.h"
+#include "ftpc.h"
+
+#include <string.h>
+#include <stdio.h>
+
+#define ISO_nl 0x0a
+#define ISO_cr 0x0d
+
+#define DATAPORT 6510
+
+#define MAX_FILENAMELEN 32
+
+struct ftp_dataconn {
+  unsigned char type;
+  unsigned char conntype;
+#define CONNTYPE_LIST 0
+#define CONNTYPE_FILE 1
+
+  u16_t port;
+  
+  unsigned char filenameptr;
+  char filename[MAX_FILENAMELEN];  
+
+  
+};
+
+struct ftp_connection {
+  unsigned char type;
+#define TYPE_CONTROL 1
+#define TYPE_DATA    2
+#define TYPE_ABORT   3
+#define TYPE_CLOSE   4
+
+  unsigned char state;
+#define STATE_NONE         0
+#define STATE_INITIAL      1  
+#define STATE_SEND_USER    2
+#define STATE_USER_SENT    3
+#define STATE_SEND_PASS    4
+#define STATE_PASS_SENT    5
+#define STATE_SEND_PORT    6
+#define STATE_PORT_SENT    7
+#define STATE_SEND_OPTIONS 8
+#define STATE_OPTION_SENT  9
+#define STATE_CONNECTED   10
+#define STATE_SEND_NLST   11
+#define STATE_NLST_SENT   12
+#define STATE_SEND_RETR   13
+#define STATE_RETR_SENT   14
+  
+#define STATE_SEND_CWD    15
+#define STATE_CWD_SENT    16
+
+#define STATE_SEND_CDUP   17
+#define STATE_CDUP_SENT   18
+
+#define STATE_SEND_QUIT   19
+#define STATE_QUIT_SENT   20
+  
+  unsigned char connected_confirmed;
+  
+  struct ftp_dataconn dataconn;
+  
+  char code[3];
+  unsigned char codeptr;
+
+  unsigned char optionsptr;
+
+  char filename[MAX_FILENAMELEN];
+
+};
+
+#define NUM_OPTIONS 1
+static const struct {
+  unsigned char num;
+  char *commands[NUM_OPTIONS];
+} options = {
+  NUM_OPTIONS,
+  {"TYPE I\r\n"}
+};
+
+static struct ftp_connection *waiting_for_dataconn;
+
+MEMB(connections, sizeof(struct ftp_connection), 1);
+
+/*---------------------------------------------------------------------------*/
+void
+ftpc_init(void)
+{
+  memb_init(&connections);
+  /*  tcp_listen(HTONS(DATAPORT));*/
+}
+/*---------------------------------------------------------------------------*/
+void *
+ftpc_connect(u16_t *ipaddr, u16_t port)
+{
+  struct ftp_connection *c;
+
+  c = (struct ftp_connection *)memb_alloc(&connections);
+  if(c == NULL) {
+    return NULL;
+  }
+  c->type = TYPE_CONTROL;
+  c->state = STATE_INITIAL;
+  c->connected_confirmed = 0;
+  c->codeptr = 0;  
+  c->dataconn.type = TYPE_DATA;
+  c->dataconn.port = DATAPORT;
+  tcp_listen(HTONS(DATAPORT));
+
+  if(tcp_connect(ipaddr, port, c) == NULL) {
+    memb_free(&connections, c);
+    return NULL;
+  }
+
+  return c;  
+}
+/*---------------------------------------------------------------------------*/
+static void
+handle_input(struct ftp_connection *c)
+{
+  int code;
+
+  code = (c->code[0] - '0') * 100 +
+    (c->code[1] - '0') * 10 +
+    (c->code[2] - '0');
+  /*  printf("Handle input code %d state %d\n", code, c->state);*/
+
+  if(c->state == STATE_INITIAL) {
+    if(code == 220) {
+      c->state = STATE_SEND_USER;
+    }
+  } else if(c->state == STATE_USER_SENT) {
+    if(code == 331) {
+      c->state = STATE_SEND_PASS;
+    }
+  } else if(c->state == STATE_PASS_SENT) {
+    if(code == 230) {
+      c->state = STATE_SEND_OPTIONS;
+      c->optionsptr = 0;
+    }
+  } else if(c->state == STATE_PORT_SENT) {
+    c->state = STATE_CONNECTED;
+    if(c->connected_confirmed == 0) {
+      ftpc_connected(c);
+      c->connected_confirmed = 1;
+    }
+  } else if(c->state == STATE_OPTION_SENT) {
+    if(c->optionsptr >= options.num) {
+      c->state = STATE_SEND_PORT;
+    } else {
+      c->state = STATE_SEND_OPTIONS;
+    }
+  } else if((c->state == STATE_NLST_SENT ||
+	     c->state == STATE_RETR_SENT ||
+	     c->state == STATE_CONNECTED)) {
+    if(code == 226 || code == 550) {
+      tcp_unlisten(htons(c->dataconn.port));
+      ++c->dataconn.port;
+      tcp_listen(htons(c->dataconn.port));
+      c->state = STATE_SEND_PORT;
+    }
+
+    if(code == 550) {
+      ftpc_list_file(NULL);
+    }
+  } else if(c->state == STATE_CWD_SENT ||
+	    c->state == STATE_CDUP_SENT) {
+    c->state = STATE_CONNECTED;
+    ftpc_cwd_done(code);
+    /*  } else if(c->state == STATE_) {
+	c->state = STATE_CONNECTED;*/
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+newdata(struct ftp_connection *c)
+{
+  u16_t i;
+  u8_t d;
+  
+  for(i = 0; i < uip_datalen(); ++i) {
+    d = ((char *)uip_appdata)[i];
+    if(c->codeptr < sizeof(c->code)) {
+      c->code[c->codeptr] = d;
+      ++c->codeptr;
+    }
+
+    if(d == ISO_nl) {
+      handle_input(c);
+      c->codeptr = 0;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+acked(struct ftp_connection *c)
+{
+  switch(c->state) {
+  case STATE_SEND_USER:
+    c->state = STATE_USER_SENT;
+    break;
+  case STATE_SEND_PASS:
+    c->state = STATE_PASS_SENT;
+    break;
+  case STATE_SEND_PORT:
+    c->state = STATE_PORT_SENT;
+    break;
+  case STATE_SEND_OPTIONS:
+    ++c->optionsptr;
+    c->state = STATE_OPTION_SENT;
+    break;
+  case STATE_SEND_NLST:
+    c->state = STATE_NLST_SENT;
+    break;
+  case STATE_SEND_RETR:
+    c->state = STATE_RETR_SENT;
+    break;
+  case STATE_SEND_CWD:
+    c->state = STATE_CWD_SENT;
+    break;
+  case STATE_SEND_CDUP:
+    c->state = STATE_CDUP_SENT;
+    break;
+  case STATE_SEND_QUIT:
+    c->state = STATE_QUIT_SENT;
+    uip_close();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+senddata(struct ftp_connection *c)
+{
+  u16_t len;
+  
+  switch(c->state) {
+  case STATE_SEND_USER:
+    strcpy(uip_appdata, "USER ");
+    strncpy(uip_appdata + 5, ftpc_username(), uip_mss() - 7);
+    len = strlen(ftpc_username());
+    strcpy(uip_appdata + 5 + len, "\r\n");
+    uip_send(uip_appdata, len + 2 + 5);
+    break;
+  case STATE_SEND_PASS:
+    strcpy(uip_appdata, "PASS ");
+    strncpy(uip_appdata + 5, ftpc_password(), uip_mss() - 7);
+    len = strlen(ftpc_password());
+    strcpy(uip_appdata + 5 + len, "\r\n");
+    uip_send(uip_appdata, len + 2 + 5);
+    break;
+  case STATE_SEND_PORT:
+    len = sprintf(uip_appdata, "PORT %d,%d,%d,%d,%d,%d\n",
+		  uip_ipaddr1(uip_hostaddr),
+		  uip_ipaddr2(uip_hostaddr),
+		  uip_ipaddr3(uip_hostaddr),
+		  uip_ipaddr4(uip_hostaddr),
+		  (c->dataconn.port) >> 8,
+		  (c->dataconn.port) & 0xff);
+    uip_send(uip_appdata, len);		  
+    break;
+  case STATE_SEND_OPTIONS:
+    len = strlen(options.commands[c->optionsptr]);
+    uip_send(options.commands[c->optionsptr], len);
+    break;
+  case STATE_SEND_NLST:
+    uip_send("NLST\r\n", 6);
+    break;
+  case STATE_SEND_RETR:    
+    len = sprintf(uip_appdata, "RETR %s\r\n", c->filename);
+    uip_send(uip_appdata, len);
+    break;
+  case STATE_SEND_CWD:    
+    len = sprintf(uip_appdata, "CWD %s\r\n", c->filename);
+    uip_send(uip_appdata, len);
+    break;
+  case STATE_SEND_CDUP:
+    uip_send("CDUP\r\n", 6);
+    break;
+  case STATE_SEND_QUIT:
+    uip_send("QUIT\r\n", 6);
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_appcall(void *state)
+{
+  int i, t;
+  struct ftp_connection *c = (struct ftp_connection *)state;
+  struct ftp_dataconn *d = (struct ftp_dataconn *)state;
+    
+  if(uip_connected()) {
+    if(state == NULL) {
+      if(waiting_for_dataconn != NULL) {
+	d = &waiting_for_dataconn->dataconn;
+	waiting_for_dataconn = NULL;
+	tcp_markconn(uip_conn, d);
+	d->filenameptr = 0;
+	
+      } else {
+	uip_abort();
+      }
+    } else {
+      /*      tcp_listen(uip_conn->lport);*/
+      senddata(c);
+    }
+    return;
+  }
+
+  if(c->type == TYPE_ABORT) {
+    uip_abort();
+    return;
+  }
+
+  if(c->type == TYPE_CLOSE) {
+    uip_close();
+    c->type = TYPE_CONTROL;
+    return;
+  }
+
+  if(c->type == TYPE_CONTROL) {
+    if(uip_closed()) {
+      c->dataconn.type = TYPE_ABORT;
+      ftpc_closed();
+      memb_free(&connections, c);
+    }  
+    if(uip_aborted()) {
+      c->dataconn.type = TYPE_ABORT;
+      ftpc_aborted();
+      memb_free(&connections, c);
+    }
+    if(uip_timedout()) {
+      c->dataconn.type = TYPE_ABORT;
+      ftpc_timedout();
+      memb_free(&connections, c);
+    }
+
+
+    if(uip_acked()) {
+      acked(c);
+    }
+    if(uip_newdata()) {
+      newdata(c);
+    }
+    if(uip_rexmit() ||
+       uip_newdata() ||
+     uip_acked()) {
+      senddata(c);
+    } else if(uip_poll()) {    
+      senddata(c);
+    }
+  } else {
+    if(d->conntype == CONNTYPE_LIST) {
+      if(uip_newdata()) {
+	for(i = 0; i < uip_datalen(); ++i) {
+	  t = ((char *)uip_appdata)[i];
+	  
+	  if(d->filenameptr < sizeof(d->filename) - 1 &&
+	     t != ISO_cr &&
+	     t != ISO_nl) {	    
+	    d->filename[d->filenameptr] = t;
+	    ++d->filenameptr;
+	  }
+	  
+	  if(t == ISO_nl) {
+	    d->filename[d->filenameptr] = 0;
+	    ftpc_list_file(d->filename);
+	    d->filenameptr = 0;
+	  }
+
+	}
+      }
+      if(uip_closed()) {
+	ftpc_list_file(NULL);
+      }
+    } else {
+      if(uip_newdata()) {
+	ftpc_data(uip_appdata, uip_datalen());
+	/*	printf("Received %d data bytes: '%s'\n",
+		uip_datalen(), uip_appdata);*/
+      } else if(uip_closed() || uip_timedout() || uip_aborted()) {
+	ftpc_data(NULL, 0);
+      }
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+char
+ftpc_list(void *conn)
+{
+  struct ftp_connection *c;
+
+  c = conn;
+  
+  if(c == NULL ||
+     c->state != STATE_CONNECTED) {
+    return 0;
+  }
+
+  c->state = STATE_SEND_NLST;
+  c->dataconn.conntype = CONNTYPE_LIST;
+  waiting_for_dataconn = c;
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
+char
+ftpc_get(void *conn, char *filename)
+{
+  struct ftp_connection *c;
+
+  c = conn;
+  
+  if(c == NULL ||
+     c->state != STATE_CONNECTED) {
+    return 0;
+  }
+
+  strncpy(c->filename, filename, sizeof(c->filename));
+
+  c->state = STATE_SEND_RETR;
+  c->dataconn.conntype = CONNTYPE_FILE;
+  waiting_for_dataconn = c;
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_close(void *conn)
+{
+  struct ftp_connection *c;
+  
+  c = conn;
+  
+  if(c == NULL) {
+    return;
+  }
+
+  c->type = TYPE_CLOSE;
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_cwd(void *conn, char *dirname)
+{
+  struct ftp_connection *c;
+  
+  c = conn;
+  
+  if(c == NULL ||
+     c->state != STATE_CONNECTED) {
+    return;
+  }
+
+  strncpy(c->filename, dirname, sizeof(c->filename));
+  c->state = STATE_SEND_CWD;  
+}
+/*---------------------------------------------------------------------------*/
+void
+ftpc_cdup(void *conn)
+{
+  struct ftp_connection *c;
+  
+  c = conn;
+  
+  if(c == NULL ||
+     c->state != STATE_CONNECTED) {
+    return;
+  }
+  
+  c->state = STATE_SEND_CDUP;  
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/ftpc.h b/contiki/apps/ftpc.h
new file mode 100644
index 0000000..71b0536
--- /dev/null
+++ b/contiki/apps/ftpc.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ftpc.h,v 1.2 2004/09/12 20:24:54 adamdunkels Exp $
+ */
+#ifndef __FTPC_H__
+#define __FTPC_H__
+
+#include "uip.h"
+
+void ftpc_init(void);
+
+void *ftpc_connect(u16_t *ipaddr, u16_t port);
+char ftpc_list(void *connection);
+void ftpc_cwd(void *connection, char *dir);
+void ftpc_cdup(void *connection);
+char ftpc_get(void *connection, char *filename);
+void ftpc_close(void *connection);
+
+
+void ftpc_appcall(void *state);
+
+#define FTPC_OK        200
+#define FTPC_COMPLETED 250
+#define FTPC_NODIR     431
+#define FTPC_NOTDIR    550
+
+/* Functions to be implemented by the calling module: */
+void ftpc_connected(void *connection);
+void ftpc_cwd_done(unsigned short status);
+char *ftpc_username(void);
+char *ftpc_password(void);
+void ftpc_closed(void);
+void ftpc_aborted(void);
+void ftpc_timedout(void);
+void ftpc_list_file(char *filename);
+void ftpc_data(u8_t *data, u16_t len);
+
+#endif /* __FTPC_H__ */
diff --git a/contiki/apps/html-strings b/contiki/apps/html-strings
new file mode 100644
index 0000000..e3c43c9
--- /dev/null
+++ b/contiki/apps/html-strings
@@ -0,0 +1,36 @@
+html_slasha "/a\0"
+html_slashcenter "/center\0"
+html_slashform "/form\0"
+html_slashh "/h\0"
+html_slashscript "/script\0"
+html_slashselect "/select\0"
+html_slashstyle "/style\0"
+html_a "a\0"
+html_body "body\0"
+html_br "br\0"
+html_center "center\0"
+html_form "form\0"
+html_frame "frame\0"
+html_h1 "h1\0"
+html_h2 "h2\0"
+html_h3 "h3\0"
+html_h4 "h4\0"
+html_img "img\0"
+html_input "input\0"
+html_li "li\0"
+html_p "p\0"
+html_script "script\0"
+html_select "select\0"
+html_style "style\0"
+html_tr "tr\0"
+html_href "href\0"
+html_alt "alt\0"
+html_src "src\0"
+html_type "type\0"
+html_submit "submit\0"
+html_value "value\0"
+html_action "action\0"
+html_name "name\0"
+html_text "text\0"
+html_size "size\0"
+html_image "image\0"
\ No newline at end of file
diff --git a/contiki/apps/html-strings.c b/contiki/apps/html-strings.c
new file mode 100644
index 0000000..e4062ec
--- /dev/null
+++ b/contiki/apps/html-strings.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: html-strings.c,v 1.3 2004/09/12 20:24:54 adamdunkels Exp $
+ */
+const char html_slasha[4] = 
+/* "/a\0" */
+{0x2f, 0x61, 00, };
+const char html_slashcenter[9] = 
+/* "/center\0" */
+{0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
+const char html_slashform[7] = 
+/* "/form\0" */
+{0x2f, 0x66, 0x6f, 0x72, 0x6d, 00, };
+const char html_slashh[4] = 
+/* "/h\0" */
+{0x2f, 0x68, 00, };
+const char html_slashscript[9] = 
+/* "/script\0" */
+{0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 00, };
+const char html_slashselect[9] = 
+/* "/select\0" */
+{0x2f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 00, };
+const char html_slashstyle[8] = 
+/* "/style\0" */
+{0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 00, };
+const char html_a[3] = 
+/* "a\0" */
+{0x61, 00, };
+const char html_body[6] = 
+/* "body\0" */
+{0x62, 0x6f, 0x64, 0x79, 00, };
+const char html_br[4] = 
+/* "br\0" */
+{0x62, 0x72, 00, };
+const char html_center[8] = 
+/* "center\0" */
+{0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 00, };
+const char html_form[6] = 
+/* "form\0" */
+{0x66, 0x6f, 0x72, 0x6d, 00, };
+const char html_frame[7] = 
+/* "frame\0" */
+{0x66, 0x72, 0x61, 0x6d, 0x65, 00, };
+const char html_h1[4] = 
+/* "h1\0" */
+{0x68, 0x31, 00, };
+const char html_h2[4] = 
+/* "h2\0" */
+{0x68, 0x32, 00, };
+const char html_h3[4] = 
+/* "h3\0" */
+{0x68, 0x33, 00, };
+const char html_h4[4] = 
+/* "h4\0" */
+{0x68, 0x34, 00, };
+const char html_img[5] = 
+/* "img\0" */
+{0x69, 0x6d, 0x67, 00, };
+const char html_input[7] = 
+/* "input\0" */
+{0x69, 0x6e, 0x70, 0x75, 0x74, 00, };
+const char html_li[4] = 
+/* "li\0" */
+{0x6c, 0x69, 00, };
+const char html_p[3] = 
+/* "p\0" */
+{0x70, 00, };
+const char html_script[8] = 
+/* "script\0" */
+{0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 00, };
+const char html_select[8] = 
+/* "select\0" */
+{0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 00, };
+const char html_style[7] = 
+/* "style\0" */
+{0x73, 0x74, 0x79, 0x6c, 0x65, 00, };
+const char html_tr[4] = 
+/* "tr\0" */
+{0x74, 0x72, 00, };
+const char html_href[6] = 
+/* "href\0" */
+{0x68, 0x72, 0x65, 0x66, 00, };
+const char html_alt[5] = 
+/* "alt\0" */
+{0x61, 0x6c, 0x74, 00, };
+const char html_src[5] = 
+/* "src\0" */
+{0x73, 0x72, 0x63, 00, };
+const char html_type[6] = 
+/* "type\0" */
+{0x74, 0x79, 0x70, 0x65, 00, };
+const char html_submit[8] = 
+/* "submit\0" */
+{0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 00, };
+const char html_value[7] = 
+/* "value\0" */
+{0x76, 0x61, 0x6c, 0x75, 0x65, 00, };
+const char html_action[8] = 
+/* "action\0" */
+{0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 00, };
+const char html_name[6] = 
+/* "name\0" */
+{0x6e, 0x61, 0x6d, 0x65, 00, };
+const char html_text[6] = 
+/* "text\0" */
+{0x74, 0x65, 0x78, 0x74, 00, };
+const char html_size[6] = 
+/* "size\0" */
+{0x73, 0x69, 0x7a, 0x65, 00, };
+const char html_image[7] = 
+/* "image\0" */
+{0x69, 0x6d, 0x61, 0x67, 0x65, 00, };
diff --git a/contiki/apps/html-strings.h b/contiki/apps/html-strings.h
new file mode 100644
index 0000000..5f53c44
--- /dev/null
+++ b/contiki/apps/html-strings.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: html-strings.h,v 1.3 2004/09/12 20:24:54 adamdunkels Exp $
+ */
+extern const char html_slasha[4];
+extern const char html_slashcenter[9];
+extern const char html_slashform[7];
+extern const char html_slashh[4];
+extern const char html_slashscript[9];
+extern const char html_slashselect[9];
+extern const char html_slashstyle[8];
+extern const char html_a[3];
+extern const char html_body[6];
+extern const char html_br[4];
+extern const char html_center[8];
+extern const char html_form[6];
+extern const char html_frame[7];
+extern const char html_h1[4];
+extern const char html_h2[4];
+extern const char html_h3[4];
+extern const char html_h4[4];
+extern const char html_img[5];
+extern const char html_input[7];
+extern const char html_li[4];
+extern const char html_p[3];
+extern const char html_script[8];
+extern const char html_select[8];
+extern const char html_style[7];
+extern const char html_tr[4];
+extern const char html_href[6];
+extern const char html_alt[5];
+extern const char html_src[5];
+extern const char html_type[6];
+extern const char html_submit[8];
+extern const char html_value[7];
+extern const char html_action[8];
+extern const char html_name[6];
+extern const char html_text[6];
+extern const char html_size[6];
+extern const char html_image[7];
diff --git a/contiki/apps/htmlparser.c b/contiki/apps/htmlparser.c
new file mode 100644
index 0000000..1102e6b
--- /dev/null
+++ b/contiki/apps/htmlparser.c
@@ -0,0 +1,842 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: htmlparser.c,v 1.11 2005/06/12 23:44:29 oliverschmidt Exp $
+ *
+ */
+
+/* htmlparser.c:
+ *
+ * Implements a very simplistic HTML parser. It recognizes HTML links
+ * (<a href>-tags), HTML img alt tags, a few text flow break tags
+G * (<br>, <p>, <h>), the <li> tag (but does not even try to
+ * distinguish between <ol> or <ul>) as well as HTML comment tags
+ * (<!-- -->).
+ *
+ * To save memory, the HTML parser is state machine driver, which
+ * means that it will shave off one character from the HTML page,
+ * process that character, and return to the next. Another way of
+ * doing it would be to buffer a number of characters and process them
+ * together.
+ *
+ * The main function in this file is the htmlparser_parse() function
+ * which takes a htmlparser_state structur and a part of an HTML file
+ * as an argument. The htmlparser_parse() function will call the
+ * helper functions parse_char() and parse_tag(). Those functions will
+ * in turn call the two callback functions htmlparser_char() and
+ * htmlparser_tag(). Those functions must be implemented by the using
+ * module (e.g., a web browser program).
+ *
+ * htmlparser_char() will be called for every non-tag character.
+ *
+ * htmlparser_tag() will be called whenever a full tag has been found.
+ *
+ */
+
+
+#include "htmlparser.h"
+#include "html-strings.h"
+#include "www-conf.h"
+#include "cc.h"
+
+#include <string.h>
+
+#if 1
+#define PRINTF(x)
+#else
+#include <stdio.h>
+#define PRINTF(x) printf x
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+#define ISO_A     0x41
+#define ISO_B     0x42
+#define ISO_E     0x45
+#define ISO_F     0x46
+#define ISO_G     0x47
+#define ISO_H     0x48
+#define ISO_I     0x49
+#define ISO_L     0x4c
+#define ISO_M     0x4d
+#define ISO_P     0x50
+#define ISO_R     0x52
+#define ISO_T     0x54
+
+#define ISO_a     (ISO_A | 0x20)
+#define ISO_b     (ISO_B | 0x20)
+#define ISO_e     (ISO_E | 0x20)
+#define ISO_f     (ISO_F | 0x20)
+#define ISO_g     (ISO_G | 0x20)
+#define ISO_h     (ISO_H | 0x20)
+#define ISO_i     (ISO_I | 0x20)
+#define ISO_l     (ISO_L | 0x20)
+#define ISO_m     (ISO_M | 0x20)
+#define ISO_p     (ISO_P | 0x20)
+#define ISO_r     (ISO_R | 0x20)
+#define ISO_t     (ISO_T | 0x20)
+
+#define ISO_ht    0x09
+#define ISO_nl    0x0a
+#define ISO_cr    0x0d
+#define ISO_space 0x20
+#define ISO_bang  0x21
+#define ISO_citation 0x22
+#define ISO_ampersand 0x26
+#define ISO_citation2 0x27
+#define ISO_asterisk 0x2a
+#define ISO_dash  0x2d
+#define ISO_slash 0x2f
+#define ISO_semicolon  0x3b
+#define ISO_lt    0x3c
+#define ISO_eq    0x3d
+#define ISO_gt    0x3e
+
+#define ISO_rbrack 0x5b
+#define ISO_lbrack 0x5d
+
+#define MINORSTATE_NONE           0
+#define MINORSTATE_TEXT           1 /* Parse normal text */
+#define MINORSTATE_EXTCHAR        2 /* Check for semi-colon */
+#define MINORSTATE_TAG            3 /* Check for name of tag. */
+#define MINORSTATE_TAGEND         4 /* Scan for end of tag. */
+#define MINORSTATE_TAGATTR        5 /* Parse tag attr. */
+#define MINORSTATE_TAGATTRSPACE   6 /* Parse optional space after tag
+				       attr. */
+#define MINORSTATE_TAGATTRPARAM   7 /* Parse tag attr parameter. */
+#define MINORSTATE_TAGATTRPARAMNQ 8 /* Parse tag attr parameter without
+				  quotation marks. */
+#define MINORSTATE_HTMLCOMMENT    9 /* Scan for HTML comment end */
+
+#define MAJORSTATE_NONE       0
+#define MAJORSTATE_BODY       1
+#define MAJORSTATE_LINK       2
+#define MAJORSTATE_FORM       3
+#define MAJORSTATE_DISCARD    4
+
+
+struct htmlparser_state {
+
+  unsigned char minorstate;
+  char tag[20];
+  unsigned char tagptr;
+  char tagattr[20];
+  unsigned char tagattrptr;
+  char tagattrparam[WWW_CONF_MAX_URLLEN];
+  unsigned char tagattrparamptr;
+  unsigned char lastchar, quotechar;
+  unsigned char majorstate, lastmajorstate;
+  char linkurl[WWW_CONF_MAX_URLLEN];
+
+  char word[WWW_CONF_WEBPAGE_WIDTH];
+  unsigned char wordlen;  
+  
+#if WWW_CONF_FORMS
+  char formaction[WWW_CONF_MAX_FORMACTIONLEN];
+  char formname[WWW_CONF_MAX_FORMNAMELEN];
+  unsigned char inputtype;
+  char inputname[WWW_CONF_MAX_INPUTNAMELEN];
+  char inputvalue[WWW_CONF_MAX_INPUTVALUELEN];
+  unsigned char inputvaluesize;
+#endif /* WWW_CONF_FORMS */
+};
+
+static struct htmlparser_state s;
+
+/*-----------------------------------------------------------------------------------*/
+static char last[1] = {0xff};
+
+static const char *tags[] = {
+#define TAG_FIRST       0
+#define TAG_SLASHA      0
+  html_slasha,
+#define TAG_SLASHCENTER 1
+  html_slashcenter,
+#define TAG_SLASHFORM   2
+  html_slashform,
+#define TAG_SLASHH      3
+  html_slashh,
+#define TAG_SLASHSCRIPT 4
+  html_slashscript,
+#define TAG_SLASHSELECT 5
+  html_slashselect,
+#define TAG_SLASHSTYLE  6
+  html_slashstyle,
+#define TAG_A           7
+  html_a,
+#define TAG_BODY        8
+  html_body,
+#define TAG_BR          9
+  html_br,
+#define TAG_CENTER     10 
+  html_center,
+#define TAG_FORM       11
+  html_form,
+#define TAG_FRAME      12    
+  html_frame,
+#define TAG_H1         13  
+  html_h1,
+#define TAG_H2         14
+  html_h2,
+#define TAG_H3         15  
+  html_h3,
+#define TAG_H4         16  
+  html_h4,
+#define TAG_IMG        17  
+  html_img,
+#define TAG_INPUT      18  
+  html_input,
+#define TAG_LI         19
+  html_li,
+#define TAG_P          20
+  html_p,
+#define TAG_SCRIPT     21
+  html_script, 
+#define TAG_SELECT     22
+  html_select,
+#define TAG_STYLE      23
+  html_style,
+#define TAG_TR         24   
+  html_tr,
+#define TAG_LAST       25
+  last,
+};
+
+/*-----------------------------------------------------------------------------------*/
+static unsigned char CC_FASTCALL
+iswhitespace(char c)
+{
+  return (c == ISO_space ||
+	  c == ISO_nl ||
+	  c == ISO_cr ||
+	  c == ISO_ht);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_init(void)
+{
+  s.majorstate = s.lastmajorstate = MAJORSTATE_DISCARD;
+  s.minorstate = MINORSTATE_TEXT;
+  s.lastchar = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static char CC_FASTCALL
+lowercase(char c)
+{
+  /* XXX: This is a *brute force* approach to lower-case
+     converting and should *not* be used anywhere else! It
+     works for our purposes, however (i.e., HTML tags). */
+  if(c > 0x40) {
+    return (c & 0x1f) | 0x60;
+  } else {
+    return c;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void 
+endtagfound(void)
+{
+  s.tag[s.tagptr] = 0;
+  s.tagattr[s.tagattrptr] = 0;
+  s.tagattrparam[s.tagattrparamptr] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+switch_majorstate(unsigned char newstate)
+{
+  if(s.majorstate != newstate) {
+    PRINTF(("Switching state from %d to %d (%d)\n", s.majorstate, newstate, s.lastmajorstate));
+    s.lastmajorstate = s.majorstate;
+    s.majorstate = newstate;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+add_char(unsigned char c)
+{
+  if(s.wordlen < WWW_CONF_WEBPAGE_WIDTH - 1 && c < 0x80) {
+    s.word[s.wordlen] = c;
+    ++s.wordlen;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+do_word(void)
+{
+  if(s.wordlen > 0) {
+    if(s.majorstate == MAJORSTATE_LINK) {
+      if(s.word[s.wordlen] != ISO_space) {
+	add_char(ISO_space);
+      }
+    } else if(s.majorstate == MAJORSTATE_DISCARD) {
+      s.wordlen = 0;
+    } else {
+      s.word[s.wordlen] = '\0';
+      htmlparser_word(s.word, s.wordlen);
+      s.wordlen = 0;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newline(void)
+{
+  do_word();
+  htmlparser_newline();
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char CC_FASTCALL
+find_tag(char *tag)
+{
+  static unsigned char first, last, i, tabi;
+  static char tagc;
+  
+  first = TAG_FIRST;
+  last = TAG_LAST;
+  i = 0;
+  
+  do {
+    tagc = tag[i];
+
+    if(tagc == 0 &&
+       tags[first][i] == 0) {
+      return first;
+    }
+
+    tabi = first;
+    
+    /* First, find first matching tag from table. */
+    while(tagc > (tags[tabi])[i] &&
+	  tabi < last) {
+      ++tabi;
+    }
+    first = tabi;
+    
+    /* Second, find last matching tag from table. */
+    while(tagc == (tags[tabi])[i] &&
+	  tabi < last) {
+      ++tabi;
+    }
+    last = tabi;
+    
+    /* If first and last matching tags are equal, we have a non-match
+       and return. Else we continue with the next character. */
+    ++i;
+
+  } while(last != first);
+  return TAG_LAST;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+parse_tag(void)
+{
+  static char *tagattrparam;
+  static unsigned char size;
+
+  static char dummy;
+  
+  PRINTF(("Parsing tag '%s' '%s' '%s'\n",
+	  s.tag, s.tagattr, s.tagattrparam));
+
+  switch(find_tag(s.tag)) {
+  case TAG_P:
+  case TAG_H1:
+  case TAG_H2:
+  case TAG_H3:
+  case TAG_H4:
+    /*    parse_char(ISO_nl);*/
+    newline();
+    /* FALLTHROUGH */
+  case TAG_BR:
+  case TAG_TR:
+  case TAG_SLASHH:
+    /*    parse_char(ISO_nl);*/
+    dummy = 0;
+    newline();
+    break;
+  case TAG_LI:
+    newline();
+    add_char(ISO_asterisk);
+    add_char(ISO_space);
+    break;
+  case TAG_SCRIPT:
+  case TAG_STYLE:
+  case TAG_SELECT:
+    switch_majorstate(MAJORSTATE_DISCARD);
+    break;
+  case TAG_SLASHSCRIPT:
+  case TAG_SLASHSTYLE:
+  case TAG_SLASHSELECT:
+    do_word();
+    switch_majorstate(s.lastmajorstate);
+    break;
+  case TAG_BODY:
+    s.majorstate = s.lastmajorstate = MAJORSTATE_BODY;
+    break;
+  case TAG_FRAME:
+    if(strncmp(s.tagattr, html_src, sizeof(html_src)) == 0 &&
+       s.tagattrparam[0] != 0) {
+      switch_majorstate(MAJORSTATE_BODY);
+      newline();
+      add_char(ISO_rbrack);
+      do_word();
+      htmlparser_link((char *)html_frame, strlen(html_frame), s.tagattrparam);
+      PRINTF(("Frame [%s]\n", s.tagattrparam));
+      add_char(ISO_lbrack);
+      newline();
+    }
+    break;
+  case TAG_IMG:
+    if(strncmp(s.tagattr, html_alt, sizeof(html_alt)) == 0 &&
+       s.tagattrparam[0] != 0) {
+      /*      parse_char(ISO_lt);*/
+      add_char(ISO_lt);
+      tagattrparam = &s.tagattrparam[0];
+      while(*tagattrparam) {
+	/*	parse_char(*tagattrparam);*/
+	add_char(*tagattrparam);
+	++tagattrparam;
+      }
+      /*      parse_char(ISO_gt);*/
+      add_char(ISO_gt);
+      do_word();
+    }
+    break;
+  case TAG_A:
+    PRINTF(("A %s %s\n", s.tagattr, s.tagattrparam));
+    if(strncmp(s.tagattr, html_href, sizeof(html_href)) == 0 &&
+       s.tagattrparam[0] != 0) {
+      strcpy(s.linkurl, s.tagattrparam);
+      do_word();
+      switch_majorstate(MAJORSTATE_LINK);
+    }
+    break;
+  case TAG_SLASHA:
+    if(s.majorstate == MAJORSTATE_LINK) {
+      switch_majorstate(s.lastmajorstate);
+      s.word[s.wordlen] = 0;
+      htmlparser_link(s.word, s.wordlen, s.linkurl);
+      s.wordlen = 0;
+    }
+    break;
+#if WWW_CONF_FORMS
+  case TAG_FORM:
+    PRINTF(("Form tag\n"));
+    switch_majorstate(MAJORSTATE_FORM);
+    if(strncmp(s.tagattr, html_action, sizeof(html_action)) == 0) {
+      PRINTF(("Form action '%s'\n", s.tagattrparam));
+      strncpy(s.formaction, s.tagattrparam, WWW_CONF_MAX_FORMACTIONLEN - 1);
+    } else if(strncmp(s.tagattr, html_name, sizeof(html_name)) == 0) {
+      PRINTF(("Form name '%s'\n", s.tagattrparam));
+      strncpy(s.formname, s.tagattrparam, WWW_CONF_MAX_FORMNAMELEN - 1);
+    }
+    s.inputname[0] = s.inputvalue[0] = 0;
+    break;
+  case TAG_SLASHFORM:
+    switch_majorstate(MAJORSTATE_BODY);
+    s.formaction[0] = s.formname[0] = 0;
+    break;
+  case TAG_INPUT:
+    if(s.majorstate == MAJORSTATE_FORM) {
+      /* First check if we are called at the end of an input tag. If
+	 so, we should render the input widget. */
+      if(s.tagattr[0] == 0 &&
+	 s.inputname[0] != 0) {
+	PRINTF(("Render input type %d\n", s.inputtype));
+	switch(s.inputtype) {
+	case HTMLPARSER_INPUTTYPE_NONE:
+	case HTMLPARSER_INPUTTYPE_TEXT:
+	  s.inputvalue[s.inputvaluesize] = 0;
+	  htmlparser_inputfield(s.inputvaluesize, s.inputvalue, s.inputname,
+				s.formname, s.formaction);
+	  break;
+	case HTMLPARSER_INPUTTYPE_SUBMIT:
+	case HTMLPARSER_INPUTTYPE_IMAGE:
+	  htmlparser_submitbutton(s.inputvalue, s.inputname,
+				  s.formname, s.formaction);
+	  break;
+	}
+	s.inputtype = HTMLPARSER_INPUTTYPE_NONE;
+      } else {
+	PRINTF(("Input '%s' '%s'\n", s.tagattr, s.tagattrparam));
+	if(strncmp(s.tagattr, html_type, sizeof(html_type)) == 0) {
+	  if(strncmp(s.tagattrparam, html_submit,
+		     sizeof(html_submit)) == 0) {
+	    s.inputtype = HTMLPARSER_INPUTTYPE_SUBMIT;
+	  } else if(strncmp(s.tagattrparam, html_image,
+			    sizeof(html_image)) == 0) {
+	    s.inputtype = HTMLPARSER_INPUTTYPE_IMAGE;
+	  } else if(strncmp(s.tagattrparam, html_text,
+			    sizeof(html_text)) == 0) {
+	    s.inputtype = HTMLPARSER_INPUTTYPE_TEXT;
+	  } else {
+	    s.inputtype = HTMLPARSER_INPUTTYPE_OTHER;
+	  }
+	} else if(strncmp(s.tagattr, html_name,
+			  sizeof(html_name)) == 0) {
+	  strncpy(s.inputname, s.tagattrparam,
+		  WWW_CONF_MAX_INPUTNAMELEN);
+	} else if(strncmp(s.tagattr, html_alt,
+			  sizeof(html_alt)) == 0 &&
+		  s.inputtype == HTMLPARSER_INPUTTYPE_IMAGE) {	  
+	  strncpy(s.inputvalue, s.tagattrparam,
+		  WWW_CONF_MAX_INPUTVALUELEN);	  
+	} else if(strncmp(s.tagattr, html_value,
+			  sizeof(html_value)) == 0) {
+	  strncpy(s.inputvalue, s.tagattrparam,
+		  WWW_CONF_MAX_INPUTVALUELEN);
+	} else if(strncmp(s.tagattr, html_size,
+			  sizeof(html_size)) == 0) {
+	  size = 0;
+	  if(s.tagattrparam[0] >= '0' &&
+	     s.tagattrparam[0] <= '9') {
+	    size = s.tagattrparam[0] - '0';
+	    if(s.tagattrparam[1] >= '0' &&
+	       s.tagattrparam[1] <= '9') {
+	      size = size * 10 + (s.tagattrparam[1] - '0');
+	    }
+	  }
+	  if(size >= WWW_CONF_MAX_INPUTVALUELEN) {
+	    size = WWW_CONF_MAX_INPUTVALUELEN - 1;
+	  }
+	  s.inputvaluesize = size;
+	  /*	  strncpy(s.inputvalue, s.tagattrparam,
+		  WWW_CONF_MAX_INPUTVALUELEN);*/
+	}
+      }
+      
+    }
+    break;
+#endif /* WWW_CONF_FORMS */    
+#if WWW_CONF_RENDERSTATE
+  case TAG_CENTER:
+    /*    parse_char(ISO_nl);    */
+    newline();
+    htmlparser_renderstate(HTMLPARSER_RENDERSTATE_BEGIN |
+			   HTMLPARSER_RENDERSTATE_CENTER);
+    break;
+  case TAG_SLASHCENTER:
+    /*    parse_char(ISO_nl);*/
+    newline();
+    htmlparser_renderstate(HTMLPARSER_RENDERSTATE_END |
+			   HTMLPARSER_RENDERSTATE_CENTER);
+    break;
+#endif /* WWW_CONF_RENDERSTATE */
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_word(char *data, u8_t dlen)
+{
+  static u8_t i;
+  static u8_t len;
+  unsigned char c;
+
+  len = dlen;
+
+  switch(s.minorstate) {
+  case MINORSTATE_TEXT:
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(iswhitespace(c)) {
+	do_word();
+      } else if(c == ISO_lt) {
+	s.minorstate = MINORSTATE_TAG;
+	s.tagptr = 0;
+	/*	do_word();*/
+	break;
+      } else if(c == ISO_ampersand) {
+	s.minorstate = MINORSTATE_EXTCHAR;
+	break;
+      } else {
+	add_char(c);
+      }
+    }
+    break;
+  case MINORSTATE_EXTCHAR:
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == ISO_semicolon) {	
+	s.minorstate = MINORSTATE_TEXT;
+	add_char(' ');
+	break;
+      } else if(iswhitespace(c)) {	
+	s.minorstate = MINORSTATE_TEXT;
+	add_char('&');
+	add_char(' ');
+	break;
+      }
+    }
+    break;
+  case MINORSTATE_TAG:
+    /* We are currently parsing within the name of a tag. We check
+       for the end of a tag (the '>' character) or whitespace (which
+       indicates that we should parse a tag attr argument
+       instead). */
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == ISO_gt) {
+	/* Full tag found. We continue parsing regular text. */
+	s.minorstate = MINORSTATE_TEXT;
+	s.tagattrptr = s.tagattrparamptr = 0;
+	endtagfound();	  
+	parse_tag();
+	break;
+      } else if(iswhitespace(c)) {
+	/* The name of the tag found. We continue parsing the tag
+	   attr.*/
+	s.minorstate = MINORSTATE_TAGATTR;
+	s.tagattrptr = 0;
+	endtagfound();
+	break;
+      } else {
+	/* Keep track of the name of the tag, but convert it to
+	   lower case. */
+	  
+	s.tag[s.tagptr] = lowercase(c);
+	++s.tagptr;
+	/* Check if the ->tag field is full. If so, we just eat up
+	   any data left in the tag. */
+	if(s.tagptr == sizeof(s.tag)) {
+	  s.minorstate = MINORSTATE_TAGEND;
+	  break;
+	}
+      }
+	
+      /* Check for HTML comment, indicated by <!-- */
+      if(s.tagptr == 3 &&
+	 s.tag[0] == ISO_bang &&
+	 s.tag[1] == ISO_dash &&
+	 s.tag[2] == ISO_dash) {
+	PRINTF(("Starting comment...\n"));
+	s.minorstate = MINORSTATE_HTMLCOMMENT;
+	s.tagptr = 0;
+	endtagfound();
+	break;
+      }
+    }
+    break;
+  case MINORSTATE_TAGATTR:
+    /* We parse the "tag attr", i.e., the "href" in <a
+       href="...">. */
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == ISO_gt) {
+	/* Full tag found. */
+	s.minorstate = MINORSTATE_TEXT;
+	s.tagattrparamptr = 0;
+	s.tagattrptr = 0;
+	endtagfound();
+	parse_tag();
+	s.tagptr = 0;
+	endtagfound();
+	break;
+      } else if(iswhitespace(c)) {
+	if(s.tagattrptr == 0) {
+	  /* Discard leading spaces. */
+	} else {
+	  /* A non-leading space is the end of the attribute. */
+	  s.tagattrparamptr = 0;
+	  endtagfound();
+	  parse_tag();
+	  s.minorstate = MINORSTATE_TAGATTRSPACE;
+	  break;
+	  /*	    s.tagattrptr = 0;
+		    endtagfound();*/
+	}
+      } else if(c == ISO_eq) {	
+	s.minorstate = MINORSTATE_TAGATTRPARAMNQ;
+	s.tagattrparamptr = 0;
+	endtagfound();
+	break;
+      } else {
+	s.tagattr[s.tagattrptr] = lowercase(c);
+	++s.tagattrptr;
+	/* Check if the "tagattr" field is full. If so, we just eat
+	   up any data left in the tag. */
+	if(s.tagattrptr == sizeof(s.tagattr)) {
+	  s.minorstate = MINORSTATE_TAGEND;
+	  break;
+	}
+      }
+    }
+    break;
+  case MINORSTATE_TAGATTRSPACE:
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(iswhitespace(c)) {
+	/* Discard spaces. */
+      } else if(c == ISO_eq) {
+	s.minorstate = MINORSTATE_TAGATTRPARAMNQ;
+	s.tagattrparamptr = 0;
+	endtagfound();
+	parse_tag();
+	break;
+      } else {
+	s.tagattr[0] = lowercase(c);
+	s.tagattrptr = 1;
+	s.minorstate = MINORSTATE_TAGATTR;
+	break;
+      }
+    }
+    break;
+  case MINORSTATE_TAGATTRPARAMNQ:
+    /* We are parsing the "tag attr parameter", i.e., the link part
+       in <a href="link">. */
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == ISO_gt) {
+	/* Full tag found. */
+	endtagfound();
+	parse_tag();
+	s.minorstate = MINORSTATE_TEXT;
+	s.tagattrptr = 0;       
+	endtagfound();
+	parse_tag();
+	s.tagptr = 0;       
+	endtagfound();
+	break;
+      } else if(iswhitespace(c) &&
+		s.tagattrparamptr == 0) {
+	/* Discard leading spaces. */	  
+      } else if((c == ISO_citation ||
+		 c == ISO_citation2) &&
+		s.tagattrparamptr == 0) {
+	s.minorstate = MINORSTATE_TAGATTRPARAM;
+	s.quotechar = c;
+	PRINTF(("tag attr param q found\n"));
+	break;
+      } else if(iswhitespace(c)) {
+	PRINTF(("Non-leading space found at %d\n",
+		s.tagattrparamptr));
+	/* Stop parsing if a non-leading space was found */
+	endtagfound();
+	parse_tag();
+	  
+	s.minorstate = MINORSTATE_TAGATTR;
+	s.tagattrptr = 0;
+	endtagfound();
+	break;
+      } else {
+	s.tagattrparam[s.tagattrparamptr] = c;
+	++s.tagattrparamptr;
+	/* Check if the "tagattr" field is full. If so, we just eat
+	   up any data left in the tag. */
+	if(s.tagattrparamptr >= sizeof(s.tagattrparam) - 1) {
+	  s.minorstate = MINORSTATE_TAGEND;
+	  break;
+	}
+      }
+    }
+    break;
+  case MINORSTATE_TAGATTRPARAM:
+    /* We are parsing the "tag attr parameter", i.e., the link
+       part in <a href="link">. */
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == s.quotechar) {
+	/* Found end of tag attr parameter. */
+	endtagfound();
+	parse_tag();
+	  
+	s.minorstate = MINORSTATE_TAGATTR;
+	s.tagattrptr = 0;
+	endtagfound();
+	break;
+      } else {
+	if(iswhitespace(c)) {
+	  s.tagattrparam[s.tagattrparamptr] = ISO_space;
+	} else {
+	  s.tagattrparam[s.tagattrparamptr] = c;
+	}
+	  
+	++s.tagattrparamptr;
+	/* Check if the "tagattr" field is full. If so, we just eat
+	   up any data left in the tag. */
+	if(s.tagattrparamptr >= sizeof(s.tagattrparam) - 1) {
+	  s.minorstate = MINORSTATE_TAGEND;
+	  break;
+	}
+      }
+    }
+    break;
+  case MINORSTATE_HTMLCOMMENT:
+    for(i = 0; i < len; ++i) {
+      c = data[i];
+      if(c == ISO_dash) {
+	++s.tagptr;
+      } else if(c == ISO_gt && s.tagptr > 0) {
+	PRINTF(("Comment done.\n"));
+	s.minorstate = MINORSTATE_TEXT;
+	break;
+      } else {
+	s.tagptr = 0;
+      }
+    }
+    break;
+  case MINORSTATE_TAGEND:
+    /* Discard characters until a '>' is seen. */
+    for(i = 0; i < len; ++i) {
+      if(data[i] == ISO_gt) {
+	s.minorstate = MINORSTATE_TEXT;
+	s.tagattrptr = 0;
+	endtagfound();
+	parse_tag();
+	break;
+      }
+    }
+    break;
+  default:
+    i = 0;
+    break;
+  }
+  if(i >= len) {
+    return len;
+  }
+  return i + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_parse(char *data, u16_t datalen)
+{
+  u16_t plen;
+  
+  while(datalen > 0) {
+    if(datalen > 255) {
+      plen = parse_word(data, 255);
+    } else {
+      plen = parse_word(data, datalen);
+    }
+    datalen -= plen;
+    data += plen;
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/htmlparser.h b/contiki/apps/htmlparser.h
new file mode 100644
index 0000000..ce9f7ef
--- /dev/null
+++ b/contiki/apps/htmlparser.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: htmlparser.h,v 1.4 2005/06/12 23:44:30 oliverschmidt Exp $
+ *
+ */
+#ifndef __HTMLPARSER_H__
+#define __HTMLPARSER_H__
+
+#include "uip.h"
+
+/* Callbacks. */
+void htmlparser_link(char *text, unsigned char textlen, char *url);
+void htmlparser_submitbutton(char *value,
+			     char *name,
+			     char *formname,
+			     char *formaction);
+void htmlparser_inputfield(unsigned char size,
+			   char *value,
+			   char *name,
+			   char *formname,
+			   char *formaction);
+void htmlparser_newline(void);
+void htmlparser_word(char *word, unsigned char wordlen);
+
+void htmlparser_renderstate(unsigned char state);
+#define HTMLPARSER_RENDERSTATE_STATUSMASK 0x80
+#define HTMLPARSER_RENDERSTATE_BEGIN      0x00
+#define HTMLPARSER_RENDERSTATE_END        0x80
+
+#define HTMLPARSER_RENDERSTATE_NONE       0x00
+#define HTMLPARSER_RENDERSTATE_CENTER     0x01
+#define HTMLPARSER_RENDERSTATE_TABLE      0x02
+#define HTMLPARSER_RENDERSTATE_TR         0x04
+#define HTMLPARSER_RENDERSTATE_TD         0x08
+
+
+#define HTMLPARSER_INPUTTYPE_NONE     0
+#define HTMLPARSER_INPUTTYPE_TEXT     1
+#define HTMLPARSER_INPUTTYPE_PASSWORD 2
+#define HTMLPARSER_INPUTTYPE_SUBMIT   3
+#define HTMLPARSER_INPUTTYPE_IMAGE    4
+#define HTMLPARSER_INPUTTYPE_OTHER    5
+
+
+/* Functions. */
+void htmlparser_init(void);
+void htmlparser_parse(char *data, u16_t len);
+
+
+#endif /* __HTMLPARSER_H__ */
diff --git a/contiki/apps/http-strings b/contiki/apps/http-strings
new file mode 100644
index 0000000..d77c32f
--- /dev/null
+++ b/contiki/apps/http-strings
@@ -0,0 +1,35 @@
+http_http "http://"
+http_200 "200 "
+http_301 "301 "
+http_302 "302 "
+http_get "GET "
+http_10 "HTTP/1.0"
+http_11 "HTTP/1.1"
+http_content_type "content-type: "
+http_texthtml "text/html"
+http_location "location: "
+http_host "host: "
+http_crnl "\r\n"
+http_index_html "/index.html"
+http_404_html "/404.html"
+http_referer "Referer:"
+http_header_200 "HTTP/1.0 200 OK\r\nServer: Contiki/1.2 http://www.sics.se/~adam/contiki/\r\nConnection: close\r\n"
+http_header_404 "HTTP/1.0 404 Not found\r\nServer: Contiki/1.2 http://www.sics.se/~adam/contiki/\r\nConnection: close\r\n"
+http_content_type_plain "Content-type: text/plain\r\n\r\n"
+http_content_type_html "Content-type: text/html\r\n\r\n"
+http_content_type_css  "Content-type: text/css\r\n\r\n"
+http_content_type_text "Content-type: text/text\r\n\r\n"
+http_content_type_png  "Content-type: image/png\r\n\r\n"
+http_content_type_gif  "Content-type: image/gif\r\n\r\n"
+http_content_type_jpg  "Content-type: image/jpeg\r\n\r\n"
+http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
+http_html ".html"
+http_shtml ".shtml"
+http_htm ".htm"
+http_css ".css"
+http_png ".png"
+http_gif ".gif"
+http_jpg ".jpg"
+http_text ".txt"
+http_txt ".txt"
+
diff --git a/contiki/apps/http-strings.c b/contiki/apps/http-strings.c
new file mode 100644
index 0000000..ea743bb
--- /dev/null
+++ b/contiki/apps/http-strings.c
@@ -0,0 +1,102 @@
+const char http_http[8] = 
+/* "http://" */
+{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
+const char http_200[5] = 
+/* "200 " */
+{0x32, 0x30, 0x30, 0x20, };
+const char http_301[5] = 
+/* "301 " */
+{0x33, 0x30, 0x31, 0x20, };
+const char http_302[5] = 
+/* "302 " */
+{0x33, 0x30, 0x32, 0x20, };
+const char http_get[5] = 
+/* "GET " */
+{0x47, 0x45, 0x54, 0x20, };
+const char http_10[9] = 
+/* "HTTP/1.0" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
+const char http_11[9] = 
+/* "HTTP/1.1" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
+const char http_content_type[15] = 
+/* "content-type: " */
+{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
+const char http_texthtml[10] = 
+/* "text/html" */
+{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_location[11] = 
+/* "location: " */
+{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
+const char http_host[7] = 
+/* "host: " */
+{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
+const char http_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, };
+const char http_index_html[12] = 
+/* "/index.html" */
+{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_404_html[10] = 
+/* "/404.html" */
+{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_referer[9] = 
+/* "Referer:" */
+{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
+const char http_header_200[92] = 
+/* "HTTP/1.0 200 OK\r\nServer: Contiki/1.2 http://www.sics.se/~adam/contiki/\r\nConnection: close\r\n" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x32, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
+const char http_header_404[99] = 
+/* "HTTP/1.0 404 Not found\r\nServer: Contiki/1.2 http://www.sics.se/~adam/contiki/\r\nConnection: close\r\n" */
+{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x32, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
+const char http_content_type_plain[29] = 
+/* "Content-type: text/plain\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_html[28] = 
+/* "Content-type: text/html\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_css [27] = 
+/* "Content-type: text/css\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_text[28] = 
+/* "Content-type: text/text\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_png [28] = 
+/* "Content-type: image/png\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_gif [28] = 
+/* "Content-type: image/gif\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_jpg [29] = 
+/* "Content-type: image/jpeg\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
+const char http_content_type_binary[43] = 
+/* "Content-type: application/octet-stream\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+const char http_html[6] = 
+/* ".html" */
+{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_shtml[7] = 
+/* ".shtml" */
+{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
+const char http_htm[5] = 
+/* ".htm" */
+{0x2e, 0x68, 0x74, 0x6d, };
+const char http_css[5] = 
+/* ".css" */
+{0x2e, 0x63, 0x73, 0x73, };
+const char http_png[5] = 
+/* ".png" */
+{0x2e, 0x70, 0x6e, 0x67, };
+const char http_gif[5] = 
+/* ".gif" */
+{0x2e, 0x67, 0x69, 0x66, };
+const char http_jpg[5] = 
+/* ".jpg" */
+{0x2e, 0x6a, 0x70, 0x67, };
+const char http_text[5] = 
+/* ".txt" */
+{0x2e, 0x74, 0x78, 0x74, };
+const char http_txt[5] = 
+/* ".txt" */
+{0x2e, 0x74, 0x78, 0x74, };
diff --git a/contiki/apps/http-strings.h b/contiki/apps/http-strings.h
new file mode 100644
index 0000000..ec5b1fe
--- /dev/null
+++ b/contiki/apps/http-strings.h
@@ -0,0 +1,34 @@
+extern const char http_http[8];
+extern const char http_200[5];
+extern const char http_301[5];
+extern const char http_302[5];
+extern const char http_get[5];
+extern const char http_10[9];
+extern const char http_11[9];
+extern const char http_content_type[15];
+extern const char http_texthtml[10];
+extern const char http_location[11];
+extern const char http_host[7];
+extern const char http_crnl[3];
+extern const char http_index_html[12];
+extern const char http_404_html[10];
+extern const char http_referer[9];
+extern const char http_header_200[92];
+extern const char http_header_404[99];
+extern const char http_content_type_plain[29];
+extern const char http_content_type_html[28];
+extern const char http_content_type_css [27];
+extern const char http_content_type_text[28];
+extern const char http_content_type_png [28];
+extern const char http_content_type_gif [28];
+extern const char http_content_type_jpg [29];
+extern const char http_content_type_binary[43];
+extern const char http_html[6];
+extern const char http_shtml[7];
+extern const char http_htm[5];
+extern const char http_css[5];
+extern const char http_png[5];
+extern const char http_gif[5];
+extern const char http_jpg[5];
+extern const char http_text[5];
+extern const char http_txt[5];
diff --git a/contiki/apps/http-user-agent-string b/contiki/apps/http-user-agent-string
new file mode 100644
index 0000000..451ab12
--- /dev/null
+++ b/contiki/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.2 (; http://www.sics.se/~adam/contiki/)\r\n\r\n"
diff --git a/contiki/apps/http-user-agent-string.c b/contiki/apps/http-user-agent-string.c
new file mode 100644
index 0000000..9ee4b18
--- /dev/null
+++ b/contiki/apps/http-user-agent-string.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.c,v 1.4 2005/05/16 22:00:43 oliverschmidt Exp $
+ */
+const char http_user_agent_fields[85] = 
+/* "Connection: close\r\nUser-Agent: Contiki/1.1 (; http://www.sics.se/~adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x32, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki/apps/http-user-agent-string.h b/contiki/apps/http-user-agent-string.h
new file mode 100644
index 0000000..80ea025
--- /dev/null
+++ b/contiki/apps/http-user-agent-string.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.h,v 1.4 2005/05/16 22:00:43 oliverschmidt Exp $
+ */
+extern const char http_user_agent_fields[85];
diff --git a/contiki/apps/httpd-cgi.c b/contiki/apps/httpd-cgi.c
new file mode 100644
index 0000000..495141b
--- /dev/null
+++ b/contiki/apps/httpd-cgi.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.10 2007/06/02 07:32:06 ryohji Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#include <stdio.h>
+#include <string.h>
+
+static PT_THREAD(file_stats(struct httpd_state *s, char *arg));
+static PT_THREAD(tcp_stats(struct httpd_state *s, char *arg));
+static PT_THREAD(processes(struct httpd_state *s, char *arg));
+
+struct cgifunction {
+  char *name;
+  httpd_cgifunction function;
+};
+
+static struct cgifunction cgitab[] = {
+  {"file-stats", file_stats},
+  {"tcp-connections", tcp_stats},
+  {"processes", processes},
+  {NULL, NULL}
+};
+
+
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49, 
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
+{
+  PSOCK_BEGIN(&s->sout);  
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+httpd_cgifunction
+httpd_cgi(char *name)
+{
+  struct cgifunction *f;
+
+  /* Find the matching name in the table, return the function. */
+  for(f = cgitab; f->name != NULL; ++f) {
+    if(strncmp(f->name, name, strlen(f->name)) == 0) {
+      return f->function;
+    }
+  }
+  return nullfunction;
+}
+/*---------------------------------------------------------------------------*/
+static unsigned short
+generate_file_stats(void *arg)
+{
+  char *f = (char *)arg;
+  return sprintf((char *)uip_appdata, "%5u", httpd_fs_count(f));
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
+{
+  PSOCK_BEGIN(&s->sout);
+
+  PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
+  
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static unsigned short
+make_tcp_stats(void *arg)
+{
+  struct uip_conn *conn;
+  struct httpd_state *s = (struct httpd_state *)arg;
+    
+  conn = &uip_conns[s->count];
+  return sprintf((char *)uip_appdata,
+		 "<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+		 htons(conn->lport),
+		 htons(conn->ripaddr[0]) >> 8,
+		 htons(conn->ripaddr[0]) & 0xff,
+		 htons(conn->ripaddr[1]) >> 8,
+		 htons(conn->ripaddr[1]) & 0xff,
+		 htons(conn->rport),
+		 states[conn->tcpstateflags & TS_MASK],
+		 conn->nrtx,
+		 conn->timer,
+		 (uip_outstanding(conn))? '*':' ',
+		 (uip_stopped(conn))? '!':' ');
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
+{
+  
+  PSOCK_BEGIN(&s->sout);
+
+  for(s->count = 0; s->count < UIP_CONNS; ++s->count) {   
+    if((uip_conns[s->count].tcpstateflags & TS_MASK) != CLOSED) {
+      PSOCK_GENERATOR_SEND(&s->sout, make_tcp_stats, s);
+    }
+  }
+
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static unsigned short
+make_processes(void *s)
+{
+  struct ek_proc *p = (struct ek_proc *)s;
+  char name[40];
+
+  strncpy(name, p->name, 40);
+  petsciiconv_toascii(name, 40);
+
+  return sprintf((char *)uip_appdata,
+		 "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%02x</td><td>%p</td><td>%p</td><td>%p</td></tr>\r\n",
+		 p->id, name, p->prio,
+		 p->pollhandler, p->eventhandler, p->procstate);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(processes(struct httpd_state *s, char *ptr))
+{
+  static struct ek_proc *p;
+  
+  PSOCK_BEGIN(&s->sout);
+
+  for(s->count = 0; s->count < EK_CONF_MAXPROCS; ++s->count) {
+    p = ek_process(s->count);
+    if(p != NULL) {
+      PSOCK_GENERATOR_SEND(&s->sout, make_processes, p);
+    }    
+  }
+  
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/httpd-cgi.h b/contiki/apps/httpd-cgi.h
new file mode 100644
index 0000000..0171fdd
--- /dev/null
+++ b/contiki/apps/httpd-cgi.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.h,v 1.4 2005/02/27 09:33:51 adamdunkels Exp $
+ *
+ */
+
+#ifndef __HTTPD_CGI_H__
+#define __HTTPD_CGI_H__
+
+#include "pt.h"
+#include "httpd.h"
+
+typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
+
+httpd_cgifunction httpd_cgi(char *name);
+
+#endif /* __HTTPD_CGI_H__ */
diff --git a/contiki/apps/httpd-fs.c b/contiki/apps/httpd-fs.c
new file mode 100644
index 0000000..70958c3
--- /dev/null
+++ b/contiki/apps/httpd-fs.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.c,v 1.3 2004/06/06 05:59:21 adamdunkels Exp $
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+
+#include "httpd-fsdata.c"
+
+#if HTTPD_FS_STATISTICS
+static u16_t count[HTTPD_FS_NUMFILES];
+#endif /* HTTPD_FS_STATISTICS */
+
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+httpd_fs_strcmp(const char *str1, const char *str2)
+{
+  u8_t i;
+  i = 0;
+ loop:
+
+  if(str2[i] == 0 ||
+     str1[i] == '\r' || 
+     str1[i] == '\n') {
+    return 0;
+  }
+
+  if(str1[i] != str2[i]) {
+    return 1;
+  }
+
+
+  ++i;
+  goto loop;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+httpd_fs_open(const char *name, struct httpd_fs_file *file)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i = 0;
+#endif /* HTTPD_FS_STATISTICS */
+  struct httpd_fsdata_file_noconst *f;
+
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      file->data = f->data;
+      file->len = f->len;
+#if HTTPD_FS_STATISTICS
+      ++count[i];
+#endif /* HTTPD_FS_STATISTICS */
+      return 1;
+    }
+#if HTTPD_FS_STATISTICS
+    ++i;
+#endif /* HTTPD_FS_STATISTICS */
+
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_fs_init(void)
+{
+#if HTTPD_FS_STATISTICS
+  u16_t i;
+  for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
+    count[i] = 0;
+  }
+#endif /* HTTPD_FS_STATISTICS */
+}
+/*-----------------------------------------------------------------------------------*/
+#if HTTPD_FS_STATISTICS
+u16_t httpd_fs_count
+(char *name)
+{
+  struct httpd_fsdata_file_noconst *f;
+  u16_t i;
+
+  i = 0;
+  for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
+      f != NULL;
+      f = (struct httpd_fsdata_file_noconst *)f->next) {
+
+    if(httpd_fs_strcmp(name, f->name) == 0) {
+      return count[i];
+    }
+    ++i;
+  }
+  return 0;
+}
+#endif /* HTTPD_FS_STATISTICS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/httpd-fs.h b/contiki/apps/httpd-fs.h
new file mode 100644
index 0000000..788924c
--- /dev/null
+++ b/contiki/apps/httpd-fs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.2 2004/06/06 05:59:21 adamdunkels Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 1
+
+struct httpd_fs_file {
+  char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1  
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki/apps/httpd-fs/404.html b/contiki/apps/httpd-fs/404.html
new file mode 100644
index 0000000..a17711d
--- /dev/null
+++ b/contiki/apps/httpd-fs/404.html
@@ -0,0 +1,8 @@
+<html>
+  <body bgcolor="white">
+    <center>
+      <h1>404 - file not found</h1>
+      <h3>Go <a href="/">here</a> instead.</h3>
+    </center>
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki/apps/httpd-fs/files.shtml b/contiki/apps/httpd-fs/files.shtml
new file mode 100644
index 0000000..7f985db
--- /dev/null
+++ b/contiki/apps/httpd-fs/files.shtml
@@ -0,0 +1,24 @@
+%!: /header.html
+ <h1>File statistics</h1><br><table width="100%">
+ <tr><td><a href="/index.html">/index.html</a></td>
+ <td>%! file-stats /index.html
+</td></tr>
+<tr><td><a href="/files.shtml">/files.shtml</a></td>
+<td>%! file-stats /files.shtml
+</td></tr>
+<tr><td><a href="/tcp.shtml">/tcp.shtml</a></td>
+<td>%! file-stats /tcp.shtml
+</td></tr>
+<tr><td><a href="/processes.shtml">/processes.shtml</a></td>
+<td>%! file-stats /processes.shtml
+</td></tr>
+<tr><td><a href="/style.css">/style.css</a></td>
+<td>%! file-stats /contiki.css
+</td></tr>
+<tr><td><a href="/404.html">/404.html</a></td>
+<td>%! file-stats /404.html
+</td></tr>
+<tr><td><a href="/img/screenshot.png">/img/screenshot.png</a></td>
+<td>%! file-stats /img/screenshot.png
+</td></tr></table>
+%!: /footer.html
\ No newline at end of file
diff --git a/contiki/apps/httpd-fs/footer.html b/contiki/apps/httpd-fs/footer.html
new file mode 100644
index 0000000..1fd5f4f
--- /dev/null
+++ b/contiki/apps/httpd-fs/footer.html
@@ -0,0 +1,2 @@
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki/apps/httpd-fs/header.html b/contiki/apps/httpd-fs/header.html
new file mode 100644
index 0000000..815e57c
--- /dev/null
+++ b/contiki/apps/httpd-fs/header.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title>Welcome to the Contiki-demo server!</title>
+    <link rel="stylesheet" type="text/css" href="/style.css">  
+  </head>
+  <body bgcolor="#fffeec" text="black">
+
+  <div class="menublock">
+
+  <div class="menu">
+  <p class="border-title">Menu</p>
+  <p class="menu">
+  
+  <a href="/">Front page</a><br>
+  <a href="files.shtml">File statistics</a><br>
+  <a href="tcp.shtml">Network connections</a><br>
+  <a href="processes.shtml">System processes</a><br>
+
+  </p>
+  </div>
+  </div>
+
+  <div class="contentblock">
+  <p class="border-title">
+  Welcome to the <a href="http://www.sics.se/~adam/contiki/">Contiki</a> 
+  web server!
+  </p>
diff --git a/contiki/apps/httpd-fs/img/screenshot.png b/contiki/apps/httpd-fs/img/screenshot.png
new file mode 100644
index 0000000..7ee2431
--- /dev/null
+++ b/contiki/apps/httpd-fs/img/screenshot.png
Binary files differ
diff --git a/contiki/apps/httpd-fs/index.html b/contiki/apps/httpd-fs/index.html
new file mode 100644
index 0000000..40fad31
--- /dev/null
+++ b/contiki/apps/httpd-fs/index.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title>Welcome to the Contiki web server!</title>
+    <link rel="stylesheet" type="text/css" href="/style.css">  
+  </head>
+  <body bgcolor="#fffeec" text="black">
+
+  <div class="menublock">
+
+  <div class="menu">
+  <p class="border-title">Menu</p>
+  <p class="menu">
+  
+  <a href="/">Front page</a><br>
+  <a href="files.shtml">File statistics</a><br>
+  <a href="tcp.shtml">Network connections</a><br>
+  <a href="processes.shtml">System processes</a><br>
+
+  </p>
+  </div>
+  </div>
+
+  <div class="contentblock">
+  <p class="border-title">
+  Welcome to the <a href="http://www.sics.se/~adam/contiki/">Contiki</a> 
+  web server!
+  </p>
+	      
+	  <p class="intro">
+	    The web pages you are watching are served by a <a
+	    href="http://www.sics.se/~adam/contiki/apps/webserver.html">web
+	    server</a> running under the <a
+	    href="http://www.sics.se/~adam/contiki/">Contiki operating
+	    system</a>.
+	  </p>
+
+	  
+	 
+  </body>
+</html>
\ No newline at end of file
diff --git a/contiki/apps/httpd-fs/processes.shtml b/contiki/apps/httpd-fs/processes.shtml
new file mode 100644
index 0000000..2f93e35
--- /dev/null
+++ b/contiki/apps/httpd-fs/processes.shtml
@@ -0,0 +1,5 @@
+%!: /header.html
+<h1>System processes</h1><br><table width="100%">
+<tr><th>ID</th><th>Name</th><th>Priority</th><th>Poll handler</th><th>Event handler</th><th>Procstate</th></tr>
+%! processes
+%!: /footer.html
\ No newline at end of file
diff --git a/contiki/apps/httpd-fs/style.css b/contiki/apps/httpd-fs/style.css
new file mode 100644
index 0000000..6a18127
--- /dev/null
+++ b/contiki/apps/httpd-fs/style.css
@@ -0,0 +1,239 @@
+h1 
+{
+  text-align: center;
+  font-size:14pt;
+  font-family:arial,helvetica;
+  font-weight:bold;
+  padding:10px; 
+}
+
+body
+{
+
+  background-color: #fffeec;
+  color:black;
+
+  font-size:8pt;
+  font-family:arial,helvetica;
+}
+
+.wrap {
+  width: 98%;
+  margin: 0 auto;
+  text-align: left;
+  font-family:arial,helvetica;        
+}
+
+.menublock
+{
+  margin: 4px;
+  width:15%;
+  float:left;
+
+  padding:10px;
+	
+  border: solid 1px;
+  background-color: #fffcd2;
+  text-align:left;
+  
+  font-size:9pt;
+  font-family:arial,helvetica;  
+}
+
+.contentblock
+{  
+  margin: 4px;
+  width:50%;
+  float:left;
+
+  padding:10px;
+
+  border: 1px dotted;
+  background-color: white;
+
+  font-size:8pt;
+  font-family:arial,helvetica;  
+
+}
+
+.newsblock
+{
+  margin: 4px;
+  width:24%;
+  float:left;
+
+
+  padding:10px;
+
+  border: solid 1px;
+  background-color: #fffcd2;
+  text-align:left;
+  font-size:8pt;
+  font-family:arial,helvetica;
+}
+
+.printable
+{
+  margin: 4px;
+  width:24%;
+  float:left;
+
+
+  padding:10px;
+
+  border: 0;
+  background-color: #fffeec;
+  text-align:right;
+  font-size:8pt;
+  font-family:arial,helvetica;
+}
+
+div.rfig
+{
+  border: solid 1px; 
+
+  text-align: left;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:8pt;
+
+  float:right;
+}
+
+pre.example
+{
+  border: solid 1px; 
+  padding: 10px;
+  margin:10px;
+  text-align: left;
+  font-size:8pt;
+  font-family:arial,helvetica;
+  white-space:pre;  
+}
+
+
+p.intro
+{
+  margin-left:20px;
+  margin-right:20px;
+
+  font-size:10pt;
+/*  font-weight:bold; */
+  font-family:arial,helvetica;  
+}
+
+p.clink
+{
+  font-size:12pt;
+  font-family:courier,monospace;  
+  text-align:center;
+}
+
+p.clink9
+{
+  font-size:9pt;
+  font-family:courier,monospace;  
+  text-align:center;
+}
+
+p.related
+{
+  font-size:10pt;
+  font-family:arial,helvetica;  
+  text-align:center;
+}
+
+
+
+img.right
+{
+  float:right;
+  margin:10px;
+}
+
+img.left
+{
+  float:left;
+  margin:10px;
+}
+
+p.fig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+}
+
+p.rfig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+
+  float:right;
+}
+
+
+p.lfig
+{
+  border: solid 1px; 
+
+  text-align: center;
+
+  padding: 10px;
+  margin:10px;
+
+  font-size:7pt;
+
+  float:left;
+}
+
+p
+{
+  padding-left:10px;
+}
+
+p.mailaddr
+{
+  padding-left:10px;
+  font-size:7pt;
+  font-family:courier,terminal;
+  text-align:right; 
+}
+
+p.right
+{
+  text-align:right; 
+}
+
+p.border-title
+{
+  text-align:center;
+
+  font-size:14pt;
+
+  padding:0px;
+  margin:4px;
+  margin-bottom:10px;
+
+  color: black;
+  background-color: #fffcba;
+  border: solid 1px;
+
+} 
+
+
+
+
diff --git a/contiki/apps/httpd-fs/tcp.shtml b/contiki/apps/httpd-fs/tcp.shtml
new file mode 100644
index 0000000..4c4bffe
--- /dev/null
+++ b/contiki/apps/httpd-fs/tcp.shtml
@@ -0,0 +1,5 @@
+%!: /header.html
+<h1>Current connections</h1><br><table width="100%">
+<tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
+%! tcp-connections
+%!: /footer.html
\ No newline at end of file
diff --git a/contiki/apps/httpd-fsdata.c b/contiki/apps/httpd-fsdata.c
new file mode 100644
index 0000000..420000a
--- /dev/null
+++ b/contiki/apps/httpd-fsdata.c
@@ -0,0 +1,875 @@
+static const unsigned char data_img_screenshot_png[] = {
+	/* /img/screenshot.png */
+	0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 0x74, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00, 
+	00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 0x1, 0x80, 
+	00, 00, 0x1, 0xf, 0x4, 0x3, 00, 00, 00, 0xb9, 
+	0xf, 0xe, 0x81, 00, 00, 00, 0x30, 0x50, 0x4c, 0x54, 
+	0x45, 0x10, 0x10, 0x10, 0xff, 0xff, 0xff, 0xe0, 0x40, 0x40, 
+	0x60, 0xff, 0xff, 0xe0, 0x60, 0xe0, 0x40, 0xe0, 0x40, 0x40, 
+	0x40, 0xe0, 0xff, 0xff, 0x40, 0xe0, 0xa0, 0x40, 0x9c, 0x74, 
+	0x48, 0xff, 0xa0, 0xa0, 0x54, 0x54, 0x54, 0x88, 0x88, 0x88, 
+	0xa0, 0xff, 0xa0, 0xa0, 0xa0, 0xff, 0xc0, 0xc0, 0xc0, 0xe, 
+	0x8c, 0x9e, 0x90, 00, 00, 00, 0x9, 0x70, 0x48, 0x59, 
+	0x73, 00, 00, 0xf, 0xa0, 00, 00, 0xf, 0xa0, 0x1, 
+	0xa0, 0x6a, 0x8c, 0x77, 00, 00, 0x7, 0xcc, 0x49, 0x44, 
+	0x41, 0x54, 0x78, 0xda, 0xed, 0x5d, 0x4b, 0x8e, 0xa4, 0x38, 
+	0x10, 0xb5, 0x57, 0x6c, 0xed, 0x6d, 0x6f, 0xea, 0x32, 0xad, 
+	0x59, 0xf4, 0x39, 0x46, 0xb3, 0xa6, 0x57, 0x48, 0x75, 0x9b, 
+	0x92, 0x5a, 0x6a, 0xa9, 0xae, 0xc0, 0x22, 0xf, 0x96, 0xb, 
+	0xc6, 0xe1, 0x1f, 0x86, 0xcc, 0x82, 0x20, 0xe5, 0x24, 0x1c, 
+	0x59, 0x11, 0xee, 0x4c, 0x30, 0x55, 0xe0, 0x78, 0xf1, 0xfc, 
+	0xfc, 0xc1, 0x54, 0xa3, 0xfe, 0x63, 0x6e, 0x8a, 0xda, 0x1, 
+	0x1, 0x40, 0xed, 0x80, 00, 0xa0, 0x76, 0x40, 00, 0x50, 
+	0x3b, 0x20, 00, 0xa8, 0x1d, 0x10, 00, 0xd4, 0xe, 0x8, 
+	00, 0x6a, 0x7, 0x4, 00, 0xb5, 0x3, 0x2, 0x80, 0xda, 
+	0x1, 0x1, 0x40, 0xed, 0x80, 00, 0xa0, 0x76, 0x40, 00, 
+	0x50, 0x3b, 0x20, 00, 0xa8, 0x1d, 0x10, 00, 0xd4, 0xe, 
+	0x8, 00, 0x6a, 0x7, 0x4, 00, 0xb5, 0x3, 0x2, 0x80, 
+	0xda, 0x1, 0x1, 0xb0, 0x3e, 0x30, 0x80, 0x29, 0x35, 0x50, 
+	0x59, 0xaf, 0xba, 0xcd, 0x9f, 0xa3, 00, 0xf4, 0x5d, 0x3f, 
+	0x5f, 0x5, 0x76, 0xdd, 0xc7, 0x1f, 0xe9, 0xb7, 0x2f, 0x5e, 
+	0x5, 0x40, 0xa7, 0x8a, 0xfd, 0xdb, 0x32, 0x91, 00, 0x6, 
+	0xcf, 0x42, 0x1f, 0x3e, 0xdd, 0x30, 0x9c, 0xe2, 0xfb, 0x90, 
+	0x83, 0x7, 0x35, 0xc0, 0x95, 0xeb, 0x63, 0x7, 0xe5, 0x47, 
+	0x5f, 0xe, 0x1, 0x80, 0xb, 0xf9, 0x8b, 0x41, 0x46, 0x75, 
+	0x21, 0x32, 0x3b, 0xf4, 0xd6, 0x2, 0x10, 0x4b, 0xe, 0x65, 
+	0x7a, 0x17, 0xd2, 0x91, 0x47, 0x1, 0xc0, 0x46, 0x75, 0x27, 
+	0x55, 0x21, 0x97, 0x72, 0xd4, 0xbb, 0x47, 0x1, 0x14, 0x71, 
+	0xc8, 0x1a, 0x50, 0xa7, 0x69, 0x20, 0x14, 0x3, 0xa5, 0x17, 
+	0xc, 0x1c, 0xa9, 0x42, 0xb1, 0xe, 0x46, 0x31, 0xc7, 0x68, 
+	0xa4, 0xba, 0xf9, 0x6c, 00, 0x10, 0xf5, 0xa4, 0xbf, 0x45, 
+	0xf9, 0xc3, 0x1, 00, 0xd, 0x1a, 0x1a, 00, 0x37, 0x13, 
+	00, 0xd4, 0x26, 00, 0xa8, 0x4d, 00, 0x50, 0x9b, 00, 
+	0x78, 0xb6, 0xd9, 0xc2, 0x70, 00, 0xfe, 0x69, 0x2b, 0x19, 
+	0x95, 0x4d, 0xfb, 0x23, 0xdc, 0x18, 0x30, 0xd6, 0x2a, 0x88, 
+	0xbe, 0xfb, 0xd2, 0x28, 0x6, 0xc8, 0x43, 0xbe, 0x4a, 0xc6, 
+	0xb9, 0xee, 0x58, 0xd0, 0x6e, 0xa3, 0xef, 0x10, 0xc0, 0x80, 
+	0x1, 0xa3, 0x83, 00, 0x8c, 0xc6, 0x31, 0x40, 0x1e, 0xf2, 
+	0xb5, 0x6, 0x1c, 0x5, 0xde, 0xac, 0x66, 0xaa, 0x1, 0x9d, 
+	0xda, 0x20, 0xc3, 0x54, 0x3, 0x3a, 0x35, 0x42, 0x86, 0xa9, 
+	0x6, 0xe6, 0x6e, 00, 0xc9, 0x40, 0x63, 0x66, 0x72, 0x47, 
+	0xa0, 0x35, 0xe4, 0x85, 0x1, 0x2a, 0x6, 0x9c, 0x96, 0x99, 
+	0x33, 00, 0x43, 0x9, 0xc6, 0xc, 0x40, 0x67, 0xc0, 0x9a, 
+	0x1, 0xa3, 0xd8, 0x32, 0x60, 0x13, 0x1, 0x58, 0x6, 0xfe, 
+	0x6d, 0x2b, 0x85, 0x9e, 0xd8, 0xc0, 0x68, 0x4e, 0xfb, 0x23, 
+	0xec, 0x18, 0xd0, 0x30, 0x16, 0x35, 0xa, 0x86, 0x12, 0x28, 
+	0x6, 0xc8, 0x43, 0xbe, 0x4a, 0xc6, 0x84, 0x26, 0x8, 00, 
+	0xdc, 0x21, 0x80, 0x1, 0x3, 0x40, 0x81, 0x56, 0x78, 0x6, 
+	0xc8, 0x43, 0xbe, 0xd6, 0x80, 0x9f, 0x90, 0x29, 0xc6, 0x1a, 
+	0xf0, 0xb3, 0x49, 0x85, 0x6f, 0x85, 0xc8, 0x43, 0xbe, 0xd6, 
+	0x40, 0x31, 0xa9, 0x67, 0xa9, 0x81, 0xf2, 0xb6, 0xa, 0x8e, 
+	0x1, 0x42, 0x83, 0xd6, 0x7e, 0xcf, 0x9a, 0x66, 0xc0, 0xcd, 
+	0xbe, 0xa0, 0xb1, 0x59, 0x7a, 0xbc, 0xca, 0xb7, 0xcd, 0x80, 
+	0x4e, 0xfd, 0xae, 0xa, 0x4d, 0xbf, 0x4a, 0xb7, 0x54, 0xfc, 
+	0xd6, 0xc2, 0xcf, 0x1b, 0x67, 0xc0, 0x40, 0x6b, 0xe9, 0x1d, 
+	0xd, 0x29, 0x30, 0x30, 0xe7, 0x11, 00, 0xc8, 0x19, 0x8, 
+	0xff, 0x7c, 0xe4, 0x97, 00, 0x2c, 0x7, 0x6, 0x94, 0xcd, 
+	00, 0xe2, 0xa7, 0x4, 0x70, 0x6f, 0x52, 0xd3, 0x16, 0x3, 
+	0xd0, 0xa, 0xf9, 0xba, 0x6e, 0xb3, 0x6, 0xac, 0x8d, 0x1a, 
+	0xd0, 0xe1, 0xe, 0x69, 0xd3, 0xc, 0xec, 0x35, 0xa1, 00, 
+	0xb0, 0x69, 0x6, 0x30, 0xb6, 0xcf, 0xc0, 0xcf, 0xb6, 0xd3, 
+	0xeb, 0x33, 0x40, 0x1e, 0xe2, 0x9d, 0xf4, 0xfa, 0xc, 0x90, 
+	0x87, 0x58, 0x34, 0x40, 0x1d, 0xe2, 0x57, 0xd3, 0x40, 0xd9, 
+	0x91, 0xe1, 0x18, 0x68, 0xcc, 0xc, 0xdc, 0x14, 0x82, 0x21, 
+	0xb5, 0x31, 0x1a, 0xf2, 0xec, 0x18, 0x30, 0x61, 0x46, 0xf, 
+	0x23, 0x21, 0xcd, 0x94, 0x81, 0x70, 0x73, 0x14, 0x8c, 0x29, 
+	0x3, 0x26, 0x1, 0xe0, 0xca, 0x80, 0x79, 0x5, 0x6, 0x34, 
+	0xe3, 0x56, 0xc8, 0xaf, 0x13, 0xfb, 0x9b, 0xa3, 0xc8, 0x56, 
+	0xe8, 0x67, 0x5b, 0xc9, 0x58, 0xd, 0x13, 0x19, 0x3f, 0x21, 
+	0x83, 0x3c, 0x3f, 0x6, 0xac, 0xb2, 0x51, 0x2, 0x38, 0xd, 
+	0x90, 0x87, 0x7c, 0x95, 0xcc, 0xac, 0x61, 0xb, 0x79, 0x7e, 
+	0xc, 0x94, 00, 0x30, 0xc, 0x90, 0x87, 0x7c, 0x95, 0x8a, 
+	0x46, 0x88, 0xa7, 0x6, 0xf2, 0x40, 0x82, 0xab, 0x6, 0x6c, 
+	0x7e, 0xd2, 0x80, 0xa9, 0x6, 0xac, 0x3d, 0x38, 0x16, 0x3a, 
+	0x70, 0x61, 0x3b, 0xd9, 0xb7, 0xb7, 0xeb, 0x65, 0x1a, 0x27, 
+	0x94, 0x5d, 0xa7, 0x34, 0xae, 0x87, 0xf3, 0xca, 0x63, 0x5b, 
+	0xe5, 0x1c, 0x1e, 0x4a, 0x1c, 0x2, 0xe0, 0xdc, 0x48, 00, 
+	0xdc, 0x16, 0xf, 0xe0, 0x6d, 0x71, 0x6c, 0xda, 0x4, 0x10, 
+	0x6, 0x73, 0xbe, 0xe, 0xd5, 0x5, 00, 0xe5, 0x27, 00, 
+	0xe3, 0x38, 0x3, 0x18, 0xc7, 0x8b, 0xcf, 0xfb, 0x63, 0xd7, 
+	0xbc, 0xf, 0xce, 0x66, 0xf3, 0xe7, 0xc1, 0x19, 0xe1, 0xd8, 
+	0x36, 0x3, 0xbe, 0xe, 0xe9, 0xfa, 0xc, 0x4c, 0x89, 0x81, 
+	0xcb, 0x8, 0xce, 0x4, 0x27, 0x3, 0x13, 0x3e, 0xbf, 0x4a, 
+	0x37, 0xc, 0x44, 0x50, 0x2e, 0xb7, 0xc3, 0x40, 0x90, 0xf1, 
+	0x13, 00, 0xc4, 0x48, 0x8e, 0xe3, 0xe8, 0x3e, 0xd1, 0xc9, 
+	0xe0, 0x58, 0xc8, 0x47, 0x20, 0x71, 0x7f, 0xcd, 0x40, 0xa0, 
+	0xc, 0xc3, 0x80, 0x36, 0xcf, 0x2, 0x10, 0x18, 0x70, 0xee, 
+	0x27, 0x67, 0x63, 0xbd, 0x8e, 0xce, 0x47, 0x30, 0x69, 0xff, 
+	0x2b, 0x6, 0xf6, 00, 0x84, 0x47, 0x6d, 0x60, 0x52, 0xfc, 
+	0x64, 0xd, 0xa4, 0x2a, 0x4, 0xdb, 0xa4, 0x9, 0xf8, 0xca, 
+	0xfa, 0x78, 0x54, 0x3, 0x30, 0x98, 0x33, 0x9e, 0x83, 0xa7, 
+	00, 0xc0, 0xda, 0xf5, 0x3a, 0x2e, 00, 0x94, 0xc7, 0x36, 
+	0xcb, 0x29, 0xac, 0x3a, 00, 0x58, 0x92, 0xdb, 0x5d, 0xd8, 
+	0xbd, 0x67, 0x6a, 0x3e, 0x6d, 0x9a, 0x2e, 0xe3, 0x91, 0x53, 
+	0xf7, 0x1, 0xfc, 0xc1, 0xa5, 0x12, 0xc0, 0x7a, 0x69, 0xf7, 
+	0xfe, 0xf2, 0x8a, 0x2e, 0x76, 0xe7, 0x8c, 0x7, 0xb0, 0xba, 
+	0xc0, 0xcd, 0xf5, 0x8a, 0x3, 0xf5, 0x19, 0xc8, 0xeb, 0x57, 
+	0x36, 0x3e, 0x54, 0x32, 0xaf, 0xe9, 0xa6, 0xfd, 0x22, 0xf2, 
+	0x3a, 0x1, 0x48, 0xc7, 0x1, 0x40, 0x5c, 0x91, 0x54, 0xf3, 
+	0xb9, 0x37, 0xd7, 0xd3, 0xe9, 0x9c, 0x5d, 00, 0x48, 0x2, 
+	0x22, 00, 0xad, 0x4a, 0x67, 0xd2, 0x52, 0xe8, 0x3a, 0x5, 
+	0x67, 0xb4, 0x9d, 0x9f, 0xa4, 0x9f, 0x8f, 0x27, 0x6, 0xf2, 
+	0xb5, 0x7c, 0x5a, 0x5e, 0xaf, 0x5c, 0x2b, 0xae, 0xcb, 0x80, 
+	0xf2, 0xed, 0x43, 0xe1, 0xa4, 0xca, 0xeb, 0xbb, 0x11, 0xd8, 
+	0x5c, 0x59, 0x60, 0x27, 0x3, 0xbd, 0x3, 0xc0, 0x3f, 0xde, 
+	0x1d, 0xd7, 0x83, 0xd3, 0xf8, 0x39, 0xad, 0xd4, 0x1f, 0x2, 
+	0x70, 0x44, 0x3, 0xce, 0xfd, 0x1c, 0xa5, 0xa2, 0x76, 0xa7, 
+	0x65, 0xd2, 0xbc, 0x9f, 0xeb, 0xb1, 0xd1, 0x5f, 0x1, 0xb0, 
+	0xa9, 0x9a, 0xf8, 0x73, 0x94, 0x2d, 0xaf, 0x97, 0x1, 0x60, 
+	0xaa, 0xd0, 0x43, 0x1a, 0x48, 0x91, 0x4d, 0xcf, 0x37, 0xe8, 
+	0x39, 0xe2, 0x45, 0x7d, 0x9e, 0xf5, 0x90, 0x34, 0x92, 0x5b, 
+	0x21, 0xa8, 0xeb, 0x46, 0xcf, 0xa0, 0x57, 0xcf, 0x4c, 0x84, 
+	0xb5, 0x62, 0x7f, 0xb4, 0xaa, 0x6, 0x8e, 0x34, 0x7f, 0x5f, 
+	0xd9, 0x91, 0x66, 0x14, 0x5, 0xe0, 0x50, 0x47, 0x56, 0xc5, 
+	0x2e, 0x23, 0xb6, 0x4c, 0x54, 0x47, 0xf6, 0x7, 0x69, 0x35, 
+	0x1, 0x60, 0xcb, 0x4, 0x13, 0x6, 0x84, 0x1, 0x61, 0x40, 
+	0x18, 0x68, 0x9d, 0x81, 0x5f, 0xb8, 0x54, 0x95, 0x81, 0xad, 
+	0x72, 0xa, 0x83, 0x3c, 0x3b, 0x6, 0x4c, 0x1a, 0x82, 0xbb, 
+	0x2d, 0x8a, 0x1, 0x24, 0x1, 0x55, 0x35, 0xb0, 0x55, 0x8e, 
+	0xb1, 0xf9, 0xde, 0xa2, 0x86, 0x3c, 0x43, 0x6, 0x60, 0x24, 
+	0x67, 0xfd, 0x86, 0xa5, 0x6, 0xc, 0xc, 0xe1, 0x14, 0xdc, 
+	0x60, 0xb4, 0x9a, 0xa7, 0x6, 0x60, 0xc4, 0x6e, 0x35, 0x6c, 
+	0x78, 0x6a, 0xa0, 0x98, 0x87, 0x5a, 0x96, 0x1a, 0xb0, 0x2e, 
+	0xf6, 0x7e, 0xb6, 0x6c, 0xb5, 0xc5, 0x31, 0x80, 0xb4, 0xaa, 
+	0xc, 0x6c, 0x95, 0x93, 0x6f, 0x6a, 0x28, 0xb, 0x79, 0x7e, 
+	0xc, 0x68, 0x98, 0x79, 0x6b, 0x2f, 0x3, 0x9e, 0xc, 0x38, 
+	0xc7, 0x5d, 0x5f, 0xa0, 0x61, 0xcb, 0x94, 0x81, 0x3c, 0x23, 
+	0x66, 0xca, 0x80, 0xa, 0x55, 0x48, 0xf3, 0x65, 0x60, 0xae, 
+	0x42, 0x3c, 0x19, 0x28, 0xaa, 0x10, 0x4f, 0x6, 0xa0, 0x23, 
+	0x86, 0x9e, 0xc0, 0x6d, 0x78, 0x32, 00, 0x3d, 0x18, 0x24, 
+	0xf7, 0xf, 0xc7, 0xc0, 0x27, 0x2e, 0x55, 0x65, 0x60, 0xab, 
+	0x1c, 0x7f, 0x53, 0xd4, 0xfa, 0x31, 0x1d, 0xe4, 0xd9, 0x31, 
+	0x60, 0x52, 0x57, 0xec, 0xba, 0x32, 0x14, 0x3, 0x48, 0x2, 
+	0xaa, 0x6a, 0x60, 0xab, 0x1c, 0xe3, 0xef, 0x55, 0x7b, 0x2, 
+	0x34, 0xe4, 0xf9, 0x31, 0xa0, 0xd3, 0x84, 0xc6, 0xe0, 0x18, 
+	0x68, 0x4d, 0x3, 0xe5, 0x94, 0x92, 0xa7, 0x6, 0xe6, 0x35, 
+	0x5, 0x9e, 0x1a, 0x28, 0x6f, 0xab, 0xd4, 0xd7, 00, 0x3c, 
+	0xf7, 0x33, 0xa6, 0x5, 0xec, 0xeb, 0xbe, 0xaf, 0x8b, 0xdf, 
+	0x4f, 0xe7, 0x5c, 0xc6, 0x23, 0xeb, 0xcd, 0xfb, 0xc, 0x20, 
+	0x6d, 0x7e, 0xd4, 0x20, 0x3f, 0x23, 0xb1, 0xf, 0x20, 0xff, 
+	0xfe, 0x18, 0x3f, 0x4b, 00, 0xc5, 0xec, 0xf1, 0x71, 00, 
+	0x87, 0x18, 0x78, 0xcb, 0x4f, 0xa4, 0x1c, 0x3, 0x90, 0x9f, 
+	00, 0x29, 00, 0x14, 0xeb, 0x69, 0xf1, 0xaf, 0x59, 0xd3, 
+	0x1a, 0x9b, 0x2a, 0xd7, 0x9f, 0x9f, 0xc2, 0x40, 0xf9, 0xe0, 
+	0x6, 0xa, 0x40, 0x78, 0x28, 0xaa, 0x60, 0x60, 0xb5, 0xde, 
+	0x1c, 0x17, 0x1, 0x43, 0xd2, 0xaa, 0x5c, 0x7f, 0x7e, 0xe, 
+	0x3, 0x47, 0x1, 0xac, 0x19, 0x58, 0xad, 0x37, 0x97, 0x7f, 
+	0x3f, 0x6c, 0xc2, 0x7f, 0xd, 0x93, 0xd7, 0x9f, 0xdb, 0x60, 
+	0xe0, 0x6, 0xc0, 0x72, 0xbd, 0xb9, 0x4, 0x10, 0x1e, 0x4f, 
+	0x98, 0xd7, 0x9f, 0xab, 0x33, 0x30, 0xa5, 0x67, 0xe3, 0x90, 
+	00, 0x7c, 0x2b, 0xf4, 0x95, 0x6, 0x16, 0x55, 0xc8, 0xc6, 
+	0xbf, 0x29, 0x8e, 0x55, 0x2b, 0x1e, 0xab, 0xce, 0x40, 0xb2, 
+	0xc5, 0xf3, 0x40, 0x5b, 00, 0xa6, 0xf5, 0x39, 0x95, 0x1f, 
+	0xb7, 0xf9, 0xf5, 0x89, 0x4b, 0x55, 0x7b, 0x62, 0x64, 0x99, 
+	0x90, 0xea, 0x32, 0x50, 0x9, 00, 0xb6, 0x4c, 0xb0, 0x7d, 
+	00, 0xc8, 0x50, 0x54, 0x5, 0x70, 0x80, 0x82, 0xd7, 0x67, 
+	0xe0, 0x88, 0x6, 0xc6, 0x2a, 0xc6, 0x5e, 0x3, 0x13, 0x8d, 
+	0x6, 0xde, 0xaa, 0x31, 0x30, 0xd2, 0x68, 0x60, 0xaa, 0x9, 
+	0xa0, 0x2a, 0x3, 0x8d, 0x99, 0x2a, 0x8c, 0x25, 0x80, 0xae, 
+	0x78, 0x9, 0x4, 0x4f, 00, 0x2e, 0xf2, 0x5d, 0xd7, 0xf7, 
+	0x6e, 0xc3, 0x16, 00, 0x60, 0x50, 0x3d, 0x5f, 00, 0x5d, 
+	0x10, 0x40, 0xcf, 0x16, 0x40, 0x1f, 00, 0x74, 0x6c, 0x1, 
+	0xa8, 0xf0, 0x56, 0x1c, 0xb6, 0x55, 0xa8, 0xf3, 0xf5, 0x1f, 
+	0xbe, 0x99, 0x2, 0x38, 0x2c, 0xe2, 0xf7, 0x2a, 0xe9, 0xf7, 
+	0x8f, 0x3a, 0xd7, 0x79, 0xef, 0xfa, 0xd4, 0x8d, 0x75, 0x3d, 
+	0xe4, 0xcf, 0x62, 0xe0, 0x43, 0xd7, 0x63, 0xa0, 0xf, 0x1a, 
+	0x46, 0x32, 0x50, 0x29, 0x70, 0x1f, 0xaa, 0x12, 0x5, 0x8e, 
+	0x81, 0xde, 0x5, 0xdf, 0x1, 0xe8, 0x7a, 0xc8, 0x9f, 0xc6, 
+	0x80, 0xaa, 0x44, 0x41, 0x9, 00, 0xc5, 0x40, 0x2d, 0xd, 
+	0xa8, 0x4a, 0x14, 0x2c, 0xaa, 0xd0, 0x99, 0x1a, 0x50, 0x95, 
+	0x28, 0xf0, 0x22, 0x8e, 0x5f, 0x28, 0x6, 0xaa, 0x69, 0x40, 
+	0xdb, 0x3a, 0x1a, 0x50, 0xbe, 0xf6, 0xf8, 0x66, 0xf4, 0x54, 
+	0xd, 0x68, 0xf5, 0xa3, 0xe, 0x3, 0xe, 0xc1, 0xa0, 0x3a, 
+	0x7c, 0x47, 0xf6, 0x5e, 0xc7, 0x7e, 0x5b, 0xa7, 0x81, 0x1a, 
+	0x16, 0x86, 0x12, 0xa1, 0x2f, 0x83, 0xfc, 0x59, 0xc, 0x7c, 
+	0x7e, 0xd8, 0x4a, 0xc, 0xa8, 0x3e, 0xbe, 0xa5, 0x12, 0xdb, 
+	0xf, 0x34, 0x66, 0x30, 0x9c, 0xee, 00, 0x45, 0x7f, 0x32, 
+	0x3, 0xb5, 0xc, 0x44, 0xdc, 0xd, 0x7d, 0x8f, 0x1e, 0xb, 
+	0x51, 0x47, 0xfc, 0x96, 0x1, 0xff, 0x6e, 0xd5, 0xfe, 0x74, 
+	0xd, 0x54, 0x63, 0x60, 0xf0, 0xe1, 0xef, 0x3a, 0xec, 0xa4, 
+	0x9e, 0x3a, 0xe2, 0x6b, 0xb, 0xf3, 0x99, 0xd0, 0xc, 0xe1, 
+	0x18, 0xf8, 0x4b, 0x93, 0x5c, 0x5f, 0x35, 0x28, 0x84, 0x35, 
+	0xcb, 0x40, 0x2, 0x30, 0x8f, 0xff, 0x1f, 0x4, 0x40, 0x44, 
+	0xc0, 0xa7, 0x7, 00, 0x2f, 0x62, 0x4d, 00, 0x40, 0xb8, 
+	0xe1, 0x85, 0xc2, 0xca, 0xbf, 0x5b, 0x36, 0xee, 0x37, 0xcc, 
+	0x40, 0x3f, 0xc4, 0x77, 0xf8, 0xaa, 0xc4, 0x44, 0xd7, 0xdf, 
+	0xa6, 0x76, 0x35, 00, 0x4a, 0xcd, 0xaf, 0x27, 0xe, 0x77, 
+	0x22, 0x42, 0x3e, 0x2, 0x89, 0xfb, 0xed, 0x32, 0xe0, 0xdc, 
+	0x4f, 0xce, 0xa6, 0x39, 0x70, 0xc8, 0x47, 0x30, 0x71, 0xbf, 
+	0x7d, 0xd, 0xa4, 0x2a, 0x14, 0xdf, 0x92, 0x9c, 0xe7, 0x3, 
+	0x71, 0xbf, 0x59, 0x6, 0x30, 0x4d, 0x28, 0xae, 0x15, 0x6a, 
+	0xdc, 0x9a, 0x65, 00, 0x6b, 0xc2, 00, 0xb5, 0x9, 0x3, 
+	0xd4, 0x26, 0xc, 0x50, 0xdb, 0x37, 0x60, 0x60, 0x68, 0x3b, 
+	0xbd, 0x3e, 0x3, 0xe4, 0x21, 0xde, 0x49, 0xaf, 0xcf, 00, 
+	0x79, 0x88, 0x45, 0x3, 0xd4, 0x21, 0xfe, 0xf6, 0x1a, 0x18, 
+	0x1a, 0x37, 0x61, 0x80, 0xda, 0x84, 0x1, 0x6a, 0x13, 0x6, 
+	0xa8, 0x6d, 0x9f, 0x81, 0xa1, 0xed, 0xf4, 0xfa, 0xc, 0x90, 
+	0x87, 0x78, 0x27, 0xbd, 0x3e, 0x3, 0xe4, 0x21, 0x16, 0xd, 
+	0x50, 0x87, 0xf8, 0xdb, 0x6b, 0x80, 0x9b, 0x9, 00, 0x6a, 
+	0x13, 00, 0xd4, 0x26, 00, 0xa8, 0x4d, 00, 0x50, 0x9b, 
+	00, 0xa0, 0x36, 0x1, 0x40, 0x6d, 0x2, 0x80, 0xda, 0x4, 
+	00, 0xb5, 0x9, 00, 0x6a, 0x13, 00, 0xd4, 0x26, 00, 
+	0xa8, 0x4d, 00, 0x50, 0x9b, 00, 0xa0, 0x36, 0x1, 0x40, 
+	0x6d, 0x2, 0x80, 0xda, 0x4, 00, 0xb5, 0x9, 00, 0x6a, 
+	0x63, 0xf, 0xe0, 0x7f, 0xaa, 0x34, 0x79, 0xbd, 0xcc, 0x79, 
+	0xa3, 0xc, 00, 00, 00, 00, 0x49, 0x45, 0x4e, 0x44, 
+	0xae, 0x42, 0x60, 0x82, 0};
+
+static const unsigned char data_upload_html[] = {
+	/* /upload.html */
+	0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x62, 0x6f, 
+	0x64, 0x79, 0x3e, 0xa, 0x3c, 0x66, 0x6f, 0x72, 0x6d, 0x20, 
+	0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x75, 0x70, 
+	0x6c, 0x6f, 0x61, 0x64, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 
+	0x20, 0x65, 0x6e, 0x63, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 
+	0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 
+	0x66, 0x6f, 0x72, 0x6d, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x22, 
+	0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3d, 0x22, 0x70, 
+	0x6f, 0x73, 0x74, 0x22, 0x3e, 0xa, 0x3c, 0x69, 0x6e, 0x70, 
+	0x75, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x75, 
+	0x73, 0x65, 0x72, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x20, 0x74, 
+	0x79, 0x70, 0x65, 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x22, 
+	0x20, 0x73, 0x69, 0x7a, 0x65, 0x3d, 0x22, 0x35, 0x30, 0x22, 
+	0x20, 0x2f, 0x3e, 0xa, 0x3c, 0x69, 0x6e, 0x70, 0x75, 0x74, 
+	0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x55, 0x70, 
+	0x6c, 0x6f, 0x61, 0x64, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 
+	0x3d, 0x22, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x22, 0x20, 
+	0x2f, 0x3e, 0xa, 0x3c, 0x2f, 0x66, 0x6f, 0x72, 0x6d, 0x3e, 
+	0xa, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 
+	0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
+
+static const unsigned char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 
+	0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 
+	0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 
+	0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33, 
+	0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 
+	0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 
+	0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+0};
+
+static const unsigned char data_style_css[] = {
+	/* /style.css */
+	0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
+	0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20, 
+	0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 
+	0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 
+	0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 
+	0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 
+	0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 
+	0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70, 
+	0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 
+	0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64, 
+	0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 
+	0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65, 
+	0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 
+	0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 
+	0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 
+	0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa, 
+	0xa, 0x2e, 0x77, 0x72, 0x61, 0x70, 0x20, 0x7b, 0xa, 0x20, 
+	0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x20, 0x39, 0x38, 
+	0x25, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 
+	0x6e, 0x3a, 0x20, 0x30, 0x20, 0x61, 0x75, 0x74, 0x6f, 0x3b, 
+	0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 
+	0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 
+	0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 
+	0x3b, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xa, 
+	0x7d, 0xa, 0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6c, 
+	0x6f, 0x63, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61, 
+	0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78, 0x3b, 
+	0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 0x31, 
+	0x35, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 
+	0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 
+	0x30, 0x70, 0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 
+	0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 
+	0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 
+	0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 
+	0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 
+	0x66, 0x66, 0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 
+	0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 
+	0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 
+	0x3a, 0x39, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 
+	0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 
+	0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 
+	0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 
+	0xa, 0xa, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 
+	0x62, 0x6c, 0x6f, 0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 
+	0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 
+	0x34, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3a, 0x35, 0x30, 0x25, 0x3b, 0xa, 0x20, 0x20, 
+	0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 
+	0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 
+	0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 
+	0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74, 0x65, 0x64, 
+	0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 
+	0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 
+	0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 
+	0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 
+	0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 
+	0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 
+	0xa, 0x7d, 0xa, 0xa, 0x2e, 0x6e, 0x65, 0x77, 0x73, 0x62, 
+	0x6c, 0x6f, 0x63, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 
+	0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78, 
+	0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a, 
+	0x32, 0x34, 0x25, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 
+	0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0xa, 
+	0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 
+	0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 
+	0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 
+	0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 
+	0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 
+	0x66, 0x66, 0x66, 0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 
+	0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 
+	0x3a, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38, 
+	0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 
+	0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 
+	0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e, 0x70, 
+	0x72, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 
+	0x20, 0x34, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 
+	0x64, 0x74, 0x68, 0x3a, 0x32, 0x34, 0x25, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 0x66, 
+	0x74, 0x3b, 0xa, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 
+	0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 
+	0x3a, 0x20, 0x30, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 
+	0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65, 
+	0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 
+	0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 
+	0x68, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 
+	0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 
+	0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 
+	0x3b, 0xa, 0x7d, 0xa, 0xa, 0x64, 0x69, 0x76, 0x2e, 0x72, 
+	0x66, 0x69, 0x67, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x62, 0x6f, 
+	0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 
+	0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0x20, 0xa, 0xa, 0x20, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 
+	0x6e, 0x3a, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 
+	0x20, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 
+	0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 
+	0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 
+	0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 
+	0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x72, 
+	0x69, 0x67, 0x68, 0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 
+	0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 
+	0x70, 0x78, 0x3b, 0x20, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 
+	0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x31, 0x30, 0x70, 0x78, 
+	0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 
+	0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x74, 
+	0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 
+	0x20, 0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x38, 
+	0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 
+	0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 
+	0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 
+	0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x2d, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3a, 0x70, 
+	0x72, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0xa, 
+	0x70, 0x2e, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 
+	0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 
+	0x65, 0x66, 0x74, 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 
+	0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 
+	0x69, 0x67, 0x68, 0x74, 0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 
+	0x2f, 0x2a, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 
+	0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 
+	0x3b, 0x20, 0x2a, 0x2f, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 
+	0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 
+	0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 
+	0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 
+	0x7a, 0x65, 0x3a, 0x31, 0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 
+	0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 
+	0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 
+	0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 
+	0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 
+	0x63, 0x6c, 0x69, 0x6e, 0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 
+	0x3a, 0x39, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 
+	0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 
+	0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 
+	0x6e, 0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 
+	0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 
+	0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x72, 0x65, 0x6c, 
+	0x61, 0x74, 0x65, 0x64, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 
+	0x30, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 
+	0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 
+	0x74, 0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 
+	0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 
+	0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 
+	0xa, 0xa, 0xa, 0xa, 0x69, 0x6d, 0x67, 0x2e, 0x72, 0x69, 
+	0x67, 0x68, 0x74, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6c, 
+	0x6f, 0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 
+	0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 
+	0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x69, 
+	0x6d, 0x67, 0x2e, 0x6c, 0x65, 0x66, 0x74, 0xa, 0x7b, 0xa, 
+	0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 
+	0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 
+	0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 
+	0xa, 0xa, 0x70, 0x2e, 0x66, 0x69, 0x67, 0xa, 0x7b, 0xa, 
+	0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 
+	0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 
+	0x20, 0xa, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 
+	0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 
+	0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x31, 0x30, 0x70, 
+	0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 
+	0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 
+	0x3a, 0x37, 0x70, 0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 
+	0x2e, 0x72, 0x66, 0x69, 0x67, 0xa, 0x7b, 0xa, 0x20, 0x20, 
+	0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 
+	0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 0x3b, 0x20, 0xa, 
+	0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 
+	0x69, 0x6e, 0x67, 0x3a, 0x20, 0x31, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 
+	0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 
+	0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x37, 
+	0x70, 0x74, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 
+	0x61, 0x74, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0xa, 
+	0x7d, 0xa, 0xa, 0xa, 0x70, 0x2e, 0x6c, 0x66, 0x69, 0x67, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 
+	0x70, 0x78, 0x3b, 0x20, 0xa, 0xa, 0x20, 0x20, 0x74, 0x65, 
+	0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0xa, 0x20, 
+	0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 
+	0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 
+	0x72, 0x67, 0x69, 0x6e, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 
+	0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 
+	0x69, 0x7a, 0x65, 0x3a, 0x37, 0x70, 0x74, 0x3b, 0xa, 0xa, 
+	0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x6c, 0x65, 
+	0x66, 0x74, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0xa, 0x7b, 
+	0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 
+	0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a, 0x31, 0x30, 0x70, 0x78, 
+	0x3b, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x6d, 0x61, 0x69, 
+	0x6c, 0x61, 0x64, 0x64, 0x72, 0xa, 0x7b, 0xa, 0x20, 0x20, 
+	0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 
+	0x66, 0x74, 0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 
+	0x3a, 0x37, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 
+	0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 
+	0x63, 0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x74, 0x65, 
+	0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x3b, 0xa, 0x20, 0x20, 
+	0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 
+	0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20, 0xa, 0x7d, 
+	0xa, 0xa, 0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 
+	0x7b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 
+	0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 
+	0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x62, 0x6f, 
+	0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65, 
+	0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 
+	0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 
+	0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31, 0x34, 0x70, 
+	0x74, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61, 0x64, 0x64, 
+	0x69, 0x6e, 0x67, 0x3a, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 
+	0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x34, 0x70, 
+	0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 
+	0x6e, 0x2d, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x3a, 0x31, 
+	0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x62, 0x6c, 0x63, 0x61, 0x6b, 
+	0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 
+	0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 
+	0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x63, 0x62, 0x61, 0x3b, 
+	0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 
+	0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64, 0x20, 0x31, 0x70, 0x78, 
+	0x3b, 0xa, 0xa, 0x7d, 0x20, 0xa, 0xa, 0xa, 0xa, 0xa, 
+0};
+
+static const unsigned char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 
+	0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 
+	0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, 
+	0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 
+	0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, 
+	0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 
+	0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, 
+	0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, 
+	0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 
+	0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x20, 0x73, 0x65, 
+	0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 
+	0x69, 0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x73, 
+	0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, 0x65, 0x65, 0x74, 0x22, 
+	0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 
+	0x74, 0x2f, 0x63, 0x73, 0x73, 0x22, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 
+	0x63, 0x73, 0x73, 0x22, 0x3e, 0x20, 0x20, 0xa, 0x20, 0x20, 
+	0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 0x20, 
+	0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23, 0x66, 0x66, 0x66, 0x65, 
+	0x65, 0x63, 0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 
+	0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 
+	0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6c, 0x6f, 
+	0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 
+	0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 
+	0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x62, 
+	0x6f, 0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 
+	0x65, 0x22, 0x3e, 0x4d, 0x65, 0x6e, 0x75, 0x3c, 0x2f, 0x70, 
+	0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 
+	0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 
+	0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 0x72, 
+	0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x66, 0x69, 
+	0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 
+	0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 
+	0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 
+	0x77, 0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 
+	0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x70, 0x72, 0x6f, 0x63, 
+	0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 
+	0x6c, 0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 
+	0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0xa, 0x20, 
+	0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 
+	0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 
+	0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 
+	0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 
+	0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 
+	0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 
+	0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 
+	0xa, 0x20, 0x20, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 
+	0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 
+	0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 
+	0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 
+	0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 
+	0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x20, 0xa, 0x20, 0x20, 0x77, 0x65, 0x62, 
+	0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0xa, 0x20, 
+	0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0};
+
+static const unsigned char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 
+	0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 
+	0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f, 
+	0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 
+	0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 
+	0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45, 
+	0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 
+	0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 
+	0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34, 
+	0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64, 
+	0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 
+	0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 
+	0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 
+	0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 
+	0x20, 0x74, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 
+	0x65, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 
+	0x6e, 0x6b, 0x20, 0x72, 0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 
+	0x79, 0x6c, 0x65, 0x73, 0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 
+	0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 
+	0x2f, 0x63, 0x73, 0x73, 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 
+	0x73, 0x73, 0x22, 0x3e, 0x20, 0x20, 0xa, 0x20, 0x20, 0x3c, 
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20, 0x20, 0x3c, 
+	0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 
+	0x6f, 0x72, 0x3d, 0x22, 0x23, 0x66, 0x66, 0x66, 0x65, 0x65, 
+	0x63, 0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 
+	0x6c, 0x61, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 
+	0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 
+	0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6c, 0x6f, 0x63, 
+	0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 
+	0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 
+	0x65, 0x6e, 0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x62, 0x6f, 
+	0x72, 0x64, 0x65, 0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65, 
+	0x22, 0x3e, 0x4d, 0x65, 0x6e, 0x75, 0x3c, 0x2f, 0x70, 0x3e, 
+	0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 0x61, 0x73, 
+	0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x3e, 0xa, 
+	0x20, 0x20, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 
+	0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46, 0x72, 0x6f, 
+	0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x61, 
+	0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x66, 0x69, 0x6c, 
+	0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 
+	0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 
+	0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 
+	0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x70, 0x72, 0x6f, 0x63, 0x65, 
+	0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 
+	0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 
+	0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0xa, 0x20, 0x20, 
+	0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 
+	0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 
+	0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 
+	0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x63, 0x6f, 
+	0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 
+	0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 0x6c, 
+	0x61, 0x73, 0x73, 0x3d, 0x22, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x2d, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3e, 0xa, 
+	0x20, 0x20, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 
+	0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 
+	0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 
+	0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x3c, 0x2f, 
+	0x61, 0x3e, 0x20, 0xa, 0x20, 0x20, 0x77, 0x65, 0x62, 0x20, 
+	0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0xa, 0x20, 0x20, 
+	0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x20, 0x63, 
+	0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x69, 0x6e, 0x74, 0x72, 
+	0x6f, 0x22, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 
+	0x68, 0x65, 0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 
+	0x65, 0x73, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x61, 0x72, 0x65, 
+	0x20, 0x77, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x20, 
+	0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 
+	0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x3c, 0x61, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 
+	0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 
+	0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 
+	0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x61, 0x70, 0x70, 0x73, 0x2f, 0x77, 0x65, 
+	0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x68, 0x74, 
+	0x6d, 0x6c, 0x22, 0x3e, 0x77, 0x65, 0x62, 0xa, 0x9, 0x20, 
+	0x20, 0x20, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 
+	0x67, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 
+	0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 
+	0x3e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x6f, 
+	0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0xa, 0x9, 
+	0x20, 0x20, 0x20, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 
+	0x2f, 0x70, 0x3e, 0xa, 0xa, 0x9, 0x20, 0x20, 0xa, 0x9, 
+	0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 
+	0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
+
+static const unsigned char data_footer_html[] = {
+	/* /footer.html */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 
+	0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
+
+static const unsigned char data_files_shtml[] = {
+	/* /files.shtml */
+	0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x20, 0x3c, 0x68, 
+	0x31, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 
+	0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x20, 0x3c, 0x74, 
+	0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, 0x6e, 0x64, 0x65, 
+	0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x69, 
+	0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x20, 
+	0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 
+	0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x69, 
+	0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 
+	0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 
+	0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 
+	0x22, 0x3e, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 
+	0x73, 0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 
+	0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 
+	0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 
+	0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70, 0x2e, 
+	0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 
+	0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 
+	0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 
+	0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 
+	0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 
+	0x3d, 0x22, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 
+	0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 
+	0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 
+	0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 
+	0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 
+	0x61, 0x74, 0x73, 0x20, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 
+	0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 
+	0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 
+	0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 
+	0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 
+	0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 
+	0x3e, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 
+	0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 
+	0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 
+	0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 
+	0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2e, 0x63, 0x73, 
+	0x73, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 
+	0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 
+	0x3e, 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 
+	0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 
+	0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 
+	0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 
+	0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, 0x6d, 0x67, 
+	0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 
+	0x74, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x69, 0x6d, 
+	0x67, 0x2f, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 
+	0x6f, 0x74, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 
+	0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 
+	0x61, 0x74, 0x73, 0x20, 0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 
+	0x63, 0x72, 0x65, 0x65, 0x6e, 0x73, 0x68, 0x6f, 0x74, 0x2e, 
+	0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 
+	0x65, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 
+	0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
+
+static const unsigned char data_processes_shtml[] = {
+	/* /processes.shtml */
+	0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 
+	0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c, 
+	0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65, 
+	0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 
+	0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 
+	0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 
+	0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 
+	0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
+
+static const unsigned char data_tcp_shtml[] = {
+	/* /tcp.shtml */
+	0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 
+	0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f, 
+	0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 
+	0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 
+	0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 
+	0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 
+	0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63, 
+	0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 
+	0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 
+	0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 
+0};
+
+const struct httpd_fsdata_file file_img_screenshot_png[] = {{NULL, data_img_screenshot_png, data_img_screenshot_png + 20, sizeof(data_img_screenshot_png) - 20}};
+
+const struct httpd_fsdata_file file_upload_html[] = {{file_img_screenshot_png, data_upload_html, data_upload_html + 13, sizeof(data_upload_html) - 13}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_upload_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_style_css[] = {{file_404_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_style_css, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_footer_html[] = {{file_index_html, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
+
+const struct httpd_fsdata_file file_files_shtml[] = {{file_footer_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
+
+const struct httpd_fsdata_file file_processes_shtml[] = {{file_files_shtml, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
+
+const struct httpd_fsdata_file file_tcp_shtml[] = {{file_processes_shtml, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
+
+#define HTTPD_FS_ROOT file_tcp_shtml
+
+#define HTTPD_FS_NUMFILES 10
diff --git a/contiki/apps/httpd-fsdata.h b/contiki/apps/httpd-fsdata.h
new file mode 100644
index 0000000..61708ed
--- /dev/null
+++ b/contiki/apps/httpd-fsdata.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.h,v 1.2 2004/06/06 05:59:21 adamdunkels Exp $
+ */
+#ifndef __HTTPD_FSDATA_H__
+#define __HTTPD_FSDATA_H__
+
+#include "uipopt.h"
+
+struct httpd_fsdata_file {
+  const struct httpd_fsdata_file *next;
+  const char *name;
+  const char *data;
+  const int len;
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+  u16_t count;
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+};
+
+struct httpd_fsdata_file_noconst {
+  struct httpd_fsdata_file *next;
+  char *name;
+  char *data;
+  int len;
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+  u16_t count;
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+};
+
+#endif /* __HTTPD_FSDATA_H__ */
diff --git a/contiki/apps/httpd.c b/contiki/apps/httpd.c
new file mode 100644
index 0000000..caadc02
--- /dev/null
+++ b/contiki/apps/httpd.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd.c,v 1.10 2007/06/02 07:32:06 ryohji Exp $
+ */
+
+#include "contiki.h"
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-cgi.h"
+#include "psock.h"
+#include "http-strings.h"
+
+#include <string.h>
+
+#define STATE_WAITING 0
+#define STATE_OUTPUT  1
+
+#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str)) 
+MEMB(conns, sizeof(struct httpd_state), 8);
+
+#define ISO_nl      0x0a
+#define ISO_space   0x20
+#define ISO_bang    0x21
+#define ISO_percent 0x25
+#define ISO_period  0x2e
+#define ISO_slash   0x2f
+#define ISO_colon   0x3a
+
+
+/*---------------------------------------------------------------------------*/
+static unsigned short
+generate(void *state)
+{
+  struct httpd_state *s = (struct httpd_state *)state;
+
+  if(s->file.len > uip_mss()) {
+    s->len = uip_mss();
+  } else {
+    s->len = s->file.len;
+  }
+  memcpy(uip_appdata, s->file.data, s->len);
+  
+  return s->len;
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_file(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sout);
+  
+  do {
+    PSOCK_GENERATOR_SEND(&s->sout, generate, s);
+    s->file.len -= s->len;
+    s->file.data += s->len;
+  } while(s->file.len > 0);
+      
+  PSOCK_END(&s->sout);  
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_part_of_file(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sout);
+
+  PSOCK_SEND(&s->sout, s->file.data, s->len);
+  
+  PSOCK_END(&s->sout);  
+}
+/*---------------------------------------------------------------------------*/
+static void
+next_scriptstate(struct httpd_state *s)
+{
+  char *p;
+  p = strchr(s->scriptptr, ISO_nl) + 1;
+  s->scriptlen -= (unsigned short)(p - s->scriptptr);
+  s->scriptptr = p;
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_script(struct httpd_state *s))
+{
+  char *ptr;
+  
+  PT_BEGIN(&s->scriptpt);
+
+
+  while(s->file.len > 0) {
+
+    /* Check if we should start executing a script. */
+    if(*s->file.data == ISO_percent &&
+       *(s->file.data + 1) == ISO_bang) {
+      s->scriptptr = s->file.data + 3;
+      s->scriptlen = s->file.len - 3;
+      if(*(s->scriptptr - 1) == ISO_colon) {
+	httpd_fs_open(s->scriptptr + 1, &s->file);
+	PT_WAIT_THREAD(&s->scriptpt, send_file(s));       
+      } else {
+	PT_WAIT_THREAD(&s->scriptpt,
+		       httpd_cgi(s->scriptptr)(s, s->scriptptr));
+      }
+      next_scriptstate(s);
+      
+      /* The script is over, so we reset the pointers and continue
+	 sending the rest of the file. */
+      s->file.data = s->scriptptr;
+      s->file.len = s->scriptlen;
+    } else {
+      /* See if we find the start of script marker in the block of HTML
+	 to be sent. */
+
+      if(s->file.len > uip_mss()) {
+	s->len = uip_mss();
+      } else {
+	s->len = s->file.len;
+      }
+
+      if(*s->file.data == ISO_percent) {
+	ptr = strchr(s->file.data + 1, ISO_percent);
+      } else {
+	ptr = strchr(s->file.data, ISO_percent);
+      }
+      if(ptr != NULL &&
+	 ptr != s->file.data) {
+	s->len = (int)(ptr - s->file.data);
+	if(s->len >= uip_mss()) {
+	  s->len = uip_mss();
+	}
+      }
+      PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
+      s->file.data += s->len;
+      s->file.len -= s->len;
+      
+    }
+  }
+  
+  PT_END(&s->scriptpt);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
+{
+  static char *ptr;
+
+  PSOCK_BEGIN(&s->sout);
+
+  SEND_STRING(&s->sout, statushdr);
+
+  ptr = strrchr(s->filename, ISO_period);
+  if(ptr == NULL) {
+    SEND_STRING(&s->sout, http_content_type_binary);
+  } else if(strncmp(http_html, ptr, 5) == 0 ||
+	    strncmp(http_shtml, ptr, 6) == 0) {
+    SEND_STRING(&s->sout, http_content_type_html);
+  } else if(strncmp(http_css, ptr, 4) == 0) {
+    SEND_STRING(&s->sout, http_content_type_css);
+  } else if(strncmp(http_png, ptr, 4) == 0) {
+    SEND_STRING(&s->sout, http_content_type_png);
+  } else if(strncmp(http_gif, ptr, 4) == 0) {
+    SEND_STRING(&s->sout, http_content_type_gif);
+  } else if(strncmp(http_jpg, ptr, 4) == 0) {
+    SEND_STRING(&s->sout, http_content_type_jpg);	
+  } else {
+    SEND_STRING(&s->sout, http_content_type_plain);
+  }
+  PSOCK_END(&s->sout);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(struct httpd_state *s))
+{
+  char *ptr;
+  
+  PT_BEGIN(&s->outputpt);
+ 
+  if(!httpd_fs_open(s->filename, &s->file)) {
+    httpd_fs_open(http_404_html, &s->file);
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_headers(s,
+		   http_header_404));
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_file(s));
+  } else {
+    PT_WAIT_THREAD(&s->outputpt,
+		   send_headers(s,
+		   http_header_200));
+    ptr = strchr(s->filename, ISO_period);
+    if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
+      PT_INIT(&s->scriptpt);
+      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
+    } else {
+      PT_WAIT_THREAD(&s->outputpt,
+		     send_file(s));
+    }
+  }
+  PSOCK_CLOSE(&s->sout);    
+  PT_END(&s->outputpt);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(struct httpd_state *s))
+{
+  PSOCK_BEGIN(&s->sin);
+
+  PSOCK_READTO(&s->sin, ISO_space);
+
+  
+  if(strncmp(s->inputbuf, http_get, 4) != 0) {
+    PSOCK_CLOSE_EXIT(&s->sin);
+  }
+  PSOCK_READTO(&s->sin, ISO_space);
+
+  if(s->inputbuf[0] != ISO_slash) {
+    PSOCK_CLOSE_EXIT(&s->sin);
+  }
+
+  if(s->inputbuf[1] == ISO_space) {
+    strncpy(s->filename, http_index_html, sizeof(s->filename));
+  } else {
+    s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
+    strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
+  }
+
+  httpd_log_file(uip_conn->ripaddr, s->filename);
+  
+  s->state = STATE_OUTPUT;
+
+  while(1) {
+    PSOCK_READTO(&s->sin, ISO_nl);
+
+    if(strncmp(s->inputbuf, http_referer, 8) == 0) {
+      s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
+      httpd_log(&s->inputbuf[9]);
+    }
+  }
+  
+  PSOCK_END(&s->sin);
+}
+/*---------------------------------------------------------------------------*/
+static void
+handle_connection(struct httpd_state *s)
+{
+  handle_input(s);
+  if(s->state == STATE_OUTPUT) {
+    handle_output(s);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+  struct httpd_state *s = (struct httpd_state *)state;
+
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    if(s != NULL) {
+      memb_free(&conns, s);
+    }
+  } else if(uip_connected()) {
+    s = (struct httpd_state *)memb_alloc(&conns);
+    if(s == NULL) {
+      uip_abort();
+      return;
+    }
+    tcp_markconn(uip_conn, s);
+    PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
+    PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
+    PT_INIT(&s->outputpt);
+    s->state = STATE_WAITING;
+    timer_set(&s->timer, CLOCK_SECOND * 100);
+    handle_connection(s);
+  } else if(s != NULL) {
+    if(uip_poll()) {
+      
+      if(timer_expired(&s->timer)) {
+	uip_abort();
+	memb_free(&conns, s);
+      }
+    } 
+    timer_restart(&s->timer);
+    handle_connection(s);
+  } else {
+    uip_abort();
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+  tcp_listen(HTONS(80));
+  memb_init(&conns);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/httpd.h b/contiki/apps/httpd.h
new file mode 100644
index 0000000..d722e8e
--- /dev/null
+++ b/contiki/apps/httpd.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.8 2005/02/27 09:33:51 adamdunkels Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "contiki.h"
+
+#include "psock.h"
+#include "httpd-fs.h"
+
+struct httpd_state {
+  struct timer timer;
+  struct psock sin, sout;
+  struct pt outputpt, scriptpt;
+  char inputbuf[50];
+  char filename[20];
+  char state;
+  struct httpd_fs_file file;  
+  int len;
+  char *scriptptr;
+  int scriptlen;
+
+  unsigned short count;
+};
+
+
+void httpd_init(void);
+void httpd_appcall(void *state);
+
+void httpd_log(char *msg);
+void httpd_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff --git a/contiki/apps/irc-dsc.c b/contiki/apps/irc-dsc.c
new file mode 100644
index 0000000..28d653e
--- /dev/null
+++ b/contiki/apps/irc-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: irc-dsc.c,v 1.3 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon irc_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(irc_dsc,
+    "Internet Relay Chat client",
+    "irc.prg",
+    irc_init,
+    &irc_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char irc_icon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char irc_icon_textmap[9] = {
+  'I', 'R', 'C',
+  '-', '-', '-',
+  'I', 'R', 'C'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon irc_icon =
+  {CTK_ICON("IRC client", irc_icon_bitmap, irc_icon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/irc-dsc.h b/contiki/apps/irc-dsc.h
new file mode 100644
index 0000000..3f993b9
--- /dev/null
+++ b/contiki/apps/irc-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: irc-dsc.h,v 1.1 2004/09/01 19:11:42 adamdunkels Exp $
+ *
+ */
+#ifndef __IRC_DSC_H__
+#define __IRC_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(irc_dsc);
+
+#endif /* __IRC_DSC_H__ */
diff --git a/contiki/apps/irc.c b/contiki/apps/irc.c
new file mode 100644
index 0000000..948c391
--- /dev/null
+++ b/contiki/apps/irc.c
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc.c,v 1.9 2005/05/05 23:32:01 oliverschmidt Exp $
+ */
+
+#include "irc-conf.h"
+#include "contiki.h"
+#include "ircc.h"
+
+#include "ctk.h"
+#include "ctk-textedit.h"
+
+#include "petsciiconv.h"
+
+#include "ctk-textentry-cmdline.h"
+
+#include <string.h>
+
+#define LOG_WIDTH IRC_CONF_WIDTH
+#define LOG_HEIGHT IRC_CONF_HEIGHT
+/*
+#define LOG_WIDTH 78
+#define LOG_HEIGHT 21
+*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "IRC client", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static struct ctk_window window;
+static char log[LOG_WIDTH * LOG_HEIGHT];
+static char line[LOG_WIDTH*2];
+static struct ctk_label loglabel =
+  {CTK_LABEL(0, 0, LOG_WIDTH, LOG_HEIGHT, log)};
+static struct ctk_textentry lineedit =
+  {CTK_TEXTENTRY_INPUT(0, LOG_HEIGHT, LOG_WIDTH - 2, 1, line, sizeof(line) - 1,
+		       ctk_textentry_cmdline_input)};
+
+static struct ctk_window setupwindow;
+#define SETUPWINDOW_WIDTH 18
+#define SETUPWINDOW_HEIGHT 9
+#define MAX_SERVERLEN 32
+#define MAX_NICKLEN 16
+static u16_t serveraddr[2];
+static char server[MAX_SERVERLEN + 1];
+static char nick[MAX_NICKLEN + 1];
+static struct ctk_label serverlabel =
+  {CTK_LABEL(1, 1, 11, 1, "IRC server: ")};
+static struct ctk_textentry serverentry =
+  {CTK_TEXTENTRY(0, 2, 16, 1, server, MAX_SERVERLEN)};
+
+static struct ctk_label nicklabel =
+  {CTK_LABEL(1, 4, 13, 1, "IRC nickname: ")};
+static struct ctk_textentry nickentry =
+  {CTK_TEXTENTRY(0, 5, 16, 1, nick, MAX_NICKLEN)};
+
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(0, 7, 7, "Connect")};
+static struct ctk_button quitbutton =
+  {CTK_BUTTON(12, 7, 4, "Quit")};
+
+/*static char nick[] = "asdf";
+  static char server[] = "efnet.demon.co.uk";*/
+
+static struct ircc_state s;
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(irc_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ctk_window_close(&window);
+  ctk_window_close(&setupwindow);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_text_output(struct ircc_state *s, char *text1, char *text2)
+{
+  char *ptr;
+  int len;
+  
+  if(text1 == NULL) {
+    text1 = "";
+  }
+  
+  if(text2 == NULL) {
+    text2 = "";
+  }
+  
+  /* Scroll previous entries upwards */
+  memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
+
+  ptr = &log[LOG_WIDTH * (LOG_HEIGHT - 1)];
+  len = strlen(text1);
+
+  memset(ptr, 0, LOG_WIDTH);
+  strncpy(ptr, text1, LOG_WIDTH);
+  if(len < LOG_WIDTH) {
+    ptr += len;
+    *ptr = ':';
+    ++len;
+    if(LOG_WIDTH - len > 0) {
+      strncpy(ptr + 1, text2, LOG_WIDTH - len);
+    }
+  } else {
+    len = 0;
+  }
+
+  if(strlen(text2) > LOG_WIDTH - len) {
+    memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
+    strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1)],
+	    text2 + LOG_WIDTH - len, LOG_WIDTH);
+  }
+  CTK_WIDGET_REDRAW(&loglabel);
+  
+}
+/*---------------------------------------------------------------------------*/
+static void
+parse_line(void)
+{
+  int i;
+  for(i = 0; i < strlen(line); ++i) {
+    line[i] &= 0x7f;
+  }
+  
+  
+  if(line[0] == '/') {
+    if(strncmp(&line[1], "join", 4) == 0) {
+      ircc_join(&s, &line[6]);
+      ircc_text_output(&s, "Join", &line[6]);
+    } else if(strncmp(&line[1], "list", 4) == 0) {
+      ircc_list(&s);
+      ircc_text_output(&s, "Channel list", "");
+    } else if(strncmp(&line[1], "part", 4) == 0) {
+      ircc_part(&s);
+      ircc_text_output(&s, "Leaving channel", "");
+    } else if(strncmp(&line[1], "quit", 4) == 0) {
+      ircc_quit(&s);
+    } else if(strncmp(&line[1], "me", 2) == 0) {
+      petsciiconv_toascii(&line[4], strlen(&line[4]));
+      ircc_actionmsg(&s, &line[4]);
+      ircc_text_output(&s, "*", &line[4]);
+    } else {
+      ircc_text_output(&s, &line[1], "Not implemented");
+      ircc_sent(&s);
+    }
+  } else {
+    petsciiconv_toascii(line, sizeof(line) - 1);
+    ircc_msg(&s, &line[0]);
+    ircc_text_output(&s, nick, line);
+  }
+	   
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_sent(struct ircc_state *s)
+{
+  /*  ctk_textedit_init(&lineedit);*/
+  CTK_TEXTENTRY_CLEAR(&lineedit);
+  CTK_WIDGET_REDRAW(&lineedit);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  ctk_arch_key_t c;
+  u16_t *ipaddr;
+  
+  if(ev == EK_EVENT_INIT) {
+    /*    ctk_textedit_init(&lineedit);*/
+    CTK_TEXTENTRY_CLEAR(&lineedit);
+    memset(log, 0, sizeof(log));
+    ctk_window_new(&window, LOG_WIDTH, LOG_HEIGHT + 1, "IRC");
+    CTK_WIDGET_ADD(&window, &loglabel);
+    /*    ctk_textedit_add(&window, &lineedit);    */
+    CTK_WIDGET_ADD(&window, &lineedit);
+    CTK_WIDGET_FOCUS(&window, &lineedit);
+
+    ctk_window_new(&setupwindow, SETUPWINDOW_WIDTH, SETUPWINDOW_HEIGHT,
+		   "IRC setup");
+
+    CTK_WIDGET_ADD(&setupwindow, &serverlabel);
+    CTK_WIDGET_ADD(&setupwindow, &serverentry);
+    CTK_WIDGET_ADD(&setupwindow, &nicklabel);
+    CTK_WIDGET_ADD(&setupwindow, &nickentry);
+    CTK_WIDGET_ADD(&setupwindow, &connectbutton);
+    CTK_WIDGET_ADD(&setupwindow, &quitbutton);
+
+    CTK_WIDGET_FOCUS(&setupwindow, &serverentry);
+
+    ctk_window_open(&setupwindow);
+
+  } else if(ev == EK_EVENT_REQUEST_EXIT) {
+    quit();
+  } else if(ev == ctk_signal_window_close) {
+    quit();
+  } else if(ev == tcpip_event) {
+    ircc_appcall(data);
+  } else if(ev == ctk_signal_widget_activate) {
+    if(data == (ek_data_t)&lineedit) {
+      parse_line();
+    } else if(data == (ek_data_t)&quitbutton) {
+      quit();
+    } else if(data == (ek_data_t)&connectbutton) {
+      ctk_window_close(&setupwindow);
+      ctk_window_open(&window);
+      ipaddr = serveraddr;
+      if(uiplib_ipaddrconv(server, (u8_t *)serveraddr) == 0) {
+	ipaddr = resolv_lookup(server);
+	if(ipaddr == NULL) {
+	  resolv_query(server);
+	} else {
+	  uip_ipaddr_copy(serveraddr, ipaddr);
+	}
+      }
+      if(ipaddr != NULL) {
+	       
+	ircc_connect(&s, server, serveraddr, nick);
+      }
+    }
+  } else if(ev == resolv_event_found) {
+
+    ipaddr = resolv_lookup(server);
+    if(ipaddr == NULL) {
+      ircc_text_output(&s, server, "hostname not found");
+    } else {
+      uip_ipaddr_copy(serveraddr, ipaddr);
+      ircc_connect(&s, server, serveraddr, nick);
+    }
+	       
+  } else if(ev == ctk_signal_keypress) {
+    c = (ctk_arch_key_t)data;
+    if(c == CH_ENTER) {
+      parse_line();
+    } else {
+      /*      ctk_textedit_eventhandler(&lineedit, ev, data);*/
+      CTK_WIDGET_FOCUS(&window, &lineedit);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_closed(struct ircc_state *s)
+{
+  ircc_text_output(s, server, "connection closed");
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_connected(struct ircc_state *s)
+{
+  ircc_text_output(s, server, "connected");
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/ircc-strings b/contiki/apps/ircc-strings
new file mode 100644
index 0000000..92254a4
--- /dev/null
+++ b/contiki/apps/ircc-strings
@@ -0,0 +1,17 @@
+ircc_strings_nick "NICK "
+ircc_strings_crnl_user "\r\nUSER "
+ircc_strings_contiki " contiki "
+ircc_strings_colon_contiki " :Contiki\r\n"
+ircc_strings_join "JOIN "
+ircc_strings_crnl "\r\n"
+ircc_strings_part "PART "
+ircc_strings_list "LIST "
+ircc_strings_privmsg "PRIVMSG "
+ircc_strings_colon " :"
+ircc_strings_ping "PING "
+ircc_strings_notice "NOTICE "
+ircc_strings_action "\01ACTION "
+ircc_strings_version "\01VERSION"
+ircc_strings_version_query "\01VERSION\01"
+ircc_strings_ctcpcrnl "\01\r\n"
+ircc_strings_version_string " Contiki 1.2 "
\ No newline at end of file
diff --git a/contiki/apps/ircc-strings.c b/contiki/apps/ircc-strings.c
new file mode 100644
index 0000000..f23c9b6
--- /dev/null
+++ b/contiki/apps/ircc-strings.c
@@ -0,0 +1,51 @@
+const char ircc_strings_nick[6] = 
+/* "NICK " */
+{0x4e, 0x49, 0x43, 0x4b, 0x20, };
+const char ircc_strings_crnl_user[8] = 
+/* "\r\nUSER " */
+{0xd, 0xa, 0x55, 0x53, 0x45, 0x52, 0x20, };
+const char ircc_strings_contiki[10] = 
+/* " contiki " */
+{0x20, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, };
+const char ircc_strings_colon_contiki[12] = 
+/* " :Contiki\r\n" */
+{0x20, 0x3a, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0xd, 0xa, };
+const char ircc_strings_join[6] = 
+/* "JOIN " */
+{0x4a, 0x4f, 0x49, 0x4e, 0x20, };
+const char ircc_strings_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, };
+const char ircc_strings_part[6] = 
+/* "PART " */
+{0x50, 0x41, 0x52, 0x54, 0x20, };
+const char ircc_strings_list[6] = 
+/* "LIST " */
+{0x4c, 0x49, 0x53, 0x54, 0x20, };
+const char ircc_strings_privmsg[9] = 
+/* "PRIVMSG " */
+{0x50, 0x52, 0x49, 0x56, 0x4d, 0x53, 0x47, 0x20, };
+const char ircc_strings_colon[3] = 
+/* " :" */
+{0x20, 0x3a, };
+const char ircc_strings_ping[6] = 
+/* "PING " */
+{0x50, 0x49, 0x4e, 0x47, 0x20, };
+const char ircc_strings_notice[8] = 
+/* "NOTICE " */
+{0x4e, 0x4f, 0x54, 0x49, 0x43, 0x45, 0x20, };
+const char ircc_strings_action[9] = 
+/* "\01ACTION " */
+{0x1, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x20, };
+const char ircc_strings_version[9] = 
+/* "\01VERSION" */
+{0x1, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, };
+const char ircc_strings_version_query[10] = 
+/* "\01VERSION\01" */
+{0x1, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x1, };
+const char ircc_strings_ctcpcrnl[4] = 
+/* "\01\r\n" */
+{0x1, 0xd, 0xa, };
+const char ircc_strings_version_string[14] = 
+/* " Contiki 1.2 " */
+{0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x31, 0x2e, 0x32, 0x20, };
diff --git a/contiki/apps/ircc-strings.h b/contiki/apps/ircc-strings.h
new file mode 100644
index 0000000..7274829
--- /dev/null
+++ b/contiki/apps/ircc-strings.h
@@ -0,0 +1,17 @@
+extern const char ircc_strings_nick[6];
+extern const char ircc_strings_crnl_user[8];
+extern const char ircc_strings_contiki[10];
+extern const char ircc_strings_colon_contiki[12];
+extern const char ircc_strings_join[6];
+extern const char ircc_strings_crnl[3];
+extern const char ircc_strings_part[6];
+extern const char ircc_strings_list[6];
+extern const char ircc_strings_privmsg[9];
+extern const char ircc_strings_colon[3];
+extern const char ircc_strings_ping[6];
+extern const char ircc_strings_notice[8];
+extern const char ircc_strings_action[9];
+extern const char ircc_strings_version[9];
+extern const char ircc_strings_version_query[10];
+extern const char ircc_strings_ctcpcrnl[4];
+extern const char ircc_strings_version_string[14];
diff --git a/contiki/apps/ircc.c b/contiki/apps/ircc.c
new file mode 100644
index 0000000..98ce659
--- /dev/null
+++ b/contiki/apps/ircc.c
@@ -0,0 +1,527 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ircc.c,v 1.9 2005/02/22 22:23:08 adamdunkels Exp $
+ */
+
+#include "contiki.h"
+#include "ircc.h"
+
+#include "irc-conf.h"
+
+#include "ircc-strings.h"
+
+#include "petsciiconv.h"
+
+#include <string.h>
+
+#define PORT 6667
+
+#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str))
+
+#define ISO_space 0x20
+#define ISO_bang  0x21
+#define ISO_at    0x40
+#define ISO_cr    0x0d
+#define ISO_nl    0x0a
+#define ISO_colon 0x3a
+#define ISO_O     0x4f
+
+enum {
+  COMMAND_NONE,
+  COMMAND_JOIN,
+  COMMAND_PART,  
+  COMMAND_MSG,
+  COMMAND_ACTIONMSG,
+  COMMAND_LIST,
+  COMMAND_QUIT
+};
+
+/*---------------------------------------------------------------------------*/
+void
+ircc_init(void)
+{
+
+}
+/*---------------------------------------------------------------------------*/
+static char *
+copystr(char *dest, const char *src, int n)
+{
+  int len;
+
+  len = strlen(src);
+  strncpy(dest, src, n);
+
+  if(len > n) {
+    return dest + n;
+  } else {
+    return dest + len;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(setup_connection(struct ircc_state *s))
+{
+  char *ptr;
+
+  
+  PSOCK_BEGIN(&s->s);
+  
+  ptr = s->outputbuf;
+  ptr = copystr(ptr, ircc_strings_nick, sizeof(s->outputbuf));
+  ptr = copystr(ptr, s->nick, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_crnl_user, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, s->nick, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_contiki, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, s->server, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_colon_contiki, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+
+  SEND_STRING(&s->s, s->outputbuf);
+
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(join_channel(struct ircc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+  
+  SEND_STRING(&s->s, ircc_strings_join);
+  SEND_STRING(&s->s, s->channel);
+  SEND_STRING(&s->s, ircc_strings_crnl);
+
+  ircc_sent(s);
+  
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(part_channel(struct ircc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+
+  SEND_STRING(&s->s, ircc_strings_part);
+  SEND_STRING(&s->s, s->channel);
+  SEND_STRING(&s->s, ircc_strings_crnl);
+
+  ircc_sent(s);
+  
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(list_channel(struct ircc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+
+  SEND_STRING(&s->s, ircc_strings_list);
+  SEND_STRING(&s->s, s->channel);
+  SEND_STRING(&s->s, ircc_strings_crnl);
+
+  ircc_sent(s);
+  
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_message(struct ircc_state *s))
+{
+  char *ptr;
+  
+  PSOCK_BEGIN(&s->s);
+
+  ptr = s->outputbuf;
+  ptr = copystr(ptr, ircc_strings_privmsg, sizeof(s->outputbuf));
+  ptr = copystr(ptr, s->channel, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_colon, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, s->msg, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_crnl, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+
+  SEND_STRING(&s->s, s->outputbuf);
+
+  ircc_sent(s);
+  
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send_actionmessage(struct ircc_state *s))
+{
+  char *ptr;
+  
+  PSOCK_BEGIN(&s->s);
+
+  ptr = s->outputbuf;
+  ptr = copystr(ptr, ircc_strings_privmsg, sizeof(s->outputbuf));
+  ptr = copystr(ptr, s->channel, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_colon, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, ircc_strings_action, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  ptr = copystr(ptr, s->msg, sizeof(s->outputbuf) - (ptr - s->outputbuf)); 
+  ptr = copystr(ptr, ircc_strings_ctcpcrnl, sizeof(s->outputbuf) - (ptr - s->outputbuf));
+  
+
+  SEND_STRING(&s->s, s->outputbuf);
+
+  ircc_sent(s);
+  
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+struct parse_result {
+  char *msg;
+  
+  char *user;
+  char *host;
+  char *name;
+  char *command;
+  char *middle;
+  char *trailing;
+};
+static struct parse_result r;
+static void
+parse_whitespace(void)
+{
+  while(*r.msg == ISO_space) ++r.msg;
+}
+static void
+parse_word(void)
+{
+  char *ptr;
+  ptr = strchr(r.msg, ISO_space);
+  if(ptr != NULL) {
+    r.msg = ptr;
+  }  
+}
+static void
+parse_user(void)
+{
+  parse_whitespace();
+  r.user = r.msg;
+  parse_word();
+  *r.msg = 0;
+  ++r.msg;
+}
+static void
+parse_host(void)
+{
+  parse_whitespace();
+  r.host = r.msg;
+  parse_word();
+  *r.msg = 0;
+  ++r.msg;
+}
+
+static void
+parse_name(void)
+{
+  parse_whitespace();
+  r.name = r.msg;
+  parse_word();
+  *r.msg = 0;
+  ++r.msg;
+}
+
+static void
+parse_prefix(void)
+{
+  parse_name();
+  if(*r.msg == ISO_bang) {
+    ++r.msg;
+    parse_user();
+  }
+  if(*r.msg == ISO_at) {
+    ++r.msg;
+    parse_host();
+  }
+}
+
+static void
+parse_command(void)
+{
+  parse_whitespace();
+  r.command = r.msg;
+  parse_word();
+  *r.msg = 0;
+  ++r.msg;
+}
+
+/*static void
+parse_trailing(void)
+{
+  r.trailing = r.msg;
+  while(*r.msg != 0 && *r.msg != ISO_cr && *r.msg != ISO_nl) ++r.msg;
+  *r.msg = 0;
+  ++r.msg;
+}*/
+
+static void
+parse_params(void)
+{
+  char *ptr;
+
+  parse_whitespace();
+  ptr = strchr(r.msg, ISO_colon);
+  if(ptr != NULL) {
+    r.trailing = ptr + 1;
+    ptr = strchr(ptr, ISO_cr);
+    if(ptr != NULL) {
+      *ptr = 0;
+    }
+  }
+}
+
+static void
+parse(char *msg, struct parse_result *dummy)
+{
+  r.msg = msg;
+  if(*r.msg == ISO_cr || *r.msg == ISO_nl) {
+    return;
+  }
+  if(*r.msg == ISO_colon) {
+    ++r.msg;
+    parse_prefix();
+  }
+  
+  parse_command();
+  parse_params();
+
+  /*  printf("user %s host %s name %s command %s middle %s trailing %s\n",
+      r.user, r.host, r.name, r.command, r.middle, r.trailing);*/
+}
+
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(struct ircc_state *s))
+{
+  char *ptr;
+  /*  struct parse_result r;*/
+  
+  PSOCK_BEGIN(&s->s);
+  
+  PSOCK_READTO(&s->s, ISO_nl);
+  
+  if(PSOCK_DATALEN(&s->s) > 0) {
+    
+    s->inputbuf[PSOCK_DATALEN(&s->s)] = 0;
+
+    if(strncmp(s->inputbuf, ircc_strings_ping, 5) == 0) {
+      strncpy(s->outputbuf, s->inputbuf, sizeof(s->outputbuf));
+      
+      /* Turn "PING" into "PONG" */
+      s->outputbuf[1] = ISO_O;
+      SEND_STRING(&s->s, s->outputbuf);
+    } else {
+
+      memset(&r, 0, sizeof(r));
+
+      parse(s->inputbuf, &r);
+
+      if(r.name != NULL) {
+	ptr = strchr(r.name, ISO_bang);
+	if(ptr != NULL) {
+	  *ptr = 0;
+	}
+      }
+      
+      if(r.command != NULL && strncmp(r.command, ircc_strings_join, 4) == 0) {
+	ircc_text_output(s, "Joined channel", r.name);
+      } else if(r.command != NULL && strncmp(r.command, ircc_strings_part, 4) == 0) {
+	ircc_text_output(s, "Left channel", r.name);
+      } else if(r.trailing != NULL) {
+	if(strncmp(r.trailing, ircc_strings_action,
+		   strlen(ircc_strings_action)) == 0) {
+	  ptr = strchr(&r.trailing[1], 1);
+	  if(ptr != NULL) {
+	    *ptr = 0;
+	  }
+	  ptr = &r.trailing[strlen(ircc_strings_action)];
+	  petsciiconv_topetscii(r.name, strlen(r.name));
+	  petsciiconv_topetscii(ptr, strlen(ptr));
+	  ircc_text_output(s, r.name, ptr);
+	} else if(strncmp(r.trailing, ircc_strings_version_query,
+			  strlen(ircc_strings_version_query)) == 0) {
+	  if(r.name != NULL) {
+	    strncpy(s->outputbuf, r.name, sizeof(s->outputbuf));
+	    SEND_STRING(&s->s, ircc_strings_notice);
+	    /* user is temporarily stored in outputbuf. */
+	    SEND_STRING(&s->s, s->outputbuf); 
+	    SEND_STRING(&s->s, ircc_strings_colon);
+	    SEND_STRING(&s->s, ircc_strings_version);
+	    SEND_STRING(&s->s, ircc_strings_version_string);
+	    SEND_STRING(&s->s, IRC_CONF_SYSTEM_STRING);
+	    SEND_STRING(&s->s, ircc_strings_ctcpcrnl);
+	  }
+	} else {
+	  petsciiconv_topetscii(r.name, strlen(r.name));
+	  petsciiconv_topetscii(r.trailing, strlen(r.trailing));
+	  ircc_text_output(s, r.name, r.trailing);
+	}
+      }
+    }
+  }
+
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(data_or_command(struct ircc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+
+  PSOCK_WAIT_UNTIL(&s->s, PSOCK_NEWDATA(&s->s) ||
+		    (s->command != COMMAND_NONE));
+
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_connection(struct ircc_state *s))
+{
+  PT_BEGIN(&s->pt);
+
+  PSOCK_INIT(&s->s, s->inputbuf, sizeof(s->inputbuf) - 1);
+  
+  PT_WAIT_THREAD(&s->pt, setup_connection(s));
+
+  while(1) {
+
+    PT_WAIT_UNTIL(&s->pt, data_or_command(s));
+
+    if(PSOCK_NEWDATA(&s->s)) {
+      PT_WAIT_THREAD(&s->pt, handle_input(s));      
+    } 
+      
+    switch(s->command) {
+    case COMMAND_JOIN:
+      s->command = COMMAND_NONE;
+      PT_WAIT_THREAD(&s->pt, join_channel(s));
+      break;
+    case COMMAND_PART:
+      s->command = COMMAND_NONE;
+      PT_WAIT_THREAD(&s->pt, part_channel(s));
+      break;
+    case COMMAND_MSG:
+      s->command = COMMAND_NONE;
+      PT_WAIT_THREAD(&s->pt, send_message(s));
+      break;
+    case COMMAND_ACTIONMSG:
+      s->command = COMMAND_NONE;
+      PT_WAIT_THREAD(&s->pt, send_actionmessage(s));
+      break;
+    case COMMAND_LIST:
+      s->command = COMMAND_NONE;
+      PT_WAIT_THREAD(&s->pt, list_channel(s));
+      break;
+    case COMMAND_QUIT:
+      s->command = COMMAND_NONE;
+      tcp_markconn(uip_conn, NULL);
+      PSOCK_CLOSE(&s->s);
+      ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_REQUEST_EXIT, NULL);
+      PT_EXIT(&s->pt);
+      break;
+    default:
+      break;
+    }
+  }
+  
+  PT_END(&s->pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_appcall(void *s)
+{
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    ircc_closed(s);
+  } else if(uip_connected()) {
+    ircc_connected(s);
+    PT_INIT(&((struct ircc_state *)s)->pt);
+    memset(((struct ircc_state *)s)->channel, 0,
+	   sizeof(((struct ircc_state *)s)->channel));
+    ((struct ircc_state *)s)->command = COMMAND_NONE;
+    handle_connection(s);
+  } else if(s != NULL) {
+    handle_connection(s);
+  }
+}
+/*---------------------------------------------------------------------------*/
+struct ircc_state *
+ircc_connect(struct ircc_state *s, char *servername, u16_t *ipaddr,
+	     char *nick)
+{
+  s->conn = tcp_connect(ipaddr, HTONS(PORT), s);
+  if(s->conn == NULL) {
+    return NULL;
+  }
+  s->server = servername;  
+  s->nick = nick;
+  return s;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_list(struct ircc_state *s)
+{
+  s->command = COMMAND_LIST;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_join(struct ircc_state *s, char *channel)
+{
+  strncpy(s->channel, channel, sizeof(s->channel));
+  s->command = COMMAND_JOIN;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_part(struct ircc_state *s)
+{
+  s->command = COMMAND_PART;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_quit(struct ircc_state *s)
+{
+  s->command = COMMAND_QUIT;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_msg(struct ircc_state *s, char *msg)
+{
+  s->msg = msg;
+  s->command = COMMAND_MSG;
+}
+/*---------------------------------------------------------------------------*/
+void
+ircc_actionmsg(struct ircc_state *s, char *msg)
+{
+  s->msg = msg;
+  s->command = COMMAND_ACTIONMSG;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/ircc.h b/contiki/apps/ircc.h
new file mode 100644
index 0000000..7517294
--- /dev/null
+++ b/contiki/apps/ircc.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ircc.h,v 1.5 2005/02/22 22:23:08 adamdunkels Exp $
+ */
+#ifndef __IRCC_H__
+#define __IRCC_H__
+
+#include "psock.h"
+
+struct ircc_state {
+  
+  struct pt pt;
+  struct psock s;
+
+  struct uip_conn *conn;
+  
+  unsigned char command;
+  
+  char *msg;
+  char channel[32];
+  char outputbuf[200];
+  char inputbuf[400];
+  char *nick;
+  char *server;
+};
+
+void ircc_init(void);
+
+void ircc_appcall(void *s);
+
+struct ircc_state *ircc_connect(struct ircc_state *s,
+				char *server, u16_t *ipaddr, char *nick);
+
+void ircc_join(struct ircc_state *s, char *channel);
+void ircc_part(struct ircc_state *s);
+void ircc_list(struct ircc_state *s);
+void ircc_msg(struct ircc_state *s, char *msg);
+void ircc_actionmsg(struct ircc_state *s, char *msg);
+
+void ircc_sent(struct ircc_state *s);
+
+void ircc_text_output(struct ircc_state *s, char *text1, char *text2);
+
+void ircc_connected(struct ircc_state *s);
+void ircc_closed(struct ircc_state *s);
+
+void ircc_quit(struct ircc_state *s);
+
+#endif /* __IRCC_H__ */
diff --git a/contiki/apps/makefsdata b/contiki/apps/makefsdata
new file mode 100755
index 0000000..0ea353b
--- /dev/null
+++ b/contiki/apps/makefsdata
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+
+opendir(DIR, ".");
+@files =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
+closedir(DIR);
+
+foreach $file (@files) {  
+   
+    if(-d $file && $file !~ /^\./) {
+	print "Processing directory $file\n";
+	opendir(DIR, $file);
+	@newfiles =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
+	closedir(DIR);
+	printf "Adding files @newfiles\n";
+	@files = (@files, map { $_ = "$file/$_" } @newfiles);
+	next;
+    }
+}
+
+foreach $file (@files) {  
+    if(-f $file) {
+	
+	print "Adding file $file\n";
+	
+	open(FILE, $file) || die "Could not open file $file\n";
+
+	$file =~ s-^-/-;
+	$fvar = $file;
+	$fvar =~ s-/-_-g;
+	$fvar =~ s-\.-_-g;
+	print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
+	print(OUTPUT "\t/* $file */\n\t");
+	for($j = 0; $j < length($file); $j++) {
+	    printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+	}
+	printf(OUTPUT "0,\n");
+	
+	
+	$i = 0;        
+	while(read(FILE, $data, 1)) {
+	    if($i == 0) {
+		print(OUTPUT "\t");
+	    }
+	    printf(OUTPUT "%#02x, ", unpack("C", $data));
+	    $i++;
+	    if($i == 10) {
+		print(OUTPUT "\n");
+		$i = 0;
+	    }
+	}
+	print(OUTPUT "0};\n\n");
+	close(FILE);
+	push(@fvars, $fvar);
+	push(@pfiles, $file);
+    }
+}
+
+for($i = 0; $i < @fvars; $i++) {
+    $file = $pfiles[$i];
+    $fvar = $fvars[$i];
+
+    if($i == 0) {
+        $prevfile = "NULL";
+    } else {
+        $prevfile = "file" . $fvars[$i - 1];
+    }
+    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");
diff --git a/contiki/apps/makestrings b/contiki/apps/makestrings
new file mode 100755
index 0000000..3c2ef1c
--- /dev/null
+++ b/contiki/apps/makestrings
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+  my $name = shift(@_);
+  open(OUTPUTC, "> $name.c");
+  open(OUTPUTH, "> $name.h");
+  
+  open(FILE, "$name");
+  
+  while(<FILE>) {
+    if(/(.+) "(.+)"/) {
+      $var = $1;
+      $data = $2;
+      
+      $datan = $data;
+      $datan =~ s/\\r/\r/g;
+      $datan =~ s/\\n/\n/g;
+      $datan =~ s/\\01/\01/g;      
+      $datan =~ s/\\0/\0/g;
+      
+      printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
+      printf(OUTPUTC "/* \"$data\" */\n");
+      printf(OUTPUTC "{");
+      for($j = 0; $j < length($datan); $j++) {
+	printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+      }
+      printf(OUTPUTC "};\n");
+      
+      printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
+      
+    }
+  }
+  close(OUTPUTC);
+  close(OUTPUTH);
+}
+stringify("http-strings");
+stringify("http-user-agent-string");
+stringify("smtp-strings");
+stringify("html-strings");
+stringify("ircc-strings");
+stringify("popc-strings");
+
+exit 0;
+
diff --git a/contiki/apps/netconf-dsc.c b/contiki/apps/netconf-dsc.c
new file mode 100644
index 0000000..b0eb087
--- /dev/null
+++ b/contiki/apps/netconf-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: netconf-dsc.c,v 1.4 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon netconf_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(netconf_dsc,
+    "Network configuration",
+    "netconf.prg",
+    netconf_init,
+    &netconf_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+  'T', 'C', 'P',
+  '/', 'I', 'P',
+  'C', 'f', 'g'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon netconf_icon =
+  {CTK_ICON("Network setup", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/netconf-dsc.h b/contiki/apps/netconf-dsc.h
new file mode 100644
index 0000000..86f17cc
--- /dev/null
+++ b/contiki/apps/netconf-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: netconf-dsc.h,v 1.1 2003/04/17 19:00:00 adamdunkels Exp $
+ *
+ */
+#ifndef __NETCONF_DSC_H__
+#define __NETCONF_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(netconf_dsc);
+
+#endif /* __NETCONF_DSC_H__ */
diff --git a/contiki/apps/netconf.c b/contiki/apps/netconf.c
new file mode 100644
index 0000000..5a0795e
--- /dev/null
+++ b/contiki/apps/netconf.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: netconf.c,v 1.13 2004/07/04 11:35:07 adamdunkels Exp $
+ *
+ */
+
+#include "ek.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "loader.h"
+
+/* TCP/IP configuration window. */
+static struct ctk_window tcpipwindow;
+
+#ifdef WITH_ETHERNET
+static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 1, 10, 1, "IP address")};
+static char ipaddr[17];
+static struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(11, 1, 16, 1, ipaddr, 16)};
+static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 3, 10, 1, "Netmask")};
+static char netmask[17];
+static struct ctk_textentry netmasktextentry =
+  {CTK_TEXTENTRY(11, 3, 16, 1, netmask, 16)};
+static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 5, 10, 1, "Gateway")};
+static char gateway[17];
+static struct ctk_textentry gatewaytextentry =
+  {CTK_TEXTENTRY(11, 5, 16, 1, gateway, 16)};
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 7, 10, 1, "DNS server")};
+static char dnsserver[17];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(11, 7, 16, 1, dnsserver, 16)};
+#else /* WITH_ETHERNET */
+static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 2, 10, 1, "IP address")};
+static char ipaddr[17];
+static struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(11, 2, 16, 1, ipaddr, 16)};
+static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 4, 10, 1, "DNS server")};
+static char dnsserver[17];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(11, 4, 16, 1, dnsserver, 16)};
+#endif /* WITH_ETHERNET */
+
+static struct ctk_button tcpipclosebutton =
+  {CTK_BUTTON(0, 9, 2, "Ok")};
+
+EK_EVENTHANDLER(netconf_eventhandler, ev, data);
+EK_PROCESS(p, "Network configuration", EK_PRIO_NORMAL,
+	   netconf_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*static DISPATCHER_SIGHANDLER(netconf_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Network config", NULL, netconf_sighandler, NULL)};
+  static ek_id_t id;*/
+
+
+static void makestrings(void);
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(netconf_init, arg)
+{
+  arg_free(arg);
+    
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+makebyte(u8_t byte, char *str)
+{
+  if(byte >= 100) {
+    *str++ = (byte / 100 ) % 10 + '0';
+  }
+  if(byte >= 10) {
+    *str++ = (byte / 10) % 10 + '0';
+  }
+  *str++ = (byte % 10) + '0';
+
+  return str;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makeaddr(u16_t *addr, char *str)
+{
+  str = makebyte(HTONS(addr[0]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[0]) & 0xff, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) >> 8, str);
+  *str++ = '.';
+  str = makebyte(HTONS(addr[1]) & 0xff, str);
+  *str++ = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makestrings(void)
+{
+  u16_t addr[2], *addrptr;
+
+#ifdef WITH_UIP
+  uip_gethostaddr(addr);
+  makeaddr(addr, ipaddr);
+  
+#ifdef WITH_ETHERNET  
+  uip_getnetmask(addr);
+  makeaddr(addr, netmask);
+  
+  uip_getdraddr(addr);
+  makeaddr(addr, gateway);
+#endif /* WITH_ETHERNET */
+
+  addrptr = resolv_getserver();
+  if(addrptr != NULL) {
+    makeaddr(addrptr, dnsserver);
+  }
+  
+#endif /* WITH_UIP */
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+nullterminate(char *cptr)
+{
+  /* Find the first space character in the ipaddr and put a zero there
+     to end the string. */
+  for(; *cptr != ' ' && *cptr != 0; ++cptr);
+  *cptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+apply_tcpipconfig(void)
+{
+  u16_t addr[2];
+
+#ifdef WITH_UIP
+  nullterminate(ipaddr);
+  if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) {
+    uip_sethostaddr(addr);
+  }
+  
+#ifdef WITH_ETHERNET
+  nullterminate(netmask);
+  if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) {
+    uip_setnetmask(addr);
+  }
+
+  nullterminate(gateway);
+  if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) {
+    uip_setdraddr(addr);
+  }
+#endif /* WITH_ETHERNET */
+  
+  nullterminate(dnsserver);
+  if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) {
+    resolv_conf(addr);
+  }
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+netconf_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(netconf_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create TCP/IP configuration window. */
+    ctk_window_new(&tcpipwindow, 30, 10, "TCP/IP config");
+    /*    if(ctk_desktop_width(tcpipwindow.desktop) < 30) {
+      ctk_window_move(&tcpipwindow, 0,
+		      (ctk_desktop_height(tcpipwindow.desktop) - 10) / 2 - 2);
+    } else {
+      ctk_window_move(&tcpipwindow,
+		      (ctk_desktop_width(tcpipwindow.desktop) - 30) / 2,
+		      (ctk_desktop_height(tcpipwindow.desktop) - 10) / 2 - 2);
+		      }*/
+    
+#ifdef WITH_ETHERNET
+    CTK_WIDGET_ADD(&tcpipwindow, &ipaddrlabel);  
+    CTK_WIDGET_ADD(&tcpipwindow, &ipaddrtextentry);
+    CTK_WIDGET_ADD(&tcpipwindow, &netmasklabel);
+    CTK_WIDGET_ADD(&tcpipwindow, &netmasktextentry);
+    CTK_WIDGET_ADD(&tcpipwindow, &gatewaylabel);
+    CTK_WIDGET_ADD(&tcpipwindow, &gatewaytextentry);
+    CTK_WIDGET_ADD(&tcpipwindow, &dnsserverlabel);
+    CTK_WIDGET_ADD(&tcpipwindow, &dnsservertextentry);
+#else
+    CTK_WIDGET_ADD(&tcpipwindow, &ipaddrlabel);  
+    CTK_WIDGET_ADD(&tcpipwindow, &ipaddrtextentry);
+    CTK_WIDGET_ADD(&tcpipwindow, &dnsserverlabel);
+    CTK_WIDGET_ADD(&tcpipwindow, &dnsservertextentry);  
+#endif /* WITH_ETHERNET */
+    
+    CTK_WIDGET_ADD(&tcpipwindow, &tcpipclosebutton);
+    
+    CTK_WIDGET_FOCUS(&tcpipwindow, &ipaddrtextentry);  
+
+    /* Fill the configuration strings with values from the current
+       configuration */
+    makestrings();
+    
+    /*    dispatcher_listen(ctk_signal_button_activate);
+	  dispatcher_listen(ctk_signal_window_close);*/
+    ctk_window_open(&tcpipwindow);
+  } else if(ev == ctk_signal_button_activate) {   
+    if(data == (ek_data_t)&tcpipclosebutton) {
+      apply_tcpipconfig();
+      ctk_window_close(&tcpipwindow);
+      netconf_quit();
+      /*      ctk_desktop_redraw(tcpipwindow.desktop);*/
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&tcpipwindow);
+    netconf_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/popc-strings b/contiki/apps/popc-strings
new file mode 100644
index 0000000..1a299f5
--- /dev/null
+++ b/contiki/apps/popc-strings
@@ -0,0 +1,5 @@
+popc_strings_user "USER "
+popc_strings_pass "PASS "
+popc_strings_retr "RETR "
+popc_strings_stat "STAT\r\n"
+popc_strings_crnl "\r\n"
\ No newline at end of file
diff --git a/contiki/apps/popc-strings.c b/contiki/apps/popc-strings.c
new file mode 100644
index 0000000..d05f1c1
--- /dev/null
+++ b/contiki/apps/popc-strings.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: popc-strings.c,v 1.2 2004/09/12 20:24:54 adamdunkels Exp $
+ */
+const char popc_strings_user[6] = 
+/* "USER " */
+{0x55, 0x53, 0x45, 0x52, 0x20, };
+const char popc_strings_pass[6] = 
+/* "PASS " */
+{0x50, 0x41, 0x53, 0x53, 0x20, };
+const char popc_strings_retr[6] = 
+/* "RETR " */
+{0x52, 0x45, 0x54, 0x52, 0x20, };
+const char popc_strings_stat[7] = 
+/* "STAT\r\n" */
+{0x53, 0x54, 0x41, 0x54, 0xd, 0xa, };
+const char popc_strings_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, };
diff --git a/contiki/apps/popc-strings.h b/contiki/apps/popc-strings.h
new file mode 100644
index 0000000..e679bfb
--- /dev/null
+++ b/contiki/apps/popc-strings.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: popc-strings.h,v 1.2 2004/09/12 20:24:54 adamdunkels Exp $
+ */
+extern const char popc_strings_user[6];
+extern const char popc_strings_pass[6];
+extern const char popc_strings_retr[6];
+extern const char popc_strings_stat[7];
+extern const char popc_strings_crnl[3];
diff --git a/contiki/apps/popc.c b/contiki/apps/popc.c
new file mode 100644
index 0000000..d1ac150
--- /dev/null
+++ b/contiki/apps/popc.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: popc.c,v 1.3 2005/02/22 22:23:08 adamdunkels Exp $
+ */
+
+#include "contiki.h"
+#include "popc.h"
+#include "popc-strings.h"
+
+#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str))
+
+enum {
+  COMMAND_NONE,
+  COMMAND_RETR,
+  COMMAND_TOP,  
+  COMMAND_QUIT
+};
+
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(init_connection(struct popc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+
+  PSOCK_READTO(&s->s, '\n');
+  if(s->inputbuf[0] != '+') {
+    PSOCK_CLOSE_EXIT(&s->s);    
+  }
+
+  SEND_STRING(&s->s, popc_strings_user);
+  SEND_STRING(&s->s, s->user);
+  SEND_STRING(&s->s, popc_strings_crnl);
+  
+  PSOCK_READTO(&s->s, '\n');
+  if(s->inputbuf[0] != '+') {
+    PSOCK_CLOSE_EXIT(&s->s);    
+  }
+
+  SEND_STRING(&s->s, popc_strings_pass);
+  SEND_STRING(&s->s, s->pass);
+  SEND_STRING(&s->s, popc_strings_crnl);
+  
+  PSOCK_READTO(&s->s, '\n');
+  if(s->inputbuf[0] != '+') {
+    PSOCK_CLOSE_EXIT(&s->s);    
+  }
+
+  popc_connected(s);
+
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(stat(struct popc_state *s))
+{
+  unsigned short num;
+  unsigned long size;
+  char *ptr;
+  
+  PSOCK_BEGIN(&s->s);
+  
+  SEND_STRING(&s->s, popc_strings_stat);
+  
+  PSOCK_READTO(&s->s, '\n');
+  if(s->inputbuf[0] != '+') {
+    PSOCK_CLOSE_EXIT(&s->s);    
+  }
+
+  num = 0;
+  for(ptr = &s->inputbuf[4]; *ptr >= '0' && *ptr <= '9'; ++ptr) {
+    num *= 10;
+    num += *ptr - '0';
+  }
+
+  size = 0;
+  for(ptr = ptr + 1; *ptr >= '0' && *ptr <= '9'; ++ptr) {
+    size *= 10;
+    size += *ptr - '0';
+  }
+
+  popc_messages(s, num, size);
+
+  PSOCK_END(&s->s);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(retr(struct popc_state *s))
+{
+  PSOCK_BEGIN(&s->s);
+
+  SEND_STRING(&s->s, popc_strings_retr);
+  snprintf(s->outputbuf, sizeof(s->outputbuf), "%d", s->num);
+  SEND_STRING(&s->s, s->outputbuf);
+  SEND_STRING(&s->s, popc_strings_crnl);
+  
+  PSOCK_READTO(&s->s, '\n');
+  if(s->inputbuf[0] != '+') {
+    PSOCK_CLOSE_EXIT(&s->s);    
+  }
+
+  popc_msgbegin(s);
+  while(s->inputbuf[0] != '.') {
+    PSOCK_READTO(&s->s, '\n');
+    if(s->inputbuf[0] != '.') {
+      s->inputbuf[PSOCK_DATALEN(&s->s)] = 0;
+      popc_msgline(s, s->inputbuf, PSOCK_DATALEN(&s->s));
+    }
+  }
+  popc_msgend(s);
+  
+  PSOCK_END(&s->s);
+
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_connection(struct popc_state *s))
+{
+  PT_BEGIN(&s->pt);
+
+  PSOCK_INIT(&s->s, s->inputbuf, sizeof(s->inputbuf) - 1);
+
+  PT_WAIT_UNTIL(&s->pt, init_connection(s));
+  PT_WAIT_UNTIL(&s->pt, stat(s));  
+
+  timer_set(&s->timer, CLOCK_SECOND * 30);
+	
+  while(1) {
+    PT_WAIT_UNTIL(&s->pt, s->command != COMMAND_NONE ||
+		  timer_expired(&s->timer));
+
+    if(timer_expired(&s->timer)) {
+      PT_WAIT_UNTIL(&s->pt, stat(s));
+      timer_set(&s->timer, CLOCK_SECOND * 30);
+    }
+
+    switch(s->command) {
+    case COMMAND_RETR:
+      PT_WAIT_UNTIL(&s->pt, retr(s));
+      break;
+    case COMMAND_QUIT:
+      tcp_markconn(uip_conn, NULL);
+      PSOCK_CLOSE(&s->s);
+      PT_EXIT(&s->pt);
+      break;
+    default:
+      break;
+    }
+    s->command = COMMAND_NONE;
+    
+  }
+  PT_END(&s->pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+popc_appcall(void *state)
+{
+  struct popc_state *s = (struct popc_state *)state;
+  
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    popc_closed(s);
+  } else if(uip_connected()) {
+    PT_INIT(&s->pt);
+    handle_connection(s);
+  } else if(s != NULL) {
+    handle_connection(s);
+  }
+
+}
+/*---------------------------------------------------------------------------*/
+void *
+popc_connect(struct popc_state *s, u16_t *addr,
+	     char *user, char *pass)
+{
+  strncpy(s->user, user, sizeof(s->user));
+  strncpy(s->pass, pass, sizeof(s->pass));
+  s->conn = tcp_connect(addr, HTONS(110), s);
+  return s->conn;
+}
+/*---------------------------------------------------------------------------*/
+void
+popc_retr(struct popc_state *s, unsigned short num)
+{
+  s->command = COMMAND_RETR;
+  s->num = num;
+}
+/*---------------------------------------------------------------------------*/
+void
+popc_top(struct popc_state *s, unsigned short num, unsigned short lines)
+{
+  s->command = COMMAND_TOP;
+  s->num = num;
+  s->lines = lines;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/apps/popc.h b/contiki/apps/popc.h
new file mode 100644
index 0000000..42e59af
--- /dev/null
+++ b/contiki/apps/popc.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: popc.h,v 1.3 2005/02/22 22:23:08 adamdunkels Exp $
+ */
+#ifndef __POPC_H__
+#define __POPC_H__
+
+#include "psock.h"
+
+
+struct popc_state {
+  struct pt pt;
+  struct psock s;
+  struct uip_conn *conn;
+
+  struct timer timer;
+  
+  char inputbuf[100];
+  char outputbuf[10];
+  
+  char user[32], pass[32];
+
+  char command;
+  unsigned short num;
+  unsigned short lines;
+};
+
+void popc_appcall(void *state);
+void popc_init(void);
+void *popc_connect(struct popc_state *s, u16_t *ipaddr, 
+		  char *user, char *passwd);
+
+void popc_retr(struct popc_state *s, unsigned short msg);
+void popc_top(struct popc_state *s, unsigned short msg,
+	      unsigned short numlines);
+
+
+void popc_connected(struct popc_state *s);
+void popc_messages(struct popc_state *s,
+		   unsigned short num, unsigned long size);
+void popc_msgbegin(struct popc_state *s);
+void popc_msgline(struct popc_state *s, char *line, int len);
+void popc_msgend(struct popc_state *s);
+
+
+#endif /* __POPC_H__ */
diff --git a/contiki/apps/processes-dsc.c b/contiki/apps/processes-dsc.c
new file mode 100644
index 0000000..7315828
--- /dev/null
+++ b/contiki/apps/processes-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: processes-dsc.c,v 1.5 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon processes_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(processes_dsc,
+    "Process information",
+    "processes.prg",
+    processes_init,
+    &processes_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char processesicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char processesicon_textmap[9] = {
+  '0', '1', ' ',
+  ' ', '0', '1',
+  '1', '0', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon processes_icon =
+  {CTK_ICON("Processes", processesicon_bitmap, processesicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/processes-dsc.h b/contiki/apps/processes-dsc.h
new file mode 100644
index 0000000..a00c0d8
--- /dev/null
+++ b/contiki/apps/processes-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: processes-dsc.h,v 1.1 2003/04/17 19:00:00 adamdunkels Exp $
+ *
+ */
+#ifndef __PROCESSES_DSC_H__
+#define __PROCESSES_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(processes_dsc);
+
+#endif /* __PROCESSES_DSC_H__ */
diff --git a/contiki/apps/processes.c b/contiki/apps/processes.c
new file mode 100644
index 0000000..a5fe420
--- /dev/null
+++ b/contiki/apps/processes.c
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: processes.c,v 1.14 2005/03/13 22:14:43 oliverschmidt Exp $
+ *
+ */
+
+#include "ek.h"
+#include "ctk.h"
+#include "loader.h"
+
+#include <string.h>
+
+#define MAX_PROCESSLABELS 13
+static struct ctk_window processwindow;
+static unsigned char ids[MAX_PROCESSLABELS][4];
+static struct ctk_label processidlabels[MAX_PROCESSLABELS];
+static struct ctk_label processnamelabels[MAX_PROCESSLABELS];
+
+static struct ctk_label killlabel =
+  {CTK_LABEL(0, 14, 12, 1, "Kill process")};
+static char killprocnum[4];
+static struct ctk_textentry killtextentry =
+  {CTK_TEXTENTRY(13, 14, 3, 1, killprocnum, 3)};
+static struct ctk_button killbutton =
+  {CTK_BUTTON(19, 14, 2, "Ok")};
+static struct ctk_button processupdatebutton =
+  {CTK_BUTTON(0, 15, 6, "Update")};
+static struct ctk_button processclosebutton =
+  {CTK_BUTTON(19, 15, 5, "Close")};
+
+/*static DISPATCHER_SIGHANDLER(processes_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Process listing", NULL, processes_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(processes_eventhandler, ev, data);
+EK_PROCESS(p, "Process listing", EK_PRIO_NORMAL,
+	   processes_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+enum {
+  EVENT_UPDATE
+};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+update_processwindow(void)
+{
+  unsigned char i, j, *idsptr;
+  struct ek_proc *p;
+
+  /* Step through each possible process ID and see if there is a
+     matching process. */
+  j = 0;
+  for(p = EK_PROCS(); p != NULL && j < MAX_PROCESSLABELS; p = p->next) {
+    idsptr = ids[j];
+    i = p->id;
+    idsptr[0] = '0' + i / 100;
+    if(idsptr[0] == '0') {
+      idsptr[0] = ' ';
+    }
+    idsptr[1] = '0' + (i / 10) % 10;
+    idsptr[2] = '0' + i % 10;
+    idsptr[3] = 0;
+    CTK_LABEL_NEW(&processidlabels[j],
+		  0, j + 1, 3, 1, idsptr);
+    CTK_WIDGET_ADD(&processwindow, &processidlabels[j]);
+    
+    CTK_LABEL_NEW(&processnamelabels[j],
+		  4, j + 1, 22, 1, (char *)p->name);
+    CTK_WIDGET_ADD(&processwindow, &processnamelabels[j]);
+
+    ++j;
+  }
+
+  CTK_WIDGET_ADD(&processwindow, &killlabel);
+
+  CTK_WIDGET_ADD(&processwindow, &killtextentry);
+  CTK_WIDGET_ADD(&processwindow, &killbutton);  
+  
+  CTK_WIDGET_ADD(&processwindow, &processupdatebutton);
+  CTK_WIDGET_ADD(&processwindow, &processclosebutton);
+  CTK_WIDGET_FOCUS(&processwindow, &processupdatebutton);
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(processes_init, arg)
+{
+  arg_free(arg);
+    
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(void)
+{
+  int procnum;
+  unsigned char i, j;
+  struct ek_proc *p;
+  
+  /* Find first zero char in killprocnum string. */
+  for(i = 0; killprocnum[i] != 0 &&
+	i < sizeof(killprocnum); ++i);
+
+  if(i == 0) {
+    return;
+  }
+  
+  procnum = 0;
+  
+  for(j = 0; j < i; ++j) {
+    procnum = procnum * 10 + (killprocnum[j] - '0');
+    killprocnum[j] = 0;
+  }
+
+  /* Make sure the process ID exists. */
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    if(EK_PROC_ID(p) == procnum) {
+      break;
+    }
+  }
+
+  if(p != NULL) {
+    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+    ek_post(id, EVENT_UPDATE, NULL);
+    CTK_TEXTENTRY_CLEAR(&killtextentry);
+    CTK_WIDGET_REDRAW(&killtextentry);
+    CTK_WIDGET_FOCUS(&processwindow, &processupdatebutton);
+    CTK_WIDGET_REDRAW(&killbutton);
+    CTK_WIDGET_REDRAW(&processupdatebutton);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(processes_sighandler, s, data)*/
+EK_EVENTHANDLER(processes_eventhandler, ev, data)
+{
+/*  DISPATCHER_SIGHANDLER_ARGS(s, data);*/
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&processwindow, 26, 16, "Processes");
+    update_processwindow();
+    
+    ctk_window_open(&processwindow);
+  } else if(ev == EVENT_UPDATE) {
+    ctk_window_clear(&processwindow);
+    update_processwindow();
+    ctk_window_open(&processwindow);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&processupdatebutton) {
+      ctk_window_clear(&processwindow);
+      update_processwindow();
+      ctk_window_open(&processwindow);
+    } else if(data == (ek_data_t)&processclosebutton) {
+      ctk_window_close(&processwindow);
+      processes_quit();
+      /*      ctk_desktop_redraw(processwindow.desktop);      */
+    } else if(data == (ek_data_t)&killbutton) {
+      killproc();
+    }
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    (ev == ctk_signal_window_close &&
+	     data == (ek_data_t)&processwindow)) {
+    ctk_window_close(&processwindow);
+    processes_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/program-handler.c b/contiki/apps/program-handler.c
new file mode 100644
index 0000000..9d15e23
--- /dev/null
+++ b/contiki/apps/program-handler.c
@@ -0,0 +1,450 @@
+/**
+ * \file
+ * The program handler, used for loading programs and starting the
+ * screensaver. 
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The Contiki program handler is responsible for the Contiki menu and
+ * the desktop icons, as well as for loading programs and displaying a
+ * dialog with a message telling which program that is loading.
+ *
+ * The program handler also is responsible for starting the
+ * screensaver when the CTK detects that it should be started.
+ */
+ 
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: program-handler.c,v 1.32 2006/05/14 23:23:30 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "ek.h"
+#include "petsciiconv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-conf.h"
+
+#include "log.h"
+
+#include "loader.h"
+
+#include "program-handler.h"
+
+#include "program-handler-conf.h"
+
+/* Menus */
+static struct ctk_menu contikimenu;
+
+#ifndef PROGRAM_HANDLER_CONF_MAX_NUMDSCS
+#define MAX_NUMDSCS 10
+#else /* PROGRAM_HANDLER_CONF_MAX_NUMDSCS */
+#define MAX_NUMDSCS PROGRAM_HANDLER_CONF_MAX_NUMDSCS
+#endif /* PROGRAM_HANDLER_CONF_MAX_NUMDSCS */
+
+static struct dsc *contikidsc[MAX_NUMDSCS];
+static unsigned char contikidsclast = 0;
+
+#ifndef PROGRAM_HANDLER_CONF_QUIT_MENU
+#define QUIT_MENU 0
+#else /* PROGRAM_HANDLER_CONF_QUIT_MENU */
+#define QUIT_MENU PROGRAM_HANDLER_CONF_QUIT_MENU
+#endif /* PROGRAM_HANDLER_CONF_QUIT_MENU */
+
+#if QUIT_MENU
+
+static unsigned char quitmenuitem;
+
+/* "Quit" dialog */
+static struct ctk_window quitdialog;
+static struct ctk_label quitdialoglabel =
+  {CTK_LABEL(2, 1, 20, 1, "Really quit Contiki?")};
+static struct ctk_button quityesbutton =
+  {CTK_BUTTON(4, 3, 3, "Yes")};
+static struct ctk_button quitnobutton =
+  {CTK_BUTTON(16, 3, 2, "No")};
+
+#endif /* QUIT_MENU */
+
+#if WITH_LOADER_ARCH
+
+/* "Run..." window */
+static struct ctk_window runwindow;
+static unsigned char runmenuitem;
+static struct ctk_label namelabel =
+  {CTK_LABEL(0, 0, 13, 1, "Program name:")};
+static char name[31];
+static struct ctk_textentry nameentry =
+  {CTK_TEXTENTRY(0, 1, 14, 1, name, 30)};
+static struct ctk_button loadbutton =
+  {CTK_BUTTON(10, 2, 4, "Load")};
+
+static struct ctk_window loadingdialog;
+static struct ctk_label loadingmsg =
+  {CTK_LABEL(0, 0, 8, 1, "Starting")};
+static struct ctk_label loadingname =
+  {CTK_LABEL(9, 0, 16, 1, name)};
+
+static struct ctk_window errordialog;
+static struct ctk_label errormsg =
+  {CTK_LABEL(0, 1, 22, 1, "Error loading program:")};
+static char errorfilename[22];
+static struct ctk_label errorfilelabel =
+  {CTK_LABEL(0, 3, 22, 1, errorfilename)};
+static struct ctk_label errortype =
+  {CTK_LABEL(4, 5, 16, 1, "")};
+static struct ctk_button errorokbutton =
+  {CTK_BUTTON(9, 7, 2, "Ok")};
+
+#endif /* WITH_LOADER_ARCH */
+
+/*static DISPATCHER_SIGHANDLER(program_handler_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Program handler", NULL, program_handler_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(program_handler_eventhandler, ev, data);
+EK_PROCESS(p, "Program handler", EK_PRIO_NORMAL,
+	   program_handler_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static const char * const errormsgs[] = {
+  "Ok",
+  "Read error",
+  "Header error",
+  "OS error",
+  "Data format error",
+  "Out of memory",
+  "File not found",
+  "No loader"
+};
+
+#define LOADER_EVENT_LOAD 1
+#define LOADER_EVENT_DISPLAY_NAME 2
+
+static char *displayname;
+
+#if CTK_CONF_SCREENSAVER
+char program_handler_screensaver[20];
+#endif /* CTK_CONF_SCREENSAVER */
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Add a program to the program handler.
+ *
+ * \param dsc The DSC description structure for the program to be added.
+ *
+ * \param menuname The name that the program should have in the
+ * Contiki menu.
+ *
+ * \param desktop Flag which specifies if the program should show up
+ * as an icon on the desktop or not.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+program_handler_add(struct dsc *dsc, char *menuname,
+		    unsigned char desktop)
+{
+  contikidsc[contikidsclast++] = dsc;
+  ctk_menuitem_add(&contikimenu, menuname);
+  if(desktop) {
+    CTK_ICON_ADD(dsc->icon, id);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initializes the program handler.
+ *
+ * Is called by the initialization before any programs have been added
+ * with program_handler_add().
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+program_handler_init(void)     
+{
+  id = ek_start(&p);
+  ctk_menu_new(&contikimenu, "Contiki");  
+}
+/*-----------------------------------------------------------------------------------*/
+#ifdef WITH_LOADER_ARCH
+#define NUM_PNARGS 6
+#define NAMELEN 16
+struct pnarg {
+  char name[NAMELEN];
+  char *arg;
+};
+static struct pnarg pnargs[NUM_PNARGS];
+static struct pnarg *
+pnarg_copy(char *name, char *arg)
+{
+  char i;
+  struct pnarg *pnargsptr;
+
+  pnargsptr = pnargs;
+  /* Allocate a place in the loadernames table. */
+  for(i = 0; i < NUM_PNARGS; ++i) {
+    if(*(pnargsptr->name) == 0) {
+      strncpy(pnargsptr->name, name, NAMELEN);
+      pnargsptr->arg = arg;
+      return pnargsptr;
+    }
+    ++pnargsptr;
+  }
+  return NULL;
+}
+
+static void
+pnarg_free(struct pnarg *pn)
+{
+  *(pn->name) = 0;
+}
+#endif /* WITH_LOADER_ARCH */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Loads a program and displays a dialog telling the user about it.
+ *
+ * \param name The name of the program to be loaded.
+ *
+ * \param arg An argument which is passed to the new process when it
+ * is loaded.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+program_handler_load(char *name, char *arg)
+{
+#ifdef WITH_LOADER_ARCH
+  struct pnarg *pnarg;
+  
+  pnarg = pnarg_copy(name, arg);
+  if(pnarg != NULL) {
+    ek_post(id, LOADER_EVENT_DISPLAY_NAME, pnarg);
+  } else {
+    ctk_label_set_text(&errortype, "Out of memory");
+    ctk_dialog_open(&errordialog);
+  }
+  /*  ctk_redraw(); */
+  /*  ctk_window_redraw(&loadingdialog);*/
+#endif /* WITH_LOADER_ARCH */
+}
+
+#ifdef WITH_LOADER_ARCH
+#define RUN(prg, name, arg) program_handler_load(prg, arg)
+#else /* WITH_LOADER_ARCH */
+#define RUN(prg, initfunc, arg) initfunc(arg)
+#endif /* WITH_LOADER_ARCH */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Configures the name of the screensaver to be loaded when
+ * appropriate.
+ *
+ * \param name The name of the screensaver or NULL if no screensaver
+ * should be used.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_SCREENSAVER
+void
+program_handler_setscreensaver(char *name)
+{
+  if(name == NULL) {
+    program_handler_screensaver[0] = 0;
+  } else {
+    strncpy(program_handler_screensaver, name, sizeof(program_handler_screensaver));
+  }
+}
+#endif /* CTK_CONF_SCREENSAVER */
+/*-----------------------------------------------------------------------------------*/
+static void
+make_windows(void)
+{
+#ifdef WITH_LOADER_ARCH
+  ctk_window_new(&runwindow, 16, 3, "Run");
+  
+  CTK_WIDGET_ADD(&runwindow, &namelabel);
+  CTK_WIDGET_ADD(&runwindow, &nameentry);
+  CTK_WIDGET_ADD(&runwindow, &loadbutton);
+  
+  CTK_WIDGET_FOCUS(&runwindow, &nameentry);
+  
+  ctk_dialog_new(&loadingdialog, 25, 1);
+  CTK_WIDGET_ADD(&loadingdialog, &loadingmsg);
+  CTK_WIDGET_ADD(&loadingdialog, &loadingname);
+  
+  ctk_dialog_new(&errordialog, 22, 8);
+  CTK_WIDGET_ADD(&errordialog, &errormsg);
+  CTK_WIDGET_ADD(&errordialog, &errorfilelabel);
+  CTK_WIDGET_ADD(&errordialog, &errortype);
+  CTK_WIDGET_ADD(&errordialog, &errorokbutton);
+  CTK_WIDGET_FOCUS(&errordialog, &errorokbutton);
+#endif /* WITH_LOADER_ARCH */
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(program_handler_sighandler, s, data)*/
+EK_EVENTHANDLER(program_handler_eventhandler, ev, data)
+{
+#ifdef WITH_LOADER_ARCH
+  unsigned char err;
+  struct dsc *dsc;
+#endif /* WITH_LOADER_ARCH */
+  unsigned char i;
+  struct dsc **dscp;
+  /*  DISPATCHER_SIGHANDLER_ARGS(s, data);*/
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create the menus */
+    ctk_menu_add(&contikimenu);
+#if WITH_LOADER_ARCH
+    runmenuitem = ctk_menuitem_add(&contikimenu, "Run program...");
+
+    make_windows();
+#endif /* WITH_LOADER_ARCH */
+#if QUIT_MENU
+    quitmenuitem = ctk_menuitem_add(&contikimenu, "Quit");
+#endif /* QUIT_MENU */
+    
+    displayname = NULL;
+
+#if CTK_CONF_SCREENSAVER
+    program_handler_screensaver[0] = 0;
+#endif /* CTK_CONF_SCREENSAVER */
+
+  } else if(ev == ctk_signal_button_activate) {
+#ifdef WITH_LOADER_ARCH
+    if(data == (ek_data_t)&loadbutton) {
+      ctk_window_close(&runwindow);
+      program_handler_load(name, NULL);
+    } else if(data == (ek_data_t)&errorokbutton) {
+      ctk_dialog_close();
+    }
+#endif /* WITH_LOADER_ARCH */
+#if QUIT_MENU
+    if(data == (ek_data_t)&quityesbutton) {
+      ctk_draw_init();
+      exit(EXIT_SUCCESS);
+    } else if(data == (ek_data_t)&quitnobutton) {
+      ctk_dialog_close();
+    }
+#endif /* QUIT_MENU */
+    dscp = &contikidsc[0];
+    for(i = 0; i < CTK_CONF_MAXMENUITEMS; ++i) {    
+      if(*dscp != NULL &&
+	 data == (ek_data_t)(*dscp)->icon) {
+	RUN((*dscp)->prgname, (*dscp)->init, NULL);
+	break;
+      }
+      ++dscp;
+    }
+  } else if(ev == ctk_signal_menu_activate) {
+    if((struct ctk_menu *)data == &contikimenu) {
+#if WITH_LOADER_ARCH
+      dsc = contikidsc[contikimenu.active];
+      if(dsc != NULL) {
+	RUN(dsc->prgname, dsc->init, NULL);
+      } else if(contikimenu.active == runmenuitem) {
+	make_windows();
+	ctk_window_close(&runwindow);
+	ctk_window_open(&runwindow);
+	CTK_WIDGET_FOCUS(&runwindow, &nameentry);
+      }
+#else /* WITH_LOADER_ARCH */
+      if(contikidsc[contikimenu.active] != NULL) {
+	RUN(contikidsc[contikimenu.active]->prgname,
+	    contikidsc[contikimenu.active]->init,
+	    NULL);
+      }
+#endif /* WITH_LOADER_ARCH */
+#if QUIT_MENU
+      if(contikimenu.active == quitmenuitem) {
+	ctk_dialog_new(&quitdialog, 24, 5);
+	CTK_WIDGET_ADD(&quitdialog, &quitdialoglabel);
+	CTK_WIDGET_ADD(&quitdialog, &quityesbutton);
+	CTK_WIDGET_ADD(&quitdialog, &quitnobutton);
+	CTK_WIDGET_FOCUS(&quitdialog, &quitnobutton);
+	ctk_dialog_open(&quitdialog);      
+      }
+#endif /* QUIT_MENU */
+    }
+#if CTK_CONF_SCREENSAVER
+  } else if(ev == ctk_signal_screensaver_start) {
+#if WITH_LOADER_ARCH
+    if(program_handler_screensaver[0] != 0) {
+      program_handler_load(program_handler_screensaver, NULL);
+    }
+#endif /* WITH_LOADER_ARCH */
+#endif /* CTK_CONF_SCREENSAVER */
+  } else if(ev == LOADER_EVENT_DISPLAY_NAME) {
+#if WITH_LOADER_ARCH
+    if(displayname == NULL) {
+      make_windows();
+
+      ctk_label_set_text(&loadingname, ((struct pnarg *)data)->name);
+      ctk_dialog_open(&loadingdialog);
+      /*      dispatcher_emit(loader_signal_load, data, id);*/
+      ek_post(id, LOADER_EVENT_LOAD, data);
+      displayname = data;
+    } else {
+      /* Try again. */
+      /*      dispatcher_emit(loader_signal_display_name, data, id);*/
+      ek_post(id, LOADER_EVENT_DISPLAY_NAME, data);
+    }
+#endif /* WITH_LOADER_ARCH */
+  } else if(ev == LOADER_EVENT_LOAD) {
+#if WITH_LOADER_ARCH
+    if(displayname == data) {
+      ctk_dialog_close();
+      displayname = NULL;
+      log_message("Loading ", ((struct pnarg *)data)->name);
+      err = LOADER_LOAD(((struct pnarg *)data)->name,
+			((struct pnarg *)data)->arg);
+      if(err != LOADER_OK) {
+	make_windows();
+	errorfilename[0] = '"';
+	strncpy(errorfilename + 1, ((struct pnarg *)data)->name,
+		sizeof(errorfilename) - 2);
+	errorfilename[1 + strlen(((struct pnarg *)data)->name)] = '"';
+	ctk_label_set_text(&errortype, (char *)errormsgs[err]);
+	ctk_dialog_open(&errordialog);
+	log_message((char *)errormsgs[err], errorfilename);
+      }
+      pnarg_free(data);
+    } else {
+      /* Try again. */
+/*      dispatcher_emit(loader_signal_display_name, data, id);*/
+      ek_post(id, LOADER_EVENT_DISPLAY_NAME, data);
+    }
+#endif /* WITH_LOADEER_ARCH */
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/program-handler.h b/contiki/apps/program-handler.h
new file mode 100644
index 0000000..9cf1d56
--- /dev/null
+++ b/contiki/apps/program-handler.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: program-handler.h,v 1.8 2005/05/12 23:55:18 oliverschmidt Exp $
+ *
+ */
+#ifndef __PROGRAM_HANDLER_H__
+#define __PROGRAM_HANDLER_H__
+
+#include "dsc.h"
+
+#define program_handler_getscreensaver() program_handler_screensaver
+
+extern char program_handler_screensaver[];
+
+void program_handler_init(void);
+void program_handler_load(char *name, char *arg);
+void program_handler_setscreensaver(char *name);
+
+void program_handler_add(struct dsc *dsc, char *menuname,
+			 unsigned char desktop);
+
+#endif /* __PROGRAM_HANDLER_H__ */
diff --git a/contiki/apps/shell-dsc.c b/contiki/apps/shell-dsc.c
new file mode 100644
index 0000000..6996cb0
--- /dev/null
+++ b/contiki/apps/shell-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: shell-dsc.c,v 1.4 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon shell_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(shell_dsc,
+    "The Contiki command shell",
+    "shell.prg",
+    shell_gui_init,
+    &shell_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char shellicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char shellicon_textmap[9] = {
+  'C', 'o', 'n',
+  't', 'i', 'k',
+  'i', 'S', 'h'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon shell_icon =
+  {CTK_ICON("Command shell", shellicon_bitmap, shellicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/shell-dsc.h b/contiki/apps/shell-dsc.h
new file mode 100644
index 0000000..f0bde2a
--- /dev/null
+++ b/contiki/apps/shell-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: shell-dsc.h,v 1.1 2004/07/04 17:47:46 adamdunkels Exp $
+ *
+ */
+#ifndef __SHELL_DSC_H__
+#define __SHELL_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(shell_dsc);
+
+#endif /* __SHELL_DSC_H__ */
diff --git a/contiki/apps/shell-gui.c b/contiki/apps/shell-gui.c
new file mode 100644
index 0000000..d810bd9
--- /dev/null
+++ b/contiki/apps/shell-gui.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell-gui.c,v 1.13 2005/05/05 23:32:01 oliverschmidt Exp $
+ *
+ */
+
+#include "ek.h"
+
+#include "program-handler.h"
+#include "loader.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include "ctk-textentry-cmdline.h"
+
+#include "shell-gui-conf.h"
+
+#include <string.h>
+
+
+static struct ctk_window window;
+static char log[SHELL_GUI_CONF_XSIZE * SHELL_GUI_CONF_YSIZE];
+static struct ctk_label loglabel =
+  {CTK_LABEL(0, 0, SHELL_GUI_CONF_XSIZE, SHELL_GUI_CONF_YSIZE, log)};
+static char command[SHELL_GUI_CONF_XSIZE - 1];
+static struct ctk_textentry commandentry =
+  {CTK_TEXTENTRY_INPUT(0, SHELL_GUI_CONF_YSIZE, SHELL_GUI_CONF_XSIZE - 2, 1, command,
+		       SHELL_GUI_CONF_XSIZE - 2, ctk_textentry_cmdline_input)};
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Command shell", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Command shell", shell_idle, sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+
+/*-----------------------------------------------------------------------------------*/
+void
+shell_quit(char *str)
+{
+  ctk_window_close(&window);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_output(char *str1, char *str2)
+{
+  static unsigned char i, len;
+  
+  for(i = 1; i < SHELL_GUI_CONF_YSIZE; ++i) {
+    memcpy(&log[(i - 1) * SHELL_GUI_CONF_XSIZE],
+	   &log[i * SHELL_GUI_CONF_XSIZE], SHELL_GUI_CONF_XSIZE);
+  }
+  memset(&log[(SHELL_GUI_CONF_YSIZE - 1) * SHELL_GUI_CONF_XSIZE],
+	 0, SHELL_GUI_CONF_XSIZE);
+
+  len = strlen(str1);
+
+  strncpy(&log[(SHELL_GUI_CONF_YSIZE - 1) * SHELL_GUI_CONF_XSIZE],
+	  str1, SHELL_GUI_CONF_XSIZE);
+  if(len < SHELL_GUI_CONF_XSIZE) {
+    strncpy(&log[(SHELL_GUI_CONF_YSIZE - 1) * SHELL_GUI_CONF_XSIZE] + len,
+	    str2, SHELL_GUI_CONF_XSIZE - len);
+  }
+
+  CTK_WIDGET_REDRAW(&loglabel);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_prompt(char *str)
+{
+  
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(shell_gui_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, SHELL_GUI_CONF_XSIZE,
+		   SHELL_GUI_CONF_YSIZE + 1, "Command shell");
+    CTK_WIDGET_ADD(&window, &loglabel);
+    /*    CTK_WIDGET_SET_FLAG(&loglabel, CTK_WIDGET_FLAG_MONOSPACE);*/
+    CTK_WIDGET_ADD(&window, &commandentry);
+    /*    CTK_WIDGET_SET_FLAG(&commandentry, CTK_WIDGET_FLAG_MONOSPACE);*/
+    CTK_WIDGET_FOCUS(&window, &commandentry);
+    memset(log, 0, sizeof(log));
+    
+    shell_init();
+    ctk_window_open(&window);
+    shell_start();
+  } else if(ev == ctk_signal_widget_activate &&
+     data == (ek_data_t)&commandentry) {
+    shell_output("> ", command);
+    shell_input(command);
+    CTK_TEXTENTRY_CLEAR(&commandentry);
+    CTK_WIDGET_REDRAW(&commandentry);
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    shell_quit(NULL);
+  } else {
+    shell_eventhandler(ev, data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/shell.c b/contiki/apps/shell.c
new file mode 100644
index 0000000..2b8adb4
--- /dev/null
+++ b/contiki/apps/shell.c
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.c,v 1.3 2005/05/08 10:39:08 oliverschmidt Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include <string.h>
+
+static char showingdir = 0;
+static struct cfs_dir dir;
+static unsigned int totsize;
+
+struct ptentry {
+  char c1;
+  char c2;
+  void (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+parse(register char *str, struct ptentry *t)
+{
+  register struct ptentry *p;
+  char *sstr;
+
+  sstr = str;
+  
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c1 != 0; ++p) {
+    if(*str == p->c1 || *str == p->c2) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      p->pfunc(str);
+      return;
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+inttostr(register char *str, unsigned int i)
+{
+  str[0] = '0' + i / 100;
+  if(str[0] == '0') {
+    str[0] = ' ';
+  }
+  str[1] = '0' + (i / 10) % 10;
+  if(str[0] == ' ' && str[1] == '0') {
+    str[1] = ' ';
+  }
+  str[2] = '0' + i % 10;
+  str[3] = ' ';
+  str[4] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes(char *str)
+{
+  static char idstr[5];
+  struct ek_proc *p;
+
+  shell_output("Processes:", "");
+  /* Step through each possible process ID and see if there is a
+     matching process. */
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    inttostr(idstr, p->id);
+    shell_output(idstr, (char *)p->name);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+runfile(char *str)
+{
+  nullterminate(str);
+
+  if(strlen(str) > 0) {
+    /* Call loader function. */
+    program_handler_load(str, NULL);
+    shell_output("Starting program ", str);  
+  } else {
+    shell_output("Must supply a program name", "");  
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+execfile(char *str)
+{
+  runfile(str);
+  shell_quit(NULL);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(char *str)
+{
+  char procnum, j, c;
+  char procstr[5];
+
+  nullterminate(str);
+  
+  procnum = 0;
+  
+  for(j = 0; j < 4; ++j) {
+    c = str[j];
+    if(c >= '0' && c <= '9') {
+      procnum = procnum * 10 + (str[j] - '0');
+    } else {
+      break;
+    }
+  }
+  if(procnum != 0) {
+    inttostr(procstr, procnum);
+    shell_output("Killing process ", procstr);
+    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+  } else {
+    shell_output("Invalid process number", "");
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+  shell_output("Available commands:", "");
+  shell_output("run  - start program", "");
+  shell_output("exec - start program & exit shell", "");  
+  shell_output("ps   - show processes", "");
+  shell_output("kill - kill process", "");
+  shell_output("ls   - display directory", "");
+  shell_output("quit - quit shell", "");
+  shell_output("?    - show this help", "");      
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+directory(char *str)
+{
+  if(cfs_opendir(&dir, ".") != 0) {
+    shell_output("Cannot open directory", "");
+    showingdir = 0;
+  } else {
+    shell_output("Disk directory:", "");
+    showingdir = 1;
+    totsize = 0;
+    ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+none(char *str)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+  {{'e', 'E', execfile},
+   {'r', 'R', runfile},
+   {'k', 'K', killproc},   
+   {'p', 'P', processes},
+   {'l', 'L', directory},
+   {'q', 'Q', shell_quit},
+   {'h', '?', help},
+
+   /* Default action */
+   {0,   0,   none}};
+/*-----------------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+  showingdir = 0;
+  shell_output("Contiki command shell", "");
+  shell_output("Type '?' and return for help", "");  
+  shell_prompt("contiki> "); 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+  if(showingdir != 0) {
+    showingdir = 0;
+    shell_output("Directory stopped", "");
+    cfs_closedir(&dir);
+  }
+  parse(cmd, configparsetab);
+  if(showingdir == 0) {
+    shell_prompt("contiki> ");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  static struct cfs_dirent dirent;
+  static char size[10];
+
+  if(ev == EK_EVENT_CONTINUE) {
+    if(showingdir != 0) {
+      if(cfs_readdir(&dir, &dirent) != 0) {
+	cfs_closedir(&dir);
+	showingdir = 0;
+	inttostr(size, totsize);
+	shell_output("Total number of blocks: ", size);
+	shell_prompt("contiki> ");
+      } else {
+	totsize += dirent.size;
+	inttostr(size, dirent.size);
+	shell_output(size, dirent.name);
+	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/shell.h b/contiki/apps/shell.h
new file mode 100644
index 0000000..92fd22e
--- /dev/null
+++ b/contiki/apps/shell.h
@@ -0,0 +1,114 @@
+/**
+ * \file
+ * Interface for the Contiki shell.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * Some of the functions declared in this file must be implemented as
+ * a shell back-end in the architecture specific files of a Contiki
+ * port.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.h,v 1.4 2004/08/20 21:37:39 adamdunkels Exp $
+ *
+ */
+#ifndef __SHELL_H__
+#define __SHELL_H__
+
+/**
+ * Initialize the shell.
+ *
+ * Called when the shell front-end process starts. This function may
+ * be used to start listening for signals.
+ */
+void shell_init(void);
+
+/**
+ * Start the shell back-end.
+ *
+ * Called by the front-end when a new shell is started.
+ */
+void shell_start(void);
+
+/**
+ * The shell event handler.
+ *
+ * This function will be called when an event is received.
+ */
+void shell_eventhandler(ek_event_t ev, ek_data_t data);
+
+/**
+ * Process a shell command.
+ *
+ * This function will be called by the shell GUI / telnet server whan
+ * a command has been entered that should be processed by the shell
+ * back-end.
+ *
+ * \param command The command to be processed.
+ */
+void shell_input(char *command);
+
+/**
+ * Quit the shell.
+ *
+ */
+void shell_quit(char *);
+
+
+/**
+ * Print a string to the shell window.
+ *
+ * This function is implemented by the shell GUI / telnet server and
+ * can be called by the shell back-end to output a string in the
+ * shell window. The string is automatically appended with a linebreak.
+ *
+ * \param str1 The first half of the string to be output.
+ * \param str2 The second half of the string to be output.
+ */
+void shell_output(char *str1, char *str2);
+
+/**
+ * Print a prompt to the shell window.
+ *
+ * This function can be used by the shell back-end to print out a
+ * prompt to the shell window.
+ *
+ * \param prompt The prompt to be printed.
+ *
+ */
+void shell_prompt(char *prompt);
+
+#endif /* __SHELL_H__ */
+
+
+
diff --git a/contiki/apps/simpletelnet.c b/contiki/apps/simpletelnet.c
new file mode 100644
index 0000000..5ba57e8
--- /dev/null
+++ b/contiki/apps/simpletelnet.c
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: simpletelnet.c,v 1.14 2005/04/16 14:17:32 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ek.h"
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "uip.h"
+#include "ctk.h"
+#include "resolv.h"
+#include "telnet.h"
+#include "simpletelnet.h"
+#include "loader.h"
+#include "tcpip.h"
+
+/* Telnet window */
+static struct ctk_window telnetwindow;
+
+static struct ctk_label telnethostlabel =
+  {CTK_LABEL(1, 0, 4, 1, "Host")};
+static char telnethost[25];
+static struct ctk_textentry telnethosttextentry =
+  {CTK_TEXTENTRY(0, 1, 24, 1, telnethost, 24)};
+
+static struct ctk_label telnetportlabel =
+  {CTK_LABEL(31, 0, 4, 1, "Port")};
+static char telnetport[6];
+static struct ctk_textentry telnetporttextentry =
+  {CTK_TEXTENTRY(30, 1, 5, 1, telnetport, 5)};
+
+static struct ctk_button telnetconnectbutton =
+  {CTK_BUTTON(2, 3, 7, "Connect")};
+static struct ctk_button telnetdisconnectbutton =
+  {CTK_BUTTON(25, 3, 10, "Disconnect")};
+
+static char telnetline[31];
+static struct ctk_textentry telnetlinetextentry =
+  {CTK_TEXTENTRY(0, 5, 30, 1, telnetline, 30)};
+
+
+static struct ctk_button telnetsendbutton =
+  {CTK_BUTTON(32, 5, 4, "Send")};
+
+static struct ctk_label telnetstatus =
+  {CTK_LABEL(0, 19, 38, 1, "")};
+
+static struct ctk_separator telnetsep1 =
+  {CTK_SEPARATOR(0, 7, 38)};
+
+static struct ctk_separator telnetsep2 =
+  {CTK_SEPARATOR(0, 18, 38)};
+
+static char telnettext[38*10];
+static struct ctk_label telnettextarea =
+  {CTK_LABEL(0, 8, 38, 10, telnettext)};
+
+static struct telnet_state ts_appstate;
+
+#define ISO_NL       0x0a
+#define ISO_CR       0x0d
+
+static char sendline[31+2];
+
+EK_EVENTHANDLER(simpletelnet_eventhandler, ev, data);
+EK_PROCESS(p, "Telnet client", EK_PRIO_NORMAL,
+	   simpletelnet_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+/*
+static DISPATCHER_SIGHANDLER(simpletelnet_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Simple telnet", NULL, simpletelnet_sighandler,
+		   telnet_app)};
+		   static ek_id_t id;*/
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(simpletelnet_init, arg)
+{
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrollup(void)
+{
+  unsigned char i;
+  for(i = 1; i < 10; ++i) {
+    memcpy(&telnettext[(i - 1) * 38], &telnettext[i * 38], 38);
+  }
+  memset(&telnettext[9 * 38], 0, 38);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+add_text(char *text)
+{
+  unsigned char i;
+  unsigned int len;
+  
+  len = strlen(text);
+
+  i = 0;
+  while(len > 0) {
+    if(*text == '\n') {
+      scrollup();
+      i = 0;
+    } else if(*text == '\r') {
+      i = 0;
+    } else if(*text >= ' ') {
+      telnettext[9 * 38 + i] = *text;
+      ++i;
+      if(i == 38) {
+	scrollup();
+	i = 0;
+      }
+    }
+    ++text;
+    --len;
+  }
+
+  /*  if(strlen(text) > 37) {
+      memcpy(&telnettext[9 * 38], text, 37);
+      } else {
+      memcpy(&telnettext[9 * 38], text, strlen(text));
+      }
+  */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show(char *text)
+{
+  add_text(text);
+  add_text("\n");
+  ctk_label_set_text(&telnetstatus, text);
+  ctk_window_redraw(&telnetwindow);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+connect(void)
+{
+  u16_t addr[2], *addrptr;
+  u16_t port;
+  char *cptr;
+  struct uip_conn *conn;
+
+  /* Find the first space character in host and put a zero there
+     to end the string. */
+  for(cptr = telnethost; *cptr != ' ' && *cptr != 0; ++cptr);
+  *cptr = 0;
+
+  addrptr = &addr[0];  
+  if(uiplib_ipaddrconv(telnethost, (unsigned char *)addr) == 0) {
+    addrptr = resolv_lookup(telnethost);
+    if(addrptr == NULL) {
+      resolv_query(telnethost);
+      show("Resolving host...");
+      return;
+    }
+  }
+
+  port = 0;
+  for(cptr = telnetport; *cptr != ' ' && *cptr != 0; ++cptr) {
+    if(*cptr < '0' || *cptr > '9') {
+      show("Port number error");
+      return;
+    }
+    port = 10 * port + *cptr - '0';
+  }
+
+
+  conn = tcp_connect(addrptr, htons(port), &ts_appstate);
+  if(conn == NULL) {
+    show("Out of memory error");
+    return;
+  }
+
+  show("Connecting...");
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(simpletelnet_eventhandler, ev, data)
+{
+  struct ctk_widget *w;
+  int sendlen;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create Telnet window. */
+    ctk_window_new(&telnetwindow, 38, 20, "Simple telnet");
+
+    strcpy(telnetport, "23");
+    
+    CTK_WIDGET_ADD(&telnetwindow, &telnethostlabel);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetportlabel);
+    CTK_WIDGET_ADD(&telnetwindow, &telnethosttextentry);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetporttextentry);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetconnectbutton);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetdisconnectbutton);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetlinetextentry);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetsendbutton);
+    
+    CTK_WIDGET_ADD(&telnetwindow, &telnetsep1);
+    CTK_WIDGET_ADD(&telnetwindow, &telnettextarea);
+    
+    CTK_WIDGET_ADD(&telnetwindow, &telnetsep2);
+    CTK_WIDGET_ADD(&telnetwindow, &telnetstatus);
+
+    CTK_WIDGET_FOCUS(&telnetwindow, &telnethosttextentry);
+       
+    /* Attach as a listener to the CTK button press signal. */
+    /*    dispatcher_listen(ctk_signal_button_activate);
+    dispatcher_listen(ctk_signal_window_close);
+    dispatcher_listen(resolv_signal_found);*/
+    
+    ctk_window_open(&telnetwindow);
+
+  } else if(ev == ctk_signal_button_activate) {
+    
+    w = (struct ctk_widget *)data;
+    if(w == (struct ctk_widget *)&telnetsendbutton) {
+      strcpy(sendline, telnetline);
+      sendlen = strlen(sendline);
+      petsciiconv_toascii(sendline, sendlen);
+      sendline[sendlen++] = ISO_CR;
+      sendline[sendlen++] = ISO_NL;
+      if(telnet_send(&ts_appstate, sendline, sendlen)) {
+	/* Could not send. */
+	ctk_label_set_text(&telnetstatus, "Could not send");
+	ctk_window_redraw(&telnetwindow);
+	/*      } else {*/
+	/* Could send */
+      }
+    } else if(w == (struct ctk_widget *)&telnetdisconnectbutton) {
+      telnet_close(&ts_appstate);
+      show("Closing...");
+    } else if(w == (struct ctk_widget *)&telnetconnectbutton) {
+      connect();
+      ctk_window_redraw(&telnetwindow);
+    }
+  } else if(ev == resolv_event_found) {
+    if(strcmp(data, telnethost) == 0) {
+      if(resolv_lookup(telnethost) != NULL) {
+	connect();
+      } else {
+	show("Host not found");
+      }
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ek_exit();
+    ctk_window_close(&telnetwindow);
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  } else if(ev == tcpip_event) {
+    telnet_app(data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_connected(struct telnet_state *s)
+{  
+  show("Connected");
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_closed(struct telnet_state *s)
+{
+  show("Connection closed");
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_sent(struct telnet_state *s)
+{
+  petsciiconv_topetscii(sendline, sizeof(sendline));
+  scrollup();
+  add_text(sendline);
+  CTK_TEXTENTRY_CLEAR(&telnetlinetextentry);
+  ctk_window_redraw(&telnetwindow);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_aborted(struct telnet_state *s)
+{
+  show("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_timedout(struct telnet_state *s)
+{
+  show("Connection timed out");
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_newdata(struct telnet_state *s, char *data, u16_t len)
+{
+  petsciiconv_topetscii(data, len);
+  data[len] = 0;
+  add_text(data);
+  ctk_window_redraw(&telnetwindow);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/simpletelnet.h b/contiki/apps/simpletelnet.h
new file mode 100644
index 0000000..b3d9b20
--- /dev/null
+++ b/contiki/apps/simpletelnet.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: simpletelnet.h,v 1.3 2004/06/06 05:59:21 adamdunkels Exp $
+ *
+ */
+#ifndef __SIMPLETELNET_H__
+#define __SIMPLETELNET_H__
+
+void simpletelnet_init(char *arg);
+
+#endif /* __SIMPLETELNET_H__ */
diff --git a/contiki/apps/smtp-socket.c b/contiki/apps/smtp-socket.c
new file mode 100644
index 0000000..09d9b1d
--- /dev/null
+++ b/contiki/apps/smtp-socket.c
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp-socket.c,v 1.6 2005/05/05 23:02:01 oliverschmidt Exp $
+ */
+#include "smtp.h"
+
+#include "smtp-strings.h"
+#include "psock.h"
+
+#include <string.h>
+
+struct smtp_state {
+
+  char connected;
+  
+  struct psock psock;
+
+  char inputbuffer[4];
+  
+  char *to;
+  char *cc;
+  char *from;
+  char *subject;
+  char *msg;
+  u8_t msgwidth;
+  u8_t msgheight;
+  u8_t line;
+};
+
+static struct smtp_state s;
+
+static char *localhostname;
+static u16_t smtpserver[2];
+
+#define ISO_nl 0x0a
+#define ISO_cr 0x0d
+
+#define ISO_period 0x2e
+
+#define ISO_2  0x32
+#define ISO_3  0x33
+#define ISO_4  0x34
+#define ISO_5  0x35
+
+
+#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str))
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(smtp_thread(void))
+{
+  PSOCK_BEGIN(&s.psock);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+   
+  if(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(2);
+    PSOCK_EXIT(&s.psock);
+  }
+  
+  SEND_STRING(&s.psock, (char *)smtp_helo);
+  SEND_STRING(&s.psock, localhostname);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+  
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(3);
+    PSOCK_EXIT(&s.psock);
+  }  
+
+  SEND_STRING(&s.psock, (char *)smtp_mail_from);
+  SEND_STRING(&s.psock, s.from);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+  
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(4);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  SEND_STRING(&s.psock, (char *)smtp_rcpt_to);
+  SEND_STRING(&s.psock, s.to);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+  
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(5);
+    PSOCK_EXIT(&s.psock);
+  }
+  
+  if(*s.cc != 0) {
+    SEND_STRING(&s.psock, (char *)smtp_rcpt_to);
+    SEND_STRING(&s.psock, s.cc);
+    SEND_STRING(&s.psock, (char *)smtp_crnl);
+
+    PSOCK_READTO(&s.psock, ISO_nl);
+  
+    if(s.inputbuffer[0] != ISO_2) {
+      PSOCK_CLOSE(&s.psock);
+      smtp_done(6);
+      PSOCK_EXIT(&s.psock);
+    }
+  }
+  
+  SEND_STRING(&s.psock, (char *)smtp_data);
+  
+  PSOCK_READTO(&s.psock, ISO_nl);
+  
+  if(s.inputbuffer[0] != ISO_3) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(7);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  SEND_STRING(&s.psock, (char *)smtp_to);
+  SEND_STRING(&s.psock, s.to);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+  
+  if(*s.cc != 0) {
+    SEND_STRING(&s.psock, (char *)smtp_cc);
+    SEND_STRING(&s.psock, s.cc);
+    SEND_STRING(&s.psock, (char *)smtp_crnl);
+  }
+  
+  SEND_STRING(&s.psock, (char *)smtp_from);
+  SEND_STRING(&s.psock, s.from);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+  
+  SEND_STRING(&s.psock, (char *)smtp_subject);
+  SEND_STRING(&s.psock, s.subject);
+  SEND_STRING(&s.psock, (char *)smtp_crnl);
+
+  for(s.line = 0; s.line < s.msgheight; ++s.line) {
+    SEND_STRING(&s.psock, (char *)smtp_crnl);
+    SEND_STRING(&s.psock, &s.msg[s.line * s.msgwidth]);
+  }
+  
+  SEND_STRING(&s.psock, (char *)smtp_crnlperiodcrnl);
+
+  PSOCK_READTO(&s.psock, ISO_nl);
+  if(s.inputbuffer[0] != ISO_2) {
+    PSOCK_CLOSE(&s.psock);
+    smtp_done(8);
+    PSOCK_EXIT(&s.psock);
+  }
+
+  SEND_STRING(&s.psock, (char *)smtp_quit);
+  smtp_done(SMTP_ERR_OK);
+  PSOCK_END(&s.psock);
+}
+/*---------------------------------------------------------------------------*/
+void
+smtp_appcall(void *state)
+{
+  if(uip_closed()) {
+    s.connected = 0;
+    return;
+  }
+  if(uip_aborted() || uip_timedout()) {
+    s.connected = 0;
+    smtp_done(1);
+    return;
+  }
+  smtp_thread();
+}
+/*---------------------------------------------------------------------------*/
+void
+smtp_configure(char *lhostname, u16_t *server)
+{
+  localhostname = lhostname;
+  smtpserver[0] = server[0];
+  smtpserver[1] = server[1];
+}
+/*---------------------------------------------------------------------------*/
+unsigned char
+smtp_send(char *to, char *cc, char *from, char *subject,
+	  char *msg, u8_t msgwidth, u8_t msgheight)
+{
+  struct uip_conn *conn;
+
+  conn = tcp_connect(smtpserver, HTONS(25), NULL);
+  if(conn == NULL) {
+    return 0;
+  }
+  s.connected = 1;
+  s.to = to;
+  s.cc = cc;
+  s.from = from;
+  s.subject = subject;
+  s.msg = msg;
+  s.msgwidth = msgwidth;
+  s.msgheight = msgheight;
+
+  PSOCK_INIT(&s.psock, s.inputbuffer, sizeof(s.inputbuffer));
+  
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
+void
+smtp_init(void)
+{
+  s.connected = 0;
+}
+/*---------------------------------------------------------------------------*/
+
diff --git a/contiki/apps/smtp-strings b/contiki/apps/smtp-strings
new file mode 100644
index 0000000..359ceef
--- /dev/null
+++ b/contiki/apps/smtp-strings
@@ -0,0 +1,12 @@
+smtp_220 "220"
+smtp_helo "HELO "
+smtp_mail_from "MAIL FROM: "
+smtp_rcpt_to "RCPT TO: "
+smtp_data "DATA\r\n"
+smtp_to "To: "
+smtp_to "Cc: "
+smtp_from "From: "
+smtp_subject "Subject: "
+smtp_quit "QUIT\r\n"
+smtp_crnl "\r\n"
+smtp_crnlperiodcrnl "\r\n.\r\n"
\ No newline at end of file
diff --git a/contiki/apps/smtp-strings.c b/contiki/apps/smtp-strings.c
new file mode 100644
index 0000000..4076424
--- /dev/null
+++ b/contiki/apps/smtp-strings.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp-strings.c,v 1.6 2005/05/05 23:02:02 oliverschmidt Exp $
+ */
+const char smtp_220[4] = 
+/* "220" */
+{0x32, 0x32, 0x30, };
+const char smtp_helo[6] = 
+/* "HELO " */
+{0x48, 0x45, 0x4c, 0x4f, 0x20, };
+const char smtp_mail_from[12] = 
+/* "MAIL FROM: " */
+{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
+const char smtp_rcpt_to[10] = 
+/* "RCPT TO: " */
+{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
+const char smtp_data[7] = 
+/* "DATA\r\n" */
+{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
+const char smtp_to[5] = 
+/* "To: " */
+{0x54, 0x6f, 0x3a, 0x20, };
+const char smtp_cc[5] = 
+/* "Cc: " */
+{0x43, 0x63, 0x3a, 0x20, };
+const char smtp_from[7] = 
+/* "From: " */
+{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
+const char smtp_subject[10] = 
+/* "Subject: " */
+{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
+const char smtp_quit[7] = 
+/* "QUIT\r\n" */
+{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
+const char smtp_crnl[3] = 
+/* "\r\n" */
+{0xd, 0xa, };
+const char smtp_crnlperiodcrnl[6] = 
+/* "\r\n.\r\n" */
+{0xd, 0xa, 0x2e, 0xd, 0xa, };
diff --git a/contiki/apps/smtp-strings.h b/contiki/apps/smtp-strings.h
new file mode 100644
index 0000000..7f638d3
--- /dev/null
+++ b/contiki/apps/smtp-strings.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: smtp-strings.h,v 1.5 2005/04/28 22:36:07 oliverschmidt Exp $
+ */
+extern const char smtp_220[4];
+extern const char smtp_helo[6];
+extern const char smtp_mail_from[12];
+extern const char smtp_rcpt_to[10];
+extern const char smtp_data[7];
+extern const char smtp_to[5];
+extern const char smtp_cc[5];
+extern const char smtp_from[7];
+extern const char smtp_subject[10];
+extern const char smtp_quit[7];
+extern const char smtp_crnl[3];
+extern const char smtp_crnlperiodcrnl[6];
diff --git a/contiki/apps/smtp.c b/contiki/apps/smtp.c
new file mode 100644
index 0000000..9efacdf
--- /dev/null
+++ b/contiki/apps/smtp.c
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: smtp.c,v 1.6 2004/07/04 11:35:08 adamdunkels Exp $
+ *
+ */
+
+#include "uip.h"
+#include "smtp.h"
+
+#include "smtp-strings.h"
+
+#include "tcpip.h"
+
+#include <string.h>
+
+#define STATE_SEND_NONE         0
+#define STATE_SEND_HELO         1
+#define STATE_SEND_MAIL_FROM    2
+#define STATE_SEND_RCPT_TO      3
+#define STATE_SEND_DATA         4
+#define STATE_SEND_DATA_HEADERS 5
+#define STATE_SEND_DATA_MESSAGE 6
+#define STATE_SEND_DATA_END     7
+#define STATE_SEND_QUIT         8
+#define STATE_SEND_DONE         9
+
+static char *localhostname;
+static u16_t smtpserver[2];
+
+
+
+#define ISO_nl 0x0a
+#define ISO_cr 0x0d
+
+#define ISO_period 0x2e
+
+#define ISO_2  0x32
+#define ISO_3  0x33
+#define ISO_4  0x34
+#define ISO_5  0x35
+
+
+struct smtp_state {
+  u8_t state;
+  char *to;
+  char *from;
+  char *subject;
+  char *msg;
+  u16_t msglen;
+  
+  u16_t sentlen, textlen;
+  u16_t sendptr;
+
+};
+
+
+static struct smtp_state s;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)    
+{
+  char *textptr;
+
+  if(s.textlen != 0 &&
+     s.textlen == s.sendptr) {
+    return;
+  }
+
+  textptr = (char *)uip_appdata;
+  switch(s.state) {
+  case STATE_SEND_HELO:
+    /* Create HELO message. */
+    strcpy(textptr, smtp_helo);
+    textptr += sizeof(smtp_helo) - 1;
+    strcpy(textptr, localhostname);
+    textptr += strlen(localhostname);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    /*    printf("s.sendptr %d\n", s.sendptr);*/
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+      /*      printf("s.textlen %d\n", s.textlen);*/
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_MAIL_FROM:
+    /* Create MAIL FROM message. */
+    strcpy(textptr, smtp_mail_from);
+    textptr += sizeof(smtp_mail_from) - 1;
+    strcpy(textptr, s.from);
+    textptr += strlen(s.from);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_RCPT_TO:
+    /* Create RCPT_TO message. */
+    strcpy(textptr, smtp_rcpt_to);
+    textptr += sizeof(smtp_rcpt_to) - 1;
+    strcpy(textptr, s.to);
+    textptr += strlen(s.to);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_DATA:
+    strcpy(textptr, smtp_data);
+    textptr += sizeof(smtp_data) - 1;
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_DATA_HEADERS:
+    /* Create mail headers. */
+    strcpy(textptr, smtp_to);
+    textptr += sizeof(smtp_to) - 1;
+    strcpy(textptr, s.to);
+    textptr += strlen(s.to);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    
+    strcpy(textptr, smtp_from);
+    textptr += sizeof(smtp_from) - 1;
+    strcpy(textptr, s.from);
+    textptr += strlen(s.from);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    
+    strcpy(textptr, smtp_subject);
+    textptr += sizeof(smtp_subject) - 1;
+    strcpy(textptr, s.subject);
+    textptr += strlen(s.subject);
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_DATA_MESSAGE:
+    textptr = s.msg;
+    if(s.sendptr == 0) {
+      s.textlen = s.msglen;
+    } 
+    break;
+  case STATE_SEND_DATA_END:
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    *textptr = ISO_period;
+    ++textptr;
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    if(s.sendptr == 0) {
+      s.textlen = 5;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  case STATE_SEND_QUIT:
+    strcpy(textptr, smtp_quit);
+    textptr += sizeof(smtp_quit) - 1;
+    *textptr = ISO_cr;
+    ++textptr;
+    *textptr = ISO_nl;
+    ++textptr;
+    if(s.sendptr == 0) {
+      s.textlen = textptr - (char *)uip_appdata;
+    }
+    textptr = (char *)uip_appdata;
+    break;
+  default:
+    return;
+  }
+
+  textptr += s.sendptr;
+  
+  if(s.textlen - s.sendptr > uip_mss()) {
+    s.sentlen = uip_mss();
+  } else {
+    s.sentlen = s.textlen - s.sendptr;
+  }
+
+  /*  textptr[s.sentlen] = 0;
+      printf("Senidng '%s'\n", textptr);*/
+  
+  uip_send(textptr, s.sentlen);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)    
+{  
+  s.sendptr += s.sentlen;
+  s.sentlen = 0;
+
+  if(s.sendptr == s.textlen) {
+    switch(s.state) {
+    case STATE_SEND_DATA_HEADERS:
+      s.state = STATE_SEND_DATA_MESSAGE;
+      s.sendptr = s.textlen = 0;
+      break;
+    case STATE_SEND_DATA_MESSAGE:
+      s.state = STATE_SEND_DATA_END;
+      s.sendptr = s.textlen = 0;
+      break;
+    case STATE_SEND_DATA_END:
+      s.state = STATE_SEND_QUIT;
+      s.sendptr = s.textlen = 0;
+      break;
+    case STATE_SEND_QUIT:
+      s.state = STATE_SEND_DONE;
+      smtp_done(SMTP_ERR_OK);
+      uip_close();
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  if(*(char *)uip_appdata == ISO_5) {
+    smtp_done(1);
+    uip_abort();
+    return;
+  }
+  /*  printf("Got %d bytes: '%s'\n", uip_datalen(),
+      uip_appdata);*/
+  switch(s.state) {
+  case STATE_SEND_NONE:       
+    if(strncmp((char *)uip_appdata, smtp_220, 3) == 0) {
+      /*      printf("Newdata(): SEND_NONE, got 220, towards SEND_HELO\n");*/
+      s.state = STATE_SEND_HELO;
+      s.sendptr = 0;
+    }
+    break;
+  case STATE_SEND_HELO:
+    if(*(char *)uip_appdata == ISO_2) {
+      /*      printf("Newdata(): SEND_HELO, got 2*, towards SEND_MAIL_FROM\n");*/
+      s.state = STATE_SEND_MAIL_FROM;
+      s.sendptr = 0;
+    }    
+    break;
+  case STATE_SEND_MAIL_FROM:
+    if(*(char *)uip_appdata == ISO_2) {
+      /*      printf("Newdata(): SEND_MAIL_FROM, got 2*, towards SEND_RCPT_TO\n");      */
+      /*      printf("2\n");*/
+      s.state = STATE_SEND_RCPT_TO;
+      s.textlen = s.sendptr = 0;
+    }
+    break;
+  case STATE_SEND_RCPT_TO:
+    if(*(char *)uip_appdata == ISO_2) {
+      /*      printf("2\n");*/
+      s.state = STATE_SEND_DATA;
+      s.textlen = s.sendptr = 0;
+    }
+    break;
+  case STATE_SEND_DATA:
+    if(*(char *)uip_appdata == ISO_3) {
+      /*      printf("3\n");*/
+      s.state = STATE_SEND_DATA_HEADERS;
+      s.textlen = s.sendptr = 0;
+    }
+    break;
+  case STATE_SEND_DATA_HEADERS:    
+    if(*(char *)uip_appdata == ISO_3) {
+      /*      printf("3\n");*/
+      s.state = STATE_SEND_DATA_MESSAGE;
+      s.textlen = s.sendptr = 0;
+    }
+    break;
+  }
+    
+}
+/*-----------------------------------------------------------------------------------*/
+/*DISPATCHER_UIPCALL(smtp_appcall, state)*/
+void
+smtp_appcall(void *state)
+{
+  if(uip_connected()) {
+    /*    senddata();*/
+    return;
+  }
+  if(uip_acked()) {
+    acked();
+  }
+  if(uip_newdata()) {
+    newdata();
+  }
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata();
+  } else if(uip_poll()) {    
+    senddata();
+  }
+  /*  if(uip_closed()) {
+    printf("Dnoe\n");
+    }*/
+
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+smtp_send(char *to, char *from, char *subject,
+	  char *msg, u16_t msglen)
+{
+  struct uip_conn *conn;
+
+  conn = tcp_connect(smtpserver, HTONS(25), NULL);
+  if(conn == NULL) {
+    return 0;
+  }
+  
+  s.state = STATE_SEND_NONE;
+  s.sentlen = s.sendptr = s.textlen = 0;
+  s.to = to;
+  s.from = from;
+  s.subject = subject;
+  s.msg = msg;
+  s.msglen = msglen;
+
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+smtp_configure(char *lhostname, u16_t *server)
+{
+  localhostname = lhostname;
+  smtpserver[0] = server[0];
+  smtpserver[1] = server[1];
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/smtp.h b/contiki/apps/smtp.h
new file mode 100644
index 0000000..e10a6de
--- /dev/null
+++ b/contiki/apps/smtp.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: smtp.h,v 1.5 2005/05/04 23:51:09 oliverschmidt Exp $
+ *
+ */
+#ifndef __SMTP_H__
+#define __SMTP_H__
+
+#include "uip.h"
+
+/* Callbacks. */
+#define SMTP_ERR_OK 0
+void smtp_done(unsigned char error);
+
+/* Functions. */
+void smtp_configure(char *localhostname, u16_t *smtpserver);
+unsigned char smtp_send(char *to, char *cc, char *from,
+			char *subject, char *msg,
+			u8_t msgwidth, u8_t msgheight);
+
+/*DISPATCHER_UIPCALL(smtp_appcall, state);*/
+
+void smtp_appcall(void *state);
+
+
+#ifndef UIP_APPCALL
+#define UIP_APPCALL     smtp_appcall
+#endif
+
+#ifndef UIP_APPSTATE_SIZE
+#define UIP_APPSTATE_SIZE (sizeof(struct smtp_state))
+#endif
+
+
+#endif /* __SMTP_H__ */
diff --git a/contiki/apps/telnet-dsc.c b/contiki/apps/telnet-dsc.c
new file mode 100644
index 0000000..54c8452
--- /dev/null
+++ b/contiki/apps/telnet-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: telnet-dsc.c,v 1.7 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon telnet_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(telnet_dsc,
+    "A simple Telnet client",
+    "telnet.prg",
+    simpletelnet_init,
+    &telnet_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char telneticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char telneticon_textmap[9] = {
+  't', 'e', 'l',
+  'n', 'e', 't',
+  '-', '-', '-'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon telnet_icon =
+  {CTK_ICON("Telnet", telneticon_bitmap, telneticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/telnet-dsc.h b/contiki/apps/telnet-dsc.h
new file mode 100644
index 0000000..6275654
--- /dev/null
+++ b/contiki/apps/telnet-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: telnet-dsc.h,v 1.1 2003/04/17 19:00:01 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNET_DSC_H__
+#define __TELNET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(telnet_dsc);
+
+#endif /* __TELNET_DSC_H__ */
diff --git a/contiki/apps/telnet.c b/contiki/apps/telnet.c
new file mode 100644
index 0000000..df7bf2f
--- /dev/null
+++ b/contiki/apps/telnet.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: telnet.c,v 1.5 2004/07/04 11:35:08 adamdunkels Exp $
+ *
+ */
+
+#include "tcpip.h"
+
+#include "telnet.h"
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define FLAG_CLOSE 1
+#define FLAG_ABORT 2
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+telnet_send(struct telnet_state *s, char *text, u16_t len)
+{
+  if(s->text != NULL) {
+    return 1;
+  }
+  s->text = text;
+  s->textlen = len;  
+  s->sentlen = 0;
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+telnet_close(struct telnet_state *s)
+{
+  s->flags = FLAG_CLOSE;
+  if(s->text != NULL) {
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+telnet_abort(struct telnet_state *s)
+{
+  s->flags = FLAG_ABORT;
+  if(s->text != NULL) {
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(struct telnet_state *s)    
+{
+  s->textlen -= s->sentlen;
+  if(s->textlen == 0) {
+    s->text = NULL;
+    telnet_sent(s);
+  } else {
+    s->text += s->sentlen;
+  }
+  s->sentlen = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(struct telnet_state *s)    
+{
+  if(s->text == NULL) {
+    uip_send(s->text, 0);
+    return;
+  }
+  if(s->textlen > uip_mss()) {
+    s->sentlen = uip_mss();
+  } else {
+    s->sentlen = s->textlen;
+  }
+  uip_send(s->text, s->sentlen);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnet_app(void *ts)
+{
+  struct telnet_state *s = (struct telnet_state *)ts;
+    
+  if(uip_connected()) {
+    s->flags = 0;
+    telnet_connected(s);
+    senddata(s);
+    return;
+  }
+  
+  if(uip_closed()) {
+    telnet_closed(s);
+  }
+  
+  if(uip_aborted()) {
+    telnet_aborted(s);
+  }
+  if(uip_timedout()) {
+    telnet_timedout(s);
+  }
+
+
+  if(s->flags & FLAG_CLOSE) {
+    uip_close();
+    return;
+  }
+  if(s->flags & FLAG_ABORT) {
+    uip_abort();
+    return;
+  }
+  if(uip_acked()) {
+    acked(s);
+  }
+  if(uip_newdata()) {
+    telnet_newdata(s, (char *)uip_appdata, uip_datalen());
+  }
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata(s);
+  } else if(uip_poll()) {    
+    senddata(s);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/telnet.h b/contiki/apps/telnet.h
new file mode 100644
index 0000000..57bf23a
--- /dev/null
+++ b/contiki/apps/telnet.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: telnet.h,v 1.4 2004/07/04 17:50:39 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNET_H__
+#define __TELNET_H__
+
+#include "uipopt.h"
+
+struct telnet_state {
+  unsigned char flags;
+  char *text;
+  u16_t textlen;
+  u16_t sentlen;
+};
+
+/*DISPATCHER_UIPCALL(telnet_app, s);*/
+void telnet_app(void *s);
+unsigned char telnet_send(struct telnet_state *s, char *text, u16_t len);
+unsigned char telnet_close(struct telnet_state *s);
+unsigned char telnet_abort(struct telnet_state *s);
+
+/* Callbacks, implemented by the caller. */
+void telnet_connected(struct telnet_state *s);
+void telnet_closed(struct telnet_state *s);
+void telnet_sent(struct telnet_state *s);
+void telnet_aborted(struct telnet_state *s);
+void telnet_timedout(struct telnet_state *s);
+void telnet_newdata(struct telnet_state *s, char *data, u16_t len);
+#endif /* __TELNET_H__ */
diff --git a/contiki/apps/telnetd-dsc.c b/contiki/apps/telnetd-dsc.c
new file mode 100644
index 0000000..9e02a57
--- /dev/null
+++ b/contiki/apps/telnetd-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: telnetd-dsc.c,v 1.5 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon telnetd_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(telnetd_dsc,
+    "Telnet shell server",
+    "telnetd.prg",
+    telnetd_init,
+    &telnetd_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char telnetdicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char telnetdicon_textmap[9] = {
+  't', 'e', 'l',
+  'n', 'e', 't',
+  's', 'r', 'v'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon telnetd_icon =
+  {CTK_ICON("Telnet server", telnetdicon_bitmap, telnetdicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/telnetd-dsc.h b/contiki/apps/telnetd-dsc.h
new file mode 100644
index 0000000..36cf3c5
--- /dev/null
+++ b/contiki/apps/telnetd-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: telnetd-dsc.h,v 1.1 2003/08/21 22:24:19 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNETD_DSC_H__
+#define __TELNETD_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(telnetd_dsc);
+
+#endif /* __TELNETD_DSC_H__ */
diff --git a/contiki/apps/telnetd-gui.c b/contiki/apps/telnetd-gui.c
new file mode 100644
index 0000000..3384855
--- /dev/null
+++ b/contiki/apps/telnetd-gui.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: telnetd-gui.c,v 1.5 2005/04/28 21:16:37 oliverschmidt Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "uip.h"
+#include "petsciiconv.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "telnetd.h"
+#include "memb.h"
+
+#include "shell.h"
+
+#include "telnetd.h"
+
+#include <string.h>
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+
+#define XSIZE 36
+#define YSIZE 12
+
+static struct ctk_window window;
+static char log[XSIZE * YSIZE];
+static struct ctk_label loglabel =
+  {CTK_LABEL(0, 0, XSIZE, YSIZE, log)};
+
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_gui_output(char *str1, char *str2)
+{
+  static unsigned int len, i;
+  
+  for(i = 1; i < YSIZE; ++i) {
+    memcpy(&log[(i - 1) * XSIZE], &log[i * XSIZE], XSIZE);
+  }
+  memset(&log[(YSIZE - 1) * XSIZE], 0, XSIZE);
+
+  len = strlen(str1);
+
+  strncpy(&log[(YSIZE - 1) * XSIZE], str1, XSIZE);
+  if(len < XSIZE) {
+    strncpy(&log[(YSIZE - 1) * XSIZE] + len, str2, XSIZE - len);
+  }
+  
+  CTK_WIDGET_REDRAW(&loglabel);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_gui_quit(void)
+{
+  ctk_window_close(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_gui_init(void)
+{
+  ctk_window_new(&window, XSIZE, YSIZE, "Shell server");
+  CTK_WIDGET_ADD(&window, &loglabel);
+  memset(log, 0, sizeof(log));
+  ctk_window_open(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_gui_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  if(ev == ctk_signal_window_close) {
+    telnetd_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/telnetd.c b/contiki/apps/telnetd.c
new file mode 100644
index 0000000..ddcf77d
--- /dev/null
+++ b/contiki/apps/telnetd.c
@@ -0,0 +1,407 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: telnetd.c,v 1.10 2004/09/12 07:25:26 adamdunkels Exp $
+ *
+ */
+
+#include "loader.h"
+#include "uip.h"
+#include "petsciiconv.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "memb.h"
+
+#include "shell.h"
+
+#include "telnetd.h"
+
+#include "telnetd-conf.h"
+
+#include <string.h>
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+
+#define XSIZE 36
+#define YSIZE 12
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Shell server", shell_idle, sighandler,
+		   telnetd_appcall)};
+		   static ek_id_t id = EK_ID_NONE;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "Shell server", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+MEMB(linemem, TELNETD_CONF_LINELEN, TELNETD_CONF_NUMLINES);
+
+
+struct telnetd_state {
+  char *lines[TELNETD_CONF_NUMLINES];
+  char buf[TELNETD_CONF_LINELEN];
+  char bufptr;
+  u8_t numsent;
+  u8_t state;
+#define STATE_NORMAL 0
+#define STATE_IAC    1
+#define STATE_WILL   2
+#define STATE_WONT   3
+#define STATE_DO     4  
+#define STATE_DONT   5
+  
+#define STATE_CLOSE  6
+};
+static struct telnetd_state s;
+
+#define TELNET_IAC   255
+#define TELNET_WILL  251
+#define TELNET_WONT  252
+#define TELNET_DO    253
+#define TELNET_DONT  254
+/*-----------------------------------------------------------------------------------*/
+static char *
+alloc_line(void)
+{  
+  return memb_alloc(&linemem);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+dealloc_line(char *line)
+{
+  memb_free(&linemem, line);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_quit(char *str)
+{
+  s.state = STATE_CLOSE;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_quit(void)
+{
+#if TELNETD_CONF_GUI
+  telnetd_gui_quit();
+#endif /* TELNETD_CONF_GUI */
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+sendline(char *line)
+{
+  static unsigned int i;
+  
+  for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+    if(s.lines[i] == NULL) {
+      s.lines[i] = line;
+      break;
+    }
+  }
+  if(i == TELNETD_CONF_NUMLINES) {
+    dealloc_line(line);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_prompt(char *str)
+{
+  char *line;
+  line = alloc_line();
+  if(line != NULL) {
+    strncpy(line, str, TELNETD_CONF_LINELEN);
+    petsciiconv_toascii(line, TELNETD_CONF_LINELEN);
+    sendline(line);
+  }         
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_output(char *str1, char *str2)
+{
+  static unsigned len;
+  char *line;
+
+  line = alloc_line();
+  if(line != NULL) {
+    len = strlen(str1);
+    strncpy(line, str1, TELNETD_CONF_LINELEN);
+    if(len < TELNETD_CONF_LINELEN) {
+      strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
+    }
+    len = strlen(line);
+    if(len < TELNETD_CONF_LINELEN - 2) {
+      line[len] = ISO_cr;
+      line[len+1] = ISO_nl;
+      line[len+2] = 0;
+    }
+    petsciiconv_toascii(line, TELNETD_CONF_LINELEN);
+    sendline(line);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(telnetd_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {    
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    tcp_listen(HTONS(23));
+    memb_init(&linemem);
+    shell_init();
+  } else if(ev == tcpip_event) {
+    telnetd_appcall(data);
+  } else if(ev == EK_EVENT_REQUEST_EXIT) {
+    telnetd_quit();
+  } else {
+#if TELNETD_CONF_GUI    
+    telnetd_gui_eventhandler(ev, data);
+#endif /* TELNETD_CONF_GUI */
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)     
+{
+  static unsigned int i;
+  
+  while(s.numsent > 0) {
+    dealloc_line(s.lines[0]);
+    for(i = 1; i < TELNETD_CONF_NUMLINES; ++i) {
+      s.lines[i - 1] = s.lines[i];    
+    }
+    s.lines[TELNETD_CONF_NUMLINES - 1] = NULL;
+    --s.numsent;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)    
+{
+  static char *bufptr, *lineptr;
+  static int buflen, linelen;
+  
+  bufptr = uip_appdata;
+  buflen = 0;
+  for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
+	s.lines[s.numsent] != NULL ; ++s.numsent) {    
+    lineptr = s.lines[s.numsent];
+    linelen = strlen(lineptr);
+    if(linelen > TELNETD_CONF_LINELEN) {
+      linelen = TELNETD_CONF_LINELEN;
+    }
+    if(buflen + linelen < uip_mss()) {
+      memcpy(bufptr, lineptr, linelen);
+      bufptr += linelen;
+      buflen += linelen;
+    } else {
+      break;
+    }
+  }
+  uip_send(uip_appdata, buflen);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+closed(void)
+{
+  static unsigned int i;
+  
+  for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+    if(s.lines[i] != NULL) {
+      dealloc_line(s.lines[i]);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+getchar(u8_t c)
+{
+  if(c == ISO_cr) {
+    return;
+  }
+  
+  s.buf[(int)s.bufptr] = c;  
+  if(s.buf[(int)s.bufptr] == ISO_nl ||
+     s.bufptr == sizeof(s.buf) - 1) {    
+    if(s.bufptr > 0) {
+      s.buf[(int)s.bufptr] = 0;
+      petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);
+    }
+    shell_input(s.buf);
+    s.bufptr = 0;
+  } else {
+    ++s.bufptr;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+sendopt(u8_t option, u8_t value)
+{
+  char *line;
+  line = alloc_line();
+  if(line != NULL) {
+    line[0] = TELNET_IAC;
+    line[1] = option;
+    line[2] = value;
+    line[3] = 0;
+    sendline(line);
+  }       
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  u16_t len;
+  u8_t c;
+    
+  
+  len = uip_datalen();
+  
+  while(len > 0 && s.bufptr < sizeof(s.buf)) {
+    c = *uip_appdata;
+    ++uip_appdata;
+    --len;
+    switch(s.state) {
+    case STATE_IAC:
+      if(c == TELNET_IAC) {
+	getchar(c);
+	s.state = STATE_NORMAL;
+      } else {
+	switch(c) {
+	case TELNET_WILL:
+	  s.state = STATE_WILL;
+	  break;
+	case TELNET_WONT:
+	  s.state = STATE_WONT;
+	  break;
+	case TELNET_DO:
+	  s.state = STATE_DO;
+	  break;
+	case TELNET_DONT:
+	  s.state = STATE_DONT;
+	  break;
+	default:
+	  s.state = STATE_NORMAL;
+	  break;
+	}
+      }
+      break;
+    case STATE_WILL:
+      /* Reply with a DONT */
+      sendopt(TELNET_DONT, c);
+      s.state = STATE_NORMAL;
+      break;
+      
+    case STATE_WONT:
+      /* Reply with a DONT */
+      sendopt(TELNET_DONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_DO:
+      /* Reply with a WONT */
+      sendopt(TELNET_WONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_DONT:
+      /* Reply with a WONT */
+      sendopt(TELNET_WONT, c);
+      s.state = STATE_NORMAL;
+      break;
+    case STATE_NORMAL:
+      if(c == TELNET_IAC) {
+	s.state = STATE_IAC;
+      } else {
+	getchar(c);
+      }      
+      break;
+    } 
+
+    
+  }  
+  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+telnetd_appcall(void *ts)
+{
+  static unsigned int i;
+  if(uip_connected()) {
+    tcp_markconn(uip_conn, &s);
+    for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
+      s.lines[i] = NULL;
+    }
+    s.bufptr = 0;
+    s.state = STATE_NORMAL;
+
+    shell_start();
+  }
+
+  if(s.state == STATE_CLOSE) {
+    s.state = STATE_NORMAL;
+    uip_close();
+    return;
+  }
+  
+  if(uip_closed() ||
+     uip_aborted() ||
+     uip_timedout()) {
+    closed();
+  }  
+  
+  if(uip_acked()) {
+    acked();
+  }
+  
+  if(uip_newdata()) {
+    newdata();
+  }
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked() ||
+     uip_connected() ||
+     uip_poll()) {
+    senddata();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/telnetd.h b/contiki/apps/telnetd.h
new file mode 100644
index 0000000..38c92f4
--- /dev/null
+++ b/contiki/apps/telnetd.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: telnetd.h,v 1.2 2004/07/04 11:35:08 adamdunkels Exp $
+ *
+ */
+#ifndef __TELNETD_H__
+#define __TELNETD_H__
+
+#include "contiki.h"
+
+LOADER_INIT_FUNC(telnetd_init, arg);
+/*DISPATCHER_UIPCALL(telnetd_appcall, s);
+  DISPATCHER_SIGHANDLER(telnetd_gui_sighandler, s, data);*/
+void telnetd_gui_eventhandler(ek_event_t ev, ek_data_t data);
+void telnetd_appcall(void *data);
+void telnetd_gui_output(char *str1, char *str2);
+void telnetd_gui_quit(void);
+void telnetd_quit(void);
+
+#endif /* __TELNETD_H__ */
diff --git a/contiki/apps/vnc-draw.h b/contiki/apps/vnc-draw.h
new file mode 100644
index 0000000..724db43
--- /dev/null
+++ b/contiki/apps/vnc-draw.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client.
+ *
+ * $Id: vnc-draw.h,v 1.2 2004/06/06 06:03:03 adamdunkels Exp $
+ *
+ */
+
+#ifndef __VNC_DRAW_H__
+#define __VNC_DRAW_H__
+
+#include "uip_arch.h"
+
+/* Pointer to the bitmap area in memory. */
+extern u8_t vnc_draw_bitmap[];
+
+/* Initialize the vnc-draw module. */
+void vnc_draw_init(void);
+
+/* Draw one line of pixels starting at point (x, y). The pixel data is
+   given by the "data" argument and the length of data is given by the
+   "datalen" argument. The data format is one pixel per byte in bgr233
+   format (bbgggrrr). */
+void vnc_draw_pixelline(u16_t x, u16_t y,
+			u8_t *data, u16_t datalen);
+
+/* The following functions should return the x and y coordinates and
+   the width and height of the viewport. */
+u16_t vnc_draw_viewport_x(void);
+u16_t vnc_draw_viewport_y(void);
+u16_t vnc_draw_viewport_w(void);
+u16_t vnc_draw_viewport_h(void);
+
+#endif /* __VNC_DRAW_H__ */
diff --git a/contiki/apps/vnc-dsc.c b/contiki/apps/vnc-dsc.c
new file mode 100644
index 0000000..ad88987
--- /dev/null
+++ b/contiki/apps/vnc-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: vnc-dsc.c,v 1.6 2005/04/19 22:00:54 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon vnc_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(vnc_dsc,
+    "Remote control your PC using Contiki",
+    "vnc.prg",
+    vnc_init,
+    &vnc_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char vncicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char vncicon_textmap[9] = {
+  'V', 'N', 'C',
+  'c', 'l', 'i',
+  'e', 'n', 't'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon vnc_icon =
+  {CTK_ICON("VNC viewer", vncicon_bitmap, vncicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/vnc-dsc.h b/contiki/apps/vnc-dsc.h
new file mode 100644
index 0000000..f9f5241
--- /dev/null
+++ b/contiki/apps/vnc-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: vnc-dsc.h,v 1.1 2003/07/31 23:48:29 adamdunkels Exp $
+ *
+ */
+#ifndef __VNC_DSC_H__
+#define __VNC_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(vnc_dsc);
+
+#endif /* __VNC_DSC_H__ */
diff --git a/contiki/apps/vnc-viewer.c b/contiki/apps/vnc-viewer.c
new file mode 100644
index 0000000..8deb6bb
--- /dev/null
+++ b/contiki/apps/vnc-viewer.c
@@ -0,0 +1,755 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: vnc-viewer.c,v 1.9 2004/09/12 07:32:05 adamdunkels Exp $
+ *
+ */
+
+/* A micro implementation of a VNC client. VNC is a protocol for
+   remote network displays. See http://www.uk.research.att.com/vnc/
+   for information about VNC.
+*/
+
+#include "vnc-draw.h"
+#include "uip.h"
+#include "vnc-viewer.h"
+
+#include <string.h> /* XXX for memcpy */
+#include <stdio.h>  /* XXX for printf */
+
+/* RFB server initial handshaking string. */
+#define RFB_SERVER_VERSION_STRING rfb_server_version_string
+
+/* "RFB 003.003" */
+static u8_t rfb_server_version_string[12] =
+  {82,70,66,32,48,48,51,46,48,48,51,10};
+
+#if 0
+#define PRINTF(x)
+#else
+#define PRINTF(x) printf x
+#endif
+
+#ifndef NULL
+#define NULL (void *)0
+#endif
+
+static struct vnc_viewer_state vnc_viewer_state;
+#define vs (&vnc_viewer_state)
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_close(void)
+{
+  vs->close = 1;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_connect(u16_t *server, u8_t display)
+{
+  struct uip_conn *conn;
+
+  vnc_draw_init();
+
+  memset(vs, 0, sizeof(struct vnc_viewer_state));
+  conn = uip_connect(server, htons(5900 + display));
+  if(conn == NULL) {
+    return;
+  }
+  tcp_markconn(conn, NULL);
+
+  vs->close = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)
+{
+  register u8_t *dataptr;
+  u16_t dataleft;
+
+  dataptr = (u8_t *)uip_appdata;
+    
+  switch(vs->sendmsg) {
+  case VNC_SEND_VERSION:
+    PRINTF(("Sending VERSION_STRING\n"));
+    uip_send(RFB_SERVER_VERSION_STRING, sizeof(RFB_SERVER_VERSION_STRING));
+    break;
+  case VNC_SEND_AUTH:
+    /* Send 16 bytes of encrypted challange response. */
+    /* XXX: not implemented. */
+    PRINTF(("Sending AUTH\n"));
+    uip_send(uip_appdata, 16);
+    break;
+  case VNC_SEND_CINIT:
+    PRINTF(("Sending CINIT\n"));
+    /* Send one byte of client init. */
+    *(u8_t *)dataptr = 1;
+    uip_send(uip_appdata, 1);
+    break;
+  case VNC_SEND_PFMT:
+    PRINTF(("Sending PFMT\n"));
+    ((struct rfb_set_pixel_format *)dataptr)->type = RFB_SET_PIXEL_FORMAT;
+
+    /* Set to BGR233 pixel format. */
+    ((struct rfb_set_pixel_format *)dataptr)->format.bps = 8;
+    ((struct rfb_set_pixel_format *)dataptr)->format.depth = 8;
+    ((struct rfb_set_pixel_format *)dataptr)->format.endian = 1;
+    ((struct rfb_set_pixel_format *)dataptr)->format.truecolor = 1;
+    ((struct rfb_set_pixel_format *)dataptr)->format.red_max = htons(7);
+    ((struct rfb_set_pixel_format *)dataptr)->format.green_max = htons(7);
+    ((struct rfb_set_pixel_format *)dataptr)->format.blue_max = htons(3);
+    ((struct rfb_set_pixel_format *)dataptr)->format.red_shift = 0;
+    ((struct rfb_set_pixel_format *)dataptr)->format.green_shift = 3;
+    ((struct rfb_set_pixel_format *)dataptr)->format.blue_shift = 6;
+
+    uip_send(uip_appdata, sizeof(struct rfb_set_pixel_format));
+    
+    break;
+  case VNC_SEND_ENCODINGS:
+    PRINTF(("Sending ENCODINGS\n"));
+    ((struct rfb_set_encodings *)dataptr)->type = RFB_SET_ENCODINGS;
+    ((struct rfb_set_encodings *)dataptr)->encodings = htons(1);
+    dataptr += sizeof(struct rfb_set_encodings);
+    dataptr[0] = dataptr[1] = dataptr[2] = 0;
+    dataptr[3] = RFB_ENC_RAW;
+    /*    ((u8_t *)dataptr + sizeof(struct rfb_set_encodings))[4] =
+      ((u8_t *)dataptr + sizeof(struct rfb_set_encodings))[5] =
+      ((u8_t *)dataptr + sizeof(struct rfb_set_encodings))[6] = 0;
+      ((u8_t *)dataptr + sizeof(struct rfb_set_encodings))[7] = RFB_ENC_RRE;*/
+    uip_send(uip_appdata, sizeof(struct rfb_set_encodings) + 4);
+    break;
+  case VNC_SEND_UPDATERQ:
+    ((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
+    ((struct rfb_fb_update_request *)dataptr)->incremental = 0;
+    ((struct rfb_fb_update_request *)dataptr)->x = htons(vnc_draw_viewport_x());
+    ((struct rfb_fb_update_request *)dataptr)->y = htons(vnc_draw_viewport_y());
+    ((struct rfb_fb_update_request *)dataptr)->w = htons(vnc_draw_viewport_w());
+    ((struct rfb_fb_update_request *)dataptr)->h = htons(vnc_draw_viewport_h());
+    uip_send(uip_appdata, sizeof(struct rfb_fb_update_request));    
+    break;
+  case VNC_SEND_UPDATERQ_INC:
+    ((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
+    ((struct rfb_fb_update_request *)dataptr)->incremental = 1;
+    ((struct rfb_fb_update_request *)dataptr)->x = htons(vnc_draw_viewport_x());
+    ((struct rfb_fb_update_request *)dataptr)->y = htons(vnc_draw_viewport_y());
+    ((struct rfb_fb_update_request *)dataptr)->w = htons(vnc_draw_viewport_w());
+    ((struct rfb_fb_update_request *)dataptr)->h = htons(vnc_draw_viewport_h());
+    uip_send(uip_appdata, sizeof(struct rfb_fb_update_request));    
+    break;
+
+  case VNC_SEND_EVENTS:
+
+    dataleft = uip_mss();
+
+    vs->eventptr_unacked = vs->eventptr_acked;
+    while(vs->eventptr_unacked != vs->eventptr_next &&
+	  dataleft > sizeof(struct rfb_key_event)) {
+      switch(vs->event_queue[vs->eventptr_unacked].type) {
+      case VNC_POINTER_EVENT:
+	((struct rfb_pointer_event *)dataptr)->type = RFB_POINTER_EVENT;
+	((struct rfb_pointer_event *)dataptr)->buttonmask =
+	  vs->event_queue[vs->eventptr_unacked].ev.ptr.buttonmask;
+	((struct rfb_pointer_event *)dataptr)->x =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.x);
+	((struct rfb_pointer_event *)dataptr)->y =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.y);
+	/*	uip_send(uip_appdata, sizeof(struct rfb_pointer_event));*/
+	dataptr += sizeof(struct rfb_pointer_event);
+	dataleft -= sizeof(struct rfb_pointer_event);
+      break;
+      case VNC_KEY_EVENT:
+	PRINTF(("Send key event.\n"));
+	((struct rfb_key_event *)dataptr)->type = RFB_KEY_EVENT;
+	((struct rfb_key_event *)dataptr)->down =
+	  vs->event_queue[vs->eventptr_unacked].ev.key.down;
+	((struct rfb_key_event *)dataptr)->key[0] =
+	  ((struct rfb_key_event *)dataptr)->key[1];
+	((struct rfb_key_event *)dataptr)->key[2] =
+	  vs->event_queue[vs->eventptr_unacked].ev.key.key >> 8;
+	
+	((struct rfb_key_event *)dataptr)->key[3] =
+	  vs->event_queue[vs->eventptr_unacked].ev.key.key & 0xff;
+	/*	uip_send(uip_appdata, sizeof(struct rfb_key_event));*/
+	dataptr += sizeof(struct rfb_key_event);
+	dataleft -= sizeof(struct rfb_key_event);
+	break;
+      case VNC_UPDATERQ_EVENT:
+	((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
+	((struct rfb_fb_update_request *)dataptr)->incremental = 0;
+	((struct rfb_fb_update_request *)dataptr)->x =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.urq.x);
+	((struct rfb_fb_update_request *)dataptr)->y =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.urq.y);
+	((struct rfb_fb_update_request *)dataptr)->w =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.urq.w);
+	((struct rfb_fb_update_request *)dataptr)->h =
+	  htons(vs->event_queue[vs->eventptr_unacked].ev.urq.h);
+	/*	uip_send(uip_appdata, sizeof(struct rfb_fb_update_request));    */
+	dataptr += sizeof(struct rfb_fb_update_request);
+	dataleft -= sizeof(struct rfb_fb_update_request);
+	break;
+      }
+      vs->eventptr_unacked = (vs->eventptr_unacked + 1) % VNC_EVENTQUEUE_SIZE;
+    }
+
+    uip_send(uip_appdata, uip_mss() - dataleft);
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+buffer_data(u8_t *data, u16_t datalen)
+{
+  PRINTF(("Buffering %d bytes of data\n", datalen));
+
+  if(vs->buffersize + datalen > VNC_BUFFERSIZE) {
+    PRINTF(("Out of buffer space!\n"));
+    vs->buffersize = 0;
+    return;
+  }
+  
+  memcpy(&(vs->buffer[vs->buffersize]), data, datalen);
+
+  vs->buffersize += datalen;
+  vs->bufferleft -= datalen;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+clearbuffer(void)
+{
+  PRINTF(("Clearing buffer\n"));
+  vs->buffersize = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/* Returns: the amount of bytes actually read. */
+static u16_t
+recv_rectstate(u8_t *dataptr, u16_t datalen)
+{
+  u16_t pixels;
+  u16_t pixelsleft;
+  
+  switch(vs->rectstate) {
+  case VNC_RECTSTATE_RAW:
+    
+    if(vs->rectstateleft > datalen) {
+      pixels = datalen;
+      vs->rectstateleft -= datalen;
+    } else {
+      pixels = vs->rectstateleft;
+      datalen = datalen - vs->rectstateleft;
+      vs->rectstateleft = 0;
+      vs->rectstate = VNC_RECTSTATE_NONE;
+      vs->sendmsg = VNC_SEND_NONE;
+      vs->waitmsg = VNC_WAIT_NONE;
+      vnc_viewer_refresh();
+    }
+
+
+    pixelsleft = pixels;
+    while(pixelsleft > 0) {
+      if(pixelsleft >= vs->rectstatex2 - vs->rectstatex) {
+	vnc_draw_pixelline(vs->rectstatex, vs->rectstatey,
+			   dataptr,
+			   vs->rectstatex2 - vs->rectstatex);
+	dataptr += vs->rectstatex2 - vs->rectstatex;
+	pixelsleft -= vs->rectstatex2 - vs->rectstatex;
+	vs->rectstatex = vs->rectstatex0;
+	++vs->rectstatey;
+	vnc_viewer_refresh();
+      } else {
+	vnc_draw_pixelline(vs->rectstatex, vs->rectstatey,
+			   dataptr,
+			   pixelsleft);
+	vs->rectstatex += pixelsleft;
+	pixelsleft = 0;
+      }
+      
+    }
+        
+    break;
+  case VNC_RECTSTATE_RRE:
+    break;
+  }
+  return pixels;
+}
+/*-----------------------------------------------------------------------------------*/
+/* Returns: the amount of bytes that needs to be buffered before the
+   rect can be drawn. */ 
+static unsigned short
+recv_update_rect(register struct rfb_fb_update_rect_hdr *rhdr,
+		 u16_t dataleft)
+{
+  struct rfb_rre_hdr *rrehdr;			       
+
+
+  if((rhdr->encoding[0] |
+      rhdr->encoding[1] |
+      rhdr->encoding[2]) == 0) {
+    switch(rhdr->encoding[3]) {
+    case RFB_ENC_RAW:
+      vs->rectstateleft = (u32_t)htons(rhdr->rect.w) * (u32_t)htons(rhdr->rect.h);
+      vs->rectstate = VNC_RECTSTATE_RAW;
+      vs->rectstatex0 = vs->rectstatex = htons(rhdr->rect.x);
+      vs->rectstatey0 = vs->rectstatey = htons(rhdr->rect.y);
+      vs->rectstatew = htons(rhdr->rect.w);
+      vs->rectstateh = htons(rhdr->rect.h);
+      vs->rectstatex2 = vs->rectstatex0 + vs->rectstatew;
+      vs->rectstatey2 = vs->rectstatey0 + vs->rectstateh;
+      break;
+
+    case RFB_ENC_RRE:
+      rrehdr = (struct rfb_rre_hdr *)((u8_t *)rhdr +
+				      sizeof(struct rfb_fb_update_rect_hdr));
+      PRINTF(("Received RRE subrects %d (%d)\n",
+	     (htons(rrehdr->subrects[1]) << 16) +
+	     htons(rrehdr->subrects[0]),
+	     rrehdr->bgpixel));
+      vs->rectstateleft = ((u32_t)(htons(rrehdr->subrects[1]) << 16) + 
+			(u32_t)htons(rrehdr->subrects[0]));
+      vs->rectstate = VNC_RECTSTATE_RRE;
+
+      break;
+
+    default:
+      PRINTF(("Bad encoding %02x%02x%02x%02x\n", rhdr->encoding[0],
+	      rhdr->encoding[1],rhdr->encoding[2],rhdr->encoding[3]));
+      break;
+    }
+
+  }
+
+  return 0;
+	
+  PRINTF(("recv_update_rect: returning%d\n", vs->rectstateleft));
+  return sizeof(struct rfb_fb_update_rect_hdr) + vs->rectstateleft;
+}
+/*-----------------------------------------------------------------------------------*/
+/* identify_data():
+ *
+ * This function looks at the state of the connection (i.e., if it is
+ * handshaking or in steady-state) as well as on the contents of the
+ * incoming message and returns the number of bytes of data that is to
+ * be expected.
+ */ 
+static u16_t
+identify_data(register u8_t *data, u16_t datalen)
+{
+  switch(vs->waitmsg) {
+  case VNC_WAIT_VERSION:
+    /* Expecting version string (12 bytes). */
+    return 12;
+    break;
+  case VNC_WAIT_AUTH:
+    return 4;
+    break;
+  case VNC_WAIT_AUTH_RESPONSE:
+    return 1;
+    break;
+  case VNC_WAIT_SINIT:
+    /* XXX: We should check that the entire message header is
+       received, otherwise we should buffer it. */
+    return sizeof(struct rfb_server_init) +
+      ((struct rfb_server_init *)uip_appdata)->namelength[3] +
+      ((struct rfb_server_init *)uip_appdata)->namelength[2]; 
+    
+  case VNC_WAIT_UPDATE:
+  case VNC_WAIT_NONE:
+    switch(*data) {
+    case RFB_FB_UPDATE:
+      PRINTF(("RFB FB UPDATE received\n"));
+      return sizeof(struct rfb_fb_update);
+      
+    case RFB_BELL:
+      return 1;
+
+    case RFB_SERVER_CUT_TEXT:
+      PRINTF(("Cut text received, unhandled\n"));      
+      return 8 + (data[6] << 8) + data[7];
+
+    case RFB_SET_COLORMAP_ENTRIES:
+      uip_abort();
+      PRINTF(("Set colormap entries received, unhandled\n"));
+      return 0;
+      
+    default:
+      uip_abort();
+      PRINTF(("Weird message type received (%d)\n", *(u8_t *)uip_appdata));
+      return 0;
+    }
+    break;
+    
+  case VNC_WAIT_UPDATE_RECT:   
+    return sizeof(struct rfb_fb_update_rect_hdr);
+
+  default:
+    PRINTF(("identify: bad waitmsg %d\n", vs->waitmsg));
+  }
+  
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/* handle_data():
+ *
+ * Handles the data.
+ */
+static unsigned short
+handle_data(register u8_t *data, u16_t datalen)
+{
+  
+  switch(vs->waitmsg) {
+  case VNC_WAIT_VERSION:
+    /* Make sure we get the right version string from the server. */
+    /* XXX: not implemented. */
+    PRINTF(("Got version, waiting for auth, sending version\n"));
+    vs->waitmsg = VNC_WAIT_AUTH;
+    vs->sendmsg = VNC_SEND_VERSION;
+    break;
+  case VNC_WAIT_AUTH:
+    switch(data[3]) {
+    case RFB_AUTH_FAILED:
+      PRINTF(("Connection failed.\n"));
+      uip_abort();
+      return 0;
+      
+    case RFB_AUTH_NONE:
+      vs->sendmsg = VNC_SEND_CINIT;
+      vs->waitmsg = VNC_WAIT_SINIT;
+      PRINTF(("No authentication needed.\n"));
+      break;
+    case RFB_AUTH_VNC:
+      vs->sendmsg = VNC_SEND_AUTH;
+      vs->waitmsg = VNC_WAIT_AUTH_RESPONSE;
+      PRINTF(("VNC authentication needed.\n"));
+      break;
+    }
+    break;
+  case VNC_WAIT_SINIT:
+    /*    PRINTF(("Server init: w %d h %d, bps %d, d %d, name '%s'\n",
+	   htons(((struct rfb_server_init *)data)->width),
+	   htons(((struct rfb_server_init *)data)->height),
+	   ((struct rfb_server_init *)data)->format.bps,
+	   ((struct rfb_server_init *)data)->format.depth,
+	   ((u8_t *)data + sizeof(struct rfb_server_init))));*/
+    vs->w = htons(((struct rfb_server_init *)data)->width);
+    vs->h = htons(((struct rfb_server_init *)data)->height);
+    vs->sendmsg = VNC_SEND_PFMT;
+    vs->waitmsg = VNC_WAIT_NONE;
+    break;
+
+  case VNC_WAIT_UPDATE:
+  case VNC_WAIT_NONE:
+    switch(*data) {
+    case RFB_FB_UPDATE:
+      vs->waitmsg = VNC_WAIT_UPDATE_RECT;
+      vs->rectsleft = htons(((struct rfb_fb_update *)data)->rects);
+      PRINTF(("Handling RFB FB UPDATE for %d rects\n", vs->rectsleft));
+      break;
+      
+    case RFB_BELL:
+      PRINTF(("BELL\n"));
+      break;
+
+    case RFB_SERVER_CUT_TEXT:
+      PRINTF(("Cut text received, unhandled\n"));      
+      break;
+
+    case RFB_SET_COLORMAP_ENTRIES:
+      PRINTF(("Set colormap entries received, unhandled\n"));
+      break;
+      
+    default:
+      PRINTF(("Weird message type received (%d)\n", *(u8_t *)data));
+      break;
+    }
+    break;
+    
+  case VNC_WAIT_UPDATE_RECT:
+    PRINTF(("Handling data in WAIT_UPDATE_RECT, %d rects left (%d bytes)\n", vs->rectsleft, datalen));
+    --vs->rectsleft;
+    if(vs->rectsleft > 0) {
+      vs->waitmsg = VNC_WAIT_UPDATE_RECT;
+    } else {
+      vs->waitmsg = VNC_WAIT_NONE;
+      vs->sendmsg = VNC_SEND_NONE;
+      vs->rectstate = VNC_RECTSTATE_NONE;
+    }
+    return recv_update_rect((struct rfb_fb_update_rect_hdr *)data, datalen);
+    break;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/* newdata():
+ *
+ * Called whenever new data arrives.
+ *
+ * First, checks if data needs to be buffered before a previously
+ * identified request can be fulfilled. If so, the incoming data is
+ * buffered and the data handler is called. If no data needs to be
+ * buffered, the code proceeds to identify the incoming request. If
+ * the incoming request can be processed immediately (i.e., all data
+ * is contained in this message) the data handler is invoked. If data
+ * has to be buffered to fulfill the request, this is noted and taken
+ * care of the next time this function is invoked (i.e., for the next
+ * incoming data chunk).
+ */
+static u8_t
+newdata(void)
+{
+  u16_t datalen;
+  u16_t readlen;
+  u8_t *dataptr;
+  
+  datalen = uip_datalen();
+  dataptr = (u8_t *)uip_appdata;
+
+  PRINTF(("newdata: %d bytes\n", datalen));
+  
+  /* If we are in a "rectstate", meaning that the incoming data is
+     part of a rectangle that is being incrementaly drawn on the
+     screen, we handle that first. */
+  if(vs->rectstate != VNC_RECTSTATE_NONE) {
+    readlen = recv_rectstate(dataptr, datalen);
+    PRINTF(("newdata: vs->rectstate %d, datalen %d, readlen %d\n",
+	    vs->rectstate, datalen, readlen));
+    datalen -= readlen;
+    dataptr += readlen;
+  }
+
+  /* Next, check if we are supposed to buffer data from the incoming
+     segment. */
+  while(vs->bufferleft > 0 && datalen > 0) {
+    if(datalen >= vs->bufferleft) {
+      /* There is more data in the incoming chunk than we need to
+	 buffer, so we buffer as much as we can and handle the
+	 buffered data, and repeat the (identify->buffer->handle)
+	 sequence for the data that is left in the incoming chunk. */
+      datalen -= vs->bufferleft;
+      dataptr += vs->bufferleft;
+      buffer_data((u8_t *)uip_appdata, vs->bufferleft);
+      handle_data(vs->buffer, vs->buffersize);
+      clearbuffer();
+    } else { /* datalen < vs->bufferleft */
+      /* We need to buffer more data than was received with this
+         chunk, so we buffer the avaliable data and return. */
+      buffer_data(dataptr, datalen);      
+      return 0;
+    }
+  }
+
+  /* Finally, if there is data left in the segment, we handle it. */
+  while(datalen > 0) {
+
+    if(vs->rectstate != VNC_RECTSTATE_NONE) {
+      readlen = recv_rectstate(dataptr, datalen);
+      PRINTF(("newdata (2): vs->rectstate %d, datalen %d, readlen %d\n",
+	      vs->rectstate, datalen, readlen));
+      datalen -= readlen;
+      dataptr += readlen;
+    } else {
+ 
+      /* We get here if there is data to be identified in the incoming
+	 chunk. */    
+      readlen = identify_data(dataptr, datalen);
+
+      if(readlen == 0) {
+	PRINTF(("Identify returned 0\n"));
+	return 0;
+      }
+
+      PRINTF(("Reading %d bytes more\n", readlen));
+      /* The data has been identified and the amount of data that
+	 needs to be read to be able to process the data is in the
+	 "readlen" variable. If the incoming chunk contains enough
+	 data, we handle it directly, otherwise we buffer the incoming
+	 data and set the state so that we know that there is more
+	 data to be buffered. */
+      if(readlen > datalen) {
+	clearbuffer(); /* Should not be needed, but just in case... */
+	vs->bufferleft = readlen;      
+	buffer_data(dataptr, datalen);
+	return 0;
+      }      
+      if(readlen <= datalen) {
+	PRINTF(("Before handle_data %d\n", readlen));
+	readlen += handle_data(dataptr, readlen);
+	PRINTF(("After handle_data %d\n", readlen));
+	datalen -= readlen;
+	dataptr += readlen;
+      }
+
+    }
+    if(datalen > 0) {
+      PRINTF(("newdata: there is more data left after first iteration... %d\n", datalen));
+    }
+    
+  }
+  
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/* Called when there is nothing else to do - checks for any pending
+   events (mouse movements or keypresses). If no events are found, it
+   makes sure that we send out an incremental update request. */
+static void
+check_events(void)
+{
+  if(vs->sendmsg == VNC_SEND_NONE &&
+     vs->eventptr_next != vs->eventptr_acked &&
+     vs->eventptr_acked == vs->eventptr_unacked) {
+    vs->sendmsg = VNC_SEND_EVENTS;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+request_update(void)
+{
+  if(vs->sendmsg == VNC_SEND_NONE) {
+    vs->sendmsg = VNC_SEND_UPDATERQ_INC;
+    vs->waitmsg = VNC_WAIT_UPDATE;
+    PRINTF(("request_update: requesting\n"));
+  } else {
+    PRINTF(("request_update: not requesting\n"));
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)
+{
+  switch(vs->sendmsg) {
+  case VNC_SEND_PFMT:
+    vs->sendmsg = VNC_SEND_ENCODINGS;    
+    break;
+  case VNC_SEND_ENCODINGS:
+    vs->sendmsg = VNC_SEND_UPDATERQ;
+    vs->waitmsg = VNC_WAIT_UPDATE;
+    clearbuffer();
+    break;
+  case VNC_SEND_EVENTS:
+    vs->eventptr_acked = vs->eventptr_unacked;
+    vs->sendmsg = VNC_SEND_NONE;
+    check_events();
+    break;
+  default:
+    vs->sendmsg = VNC_SEND_NONE;
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_appcall(void * nullptr)
+{
+  if(vs->close == 1) {
+    uip_close();
+    return;
+  }
+  
+  if(uip_connected()) {
+    vs->sendmsg = VNC_SEND_NONE;
+    vs->waitmsg = VNC_WAIT_VERSION;
+    return;
+  }
+  
+  if(uip_acked()) {
+    acked();
+  }
+
+  if(uip_newdata()) {
+    newdata();
+  }
+
+  if(vs->sendmsg == VNC_SEND_NONE &&
+     vs->waitmsg == VNC_WAIT_NONE &&
+     vs->rectstate == VNC_RECTSTATE_NONE) {
+    check_events();
+    request_update();
+  }
+  PRINTF(("vs->sendmsg %d, vs->waitmsg %d, vs->rectstate %d\n",
+	  vs->sendmsg, vs->waitmsg, vs->rectstate));
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata();
+  } else if(uip_poll()) {
+    check_events();
+    senddata();
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_post_event(u8_t type,
+		      u16_t data1, u16_t data2,
+		      u16_t data3, u16_t data4)
+{
+  register struct vnc_event *ev;
+  struct vnc_event *ev0;
+
+  ev0 = &(vs->event_queue[(vs->eventptr_next - 1) % VNC_EVENTQUEUE_SIZE]);
+    
+  ev = &(vs->event_queue[vs->eventptr_next]);
+  switch(type) {
+  case VNC_POINTER_EVENT:
+    if(0 && vs->eventptr_next != vs->eventptr_acked &&
+       ev0->type == VNC_POINTER_EVENT &&
+       data1 == ev0->ev.ptr.buttonmask) {
+      ev0->ev.ptr.x = data2;
+      ev0->ev.ptr.y = data3;
+      return;
+    } else {
+      ev->type = type;
+      ev->ev.ptr.buttonmask = data1;
+      ev->ev.ptr.x = data2;
+      ev->ev.ptr.y = data3;
+    }
+    break;
+  case VNC_KEY_EVENT:
+    PRINTF(("Key event posted\n"));
+    ev->type = type;
+    ev->ev.key.down = data1;
+    ev->ev.key.key = data2;
+    break;
+  case VNC_UPDATERQ_EVENT:
+    PRINTF(("Update request event posted\n"));
+    ev->type = type;
+    ev->ev.urq.x = data1;
+    ev->ev.urq.y = data2;
+    ev->ev.urq.w = data3;
+    ev->ev.urq.h = data4;
+    break;
+  }
+  vs->eventptr_next = (vs->eventptr_next + 1) % VNC_EVENTQUEUE_SIZE;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/vnc-viewer.h b/contiki/apps/vnc-viewer.h
new file mode 100644
index 0000000..e331f76
--- /dev/null
+++ b/contiki/apps/vnc-viewer.h
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client.
+ *
+ * $Id: vnc-viewer.h,v 1.8 2004/09/12 07:33:26 adamdunkels Exp $
+ *
+ */
+
+#ifndef __VNC_VIEWER_H__
+#define __VNC_VIEWER_H__
+
+#include "ek.h"
+
+struct vnc_viewer_state;
+
+typedef unsigned long u32_t;
+
+void vnc_viewer_init(void);
+void vnc_viewer_appcall(void *nullptr);
+
+void vnc_viewer_connect(u16_t *server, u8_t display);
+void vnc_viewer_close(void);
+
+/* Callback: redraws the VNC viewer bitmap area. */
+void vnc_viewer_refresh(void);
+
+#define VNC_POINTER_EVENT RFB_POINTER_EVENT
+#define VNC_KEY_EVENT     RFB_KEY_EVENT
+#define VNC_UPDATERQ_EVENT 7
+
+#define VNC_VIEWER_POST_POINTER_EVENT(x, y, button) \
+        vnc_viewer_post_event(VNC_POINTER_EVENT, button, x, y, 0)
+
+#define VNC_VIEWER_POST_KEY_EVENT(key) \
+        vnc_viewer_post_event(VNC_KEY_EVENT, key, 0, 0, 0)
+
+#define VNC_VIEWER_POST_UPDATERQ_EVENT(x1,y1,x2,y2) \
+        vnc_viewer_post_event(VNC_UPDATERQ_EVENT, x1, y1, x2, y2)
+
+void vnc_viewer_post_event(u8_t event,
+			   u16_t data1, u16_t data2,
+			   u16_t data3, u16_t data4);
+
+/* UIP_APPCALL: the name of the application function. This function
+   must return void and take no arguments (i.e., C type "void
+   appfunc(void)"). */
+#ifndef UIP_APPCALL
+#define UIP_APPCALL     vnc_viewer_app
+#endif 
+
+struct vnc_key_event {
+  u8_t down;
+  u16_t key;  
+};
+
+struct vnc_pointer_event {
+  u8_t buttonmask;
+  u16_t x, y;
+};
+
+struct vnc_updaterq_event {
+  u16_t x, y;
+  u16_t w, h;
+};
+
+struct vnc_event {
+  u8_t type;
+  union {
+    struct vnc_key_event key;
+    struct vnc_pointer_event ptr;
+    struct vnc_updaterq_event urq;
+  } ev;
+};
+
+enum vnc_sendmsg {
+  VNC_SEND_NONE,
+  
+  VNC_SEND_VERSION,
+  VNC_SEND_AUTH,
+  VNC_SEND_CINIT,
+  VNC_SEND_PFMT,
+  VNC_SEND_ENCODINGS,
+  
+  VNC_SEND_UPDATERQ,
+  VNC_SEND_UPDATERQ_INC,
+  VNC_SEND_EVENTS,
+};
+
+enum vnc_waitmsg {
+  VNC_WAIT_NONE,
+  
+  VNC_WAIT_VERSION,
+  VNC_WAIT_AUTH,
+  VNC_WAIT_AUTH_RESPONSE,
+  VNC_WAIT_SINIT,
+  
+  VNC_WAIT_UPDATE,
+  VNC_WAIT_UPDATE_RECT,  
+  
+};
+
+
+enum vnc_rectstate {
+  VNC_RECTSTATE_NONE,
+  VNC_RECTSTATE_RAW,
+  VNC_RECTSTATE_RRE,
+};
+
+struct vnc_viewer_state {
+  u8_t close;
+  u16_t w, h;
+  
+  u8_t sendmsg;
+
+  u8_t waitmsg;
+  
+  u16_t rectsleft;
+  
+  u8_t rectstate;  
+  u32_t rectstateleft;
+  u16_t rectstatex, rectstatey;
+  u16_t rectstateh, rectstatew;
+  u16_t rectstatex0, rectstatey0;
+  u16_t rectstatex2, rectstatey2;
+
+  
+  u16_t eventptr_acked;
+  u16_t eventptr_unacked;
+  u16_t eventptr_next;
+#define VNC_EVENTQUEUE_SIZE 32
+  struct vnc_event event_queue[VNC_EVENTQUEUE_SIZE];
+  
+  
+  u16_t bufferleft;
+  u16_t buffersize;
+#define VNC_BUFFERSIZE 64
+  u8_t buffer[VNC_BUFFERSIZE];
+};
+
+extern struct vnc_viewer_state vnc_viewer_state;
+
+/* Definitions of the RFB (Remote Frame Buffer) protocol
+   structures and constants. */
+
+#include "uipopt.h"
+
+
+/* Generic rectangle - x, y coordinates, width and height. */
+struct rfb_rect {
+  u16_t x;
+  u16_t y;
+  u16_t w;
+  u16_t h;
+};
+
+/* Pixel format definition. */
+struct rfb_pixel_format {
+  u8_t bps;       /* Bits per pixel: 8, 16 or 32. */
+  u8_t depth;     /* Color depth: 8-32 */
+  u8_t endian;    /* 1 - big endian (motorola), 0 - little endian
+		     (x86) */
+  u8_t truecolor; /* 1 - true color is used, 0 - true color is not used. */
+
+  /* The following fields are only used if true color is used. */
+  u16_t red_max, green_max, blue_max;
+  u8_t red_shift, green_shift, blue_shift;
+  u8_t pad1;
+  u16_t pad2;
+};
+
+
+/* RFB authentication constants. */
+
+#define RFB_AUTH_FAILED      0
+#define RFB_AUTH_NONE        1
+#define RFB_AUTH_VNC         2
+
+#define RFB_VNC_AUTH_OK      0
+#define RFB_VNC_AUTH_FAILED  1
+#define RFB_VNC_AUTH_TOOMANY 2
+
+/* RFB message types. */
+
+/* From server to client: */
+#define RFB_FB_UPDATE            0
+#define RFB_SET_COLORMAP_ENTRIES 1
+#define RFB_BELL                 2
+#define RFB_SERVER_CUT_TEXT      3
+
+/* From client to server. */
+#define RFB_SET_PIXEL_FORMAT     0
+#define RFB_FIX_COLORMAP_ENTRIES 1
+#define RFB_SET_ENCODINGS        2
+#define RFB_FB_UPDATE_REQ        3
+#define RFB_KEY_EVENT            4
+#define RFB_POINTER_EVENT        5
+#define RFB_CLIENT_CUT_TEXT      6
+
+/* Encoding types. */
+#define RFB_ENC_RAW      0
+#define RFB_ENC_COPYRECT 1
+#define RFB_ENC_RRE      2
+#define RFB_ENC_CORRE    3
+#define RFB_ENC_HEXTILE  4
+
+/* Message definitions. */
+
+/* Server to client messages. */
+
+struct rfb_server_init {
+  u16_t width;
+  u16_t height;
+  struct rfb_pixel_format format;
+  u8_t namelength[4];
+  /* Followed by name. */
+};
+
+struct rfb_fb_update {
+  u8_t type;
+  u8_t pad;
+  u16_t rects; /* Number of rectanges (struct rfb_fb_update_rect_hdr +
+		  data) that follows. */
+};
+
+struct rfb_fb_update_rect_hdr {
+  struct rfb_rect rect;
+  u8_t encoding[4];
+};
+
+struct rfb_copy_rect {
+  u16_t srcx;
+  u16_t srcy;
+};
+
+struct rfb_rre_hdr {
+  u16_t subrects[2];  /* Number of subrectangles (struct
+			 rfb_rre_subrect) to follow. */
+  u8_t bgpixel;
+};
+
+struct rfb_rre_subrect {
+  u8_t pixel;
+  struct rfb_rect rect;
+};
+
+struct rfb_corre_rect {
+  u8_t x;
+  u8_t y;
+  u8_t w;
+  u8_t h;
+};
+
+/* Client to server messages. */
+
+struct rfb_set_pixel_format {
+  u8_t type;
+  u8_t pad;
+  u16_t pad2;
+  struct rfb_pixel_format format;
+};
+
+struct rfb_fix_colormap_entries {
+  u8_t type;
+  u8_t pad;
+  u16_t firstcolor;
+  u16_t colors;
+};
+
+struct rfb_set_encodings {
+  u8_t type;
+  u8_t pad;
+  u16_t encodings;
+};
+
+struct rfb_fb_update_request {
+  u8_t type;
+  u8_t incremental;
+  u16_t x;
+  u16_t y;
+  u16_t w;
+  u16_t h;
+};
+
+struct rfb_key_event {
+  u8_t type;
+  u8_t down;
+  u16_t pad;
+  u8_t key[4];
+};
+
+#define RFB_BUTTON_MASK1 1
+#define RFB_BUTTON_MASK2 2
+#define RFB_BUTTON_MASK3 4
+struct rfb_pointer_event {
+  u8_t type;
+  u8_t buttonmask;
+  u16_t x;
+  u16_t y;
+};
+
+#endif /* __VNC_VIEWER_H__ */
diff --git a/contiki/apps/vnc.c b/contiki/apps/vnc.c
new file mode 100644
index 0000000..8853d14
--- /dev/null
+++ b/contiki/apps/vnc.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc.c,v 1.10 2004/09/12 07:32:05 adamdunkels Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "contiki.h"
+
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "uip.h"
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "resolv.h"
+#include "telnet.h"
+#include "vnc.h"
+#include "vnc-draw.h"
+#include "vnc-viewer.h"
+#include "vnc-conf.h"
+
+#include "loader.h"
+
+#if 1
+#define PRINTF(x)
+#else
+#include <stdio.h>
+#define PRINTF(x) printf x
+#endif
+
+#define HEIGHT (4 + VNC_CONF_VIEWPORT_HEIGHT/8)
+
+/* Main window */
+static struct ctk_window mainwindow;
+
+static char host[20];
+static struct ctk_textentry hosttextentry =
+  {CTK_TEXTENTRY(0, 0, 18, 1, host, 18)};
+
+static char portentry[4];
+static struct ctk_textentry porttextentry =
+  {CTK_TEXTENTRY(21, 0, 3, 1, portentry, 3)};
+
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(27, 0, 7, "Connect")};
+/*static struct ctk_button disconnectbutton =
+  {CTK_BUTTON(25, 3, 10, "Disconnect")};*/
+
+static struct ctk_separator sep1 =
+  {CTK_SEPARATOR(0, 1, 36)};
+
+static struct ctk_bitmap vncbitmap =
+  {CTK_BITMAP(2, 2,
+	      VNC_CONF_VIEWPORT_WIDTH / 8,
+	      VNC_CONF_VIEWPORT_HEIGHT / 8,
+	      vnc_draw_bitmap,
+	      VNC_CONF_VIEWPORT_WIDTH,
+	      VNC_CONF_VIEWPORT_HEIGHT)};
+
+static struct ctk_button leftbutton =
+  {CTK_BUTTON(6, HEIGHT - 1, 4, "Left")};
+
+static struct ctk_button upbutton =
+  {CTK_BUTTON(13, HEIGHT - 1, 2, "Up")};
+
+static struct ctk_button downbutton =
+  {CTK_BUTTON(18, HEIGHT - 1, 4, "Down")};
+
+static struct ctk_button rightbutton =
+  {CTK_BUTTON(25, HEIGHT - 1, 5, "Right")};
+
+/*static DISPATCHER_SIGHANDLER(vnc_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("VNC client", NULL, vnc_sighandler,
+		   vnc_viewer_app)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "VNC viewer", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(vnc_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show(char *text)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+connect(void)
+{
+  u16_t addr[2], *addrptr;
+  u16_t port;
+  char *cptr;
+
+  /* Find the first space character in host and put a zero there
+     to end the string. */
+  for(cptr = host; *cptr != ' ' && *cptr != 0; ++cptr);
+  *cptr = 0;
+
+  addrptr = &addr[0];  
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
+    addrptr = resolv_lookup(host);
+    if(addrptr == NULL) {
+      resolv_query(host);
+      show("Resolving host...");
+      return;
+    }
+  }
+
+  port = 0;
+  for(cptr = portentry; *cptr != ' ' && *cptr != 0; ++cptr) {
+    if(*cptr < '0' || *cptr > '9') {
+      show("Port number error");
+      return;
+    }
+    port = 10 * port + *cptr - '0';
+  }
+
+
+  vnc_viewer_connect(addrptr, port);
+
+  show("Connecting...");
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  unsigned short x, y;
+  unsigned char xc, yc;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&mainwindow, 36, HEIGHT, "VNC client");
+    ctk_window_move(&mainwindow, 0, 0);
+    
+    CTK_WIDGET_ADD(&mainwindow, &hosttextentry);
+    CTK_WIDGET_FOCUS(&mainwindow, &hosttextentry);
+    CTK_WIDGET_ADD(&mainwindow, &porttextentry);
+    CTK_WIDGET_ADD(&mainwindow, &connectbutton);
+
+    CTK_WIDGET_ADD(&mainwindow, &sep1);
+    
+    CTK_WIDGET_ADD(&mainwindow, &vncbitmap);
+
+    CTK_WIDGET_ADD(&mainwindow, &leftbutton);
+    CTK_WIDGET_ADD(&mainwindow, &upbutton);
+    CTK_WIDGET_ADD(&mainwindow, &downbutton);
+    CTK_WIDGET_ADD(&mainwindow, &rightbutton);
+
+    vnc_draw_init();
+  
+    ctk_window_open(&mainwindow);
+
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&connectbutton) {
+      connect();
+    }
+  } else if(ev == ctk_signal_window_close) {
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  } else if(ev == resolv_event_found) {
+    if(strcmp(data, host) == 0) {
+      if(resolv_lookup(host) != NULL) {
+	connect();
+      } else {
+	show("Host not found");
+      }
+    }
+  } else if(ev == ctk_signal_pointer_move) {
+    /* Check if pointer is within the VNC viewer area */
+    x = ctk_mouse_x();
+    y = ctk_mouse_y();
+
+    xc = ctk_mouse_xtoc(x);
+    yc = ctk_mouse_ytoc(y);
+    
+    if(xc >= 2 && yc >= 2 &&
+       xc < 2 + VNC_CONF_VIEWPORT_WIDTH / 8 &&
+       yc < 2 + VNC_CONF_VIEWPORT_HEIGHT / 8) {
+    
+      VNC_VIEWER_POST_POINTER_EVENT(x, y, 0);
+    }
+       
+  } else if(ev == tcpip_event) {
+    vnc_viewer_appcall(data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_viewer_refresh(void)
+{
+  CTK_WIDGET_REDRAW(&vncbitmap);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/vnc.h b/contiki/apps/vnc.h
new file mode 100644
index 0000000..4f64360
--- /dev/null
+++ b/contiki/apps/vnc.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client.
+ *
+ * $Id: vnc.h,v 1.3 2004/06/06 06:03:03 adamdunkels Exp $
+ *
+ */
+#ifndef __VNC_H__
+#define __VNC_H__
+
+void vnc_init(char *arg);
+
+#endif /* __VNC_H__ */
diff --git a/contiki/apps/webclient.c b/contiki/apps/webclient.c
new file mode 100644
index 0000000..7e09096
--- /dev/null
+++ b/contiki/apps/webclient.c
@@ -0,0 +1,446 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "contiki" web browser.
+ *
+ * $Id: webclient.c,v 1.18 2004/07/04 17:50:39 adamdunkels Exp $
+ *
+ */
+
+#include "ek.h"
+#include "tcpip.h"
+#include "uip.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "uiplib.h"
+
+#include "www-conf.h"
+
+#include <string.h>
+
+#define WEBCLIENT_TIMEOUT 100
+
+#define WEBCLIENT_STATE_STATUSLINE 0
+#define WEBCLIENT_STATE_HEADERS    1
+#define WEBCLIENT_STATE_DATA       2
+#define WEBCLIENT_STATE_CLOSE      3
+
+#define HTTPFLAG_NONE   0
+#define HTTPFLAG_OK     1
+#define HTTPFLAG_MOVED  2
+#define HTTPFLAG_ERROR  3
+
+
+#define ISO_nl       0x0a
+#define ISO_cr       0x0d
+#define ISO_space    0x20
+
+struct webclient_state {
+  u8_t timer;
+  u8_t state;
+  u8_t httpflag;
+
+  u16_t port;
+  char host[40];
+  char file[WWW_CONF_MAX_URLLEN];  
+  u16_t getrequestptr;
+  u16_t getrequestleft;
+  
+  char httpheaderline[200];
+  u16_t httpheaderlineptr;
+
+  char mimetype[32];
+};
+
+static struct webclient_state s;
+
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_mimetype(void)
+{
+  return s.mimetype;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_filename(void)
+{
+  return s.file;
+}
+/*-----------------------------------------------------------------------------------*/
+char *
+webclient_hostname(void)
+{
+  return s.host;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+webclient_port(void)
+{
+  return s.port;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_init(void)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+init_connection(void)
+{
+  s.state = WEBCLIENT_STATE_STATUSLINE;
+
+  s.getrequestleft = sizeof(http_get) - 1 + 1 +
+    sizeof(http_10) - 1 +
+    sizeof(http_crnl) - 1 +
+    sizeof(http_host) - 1 +
+    sizeof(http_crnl) - 1 +
+    strlen(http_user_agent_fields) +
+    strlen(s.file) + strlen(s.host);
+  s.getrequestptr = 0;
+
+  s.httpheaderlineptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_close(void)
+{
+  s.state = WEBCLIENT_STATE_CLOSE;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+webclient_get(char *host, u16_t port, char *file)
+{
+  struct uip_conn *conn;
+  u16_t *ipaddr; 
+  static u16_t addr[2];
+  
+  /* First check if the host is an IP address. */
+  ipaddr = &addr[0];
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    ipaddr = resolv_lookup(host);
+    
+    if(ipaddr == NULL) {
+      return 0;
+    }
+  }
+  
+  conn = tcp_connect(ipaddr, htons(port), NULL);
+  
+  if(conn == NULL) {
+    return 0;
+  }
+  
+  s.port = port;
+  strncpy(s.file, file, sizeof(s.file));
+  strncpy(s.host, host, sizeof(s.host));
+  
+  init_connection();
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char * CC_FASTCALL
+copy_string(unsigned char *dest,
+	    const unsigned char *src, unsigned char len)
+{
+  return strcpy(dest, src) + len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+senddata(void)
+{
+  u16_t len;
+  char *getrequest;
+  char *cptr;
+  
+  if(s.getrequestleft > 0) {
+    cptr = getrequest = (char *)uip_appdata;
+
+    cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
+    cptr = copy_string(cptr, s.file, strlen(s.file));
+    *cptr++ = ISO_space;
+    cptr = copy_string(cptr, http_10, sizeof(http_10) - 1);
+
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+    
+    cptr = copy_string(cptr, http_host, sizeof(http_host) - 1);
+    cptr = copy_string(cptr, s.host, strlen(s.host));
+    cptr = copy_string(cptr, http_crnl, sizeof(http_crnl) - 1);
+
+    cptr = copy_string(cptr, http_user_agent_fields,
+		       strlen(http_user_agent_fields));
+    
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    uip_send(&(getrequest[s.getrequestptr]), len);
+  }
+}  
+/*-----------------------------------------------------------------------------------*/
+static void
+acked(void)
+{
+  u16_t len;
+  
+  if(s.getrequestleft > 0) {
+    len = s.getrequestleft > uip_mss()?
+      uip_mss():
+      s.getrequestleft;
+    s.getrequestleft -= len;
+    s.getrequestptr += len;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_statusline(u16_t len)
+{
+  char *cptr;
+  
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
+    ++uip_appdata;
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+
+      if((strncmp(s.httpheaderline, http_10,
+		  sizeof(http_10) - 1) == 0) ||
+	 (strncmp(s.httpheaderline, http_11,
+		  sizeof(http_11) - 1) == 0)) {
+	cptr = &(s.httpheaderline[9]);
+	s.httpflag = HTTPFLAG_NONE;
+	if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) {
+	  /* 200 OK */
+	  s.httpflag = HTTPFLAG_OK;
+	} else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
+		  strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) {
+	  /* 301 Moved permanently or 302 Found. Location: header line
+	     will contain thw new location. */
+	  s.httpflag = HTTPFLAG_MOVED;
+	} else {
+	  s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+	}
+      } else {
+	uip_abort();
+	webclient_aborted();
+	return 0;
+      }
+      
+      /* We're done parsing the status line, so we reset the pointer
+	 and start parsing the HTTP headers.*/
+      s.httpheaderlineptr = 0;
+      s.state = WEBCLIENT_STATE_HEADERS;
+      break;
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static char
+casecmp(char *str1, const char *str2, char len)
+{
+  static char c;
+  
+  while(len > 0) {
+    c = *str1;
+    /* Force lower-case characters. */
+    if(c & 0x40) {
+      c |= 0x20;
+    }
+    if(*str2 != c) {
+      return 1;
+    }
+    ++str1;
+    ++str2;
+    --len;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t
+parse_headers(u16_t len)
+{
+  char *cptr;
+  static unsigned char i;
+  
+  while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
+    s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
+    ++uip_appdata;
+    --len;
+    if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
+      /* We have an entire HTTP header line in s.httpheaderline, so
+	 we parse it. */
+      if(s.httpheaderline[0] == ISO_cr) {
+	/* This was the last header line (i.e., and empty "\r\n"), so
+	   we are done with the headers and proceed with the actual
+	   data. */
+	s.state = WEBCLIENT_STATE_DATA;
+	return len;
+      }
+
+      s.httpheaderline[s.httpheaderlineptr - 1] = 0;
+      /* Check for specific HTTP header fields. */      
+      if(casecmp(s.httpheaderline, http_content_type,
+		     sizeof(http_content_type) - 1) == 0) {
+	/* Found Content-type field. */
+	cptr = strchr(s.httpheaderline, ';');
+	if(cptr != NULL) {
+	  *cptr = 0;
+	}
+	strncpy(s.mimetype, s.httpheaderline +
+		sizeof(http_content_type) - 1, sizeof(s.mimetype));
+      } else if(casecmp(s.httpheaderline, http_location,
+			    sizeof(http_location) - 1) == 0) {
+	cptr = s.httpheaderline +
+	  sizeof(http_location) - 1;
+	
+	if(strncmp(cptr, http_http, 7) == 0) {
+	  cptr += 7; 
+	  for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
+	    if(*cptr == 0 ||
+	       *cptr == '/' ||
+	       *cptr == ' ' ||
+	       *cptr == ':') {
+	      s.host[i] = 0;
+	      break;
+	    }
+	    s.host[i] = *cptr;
+	    ++cptr;
+	  }
+	}
+	strncpy(s.file, cptr, sizeof(s.file));
+	/*	s.file[s.httpheaderlineptr - i] = 0;*/
+      }
+
+
+      /* We're done parsing, so we reset the pointer and start the
+	 next line. */
+      s.httpheaderlineptr = 0;      
+    } else {
+      ++s.httpheaderlineptr;
+    }
+  }
+  return len;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  u16_t len;
+
+  len = uip_datalen();
+
+  if(s.state == WEBCLIENT_STATE_STATUSLINE) {
+    len = parse_statusline(len);
+  }
+  
+  if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) {
+    len = parse_headers(len);
+  }
+
+  if(len > 0 && s.state == WEBCLIENT_STATE_DATA &&
+     s.httpflag != HTTPFLAG_MOVED) {
+    webclient_datahandler((char *)uip_appdata, len);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+webclient_appcall(void *state)
+{
+  if(uip_connected()) {
+    s.timer = 0;
+    s.state = WEBCLIENT_STATE_STATUSLINE;
+    senddata();
+    webclient_connected();
+    tcp_markconn(uip_conn, &s);
+    return;
+  }
+
+  if(uip_timedout()) {
+    webclient_timedout();
+  }
+  
+  if(state == NULL) {
+    uip_abort();
+    return;
+  }
+
+  if(s.state == WEBCLIENT_STATE_CLOSE) {
+    webclient_closed();
+    uip_abort();
+    return;
+  }        
+
+  if(uip_aborted()) {
+    webclient_aborted();
+  }
+  
+  
+  if(uip_acked()) {
+    s.timer = 0;
+    acked();
+  }
+  if(uip_newdata()) {
+    s.timer = 0;
+    newdata();
+  }
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata();
+  } else if(uip_poll()) {
+    ++s.timer;
+    if(s.timer == WEBCLIENT_TIMEOUT) {
+      webclient_timedout();
+      uip_abort();
+      return;
+    }
+        /*    senddata();*/
+  }
+
+  if(uip_closed()) {
+    tcp_markconn(uip_conn, NULL);
+    if(s.httpflag != HTTPFLAG_MOVED) {
+      /* Send NULL data to signal EOF. */
+      webclient_datahandler(NULL, 0);
+    } else {
+      /*      conn = uip_connect(uip_conn->ripaddr, s.port);
+      if(conn != NULL) {
+	dispatcher_markconn(conn, NULL);
+	init_connection();
+	}*/
+      if(resolv_lookup(s.host) == NULL) {
+	resolv_query(s.host);
+      }
+      webclient_get(s.host, s.port, s.file);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/webclient.h b/contiki/apps/webclient.h
new file mode 100644
index 0000000..eaaa1dc
--- /dev/null
+++ b/contiki/apps/webclient.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "contiki" web browser.
+ *
+ * $Id: webclient.h,v 1.6 2004/07/04 17:50:39 adamdunkels Exp $
+ *
+ */
+#ifndef __WEBCLIENT_H__
+#define __WEBCLIENT_H__
+
+
+#include "http-strings.h"
+#include "http-user-agent-string.h"
+#include "resolv.h"
+
+
+/* Callback functions that have to be implemented by the application
+   program. */
+struct webclient_state;
+void webclient_datahandler(char *data, u16_t len);
+void webclient_connected(void);
+void webclient_timedout(void);
+void webclient_aborted(void);
+void webclient_closed(void);
+
+
+/* Functions. */
+void webclient_init(void);
+unsigned char webclient_get(char *host, u16_t port, char *file);
+void webclient_close(void);
+
+void webclient_appcall(void *state);
+/*DISPATCHER_UIPCALL(webclient_appcall, state);*/
+
+char *webclient_mimetype(void);
+char *webclient_filename(void);
+char *webclient_hostname(void);
+unsigned short webclient_port(void);
+
+#endif /* __WEBCLIENT_H__ */
diff --git a/contiki/apps/webserver-dsc.c b/contiki/apps/webserver-dsc.c
new file mode 100644
index 0000000..576a6c2
--- /dev/null
+++ b/contiki/apps/webserver-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: webserver-dsc.c,v 1.3 2005/03/18 00:49:42 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon webserver_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(webserver_dsc,
+    "The Contiki web server",
+    "webserver.prg",
+    webserver_init,
+    &webserver_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char webservericon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x40, 0x41, 0x44, 0x48, 0x40, 0x50,
+  0x00, 0xff, 0x5a, 0x00, 0x00, 0x00, 0x3c, 0x81,
+  0x00, 0xfe, 0x02, 0x82, 0x22, 0x12, 0x02, 0x0a,
+
+  0x41, 0x60, 0x42, 0x62, 0x62, 0x42, 0x60, 0x41,
+  0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18,
+  0x82, 0x06, 0x42, 0x46, 0x46, 0x42, 0x06, 0x82,
+
+  0x50, 0x40, 0x48, 0x44, 0x41, 0x40, 0x7e, 0x00,
+  0xc5, 0x34, 0x3c, 0x52, 0x7a, 0x7e, 0xa1, 0xfd,
+  0x0a, 0x02, 0x12, 0x22, 0x82, 0x02, 0x7e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char webservericon_textmap[9] = {
+  '+', '-', '+',
+  '|', ')', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon webserver_icon =
+  {CTK_ICON("Web server", webservericon_bitmap, webservericon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/webserver-dsc.h b/contiki/apps/webserver-dsc.h
new file mode 100644
index 0000000..789a57d
--- /dev/null
+++ b/contiki/apps/webserver-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: webserver-dsc.h,v 1.1 2003/04/17 19:00:01 adamdunkels Exp $
+ *
+ */
+#ifndef __WEBSERVER_DSC_H__
+#define __WEBSERVER_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(webserver_dsc);
+
+#endif /* __WEBSERVER_DSC_H__ */
diff --git a/contiki/apps/webserver.c b/contiki/apps/webserver.c
new file mode 100644
index 0000000..ddc0f7e
--- /dev/null
+++ b/contiki/apps/webserver.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: webserver.c,v 1.14 2005/03/01 06:03:25 adamdunkels Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "http-strings.h"
+
+#include "loader.h"
+
+#include "webserver.h"
+#include "httpd.h"
+
+#include <string.h>
+#include <stdio.h>
+
+/* The main window. */
+static struct ctk_window mainwindow;
+
+static struct ctk_label message =
+  {CTK_LABEL(0, 0, 15, 1, "Latest requests")};
+
+/*static DISPATCHER_SIGHANDLER(webserver_sighandler, s, data);
+
+static struct dispatcher_proc p =
+{DISPATCHER_PROC("Web server", NULL, webserver_sighandler,
+		 httpd_appcall)};
+static ek_id_t id;*/
+
+EK_EVENTHANDLER(webserver_eventhandler, ev, data);
+EK_PROCESS(p, "Web server", EK_PRIO_NORMAL,
+	   webserver_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+#define LOG_WIDTH  38
+#define LOG_HEIGHT 16
+static char log[LOG_WIDTH*LOG_HEIGHT];
+
+static struct ctk_label loglabel =
+{CTK_LABEL(0, 1, LOG_WIDTH, LOG_HEIGHT, log)};
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(webserver_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(webserver_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&mainwindow, LOG_WIDTH, LOG_HEIGHT+1, "Web server");
+    
+    CTK_WIDGET_ADD(&mainwindow, &message);
+    CTK_WIDGET_ADD(&mainwindow, &loglabel);
+ 
+    httpd_init();
+
+    ctk_window_open(&mainwindow);
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&mainwindow);
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();    
+  } else if(ev == tcpip_event) {
+    httpd_appcall(data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_log_file(u16_t *requester, char *file)
+{
+  int size;
+  
+  /* Scroll previous entries upwards */
+  memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
+
+  /* Print out IP address of requesting host. */
+  size = sprintf(&log[LOG_WIDTH * (LOG_HEIGHT - 1)],
+		 "%d.%d.%d.%d: ",
+		 htons(requester[0]) >> 8,
+		 htons(requester[0]) & 0xff,
+		 htons(requester[1]) >> 8,
+		 htons(requester[1]) & 0xff);
+  
+  /* Copy filename into last line. */		 
+  strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1) + size], file, LOG_WIDTH - size);
+	   
+  /* Update log display. */
+  CTK_WIDGET_REDRAW(&loglabel);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+httpd_log(char *msg)
+{
+  /* Scroll previous entries upwards */
+  memcpy(log, &log[LOG_WIDTH], LOG_WIDTH * (LOG_HEIGHT - 1));
+
+  /* Copy filename into last line. */		 
+  strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1)], msg, LOG_WIDTH);
+  
+  /* Update log display. */
+  CTK_WIDGET_REDRAW(&loglabel);
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/webserver.h b/contiki/apps/webserver.h
new file mode 100644
index 0000000..64f8d57
--- /dev/null
+++ b/contiki/apps/webserver.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: webserver.h,v 1.5 2004/09/12 07:20:04 adamdunkels Exp $
+ *
+ */
+#ifndef __WEBSERVER_H__
+#define __WEBSERVER_H__
+
+#include "uip.h"
+
+void webserver_init(char *arg);
+void webserver_log(char *msg);
+void webserver_log_file(u16_t *requester, char *file);
+
+
+#endif /* __WEBSERVER_H__ */
diff --git a/contiki/apps/www-dsc.c b/contiki/apps/www-dsc.c
new file mode 100644
index 0000000..4d52b5e
--- /dev/null
+++ b/contiki/apps/www-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-dsc.c,v 1.4 2005/04/19 22:00:54 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon www_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(www_dsc,
+    "The Contiki web browser",
+    "www.prg",
+    www_init,
+    &www_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char wwwicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char wwwicon_textmap[9] = {
+  'w', 'w', 'w',
+  '(', ')', ' ',
+  ' ', '(', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon www_icon =
+  {CTK_ICON("Web browser", wwwicon_bitmap, wwwicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/apps/www-dsc.h b/contiki/apps/www-dsc.h
new file mode 100644
index 0000000..18bba6b
--- /dev/null
+++ b/contiki/apps/www-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-dsc.h,v 1.1 2003/04/17 19:00:01 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_DSC_H__
+#define __WWW_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(www_dsc);
+
+#endif /* __WWW_DSC_H__ */
diff --git a/contiki/apps/www.c b/contiki/apps/www.c
new file mode 100644
index 0000000..225f255
--- /dev/null
+++ b/contiki/apps/www.c
@@ -0,0 +1,983 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www.c,v 1.31 2005/06/12 23:44:30 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ek.h"
+#include "ctk.h"
+#include "webclient.h"
+#include "htmlparser.h"
+#include "http-strings.h"
+#include "resolv.h"
+
+#include "petsciiconv.h"
+
+#include "program-handler.h"
+
+#include "uiplib.h"
+
+#include "tcpip.h"
+
+#include "loader.h"
+
+#include "www-conf.h"
+
+#if 1
+#define PRINTF(x)
+#else
+#include <stdio.h>
+#define PRINTF(x) printf x
+#endif
+
+
+/* The array that holds the current URL. */
+static char url[WWW_CONF_MAX_URLLEN + 1];
+static char tmpurl[WWW_CONF_MAX_URLLEN + 1];
+
+/* The array that holds the web page text. */
+static char webpage[WWW_CONF_WEBPAGE_WIDTH *
+		    WWW_CONF_WEBPAGE_HEIGHT + 1];
+
+
+/* The CTK widgets for the main window. */
+static struct ctk_window mainwindow;
+
+static struct ctk_button backbutton =
+  {CTK_BUTTON(0, 0, 4, "Back")};
+static struct ctk_button downbutton =
+  {CTK_BUTTON(10, 0, 4, "Down")};
+static struct ctk_button stopbutton =
+  {CTK_BUTTON(WWW_CONF_WEBPAGE_WIDTH - 16, 0, 4, "Stop")};
+static struct ctk_button gobutton =
+  {CTK_BUTTON(WWW_CONF_WEBPAGE_WIDTH - 4, 0, 2, "Go")};
+
+static struct ctk_separator sep1 =
+  {CTK_SEPARATOR(0, 2, WWW_CONF_WEBPAGE_WIDTH)};
+
+static char editurl[WWW_CONF_MAX_URLLEN + 1];
+static struct ctk_textentry urlentry =
+  {CTK_TEXTENTRY(0, 1, WWW_CONF_WEBPAGE_WIDTH - 2,
+		 1, editurl, WWW_CONF_MAX_URLLEN)};
+static struct ctk_label webpagelabel =
+  {CTK_LABEL(0, 3, WWW_CONF_WEBPAGE_WIDTH,
+	     WWW_CONF_WEBPAGE_HEIGHT, webpage)};
+
+static char statustexturl[WWW_CONF_WEBPAGE_WIDTH];
+static struct ctk_label statustext =
+  {CTK_LABEL(0, WWW_CONF_WEBPAGE_HEIGHT + 4,
+	     WWW_CONF_WEBPAGE_WIDTH, 1, "")};
+static struct ctk_separator sep2 =
+  {CTK_SEPARATOR(0, WWW_CONF_WEBPAGE_HEIGHT + 3,
+		 WWW_CONF_WEBPAGE_WIDTH)};
+
+static struct ctk_window wgetdialog;
+static struct ctk_label wgetlabel1 =
+  {CTK_LABEL(1, 1, 34, 1, "This web page cannot be displayed.")};
+static struct ctk_label wgetlabel2 =
+  {CTK_LABEL(1, 3, 35, 1, "Would you like to download instead?")};
+static struct ctk_button wgetnobutton =
+  {CTK_BUTTON(1, 5, 6, "Cancel")};
+static struct ctk_button wgetyesbutton =
+  {CTK_BUTTON(11, 5, 24, "Close browser & download")};
+
+/* The char arrays that hold the history of visited URLs. */
+static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
+static char history_last;
+
+
+/* The CTK widget definitions for the hyperlinks and the char arrays
+   that hold the link URLs. */
+struct formattribs {
+  char formaction[WWW_CONF_MAX_FORMACTIONLEN];
+  char formname[WWW_CONF_MAX_FORMNAMELEN];
+#define FORMINPUTTYPE_SUBMITBUTTON 1
+#define FORMINPUTTYPE_INPUTFIELD   2
+  unsigned char inputtype;
+  char inputname[WWW_CONF_MAX_INPUTNAMELEN];
+  char *inputvalue;
+};
+
+union pagewidgetattrib {
+  char url[WWW_CONF_MAX_URLLEN];
+#if WWW_CONF_FORMS
+  struct formattribs form;
+#endif /* WWW_CONF_FORMS */
+};
+static struct ctk_widget pagewidgets[WWW_CONF_MAX_NUMPAGEWIDGETS];
+static union pagewidgetattrib pagewidgetattribs[WWW_CONF_MAX_NUMPAGEWIDGETS];
+static unsigned char pagewidgetptr;
+
+#if WWW_CONF_RENDERSTATE
+static unsigned char renderstate;
+#endif /* WWW_CONF_RENDERSTATE */
+
+#define ISO_nl    0x0a
+#define ISO_space 0x20
+#define ISO_ampersand 0x26
+#define ISO_plus 0x2b
+#define ISO_slash 0x2f
+#define ISO_eq    0x3d
+#define ISO_questionmark  0x3f
+
+/* The state of the rendering code. */
+static char *webpageptr;
+static unsigned char x, y;
+static unsigned char loading;
+static unsigned short firsty, pagey;
+
+static unsigned char count;
+static char receivingmsgs[4][23] = {
+  "Receiving web page ...",
+  "Receiving web page. ..",
+  "Receiving web page.. .",
+  "Receiving web page... "
+};
+
+
+EK_EVENTHANDLER(www_eventhandler, ev, data);
+EK_PROCESS(p, "Web browser", EK_PRIO_NORMAL,
+	   www_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*static DISPATCHER_SIGHANDLER(www_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Web browser", NULL, www_sighandler, webclient_appcall)};
+  static ek_id_t id;*/
+
+
+
+static void formsubmit(struct formattribs *attribs);
+/*-----------------------------------------------------------------------------------*/
+/* make_window()
+ *
+ * Creates the web browser's window.
+ */
+static void
+make_window(void)
+{ 
+
+  CTK_WIDGET_ADD(&mainwindow, &backbutton);
+  CTK_WIDGET_ADD(&mainwindow, &downbutton);
+  CTK_WIDGET_ADD(&mainwindow, &stopbutton);
+  CTK_WIDGET_ADD(&mainwindow, &gobutton);
+  CTK_WIDGET_ADD(&mainwindow, &urlentry);
+  CTK_WIDGET_ADD(&mainwindow, &sep1);
+  CTK_WIDGET_ADD(&mainwindow, &webpagelabel);
+  CTK_WIDGET_SET_FLAG(&webpagelabel, CTK_WIDGET_FLAG_MONOSPACE);
+  CTK_WIDGET_ADD(&mainwindow, &sep2);
+  CTK_WIDGET_ADD(&mainwindow, &statustext);
+
+  pagewidgetptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/* redraw_window():
+ *
+ * Convenience function that calls upon CTK to redraw the browser
+ * window. */
+static void
+redraw_window(void)
+{
+  ctk_window_redraw(&mainwindow);
+}
+/*-----------------------------------------------------------------------------------*/
+/* www_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(www_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    /*    id = dispatcher_start(&p);*/
+    id = ek_start(&p);
+    
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+clear_page(void)
+{
+  ctk_window_clear(&mainwindow);
+  make_window();
+  redraw_window();
+  memset(webpage, 0, WWW_CONF_WEBPAGE_WIDTH * WWW_CONF_WEBPAGE_HEIGHT);  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_url(void)
+{
+  memcpy(editurl, url, WWW_CONF_MAX_URLLEN);
+  strncpy(editurl, "http://", 7);
+  petsciiconv_topetscii(editurl + 7, WWW_CONF_MAX_URLLEN - 7);
+  CTK_WIDGET_REDRAW(&urlentry);
+}
+static void
+start_loading(void)
+{
+  loading = 1;
+  x = y = 0;
+  pagey = 0;
+  webpageptr = webpage;
+
+  clear_page();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&statustext, text);
+  CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+open_url(void)
+{
+  unsigned char i;
+  static char host[32];
+  char *file;
+  register char *urlptr;
+  static u16_t addr[2];
+
+  /* Trim off any spaces in the end of the url. */
+  urlptr = url + strlen(url) - 1;
+  while(*urlptr == ' ' && urlptr > url) {
+    *urlptr = 0;
+    --urlptr;
+  }
+
+  /* Don't even try to go further if the URL is empty. */
+  if(urlptr == url) {
+    return;
+  }
+
+  /* See if the URL starts with http://, otherwise prepend it. */
+  if(strncmp(url, http_http, 7) != 0) {
+    while(urlptr >= url) {
+      *(urlptr + 7) = *urlptr;
+      --urlptr;
+    }
+    strncpy(url, http_http, 7);
+  } 
+
+  /* Find host part of the URL. */
+  urlptr = &url[7];  
+  for(i = 0; i < sizeof(host); ++i) {
+    if(*urlptr == 0 ||
+       *urlptr == '/' ||
+       *urlptr == ' ' ||
+       *urlptr == ':') {
+      host[i] = 0;
+      break;
+    }
+    host[i] = *urlptr;
+    ++urlptr;
+  }
+
+  /* XXX: Here we should find the port part of the URL, but this isn't
+     currently done because of laziness from the programmer's side
+     :-) */
+  
+  /* Find file part of the URL. */
+  while(*urlptr != '/' && *urlptr != 0) {
+    ++urlptr;
+  }
+  if(*urlptr == '/') {
+    file = urlptr;
+  } else {
+    file = "/";
+  }
+  
+  /* Try to lookup the hostname. If it fails, we initiate a hostname
+     lookup and print out an informative message on the statusbar. */
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    if(resolv_lookup(host) == NULL) {
+      resolv_query(host);
+      show_statustext("Resolving host...");
+      return;
+    }
+  }
+
+  /* The hostname we present in the hostname table, so we send out the
+     initial GET request. */
+  if(webclient_get(host, 80, file) == 0) {
+    show_statustext("Out of memory error.");
+  } else {
+    show_statustext("Connecting...");
+  }
+  redraw_window();
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_link(link):
+ *
+ * Will format a link from the current web pages so that it suits the
+ * open_url() function and finally call it to open the requested URL.
+ */
+static void
+open_link(char *link)
+{
+  char *urlptr;
+    
+  if(strncmp(link, http_http, 7) == 0) {
+    /* The link starts with http://. We just copy the contents of the
+       link into the url string and jump away. */
+    strncpy(url, link, WWW_CONF_MAX_URLLEN);
+  } else if(*link == ISO_slash &&
+	    *(link + 1) == ISO_slash) {
+    /* The link starts with //, so we'll copy it into the url
+       variable, starting after the http (which already is present in
+       the url variable since we were able to open the web page on
+       which this link was found in the first place). */
+    strncpy(&url[5], link, WWW_CONF_MAX_URLLEN);   
+  } else if(*link == ISO_slash) {
+    /* The link starts with a slash, so it is a non-relative link
+       within the same web site. We find the start of the filename of
+       the current URL and paste the contents of this link there, and
+       head off to the new URL. */
+    for(urlptr = &url[7];
+	*urlptr != 0 && *urlptr != ISO_slash;
+	++urlptr);    
+    strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));    
+  } else {
+    /* A fully relative link is found. We find the last slash in the
+       current URL and paste the link there. */
+    
+    /* XXX: we should really parse any ../ in the link as well. */
+    for(urlptr = url + strlen(url);
+	urlptr != url && *urlptr != ISO_slash;
+	--urlptr);
+    ++urlptr;
+    strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));    
+  }
+
+  /* Open the URL. */
+  show_url();
+  open_url();
+
+
+  start_loading();
+}
+/*-----------------------------------------------------------------------------------*/
+/* log_back():
+ *
+ * Copies the current URL from the url variable and into the log for
+ * the back button.
+ */
+static void
+log_back(void)
+{
+  if(strncmp(url, history[(int)history_last], WWW_CONF_MAX_URLLEN) != 0) {
+    memcpy(history[(int)history_last], url, WWW_CONF_MAX_URLLEN);
+    ++history_last;
+    if(history_last >= WWW_CONF_HISTORY_SIZE) {
+      history_last = 0;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ctk_window_close(&mainwindow);
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/* www_dispatcher():
+ *
+ * The program's signal dispatcher function. Is called by the ek
+ * dispatcher whenever a signal arrives.
+ */
+/*static
+  DISPATCHER_SIGHANDLER(www_sighandler, s, data)*/
+EK_EVENTHANDLER(www_eventhandler, ev, data)
+{
+  static struct ctk_widget *w;
+  static unsigned char i;
+  static char *argptr;
+  
+  /*  DISPATCHER_SIGHANDLER_ARGS(s, data);*/
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  
+  w = (struct ctk_widget *)data;
+
+  if(ev == tcpip_event) {
+    webclient_appcall(data);
+  } else if(ev == EK_EVENT_INIT) {
+    /* Create the main window. */
+    memset(webpage, 0, sizeof(webpage));
+    ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH, 
+                   WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
+    make_window();
+#ifdef WWW_CONF_HOMEPAGE
+    strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
+#endif /* WWW_CONF_HOMEPAGE */    
+    CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
+
+    /* Create download dialog.*/
+    ctk_dialog_new(&wgetdialog, 38, 7);
+    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1);
+    CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2);
+    CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton);
+    CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton);
+
+    ctk_window_open(&mainwindow);
+    
+  } else if(ev == ctk_signal_widget_activate) {
+    if(w == (struct ctk_widget *)&backbutton) {
+      firsty = 0;
+      start_loading();
+
+      --history_last;
+      if(history_last > WWW_CONF_HISTORY_SIZE) {
+	history_last = WWW_CONF_HISTORY_SIZE - 1;
+      }
+      memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
+      open_url();
+      CTK_WIDGET_FOCUS(&mainwindow, &backbutton);      
+    } else if(w == (struct ctk_widget *)&downbutton) {
+      firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
+      start_loading();
+      open_url();
+      CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
+    } else if(w == (struct ctk_widget *)&gobutton ||
+	      w == (struct ctk_widget *)&urlentry) {
+      start_loading();
+      firsty = 0;
+
+      log_back();
+      memcpy(url, editurl, WWW_CONF_MAX_URLLEN);
+      petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN);
+      open_url();
+      CTK_WIDGET_FOCUS(&mainwindow, &gobutton);
+    } else if(w == (struct ctk_widget *)&stopbutton) {
+      loading = 0;
+      webclient_close();
+    } else if(w == (struct ctk_widget *)&wgetnobutton) {
+      ctk_dialog_close();
+    } else if(w == (struct ctk_widget *)&wgetyesbutton) {
+      ctk_dialog_close();      
+      quit();
+      argptr = arg_alloc(WWW_CONF_MAX_URLLEN);
+      if(argptr != NULL) {
+	strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
+      } 
+      program_handler_load("wget.prg", argptr);
+      
+#if WWW_CONF_FORMS
+    } else {
+      /* Check form buttons */
+      for(i = 0; i < pagewidgetptr; ++i) {
+	if(&pagewidgets[i] == w) {
+	  formsubmit(&pagewidgetattribs[i].form);
+	  /*	  show_statustext(pagewidgetattribs[i].form.formaction);*/
+	  /*	  PRINTF(("Formaction %s formname %s inputname %s\n",
+		  pagewidgetattribs[i].form.formaction,
+		  pagewidgetattribs[i].form.formname,
+		  pagewidgetattribs[i].form.inputname));*/
+	  break;
+	}
+      }
+#endif /* WWW_CONF_FORMS */
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    firsty = 0;
+    log_back();
+    open_link(w->widget.hyperlink.url);
+    CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
+    /*    ctk_window_open(&mainwindow);*/
+  } else if(ev == ctk_signal_hyperlink_hover) {
+    if(CTK_WIDGET_TYPE((struct ctk_widget *)data) ==
+       CTK_WIDGET_HYPERLINK) {
+      strncpy(statustexturl, w->widget.hyperlink.url,
+	      sizeof(statustexturl));
+      petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
+      show_statustext(statustexturl);
+    }
+  } else if(ev == resolv_event_found) {
+    /* Either found a hostname, or not. */
+    if((char *)data != NULL &&
+       resolv_lookup((char *)data) != NULL) {
+      open_url();
+    } else {
+      show_statustext("Host not found.");
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* set_url():
+ *
+ * Constructs an URL from the arguments and puts it into the global
+ * "url" variable and the visible "editurl" (which is shown in the URL
+ * text entry widget in the browser window).
+ */
+static void
+set_url(char *host, u16_t port, char *file)
+{
+  char *urlptr;
+
+  memset(url, 0, WWW_CONF_MAX_URLLEN);
+  
+  if(strncmp(file, http_http, 7) == 0) {
+    strncpy(url, file, sizeof(url));
+  } else {
+    strncpy(url, http_http, 7);
+    urlptr = url + 7;
+    strcpy(urlptr, host);
+    urlptr += strlen(host);
+    strcpy(urlptr, file);
+  }
+
+  show_url();
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+  show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+  show_statustext("Connection timed out");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{  
+  show_statustext("Stopped.");
+  petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
+				 WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
+  CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
+  redraw_window();
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{
+  start_loading();
+    
+  clear_page();
+  
+  show_statustext("Request sent...");
+  set_url(webclient_hostname(), webclient_port(), webclient_filename());
+
+#if WWW_CONF_RENDERSTATE 
+  renderstate = HTMLPARSER_RENDERSTATE_NONE;
+#endif /* WWW_CONF_RENDERSTATE */
+  htmlparser_init();
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():   
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+  if(len > 0) {
+    if(strcmp(webclient_mimetype(), http_texthtml) == 0) { 
+      count = (count + 1) & 3;
+      show_statustext(receivingmsgs[count]);
+      htmlparser_parse(data, len);
+      redraw_window();
+    } else {
+      uip_abort();
+      ctk_dialog_open(&wgetdialog);
+    }
+  } else {
+    /* Clear remaining parts of page. */
+    loading = 0;
+  }
+  
+  if(data == NULL) {
+    loading = 0;
+    show_statustext("Done.");
+    petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
+				   WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
+    CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
+    redraw_window();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void *
+add_pagewidget(char *text, unsigned char len, unsigned char type,
+		unsigned char border)
+{  
+  register struct ctk_widget *lptr;
+  register unsigned char *wptr;
+  static unsigned char maxwidth;
+  static void *dataptr;
+
+  if(!loading) {
+    return NULL;
+  }
+  
+  if(len + border == 0) {
+    return NULL;
+  }
+  
+  maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border);
+  
+  /* If the text of the link is too long so that it does not fit into
+     the width of the current window, counting from the current x
+     coordinate, we first try to jump to the next line. */
+  if(len + x > maxwidth) {
+    htmlparser_newline();
+    if(!loading) {
+      return NULL;
+    }
+  }
+
+  /* If the text of the link still is too long, we just chop it off!
+     XXX: this is not really the right thing to do, we should probably
+     either make a link into a multiline link, or add multiple
+     buttons. But this will do for now. */
+  if(len > maxwidth) {
+    text[maxwidth] = 0;
+    len = maxwidth;
+  }
+
+  dataptr = NULL;
+  
+  if(firsty == pagey) {
+    wptr = webpageptr;
+    /* To save memory, we'll copy the widget text to the web page
+       drawing area and reference it from there. */
+    wptr[0] = 0;
+    wptr += border;
+    memcpy(wptr, text, len);
+    wptr[len] = 0;
+    wptr[len + border] = ' ';
+    if(pagewidgetptr < WWW_CONF_MAX_NUMPAGEWIDGETS) {
+      dataptr = &pagewidgetattribs[pagewidgetptr];
+      lptr = &pagewidgets[pagewidgetptr];
+      
+      switch(type) {
+      case CTK_WIDGET_HYPERLINK:
+	CTK_HYPERLINK_NEW((struct ctk_hyperlink *)lptr, x,
+			  y + 3, len,
+			  wptr, dataptr);
+	break;
+      case CTK_WIDGET_BUTTON:
+	CTK_BUTTON_NEW((struct ctk_button *)lptr, x,
+		       y + 3, len,
+		       wptr);
+	((struct formattribs *)dataptr)->inputvalue = wptr;
+	break;
+      case CTK_WIDGET_TEXTENTRY:
+	CTK_TEXTENTRY_NEW((struct ctk_textentry *)lptr, x,
+			  y + 3, len, 1,
+			  wptr, len);
+	((struct formattribs *)dataptr)->inputvalue = wptr;
+	break;	
+      }
+      CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE);
+      CTK_WIDGET_ADD(&mainwindow, lptr);
+
+      ++pagewidgetptr;
+    }
+  }
+  /* Increase the x coordinate with the length of the link text plus
+     the extra space behind it and the CTK button markers. */
+  len = len + 1 + 2 * border;
+  x += len;
+
+  if(firsty == pagey) {
+    webpageptr += len;
+  }
+  
+  if(x == WWW_CONF_WEBPAGE_WIDTH) {
+    htmlparser_newline();
+  }
+
+  return dataptr;
+}
+/*-----------------------------------------------------------------------------------*/
+#if WWW_CONF_RENDERSTATE
+static void
+centerline(char *wptr)
+{
+  unsigned char spaces, i;
+  char *cptr;
+  register struct ctk_widget *linksptr;
+  
+  cptr = wptr + WWW_CONF_WEBPAGE_WIDTH;
+  for(spaces = 0; spaces < WWW_CONF_WEBPAGE_WIDTH; ++spaces) {
+    if(*--cptr != 0) {
+      break;
+    }
+  }
+  
+  spaces /= 2;
+
+  while(cptr >= wptr) {
+    *(cptr + spaces) = *cptr;
+    --cptr;
+  }
+
+  memset(wptr, ' ', spaces);
+  
+  linksptr = pagewidgets;
+  
+  for(i = 0; i < pagewidgetptr; ++i) {
+    if(CTK_WIDGET_YPOS(linksptr) == y + 2) {
+      linksptr->x += spaces;
+      linksptr->widget.hyperlink.text += spaces;
+    }
+    ++linksptr;
+  }
+}
+#endif /* WWW_CONF_RENDERSTATE */
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_newline(void)
+{
+  char *wptr;
+  
+  if(pagey < firsty) {
+    ++pagey;
+    x = 0;
+    return;
+  }
+  
+  if(!loading) {
+    return;
+  }
+
+  webpageptr += (WWW_CONF_WEBPAGE_WIDTH - x);
+  ++y;
+  x = 0;
+  
+  wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH;
+  petsciiconv_topetscii(wptr,
+			WWW_CONF_WEBPAGE_WIDTH);
+#if WWW_CONF_RENDERSTATE
+  if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
+    centerline(wptr);
+  }
+#endif /* WWW_CONF_RENDERSTATE */  
+  
+  if(y == WWW_CONF_WEBPAGE_HEIGHT) {
+    loading = 0;
+    webclient_close();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_word(char *word, unsigned char wordlen)
+{
+
+  if(loading) {
+    if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) {
+      htmlparser_newline();
+    }
+
+    if(loading) {
+      if(pagey == firsty) {
+	memcpy(webpageptr, word, wordlen);
+	webpageptr += wordlen;      
+	*webpageptr = ' ';
+	++webpageptr;
+      }
+      x += wordlen + 1;
+      if(x == WWW_CONF_WEBPAGE_WIDTH) {
+	htmlparser_newline();
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_link(char *text, unsigned char textlen, char *url)
+{
+  static unsigned char *linkurlptr;
+
+  linkurlptr = add_pagewidget(text, textlen, CTK_WIDGET_HYPERLINK, 0);
+  if(linkurlptr != NULL &&
+     strlen(url) < WWW_CONF_MAX_URLLEN) {
+    strcpy(linkurlptr, url);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#if WWW_CONF_RENDERSTATE
+void
+htmlparser_renderstate(unsigned char s)
+{
+  if((s & HTMLPARSER_RENDERSTATE_STATUSMASK) ==
+     HTMLPARSER_RENDERSTATE_BEGIN) {
+    renderstate |= s & ~HTMLPARSER_RENDERSTATE_STATUSMASK;
+  } else {
+    renderstate &= ~(s & ~HTMLPARSER_RENDERSTATE_STATUSMASK);
+  }
+}
+#endif /* WWW_CONF_RENDERSTATE */
+
+#if WWW_CONF_FORMS
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_submitbutton(char *text, char *name,
+			char *formname, char *formaction)
+{
+  register struct formattribs *form;
+  
+  form = add_pagewidget(text, strlen(text), CTK_WIDGET_BUTTON, 1);
+  if(form != NULL) {
+    strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN);
+    strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
+    strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
+    form->inputtype = FORMINPUTTYPE_SUBMITBUTTON;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+htmlparser_inputfield(unsigned char size, char *text, char *name,
+		      char *formname, char *formaction)
+{
+  register struct formattribs *form;
+
+  form = add_pagewidget(text, size, CTK_WIDGET_TEXTENTRY, 1);
+  if(form != NULL) {
+    strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN);
+    strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
+    strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
+    form->inputtype = FORMINPUTTYPE_INPUTFIELD;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+formsubmit(struct formattribs *attribs)
+{
+  unsigned char i, j;
+  register char *urlptr, *valueptr;
+  register struct formattribs *faptr;
+
+  urlptr = &tmpurl[0];
+
+  strncpy(urlptr, attribs->formaction, WWW_CONF_MAX_URLLEN);
+  tmpurl[WWW_CONF_MAX_URLLEN] = 0;
+  urlptr += strlen(urlptr);
+  *urlptr = ISO_questionmark;
+  ++urlptr;
+  
+  
+  /* Construct an URL by finding all input field forms with the same
+     formname as the current submit button, and add the submit button
+     URL stuff as well. */
+  for(i = 0; i < pagewidgetptr; ++i) {
+    if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
+      break;
+    }
+
+    faptr = &pagewidgetattribs[i].form;
+    
+    if(strcmp(attribs->formaction, faptr->formaction) == 0 &&
+       strcmp(attribs->formname, faptr->formname) == 0 &&
+       (faptr->inputtype == FORMINPUTTYPE_INPUTFIELD ||
+	faptr == attribs)) {
+
+      /* Copy the name of the input field into the URL and append a
+	 questionmark. */
+      strncpy(urlptr, faptr->inputname, WWW_CONF_MAX_URLLEN - strlen(tmpurl));
+      tmpurl[WWW_CONF_MAX_URLLEN] = 0;
+      urlptr += strlen(urlptr);
+      *urlptr = ISO_eq;
+      ++urlptr;
+
+      /* Convert and copy the contents of the input field to the URL
+	 and append an ampersand. */
+      valueptr = pagewidgets[i].widget.textentry.text;
+      petsciiconv_toascii(valueptr, WWW_CONF_MAX_INPUTVALUELEN);
+      for(j = 0; j < WWW_CONF_MAX_INPUTVALUELEN; ++j) {
+	if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
+	  break;
+	}
+	*urlptr = *valueptr;
+	if(*urlptr == ISO_space) {
+	  *urlptr = ISO_plus;
+	}
+	if(*urlptr == 0) {
+	  break;
+	}
+	++urlptr;
+	++valueptr;
+      }
+      
+      *urlptr = ISO_ampersand;
+      ++urlptr;
+    }
+  }
+  --urlptr;
+  *urlptr = 0;
+  log_back();
+  open_link(tmpurl);
+}
+/*-----------------------------------------------------------------------------------*/
+#endif /* WWW_CONF_FORMS */
diff --git a/contiki/apps/www.h b/contiki/apps/www.h
new file mode 100644
index 0000000..3d9c9c6
--- /dev/null
+++ b/contiki/apps/www.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: www.h,v 1.2 2004/06/06 06:03:03 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_H__
+#define __WWW_H__
+
+void www_init(void);
+
+#endif /* __WWW_H__ */
diff --git a/contiki/conf/FILES b/contiki/conf/FILES
new file mode 100644
index 0000000..72ec6f2
--- /dev/null
+++ b/contiki/conf/FILES
@@ -0,0 +1,30 @@
+The contiki/conf/ directory contains example configuration
+files.
+
+cc-conf.h.example
+
+  An example configuration file for C compiler tweaks.
+
+clock-conf.h.example
+
+  An example configuration file for the clock module.
+
+ctk-conf.h.example
+
+  An example configuration file for the CTK GUI module.
+
+ek-conf.h.example
+
+  An example configuration file for the Contiki event kernel.
+
+telnetd-conf.h.example
+
+  An example configuration file for the telnet server.
+
+uip-conf.h.example
+
+  An example configuration file for the uIP TCP/IP stack.
+
+www-conf.h.example
+
+  An example configuration file for the web browser.
\ No newline at end of file
diff --git a/contiki/conf/cc-conf.h.example b/contiki/conf/cc-conf.h.example
new file mode 100644
index 0000000..c4d2fdb
--- /dev/null
+++ b/contiki/conf/cc-conf.h.example
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h.example,v 1.3 2004/07/04 11:37:34 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+/* This file is used to configure stuff that depends on the
+   capabilities of the C compiler used. */
+
+/* CC_CONF_REGISTER_ARGS: 1 or 0; 1 if the C compiler can handle the
+   "register" keyword in function argument, 0 otherwise. */
+#define CC_CONF_REGISTER_ARGS          1
+
+/* CC_CONF_FUNCTION_POINTR_ARGS: 1 or 0; 1 if the C compiler can
+   handle function arguments with function pointers, 0 otherwise. */
+#define CC_CONF_FUNCTION_POINTER_ARGS  1
+
+/* CC_CONF_FASTCALL: if the C compiler supports the fastcall keyword,
+   it should be defined here. If the C compiler does not support it,
+   leave the definition blank. */
+
+   Example:
+   #define CC_CONF_FASTCALL               fastcall */
+#define CC_CONF_FASTCALL
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki/conf/clock-conf.h.example b/contiki/conf/clock-conf.h.example
new file mode 100644
index 0000000..a690e15
--- /dev/null
+++ b/contiki/conf/clock-conf.h.example
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki/conf/ctk-conf.h.example b/contiki/conf/ctk-conf.h.example
new file mode 100644
index 0000000..789dd32
--- /dev/null
+++ b/contiki/conf/ctk-conf.h.example
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.example,v 1.7 2004/06/27 12:31:24 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* Defines which key that is to be used for switching to the prevoius
+   widget.  */
+#define CTK_CONF_WIDGETUP_KEY         CH_F5
+
+/* Defines which key that is to be used for switching to the next
+   widget.  */
+#define CTK_CONF_WIDGETDOWN_KEY       CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT        0 /* 1342 bytes */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS                1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS         1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS        1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE           1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE          1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS                1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH            16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS         10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER          0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki/conf/ek-conf.h.example b/contiki/conf/ek-conf.h.example
new file mode 100644
index 0000000..082a5b1
--- /dev/null
+++ b/contiki/conf/ek-conf.h.example
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h.example,v 1.3 2004/07/04 11:37:34 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_EVENTS   32    /* Must be 2^n */
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 32
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki/conf/telnetd-conf.h.example b/contiki/conf/telnetd-conf.h.example
new file mode 100644
index 0000000..becfd44
--- /dev/null
+++ b/contiki/conf/telnetd-conf.h.example
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h.example,v 1.3 2004/08/22 12:35:37 oliverschmidt Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+#define __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 36
+#define TELNETD_CONF_NUMLINES 24
+
+#endif /* __TELNETD_CONF_H__ */
+
+
+
+
+
+
+
+
diff --git a/contiki/conf/uip-conf.h.example b/contiki/conf/uip-conf.h.example
new file mode 100644
index 0000000..b23c409
--- /dev/null
+++ b/contiki/conf/uip-conf.h.example
@@ -0,0 +1,93 @@
+/**
+ * \file
+ * uIP configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file contains configuration options for the uIP TCP/IP
+ * stack. Each Contiki port will contain its own uip-conf.h file
+ * containing architecture specific configuration options.
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h.example,v 1.5 2004/08/22 12:35:37 oliverschmidt Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+/**
+ * The maximum number of TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ */
+#define UIP_CONF_MAX_CONNECTIONS 40
+
+/**
+ * The maximum number of listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ */
+#define UIP_CONF_MAX_LISTENPORTS 40
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ */
+#define UIP_CONF_BUFFER_SIZE     400
+
+/**
+ * The host byte order.
+ *
+ * Used for telling uIP if the architecture has LITTLE_ENDIAN or
+ * BIG_ENDIAN byte order. x86 CPUs have LITTLE_ENDIAN byte order,
+ * whereas Motorola CPUs have BIG_ENDIAN. Check the documentation of
+ * the CPU to find out the byte order.
+ */
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+
+/**
+ * IP address configuration through ping.
+ *
+ * uIP features IP address configuration using an ICMP echo (ping)
+ * packet. In this mode, the destination IP address of the first ICMP
+ * echo packet that is received is used to set the host IP address.  
+ */
+#define UIP_CONF_PINGADDRCONF    0
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki/conf/www-conf.h.example b/contiki/conf/www-conf.h.example
new file mode 100644
index 0000000..374c78f
--- /dev/null
+++ b/contiki/conf/www-conf.h.example
@@ -0,0 +1,110 @@
+/**
+ * \file
+ * The Contiki web browser configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h.example,v 1.4 2004/07/04 11:37:34 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/**
+ * The width of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+
+/**
+ * The height of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/**
+ * The size of the "Back" history.
+ */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/**
+ * The maximum length of the URLs the web browser will handle.
+ */
+#define WWW_CONF_MAX_URLLEN 100
+
+/**
+ * The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ * a single web page view.
+ *
+ * \note This does not limit the total number of widgets in a web
+ * page, only the number of widget that are visible simultaneously.
+ */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
+
+/**
+ * Turns support for the \<center\> tag on or off, and must be on for
+ * HTML forms to work.
+ */
+#define WWW_CONF_RENDERSTATE 1
+
+/**
+ * Toggles support for HTML forms.
+ */
+#define WWW_CONF_FORMS       1
+
+/**
+ * Maximum length of HTML form action URLs.
+ */
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+
+/**
+ * Maximum length of HTML form name.
+ */
+#define WWW_CONF_MAX_FORMNAMELEN    20
+
+/**
+ * Maximum length of HTML form input name.
+ */
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+
+/**
+ * Maximum length of HTML form input value.
+ */
+#define WWW_CONF_MAX_INPUTVALUELEN  (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+/**
+ * The defaule home page.
+ */
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki/ctk/FILES b/contiki/ctk/FILES
new file mode 100644
index 0000000..c6245ba
--- /dev/null
+++ b/contiki/ctk/FILES
@@ -0,0 +1,30 @@
+The contiki/ctk/ directory contains the source code for CTK, the
+Contiki ToolKit, that provides the Contiki graphical user interface.
+
+ctk-conio*.[ch]
+
+  A CTK driver that provides a text-mode version of the CTK GUI for a
+  locally connected display.
+
+ctk-draw*.[ch]
+
+  The interface that all CTK drivers use to communicate with CTK.
+
+ctk-mouse.[ch]
+
+  The CTK mouse pointer interface.
+
+ctk-term*.[ch]
+
+  A CTK driver that provides a text-mode version of the CTK GUI for a
+  remotely connected display over a serial line or via Telnet.
+
+ctk-vnc*[ch], vnc*.[ch]
+
+  A CTK driver that provides a graphical version of the CTK GUI for a
+  remotely connected display over an IP network using the VNC
+  protocol.
+
+ctk.[ch]
+
+  CTK implementation. 
\ No newline at end of file
diff --git a/contiki/ctk/ctk-conio-service.c b/contiki/ctk/ctk-conio-service.c
new file mode 100644
index 0000000..75d082f
--- /dev/null
+++ b/contiki/ctk/ctk-conio-service.c
@@ -0,0 +1,576 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-service.c,v 1.12 2006/05/28 20:38:19 oliverschmidt Exp $
+ *
+ */
+
+#include <conio.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "ctk-draw-service.h"
+
+#include "ctk-conio-conf.h"
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+static unsigned char sizex, sizey;
+
+/*unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;*/
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+cputsn(char *str, unsigned char len)
+{
+  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_init(void)
+{
+  (void)bgcolor(SCREENCOLOR);
+  (void)bordercolor(BORDERCOLOR);
+  screensize(&sizex, &sizey);
+  ctk_draw_clear(0, sizey);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    (void)textcolor(WIDGETCOLOR_FWIN);
+    if(focus & CTK_FOCUS_WIDGET) {
+      (void)textcolor(WIDGETCOLOR_FOCUS);
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    (void)textcolor(WIDGETCOLOR_DIALOG);
+    if(focus & CTK_FOCUS_WIDGET) {
+      (void)textcolor(WIDGETCOLOR_FOCUS);
+      wfocus = 1;
+    }
+  } else {
+    (void)textcolor(WIDGETCOLOR);
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus != 0);
+      cputcxy(xpos, ypos, '[');
+      cputsn(w->widget.button.text, w->w);
+      cputc(']');
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus == 0);
+      gotoxy(xpos, ypos);
+      (void)textcolor(WIDGETCOLOR_HLINK);
+      cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+            revers(i == w->widget.textentry.xpos - xscroll);
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	  }
+	  revers(0);
+	  cputc('<');
+	} else {
+	  revers(wfocus != 0 && j == w->widget.textentry.ypos);
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus != 0);
+      gotoxy(xpos, ypos);
+      if(w->widget.icon.textmap != NULL) {
+	for(i = 0; i < 3; ++i) {
+	  gotoxy(xpos, ypos);
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    cputc(w->widget.icon.textmap[0 + 3 * i]);
+	    cputc(w->widget.icon.textmap[1 + 3 * i]);
+	    cputc(w->widget.icon.textmap[2 + 3 * i]);
+	  }
+	  ++ypos;
+	}
+      }
+      x = xpos;
+  
+      len = strlen(w->widget.icon.title);
+      if(x + len >= sizex) {
+	x = sizex - len;
+      }
+
+      gotoxy(x, ypos);
+      if(ypos >= clipy1 && ypos < clipy2) {
+	cputs(w->widget.icon.title);
+      }
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+		  unsigned char focus,
+		  unsigned char clipy1,
+		  unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+
+  if(focus & CTK_FOCUS_WINDOW) {
+    (void)textcolor(WINDOWCOLOR_FOCUS);
+  } else {
+    (void)textcolor(WINDOWCOLOR);
+  }
+    
+  h = window->y + 2 + window->h;
+
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		  unsigned char clipy1, unsigned char clipy2,
+		  unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x;
+  y = window->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  if(draw_borders) {  
+
+    /* Draw window frame. */
+    if(focus & CTK_FOCUS_WINDOW) {
+      (void)textcolor(WINDOWCOLOR_FOCUS);
+    } else {
+      (void)textcolor(WINDOWCOLOR);
+    }
+
+    if(y >= clipy1) {
+      cputcxy(x, y, CH_ULCORNER);
+      gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
+      chline(window->w - (wherex() - x) - 2);
+      cputcxy(x2, y, CH_URCORNER);
+    }
+
+    h = window->h;
+  
+    if(clipy1 > y1) {
+      if(clipy1 - y1 < h) {
+	h = clipy1 - y1;
+	      y1 = clipy1;
+      } else {
+	h = 0;
+      }
+    }
+
+    if(clipy2 < y1 + h) {
+      if(y1 >= clipy2) {
+	h = 0;
+      } else {
+	h = clipy2 - y1;
+      }
+    }
+
+    cvlinexy(x, y1, h);
+    cvlinexy(x2, y1, h);  
+
+    if(y + window->h >= clipy1 &&
+       y + window->h < clipy2) {
+      cputcxy(x, y2, CH_LLCORNER);
+      chlinexy(x1, y2, window->w);
+      cputcxy(x2, y2, CH_LRCORNER);
+    }
+  }
+
+  draw_window_contents(window, focus, clipy1, clipy2,
+		       x1, x2, y + 1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  (void)textcolor(DIALOGCOLOR);
+
+  x = dialog->x;
+  y = dialog->y + 1;
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+  /* Draw dialog frame. */
+  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
+		       x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+ 
+  (void)textcolor(BACKGROUNDCOLOR);
+  for(i = y1; i < y2; ++i) {
+    cclearxy(0, i, sizex);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m, unsigned char open)
+{
+  unsigned char x, x2, y;
+
+  if(open) {
+    x = x2 = wherex();
+    if(x2 + CTK_CONF_MENUWIDTH > sizex) {
+      x2 = sizex - CTK_CONF_MENUWIDTH;
+    }
+
+    for(y = 0; y < m->nitems; ++y) {
+      if(y == m->active) {
+	(void)textcolor(ACTIVEMENUITEMCOLOR);
+	revers(0);
+      } else {
+	(void)textcolor(MENUCOLOR);	  
+	revers(1);
+      }
+      gotoxy(x2, y + 1);
+      if(m->items[y].title[0] == '-') {
+	chline(CTK_CONF_MENUWIDTH);
+      } else {
+	cputs(m->items[y].title);
+      }
+      if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
+	cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
+      }
+    }
+
+    gotoxy(x, 0);
+    (void)textcolor(OPENMENUCOLOR);
+    revers(0);
+  }
+
+  cputs(m->title);
+  cputc(' ');
+  (void)textcolor(MENUCOLOR);
+  revers(1);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+
+  /* Draw menus */
+  (void)textcolor(MENUCOLOR);
+  gotoxy(0, 0);
+  revers(1);
+  cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    draw_menu(m, m == menus->open);
+  }
+
+  /* Draw desktopmenu */
+  if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
+    gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
+  } else {
+    cclear(sizex - wherex() -
+	   strlen(menus->desktopmenu->title) - 1);
+  }
+  draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
+
+  revers(0);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+  return sizey;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+  return sizex;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+  return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+  return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+  {CTK_DRAW_SERVICE_VERSION,
+   1,
+   1,
+   1,
+   s_ctk_draw_init,
+   s_ctk_draw_clear,
+   s_ctk_draw_clear_window,
+   s_ctk_draw_window,
+   s_ctk_draw_dialog,
+   s_ctk_draw_widget,
+   s_ctk_draw_menus,
+   s_ctk_draw_width,
+   s_ctk_draw_height,
+   s_ctk_mouse_xtoc,
+   s_ctk_mouse_ytoc,
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": text", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_conio_service_init, arg)
+{
+  s_ctk_draw_init();
+  ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    s_ctk_draw_init();
+    ctk_restore();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;    
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki/ctk/ctk-conio.c b/contiki/ctk/ctk-conio.c
new file mode 100644
index 0000000..2f8399b
--- /dev/null
+++ b/contiki/ctk/ctk-conio.c
@@ -0,0 +1,524 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio.c,v 1.24 2006/05/28 20:38:19 oliverschmidt Exp $
+ *
+ */
+
+#include <conio.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "ctk-conio-conf.h"
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+static unsigned char sizex, sizey;
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+cputsn(char *str, unsigned char len)
+{
+  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  (void)bgcolor(SCREENCOLOR);
+  (void)bordercolor(BORDERCOLOR);
+  screensize(&sizex, &sizey);
+  ctk_draw_clear(0, sizey);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len, wfocus;
+
+  wfocus = 0;
+  if(focus & CTK_FOCUS_WINDOW) {    
+    (void)textcolor(WIDGETCOLOR_FWIN);
+    if(focus & CTK_FOCUS_WIDGET) {
+      (void)textcolor(WIDGETCOLOR_FOCUS);
+      wfocus = 1;
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    (void)textcolor(WIDGETCOLOR_DIALOG);
+    if(focus & CTK_FOCUS_WIDGET) {
+      (void)textcolor(WIDGETCOLOR_FOCUS);
+      wfocus = 1;
+    }
+  } else {
+    (void)textcolor(WIDGETCOLOR);
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus != 0);
+      cputcxy(xpos, ypos, '[');
+      cputsn(w->widget.button.text, w->w);
+      cputc(']');
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus == 0);
+      gotoxy(xpos, ypos);
+      (void)textcolor(WIDGETCOLOR_HLINK);
+      cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+	    revers(i == w->widget.textentry.xpos - xscroll);
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	  }
+	  revers(0);
+	  cputc('<');
+	} else {
+	  revers(wfocus != 0 && j == w->widget.textentry.ypos);
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+#if CTK_CONF_ICONS
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      revers(wfocus != 0);
+#if CTK_CONF_ICON_TEXTMAPS
+      if(w->widget.icon.textmap != NULL) {
+	for(i = 0; i < 3; ++i) {
+	  gotoxy(xpos, ypos);
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    cputc(w->widget.icon.textmap[0 + 3 * i]);
+	    cputc(w->widget.icon.textmap[1 + 3 * i]);
+	    cputc(w->widget.icon.textmap[2 + 3 * i]);
+	  }
+	  ++ypos;
+	}
+      }
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+  
+      len = strlen(w->widget.icon.title);
+      if(xpos + len >= sizex) {
+	xpos = sizex - len;
+      }
+
+      gotoxy(xpos, ypos);
+      if(ypos >= clipy1 && ypos < clipy2) {
+	cputs(w->widget.icon.title);
+      }
+      revers(0);
+    }
+    break;
+#endif /* CTK_CONF_ICONS */
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+
+  if(focus & CTK_FOCUS_WINDOW) {
+    (void)textcolor(WINDOWCOLOR_FOCUS);
+  } else {
+    (void)textcolor(WINDOWCOLOR);
+  }
+  
+  h = window->y + 2 + window->h;
+
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x;
+  y = window->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  if(draw_borders) {
+
+    /* Draw window frame. */  
+    if(focus & CTK_FOCUS_WINDOW) {
+      (void)textcolor(WINDOWCOLOR_FOCUS);
+    } else {
+      (void)textcolor(WINDOWCOLOR);
+    }
+
+    if(y >= clipy1) {
+      cputcxy(x, y, CH_ULCORNER);
+      gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
+      chline(window->w - (wherex() - x) - 2);
+      cputcxy(x2, y, CH_URCORNER);
+    }
+
+    h = window->h;
+  
+    if(clipy1 > y1) {
+      if(clipy1 - y1 < h) {
+	h = clipy1 - y1;
+	      y1 = clipy1;
+      } else {
+	h = 0;
+      }
+    }
+
+    if(clipy2 < y1 + h) {
+      if(y1 >= clipy2) {
+	h = 0;
+      } else {
+	h = clipy2 - y1;
+      }
+    }
+
+    cvlinexy(x, y1, h);
+    cvlinexy(x2, y1, h);  
+
+    if(y + window->h >= clipy1 &&
+       y + window->h < clipy2) {
+      cputcxy(x, y2, CH_LLCORNER);
+      chlinexy(x1, y2, window->w);
+      cputcxy(x2, y2, CH_LRCORNER);
+    }
+  }
+
+  draw_window_contents(window, focus, clipy1, clipy2,
+		       x1, x2, y + 1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+  
+  (void)textcolor(DIALOGCOLOR);
+
+  x = dialog->x;
+  y = dialog->y + 1;
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+  /* Draw dialog frame. */
+  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
+		       x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+ 
+  (void)textcolor(BACKGROUNDCOLOR);
+  for(i = y1; i < y2; ++i) {
+    cclearxy(0, i, sizex);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m, unsigned char open)
+{
+  unsigned char x, x2, y;
+
+  if(open) {
+    x = x2 = wherex();
+    if(x2 + CTK_CONF_MENUWIDTH > sizex) {
+      x2 = sizex - CTK_CONF_MENUWIDTH;
+    }
+
+    for(y = 0; y < m->nitems; ++y) {
+      if(y == m->active) {
+	(void)textcolor(ACTIVEMENUITEMCOLOR);
+	revers(0);
+      } else {
+	(void)textcolor(MENUCOLOR);	  
+	revers(1);
+      }
+      gotoxy(x2, y + 1);
+      if(m->items[y].title[0] == '-') {
+	chline(CTK_CONF_MENUWIDTH);
+      } else {
+	cputs(m->items[y].title);
+      }
+      if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
+	cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
+      }
+    }
+
+    gotoxy(x, 0);
+    (void)textcolor(OPENMENUCOLOR);
+    revers(0);
+  }
+
+  cputs(m->title);
+  cputc(' ');
+  (void)textcolor(MENUCOLOR);
+  revers(1);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+
+  /* Draw menus */
+  (void)textcolor(MENUCOLOR);
+  gotoxy(0, 0);
+  revers(1);
+  cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    draw_menu(m, m == menus->open);
+  }
+
+  /* Draw desktopmenu */
+  if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
+    gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
+  } else {
+    cclear(sizex - wherex() -
+	   strlen(menus->desktopmenu->title) - 1);
+  }
+  draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
+
+  revers(0);
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return sizey;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return sizex;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+ctk_arch_isprint(char c)
+{
+  return isprint(c);
+}
diff --git a/contiki/ctk/ctk-conio.h b/contiki/ctk/ctk-conio.h
new file mode 100644
index 0000000..3c9851c
--- /dev/null
+++ b/contiki/ctk/ctk-conio.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio.h,v 1.5 2004/09/27 22:14:48 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_H__
+#define __CTK_CONIO_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey   cgetc
+
+#ifndef CH_ENTER
+#define CH_ENTER '\n'
+#endif /* CH_ENTER */
+
+#ifndef CH_F1
+#define CH_F1 CH_ESC
+#endif /* CH_F1 */
+
+#ifndef CH_F3
+#define CH_F3 CH_STOP
+#endif /* CH_F1 */
+
+#ifndef CH_CURS_RIGHT
+#define CH_CURS_RIGHT 254
+#endif /* CH_CURS_RIGHT */
+
+#ifndef CH_CURS_LEFT
+#define CH_CURS_LEFT 255
+#endif /* CH_CURS_LEFT */
+
+#endif /* __CTK_CONIO_H__ */
diff --git a/contiki/ctk/ctk-draw-service.h b/contiki/ctk/ctk-draw-service.h
new file mode 100644
index 0000000..8b19768
--- /dev/null
+++ b/contiki/ctk/ctk-draw-service.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-draw-service.h,v 1.4 2005/03/15 15:51:17 oliverschmidt Exp $
+ */
+#ifndef __CTK_DRAW_SERVICE_H__
+#define __CTK_DRAW_SERVICE_H__
+
+#include "ek-service.h"
+
+#include "ctk.h"
+
+#define CTK_DRAW_SERVICE_NAME "CTK driver"
+#define CTK_DRAW_SERVICE_VERSION 0x0001
+struct ctk_draw_service_interface {
+  unsigned char version;
+  unsigned char windowborder_width,
+    windowborder_height,
+    windowtitle_height;
+    
+  void (* draw_init)(void);
+  void (* draw_clear)(unsigned char clipy1, unsigned char clipy2);
+  void (* draw_clear_window)(struct ctk_window *window,
+			     unsigned char focus,
+			     unsigned char clipy1,
+			     unsigned char clipy2);
+  void (* draw_window)(struct ctk_window *window,
+		       unsigned char focus,
+		       unsigned char clipy1,
+		       unsigned char clipy2,
+		       unsigned char draw_borders);
+  void (* draw_dialog)(struct ctk_window *dialog);
+  void (* draw_widget)(struct ctk_widget *widget,
+		       unsigned char focus,
+		       unsigned char clipy1,
+		       unsigned char clipy2);
+  void (* draw_menus)(struct ctk_menus *menus);
+
+  unsigned char (* width)(void);
+  unsigned char (* height)(void);
+
+  unsigned short (* mouse_xtoc)(unsigned short);
+  unsigned short (* mouse_ytoc)(unsigned short);
+};
+
+#endif /* __CTK_DRAW_SERVICE_H__ */
diff --git a/contiki/ctk/ctk-draw.c b/contiki/ctk/ctk-draw.c
new file mode 100644
index 0000000..7e0827a
--- /dev/null
+++ b/contiki/ctk/ctk-draw.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-draw.c,v 1.5 2005/03/15 15:51:17 oliverschmidt Exp $
+ */
+
+#include "ek-service.h"
+
+#include "ctk-draw.h"
+#include "ctk.h"
+
+#include "ctk-draw-service.h"
+
+
+unsigned char ctk_draw_windowborder_width = 1,
+  ctk_draw_windowborder_height = 1,
+  ctk_draw_windowtitle_height = 1;
+
+EK_SERVICE(service, CTK_DRAW_SERVICE_NAME);
+
+/*---------------------------------------------------------------------------*/
+static struct ctk_draw_service_interface *
+find_interface(void)
+{
+  struct ctk_draw_service_interface *interface;
+  interface = (struct ctk_draw_service_interface *)ek_service_state(&service);
+  if(interface != NULL &&
+     interface->version == CTK_DRAW_SERVICE_VERSION) {
+    return interface;
+  } else {
+    return NULL;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_init();
+    ctk_draw_windowborder_width = interface->windowborder_width;
+    ctk_draw_windowborder_height = interface->windowborder_height;
+    ctk_draw_windowtitle_height = interface->windowtitle_height;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char clipy1, unsigned char clipy2)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_clear(clipy1, clipy2);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_clear_window(window, focus, clipy1, clipy2);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_window(window, focus, clipy1, clipy2, draw_borders);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_dialog(dialog);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *widget,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_widget(widget, focus, clipy1, clipy2);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    interface->draw_menus(menus);
+  }
+}
+/*---------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    return interface->width();
+  }
+  return 40;
+}
+/*---------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    return interface->height();
+  }
+  return 24;
+}
+/*---------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_xtoc(unsigned short x)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    return interface->mouse_xtoc(x);
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_ytoc(unsigned short y)
+{
+  struct ctk_draw_service_interface *interface;
+  
+  if((interface = find_interface()) != NULL) {   
+    return interface->mouse_ytoc(y);
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_draw_quit(void)
+{
+  ek_post(service.id, EK_EVENT_REQUEST_EXIT, NULL);
+  ek_service_reset(&service);  
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ctk/ctk-draw.h b/contiki/ctk/ctk-draw.h
new file mode 100644
index 0000000..c0ba064
--- /dev/null
+++ b/contiki/ctk/ctk-draw.h
@@ -0,0 +1,336 @@
+/**
+ * \addtogroup ctk
+ * @{
+ */
+
+/**
+ * \file
+ * CTK screen drawing module interface, ctk-draw.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file contains the interface for the ctk-draw module.The
+ * ctk-draw module takes care of the actual screen drawing for CTK by
+ * implementing a handful of functions that are called by CTK.
+ *
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: ctk-draw.h,v 1.7 2005/03/15 15:51:17 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_DRAW_H__
+#define __CTK_DRAW_H__
+
+#include "ctk.h"
+
+#include "ctk-arch.h"
+
+/**
+ * \defgroup ctkdraw CTK device driver functions
+ * @{
+ *
+ * The CTK device driver functions are divided into two modules, the
+ * ctk-draw module and the ctk-arch module. The purpose of the
+ * ctk-arch and the ctk-draw modules is to act as an interface between
+ * the CTK and the actual hardware of the system on which Contiki is
+ * run. The ctk-arch takes care of the keyboard input from the user,
+ * and the ctk-draw is responsible for drawing the CTK desktop,
+ * windows and user interface widgets onto the actual screen.
+ *
+ * More information about the ctk-draw and the ctk-arch modules can be
+ * found in the sections \ref ctk-draw and \ref ctk-arch.
+ */
+
+/**
+ * \page ctk-draw The ctk-draw module
+ *
+ * In order to work efficiently even on limited systems, CTK uses a
+ * simple coordinate system, where the screen is addressed using
+ * character coordinates instead of pixel coordinates. This makes it
+ * trivial to implement the coordinate system on a text-based screen,
+ * and significantly reduces complexity for pixel based screen
+ * systems.
+ *
+ * The top left of the screen is (0,0) with x and y coordinates
+ * growing downwards and to the right.
+ *
+ * It is the responsibility of the ctk-draw module to keep track of
+ * the screen size and must implement the two functions
+ * ctk_draw_width() and ctk_draw_height(), which are used by the CTK
+ * for querying the screen size. The functions must return the width
+ * and the height of the ctk-draw screen in character coordinates.
+ *
+ * The ctk-draw module is responsible for drawing CTK windows onto the
+ * screen through the function ctk_draw_window().. A pseudo-code
+ * implementation of this  function might look like this:
+ * \code
+   ctk_draw_window(window, focus, clipy1, clipy2, draw_borders) {
+      if(draw_borders) {
+         draw_window_borders(window, focus, clipy1, clipy2);
+      }
+      foreach(widget, window->inactive) {
+         ctk_draw_widget(widget, focus, clipy1, clipy2);
+      }
+      foreach(widget, window->active) {
+         if(widget == window->focused) {
+	    ctk_draw_widget(widget, focus | CTK_FOCUS_WIDGET,
+	                    clipy1, clipy2);
+	 } else {
+	    ctk_draw_widget(widget, focus, clipy1, clipy2);
+	 }
+      }
+   }
+   
+   \endcode
+ *
+ * Where draw_window_borders() draws the window borders (also between
+ * clipy1 and clipy2). The ctk_draw_widget() function is explained
+ * below. Notice how the clipy1 and clipy2 parameters are passed to
+ * all other functions; every function needs to know the boundaries
+ * within which they are allowed to draw.
+ *
+ * In order to aid in implementing a ctk-draw module, a text-based
+ * ctk-draw called ctk-conio has already been implemented. It conforms
+ * to the Borland conio C library, and a skeleton implementation of
+ * said library exists in lib/libconio.c. If a more machine specific
+ * ctk-draw module is to be implemented, the instructions in this file
+ * should be followed.
+ * 
+ */
+
+/**
+ * The initialization function.
+ *
+ * This function is supposed to get the screen ready for drawing, and
+ * may be called at more than one time during the operation of the
+ * system.
+ */
+void ctk_draw_init(void);
+
+/**
+ * Clear the screen between the clip bounds.
+ *
+ * This function should clear the screen between the y coordinates
+ * "clipy1" and "clipy2", including the line at y coordinate "clipy1",
+ * but not the line at y coordinate "clipy2".
+ *
+ * \note This function may be used to draw a background image
+ * (wallpaper) on the desktop; it does not necessarily "clear" the
+ * screen.
+ *
+ * \param clipy1 The lower y coordinate of the clip region.
+ * \param clipy2 The upper y coordinate of the clip region. 
+ */
+void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2);
+
+/**
+ * Draw the window background.
+ *
+ * This function will be called by the CTK before a window will be
+ * completely redrawn.The function is supposed to draw the window
+ * background, excluding window borders as these should be drawn by
+ * the function that actually draws the window, between "clipy1" and
+ * "clipy2".
+ *
+ * \note This function does not necessarily have to clear the window -
+ * it can be used for drawing a background pattern in the window as
+ * well.
+ *
+ * \param window The window for which the background should be drawn.
+ *
+ * \param focus The focus of the window, either CTK_FOCUS_NONE for a
+ * background window, or CTK_FOCUS_WINDOW for the foreground window.
+ * 
+ * \param clipy1 The lower y coordinate of the clip region.
+ * \param clipy2 The upper y coordinate of the clip region. 
+*/
+void ctk_draw_clear_window(struct ctk_window *window,
+			   unsigned char focus,
+			   unsigned char clipy1,
+			   unsigned char clipy2);
+/**
+ * Draw a window onto the screen.
+ *
+ * This function is called by the CTK when a window should be drawn on
+ * the screen. The ctk-draw layer is free to choose how the window
+ * will appear on screen; with or without window borders and the style
+ * of the borders, with or without transparent window background and
+ * how the background shall look, etc.
+ *
+ * \param window The window which is to be drawn.
+ *
+ * \param focus Specifies if the window should be drawn in foreground
+ * or background colors and can be either CTK_FOCUS_NONE or
+ * CTK_FOCUS_WINDOW. Windows with a focus of CTK_FOCUS_WINDOW is
+ * usually drawn in a brighter color than those with CTK_FOCUS_NONE.
+ *
+ * \param clipy1 Specifies the first lines on screen that actually
+ * should be drawn, in screen coordinates (line 1 is the first line
+ * below the menus).
+ *
+ * \param clipy2 Specifies the last + 1 line on screen that should be
+ * drawn, in screen coordinates (line 1 is the first line below the
+ * menus)
+ *
+ */
+void ctk_draw_window(struct ctk_window *window,
+		     unsigned char focus,
+		     unsigned char clipy1,
+		     unsigned char clipy2,
+		     unsigned char draw_borders);
+
+
+/**
+ * Draw a dialog onto the screen.
+ *
+ * In CTK, a dialog is similar to a window, with the only exception
+ * being that they are drawn in a different style. Also, since dialogs
+ * always are drawn on top of everything else, they do not need to be
+ * drawn within any special boundaries.
+ *
+ * \note This function can usually be implemented so that it uses the
+ * same widget drawing code as the ctk_draw_window() function.
+ *
+ * \param dialog The dialog that is to be drawn.
+ */
+void ctk_draw_dialog(struct ctk_window *dialog);
+
+/**
+ * Draw a widget on a window.
+ *
+ * This function is used for drawing a CTK widgets onto the screem is
+ * likely to be the most complex function in the ctk-draw
+ * module. Still, it is straightforward to implement as it can be
+ * written in an incremental fashion, starting with a single widget
+ * type and adding more widget types, one at a time.
+
+ * The ctk-draw module may exploit how the CTK focus constants are
+ * defined in order to use a look-up table for the colors. The CTK
+ * focus constants are defined in the file ctk/ctk.h as follows:
+ \code
+   #define CTK_FOCUS_NONE     0
+   #define CTK_FOCUS_WIDGET   1
+   #define CTK_FOCUS_WINDOW   2
+   #define CTK_FOCUS_DIALOG   4
+ \endcode
+
+ * This gives the following table:
+ \code
+   0: CTK_FOCUS_NONE      (Background window, non-focused widget)
+   1: CTK_FOCUS_WIDGET    (Background window, focused widget)
+   2: CTK_FOCUS_WINDOW    (Foreground window, non-focused widget)
+   3: CTK_FOCUS_WINDOW | CTK_FOCUS_WIDGET
+                          (Foreground window, focused widget)
+   4: CTK_FOCUS_DIALOG    (Dialog, non-focused widget)
+   5: CTK_FOCUS_DIALOG | CTK_FOCUS_WIDGET
+                          (Dialog, focused widget)
+ \endcode 
+
+
+ * \param w The widget to be drawn.
+ * \param focus The focus of the widget.
+ * \param clipy1 The lower y coordinate of the clip region.
+ * \param clipy2 The upper y coordinate of the clip region. 
+ */
+
+void ctk_draw_widget(struct ctk_widget *w,
+		     unsigned char focus,
+		     unsigned char clipy1,
+		     unsigned char clipy2);
+
+void ctk_draw_menus(struct ctk_menus *menus);
+
+
+
+/* Returns width and height of screen. */
+unsigned char ctk_draw_width(void);
+unsigned char ctk_draw_height(void);
+
+
+extern unsigned char ctk_draw_windowborder_width,
+  ctk_draw_windowborder_height,
+  ctk_draw_windowtitle_height;
+
+
+#endif /* __CTK_DRAW_H__ */
+
+
+/**
+ * The keyboard character type of the system
+ *
+ * The ctk_arch_key_t is usually typedef'd to the char type, but some
+ * systems (such as VNC) have a 16-bit key type.
+ *
+ * \var typedef char ctk_arch_key_t;
+ */
+
+/**
+ * Get a keypress from the keyboard input queue.
+ *
+ * This function will remove the first keypress in the keyboard input
+ * queue and return it. If the keyboard queue is empty, the return
+ * value is undefined. This function is intended to be used only after
+ * the ctk_arch_keyavail() function has returned non-zero.
+ *
+ * \return The first keypress from the keyboard input queue.
+ *
+ * \fn ctk_arch_key_t ctk_arch_getkey(void);
+ */
+
+/**
+ * Check if there is a keypress in the keyboard input queue.
+ *
+ * \return Zero if the keyboard input queue is empty, non-zero
+ * otherwise.
+ *
+ * \fn unsigned char ctk_arch_keyavail(void);
+ */
+
+/**
+ * The character used for the Return/Enter key.
+ *
+ * \define #define CH_ENTER '\n'
+ */
+
+/**
+ * \page ctk-arch The ctk-arch module
+ *
+ * The ctk-arch module deals with keyboard input from the underlying
+ * target system on which Contiki is running. The ctk-arch manages a
+ * keyboard input queue that is queried using the two functions
+ * ctk_arch_keyavail() and ctk_arch_getkey().
+ */
+
+/** @} */
+/** @} */
diff --git a/contiki/ctk/ctk-mouse.h b/contiki/ctk/ctk-mouse.h
new file mode 100644
index 0000000..09ef6f3
--- /dev/null
+++ b/contiki/ctk/ctk-mouse.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.h,v 1.4 2004/09/12 20:24:55 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_MOUSE_H__
+#define __CTK_MOUSE_H__
+
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+void ctk_mouse_init(void);
+
+unsigned short ctk_mouse_x(void);
+unsigned short ctk_mouse_y(void);
+
+unsigned char ctk_mouse_xtoc(unsigned short x);
+unsigned char ctk_mouse_ytoc(unsigned short y);
+
+unsigned char ctk_mouse_button(void);
+
+void ctk_mouse_hide(void);
+void ctk_mouse_show(void);
+
+#else
+
+#define ctk_mouse_init()
+#define ctk_mouse_x() 0
+#define ctk_mouse_y() 0
+#define ctk_mouse_xtoc(x) 0
+#define ctk_mouse_ytoc(y) 0
+
+#define ctk_mouse_button() 0
+
+#define ctk_mouse_hide()
+#define ctk_mouse_show()
+
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+
+#endif /* __CTK_MOUSE_H__ */
diff --git a/contiki/ctk/ctk-term-ascii.h b/contiki/ctk/ctk-term-ascii.h
new file mode 100644
index 0000000..7d71a97
--- /dev/null
+++ b/contiki/ctk/ctk-term-ascii.h
@@ -0,0 +1,91 @@
+/*   ascii_control.h
+ *
+ *   ASCII CONTROL CHARACTERS
+ *   from American National Standard Code for Information Interchange X3.4-1977
+ *
+ *   Abbreviations
+ *   
+ *   CC:    communication control
+ *   FE:    format effector
+ *   IS:    information separator
+ *   Delim: delimiter
+ *   Intro: introducer
+ */
+
+/*   ----------------------------------------------------------------------- */
+/*   C0 (7-bit) set                                                          */
+/*   ----------------------------------------------------------------------- */
+/*      mnemonic   octal      decimal   C     meaning                        */
+/*   ----------------------------------------------------------------------- */
+
+#define ASCII_NUL  (000)    /*      0 '\0'    Null                           */
+#define ASCII_SOH  (001)    /*      1         Start of Heading (CC)          */
+#define ASCII_STX  (002)    /*      2         Start of Text (CC)             */
+#define ASCII_ETX  (003)    /*      3         End of Text (CC)               */
+#define ASCII_EOT  (004)    /*      4         End of Transmission (CC)       */
+#define ASCII_ENQ  (005)    /*      5         Enquiry (CC)                   */
+#define ASCII_ACK  (006)    /*      6         Acknowledge (CC)               */
+#define ASCII_BEL  (007)    /*      7 '\a'    Bell / Alert                   */
+#define ASCII_BS   (010)    /*      8 '\b'    Backspace (FE)                 */
+#define ASCII_HT   (011)    /*      9 '\t'    Horizontal Tabulation (FE)     */
+#define ASCII_LF   (012)    /*     10 '\n'    Line Feed / Newline (FE)       */
+#define ASCII_VT   (013)    /*     11 '\v'    Vertical Tabulation (FE)       */
+#define ASCII_FF   (014)    /*     12 '\f'    Form Feed (FE)                 */
+#define ASCII_CR   (015)    /*     13 '\r'    Carriage Return (FE)           */
+#define ASCII_SO   (016)    /*     14         Shift Out                      */
+#define ASCII_SI   (017)    /*     15         Shift In                       */
+#define ASCII_DLE  (020)    /*     16         Data Link Escape (CC)          */
+#define ASCII_DC1  (021)    /*     17         Device Control 1  XON          */
+#define ASCII_DC2  (022)    /*     18         Device Control 2               */
+#define ASCII_DC3  (023)    /*     19         Device Control 3  XOFF         */
+#define ASCII_DC4  (024)    /*     20         Device Control 4               */
+#define ASCII_NAK  (025)    /*     21         Negative Acknowledge (CC)      */
+#define ASCII_SYN  (026)    /*     22         Synchronous Idle (CC)          */
+#define ASCII_ETB  (027)    /*     23         End of Transmission Block (CC) */
+#define ASCII_CAN  (030)    /*     24         Cancel                         */
+#define ASCII_EM   (031)    /*     25         End of Medium                  */
+#define ASCII_SUB  (032)    /*     26         Substitute                     */
+#define ASCII_ESC  (033)    /*     27         Escape                         */
+#define ASCII_FS   (034)    /*     28         File Separator                 */
+#define ASCII_GS   (035)    /*     29         Group Separator                */
+#define ASCII_RS   (036)    /*     30         Record Separator               */
+#define ASCII_US   (037)    /*     31         Unit Separator                 */
+
+#define ASCII_DEL (0177)    /*    127         Delete                         */
+
+#define ASCII_NL  ASCII_LF  /*     10         alias for Newline              */
+
+/*   ----------------------------------------------------------------------- */
+/*   C1 (8-bit) set (which have equivalent 7-bit multi-char sequences)       */
+/*   ----------------------------------------------------------------------- */
+/*      mnemonic   octal      decimal  7-bit  meaning                        */
+/*   ----------------------------------------------------------------------- */
+
+#define ASCII_IND (0204)    /*    132  Esc D  Index (FE)                     */
+#define ASCII_NEL (0205)    /*    133  Esc E  Next Line (FE)                 */
+#define ASCII_SSA (0206)    /*    134  Esc F  Start Selected Area            */
+#define ASCII_ESA (0207)    /*    135  Esc G  End Selected Area              */
+#define ASCII_HTS (0210)    /*    136  Esc H  Horizontal Tab Set (FE)        */
+#define ASCII_HTJ (0211)    /*    137  Esc I  Horizontal Tab w/Justificat(FE)*/
+#define ASCII_VTS (0212)    /*    138  Esc J  Vertical Tab Set (FE)          */
+#define ASCII_PLD (0213)    /*    138  Esc K  Partial Line Down (FE)         */
+#define ASCII_PLU (0214)    /*    140  Esc L  Partial Line Up (FE)           */
+#define ASCII_RI  (0215)    /*    141  Esc M  Reverse Index (FE)             */
+#define ASCII_SS2 (0216)    /*    142  Esc N  Single Shift G2 (Intro)        */
+#define ASCII_SS3 (0217)    /*    143  Esc O  Single Shift G3 (Intro)        */
+#define ASCII_DCS (0220)    /*    144  Esc P  Device Control String (Delim)  */
+#define ASCII_PU1 (0221)    /*    145  Esc Q  Private Use 1                  */
+#define ASCII_PU2 (0222)    /*    146  Esc R  Private Use 2                  */
+#define ASCII_STS (0223)    /*    147  Esc S  Set Transmit State             */
+#define ASCII_CCH (0224)    /*    148  Esc T  Cancel Previous Character      */
+#define ASCII_MW  (0225)    /*    149  Esc U  Message Waiting                */
+#define ASCII_SPA (0226)    /*    150  Esc V  Start Protected Area           */
+#define ASCII_EPA (0227)    /*    151  Esc W  End Protected Area             */
+
+#define ASCII_CSI (0233)    /*    155  Esc [  Control Sequence Introducer    */
+#define ASCII_ST  (0234)    /*    156  Esc \  String Terminator (Delim)      */
+#define ASCII_OSC (0235)    /*    157  Esc ]  Operating System Control (Delim*/
+#define ASCII_PM  (0236)    /*    158  Esc ^  Privacy Message (Delim)        */
+#define ASCII_APC (0237)    /*    159  Esc _  Application Program Command (De*/
+
+/* ------------------------------------------------------------------------- */
diff --git a/contiki/ctk/ctk-term-in.c b/contiki/ctk/ctk-term-in.c
new file mode 100644
index 0000000..667c33a
--- /dev/null
+++ b/contiki/ctk/ctk-term-in.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-term-in.c,v 1.2 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#include <string.h>
+#include "ctk.h"
+#include "ctk-term.h"
+#include "ctk-term-int.h"
+#include "ctk-term-ascii.h"
+
+#define PRINTF(x) 
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * #defines and enums
+ */
+/*-----------------------------------------------------------------------------------*/
+
+/* Size of input key buffer */
+#define NUMKEYS 20 
+
+/* ANSI character classes */
+enum {ACC_C0, ACC_INTERM, ACC_PARAM, ACC_LOWCASE, ACC_UPCASE,ACC_C1, ACC_G1, ACC_DEL, ACC_SPEC };
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Structures
+ */
+/*-----------------------------------------------------------------------------------*/
+
+/* Structure for mapping a character sequence to a key */
+struct seqmap
+{
+  const char* seq;
+  const ctk_arch_key_t key;
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Local variables
+ */
+/*-----------------------------------------------------------------------------------*/
+
+static ctk_arch_key_t keys[NUMKEYS];
+static int firstkey, lastkey;
+
+/* Sequences starting with ESC [ .... */
+const static struct seqmap ctrlmap[] =
+{
+  {"A",CH_CURS_UP},
+  {"B",CH_CURS_DOWN},
+  {"C",CH_CURS_RIGHT},
+  {"D",CH_CURS_LEFT},
+
+  {"11~",CH_F1},
+  {"12~",CH_F2},
+  {"13~",CH_F3},
+  {"14~",CH_F4},
+  // linux console
+  {"[A",CH_F1},
+  {"[B",CH_F2},
+  {"[C",CH_F3},
+  {"[D",CH_F4},
+  {0,0}
+};
+
+/* Sequences starting with ESC O .... */
+const static struct seqmap ss3map[] =
+{
+  {"A",CH_CURS_UP},
+  {"B",CH_CURS_DOWN},
+  {"C",CH_CURS_RIGHT},
+  {"D",CH_CURS_LEFT},
+  {"P",CH_F1},
+  {"Q",CH_F2},
+  {"R",CH_F3},
+  {"S",CH_F4},
+  {0,0}
+};
+
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Add a key to the input buffer
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+enqueue_key(ctk_arch_key_t k)
+{
+  keys[lastkey] = k;
+  ++lastkey;
+  if(lastkey >= NUMKEYS) {
+    lastkey = 0;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Classify a character 
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char 
+classify(unsigned char c)
+{
+  if (0x00 <= c && c <=0x1f) return ACC_C0;
+  if (0x20 <= c && c <=0x2f) return ACC_INTERM;
+  if (0x30 <= c && c <=0x3f) return ACC_PARAM;
+  if (0x40 <= c && c <=0x5f) return ACC_UPCASE;
+  if (0x60 <= c && c <=0x7e) return ACC_LOWCASE;
+  if (c == 0x7f) return ACC_DEL;
+  if (0x90 <= c && c <=0x9f) return ACC_C1;
+  if (c == 0xa0) return ACC_SPEC;
+  if (0xA1 <= c && c <=0xfe) return ACC_G1;
+  if (0x90 <= c && c <=0x9f) return ACC_C1;
+  if (c == 0xff) return ACC_SPEC;
+  return ACC_SPEC;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Lookup a key sequence in a sequencemap and queue the key if sequence found
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+lookup_seq(const char* str, const struct seqmap* map)
+{
+  while (map->seq !=  0) {
+    if (strcmp(str,map->seq) == 0) {
+      enqueue_key(map->key);
+      return;
+    }
+    map++;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* \internal
+ * Parse a character stream 
+ * Returns -1 if c is consumed by the state machine 1 else.
+ */
+/*-----------------------------------------------------------------------------------*/
+static int 
+parse_input(struct ctk_term_state* st, unsigned char c)
+{
+  unsigned char cl = classify(c);
+  int ret = -1;
+  switch(st->inputstate) {
+  case ANS_IDLE:
+    switch(cl) {
+    case ACC_C0:
+      {
+	switch(c) {
+	case ASCII_ESC: st->inputstate = ANS_ESCSEQ; break;
+	case ASCII_BS:  enqueue_key(CH_DEL); break;
+	case ASCII_HT:  enqueue_key(CH_TAB); break;
+	case ASCII_FF:  ctk_term_redraw(st); break;
+	case ASCII_CR:  enqueue_key(CH_ENTER); break;
+	}
+      }
+      break;
+      
+    case ACC_INTERM:
+    case ACC_PARAM:
+    case ACC_LOWCASE:
+    case ACC_UPCASE:
+    case ACC_G1:
+      ret = 1;
+      break;
+    case ACC_C1:
+      if (c == ASCII_CSI) {
+	st->inputstate = ANS_CTRLSEQ;
+	st->ctrlCnt = 0;
+      }
+      else if (c == ASCII_SS3) {
+	st->inputstate = ANS_SS3;
+	st->ctrlCnt = 0;
+      }
+      break;
+    case ACC_DEL:
+      enqueue_key(CH_DEL);
+      break;
+    case ACC_SPEC:
+      break;
+    }
+    break;
+    
+  case ANS_ESCSEQ:
+    {
+      switch(cl) {
+      case ACC_C0:
+      case ACC_DEL:
+	break;
+      case ACC_INTERM:
+	st->inputstate = ANS_ESCSEQ_1;
+	break;
+      case ACC_UPCASE:
+	/* C1 control character */
+	if (c == '[') {
+	  st->inputstate = ANS_CTRLSEQ;
+	  st->ctrlCnt = 0;
+	}
+	else if (c == 'O') {
+	  st->inputstate = ANS_SS3;
+	  st->ctrlCnt = 0;
+	}
+	else {
+	  st->inputstate = ANS_IDLE;
+	}
+	break;
+      case ACC_PARAM:
+	/* Private 2-character sequence */
+      case ACC_LOWCASE:
+	/* Standard 2-character sequence */
+      default:
+	st->inputstate = ANS_IDLE;
+	break;
+      }
+    }
+    break;
+    
+  case ANS_ESCSEQ_1:
+    {
+      switch(cl) {
+      case ACC_C0:
+      case ACC_INTERM:
+	break;
+      case ACC_PARAM:
+	/* Private function*/
+      case ACC_LOWCASE:
+      case ACC_UPCASE:
+	/* Standard function */
+      default:
+	st->inputstate = ANS_IDLE;
+	break;
+      }
+    }
+    break;
+  case ANS_SS3:
+    {
+      switch(cl) {
+      case ACC_PARAM:
+	if (st->ctrlCnt < CTK_TERM_CTRLBUFLEN) st->ctrlbuf[st->ctrlCnt++]=c;
+	break;
+      case ACC_UPCASE:
+	/* VT100 PF seq */
+	if (st->ctrlCnt < CTK_TERM_CTRLBUFLEN) st->ctrlbuf[st->ctrlCnt++]=c;
+	st->inputstate = ANS_IDLE;
+	st->ctrlbuf[st->ctrlCnt] = 0;
+	lookup_seq((const char*)(st->ctrlbuf), ss3map);
+	break;
+      default:
+	st->inputstate = ANS_IDLE;
+	break;
+      }
+    }
+    break;
+  case ANS_CTRLSEQ:
+    {
+      switch(cl) {
+      case ACC_C0:
+	break;
+      case ACC_INTERM:
+      case ACC_PARAM:
+	if (st->ctrlCnt < CTK_TERM_CTRLBUFLEN) st->ctrlbuf[st->ctrlCnt++]=c;
+	break;
+      case ACC_LOWCASE:
+      case ACC_UPCASE:
+	/* Standard control sequence */
+	if (st->ctrlCnt < CTK_TERM_CTRLBUFLEN) st->ctrlbuf[st->ctrlCnt++]=c;
+	/* Cygwin console sends ESC [ [ A for function keys */
+	if (c != '[') {
+	  st->ctrlbuf[st->ctrlCnt] = 0;
+	  lookup_seq((const char*)(st->ctrlbuf), ctrlmap);
+	  st->inputstate = ANS_IDLE;
+	}
+	break;
+      default:
+	st->inputstate = ANS_IDLE;
+	break;
+      }
+    }
+    break;
+  }
+  return ret;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Initialize the input buffer
+ */
+/*-----------------------------------------------------------------------------------*/
+void ctk_term_input_init()
+{
+  firstkey = lastkey = 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Handles an input character provided by the client
+ *
+ * \param ts State information
+ * \param b  Input character
+ */
+/*-----------------------------------------------------------------------------------*/
+void ctk_term_input(struct ctk_term_state* ts, unsigned char b)
+{
+  int ret = parse_input(ts, b);
+  PRINTF(("terminput: 0x%02x\n", b));
+  if (ret > 0) {
+    enqueue_key((ctk_arch_key_t)b);
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Checks the key press input queue to see if there are pending
+ * keys. Called by the CTK module.
+ *
+ * \return Zero if no key presses are in buffer, non-zero if there are
+ * key presses in input buffer.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_arch_keyavail(void)
+{
+  return firstkey != lastkey;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Retrieves key presses from the VNC client. Called by the CTK
+ * module.
+ *
+ * \return The next key in the input queue.
+ */
+/*-----------------------------------------------------------------------------------*/
+ctk_arch_key_t
+ctk_arch_getkey(void)
+{
+  ctk_arch_key_t key;
+  key = keys[firstkey];
+  
+  if(firstkey != lastkey) {
+    ++firstkey;
+    if(firstkey >= NUMKEYS) {
+      firstkey = 0;
+    }
+  }
+  
+  return key;  
+}
+
diff --git a/contiki/ctk/ctk-term-int.h b/contiki/ctk/ctk-term-int.h
new file mode 100644
index 0000000..711c8ab
--- /dev/null
+++ b/contiki/ctk/ctk-term-int.h
@@ -0,0 +1,67 @@
+#ifndef __CTK_TERM_INT_H__
+#define __CTK_TERM_INT_H__
+
+/* Color definitions */
+
+#define TERM_BACKGROUNDCOLOR 0
+#define TERM_WINDOWCOLOR    1
+#define TERM_SEPARATORCOLOR 7 /*(TERM_WINDOWCOLOR + 6)*/
+#define TERM_LABELCOLOR     13 /*(TERM_SEPARATORCOLOR + 6)*/
+#define TERM_BUTTONCOLOR    19 /*(TERM_LABELCOLOR + 6)*/
+#define TERM_HYPERLINKCOLOR 25 /*(TERM_BUTTONCOLOR + 6)*/
+#define TERM_TEXTENTRYCOLOR 31 /*(TERM_HYPERLINKCOLOR + 6)*/
+#define TERM_ICONCOLOR      37 /*(TERM_TEXTENTRYCOLOR + 6)*/
+#define TERM_MENUCOLOR      43 /*(TERM_ICONCOLOR + 6)*/
+#define TERM_OPENMENUCOLOR  44/*(TERM_MENUCOLOR + 1)*/
+#define TERM_ACTIVEMENUCOLOR 45 /*(TERM_OPENMENUCOLOR + 1) */
+
+/* Structure describing an updated region */
+struct ctk_term_update {
+  struct ctk_term_update *next;
+
+#define UPDATE_NONE  0
+#define UPDATE_PARTS 1
+#define UPDATE_FULL  2
+
+  unsigned char type;
+
+  unsigned char x, y;
+  unsigned char w, h;  
+};
+
+/* Character sequence parsing states */
+enum { ANS_IDLE, ANS_ESCSEQ,ANS_ESCSEQ_1,ANS_SS3, ANS_CTRLSEQ};
+
+struct ctk_term_state {
+  unsigned char type;
+  unsigned char state;
+  unsigned char height, width;
+
+  /* Variables used when sending screen updates. */
+  unsigned char x, y, x1, y1, x2, y2;
+  unsigned char w, h;
+  unsigned char c1, c2;
+
+#define CTK_TERM_MAX_UPDATES 8  
+  struct ctk_term_update *updates_current;
+  struct ctk_term_update *updates_pending;
+  struct ctk_term_update *updates_free;
+  struct ctk_term_update updates_pool[CTK_TERM_MAX_UPDATES];
+
+  /* Variables used when parsing input sequences */
+  unsigned char inputstate;
+#define CTK_TERM_CTRLBUFLEN 5
+  unsigned char ctrlbuf[CTK_TERM_CTRLBUFLEN+1];
+  unsigned char ctrlCnt;
+};
+
+struct ctk_term_update * ctk_term_update_alloc(struct ctk_term_state *vs);
+void ctk_term_update_free(struct ctk_term_state *ts, struct ctk_term_update *a);
+void ctk_term_update_remove(struct ctk_term_state *ts, struct ctk_term_update *a);
+
+void ctk_term_update_add(struct ctk_term_state *ts, struct ctk_term_update *a);
+struct ctk_term_update * ctk_term_update_dequeue(struct ctk_term_state *ts);
+
+void ctk_term_input_init();
+
+#endif /* __CTK_TERM_INT_H__ */
diff --git a/contiki/ctk/ctk-term-out.c b/contiki/ctk/ctk-term-out.c
new file mode 100644
index 0000000..5a35a5f
--- /dev/null
+++ b/contiki/ctk/ctk-term-out.c
@@ -0,0 +1,318 @@
+#include "libconio.h"
+#include "ctk-term-int.h"
+#include <string.h>
+#include <stdio.h> // sprintf
+
+#define PRINTF(x)
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * #defines and enums
+ */
+/*-----------------------------------------------------------------------------------*/
+
+#define CHARS_WIDTH    LIBCONIO_CONF_SCREEN_WIDTH
+#define CHARS_HEIGHT   LIBCONIO_CONF_SCREEN_HEIGHT
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Local variables
+ */
+/*-----------------------------------------------------------------------------------*/
+
+/* ANSI/VT100 colors
+  0 - None
+  1 - Bold (inc. inten)
+  4 - Underscore
+  7 - Reverse
+  x0 - black
+  x1 - red
+  x2 - green
+  x3 - yellow
+  x4 - blue
+  x5 - magenta
+  x6 - cyan
+  x7 - white
+  x = 3 fg x = 4 bg
+*/
+#if 0 /* Colorfull theme */
+static const char backgroundcolor[] = "\033[0;37;40m";
+
+static const char wincol[] = "\033[0;37;40m";
+static const char wincol_f[] = "\033[0;1;37;40m";
+static const char wincol_d[] = "\033[0;30;47m";
+
+static const char sepcol[] = "\033[0;37;40m";
+static const char sepcol_f[] = "\033[0;1;37;40m";
+static const char sepcol_d[] = "\033[0;30;47m";
+
+static const char labcol[] = "\033[0;37;40m";
+static const char labcol_f[] = "\033[1;37;40m";
+static const char labcol_d[] = "\033[0;30;47m";
+
+static const char butcol[] = "\033[0;37;40m";
+static const char butcol_w[] = "\033[0;30;47m";
+static const char butcol_f[] = "\033[0;1;37;40m";
+static const char butcol_fw[] = "\033[0;1;37;46m";
+static const char butcol_d[] = "\033[0;30;47m";
+static const char butcol_dw[] = "\033[0;37;46m";
+
+static const char hlcol[] = "\033[0;4;36;40m";
+static const char hlcol_w[] = "\033[0;4;30;47m";
+static const char hlcol_f[] = "\033[0;1;4;36;40m";
+static const char hlcol_fw[] = "\033[0;1;4;37;46m";
+static const char hlcol_d[] = "\033[0;4;34;47m";
+static const char hlcol_dw[] = "\033[0;4;37;46m";
+
+static const char iconcol[] = "\033[0;32;40m";
+static const char iconcol_w[] = "\033[0;30;42m";
+
+static const char menucolor[] = "\033[0;37;43m";
+static const char activemenucolor[] = "\033[0;1;37;43m";
+#endif
+
+#if 1 /* B/W theme */
+static const char backgroundcolor[] = "\033[0m";
+
+static const char wincol[] = "\033[0m";
+static const char wincol_f[] = "\033[0;1m";
+static const char wincol_d[] = "\033[0;7m";
+
+static const char sepcol[] = "\033[0m";
+static const char sepcol_f[] = "\033[0;1m";
+static const char sepcol_d[] = "\033[0;7m";
+
+static const char labcol[] = "\033[0m";
+static const char labcol_f[] = "\033[0;1m";
+static const char labcol_d[] = "\033[0;7m";
+
+static const char butcol[] = "\033[0m";
+static const char butcol_w[] = "\033[0m";
+static const char butcol_f[] = "\033[0;1m";
+static const char butcol_fw[] = "\033[0;1;7m";
+static const char butcol_d[] = "\033[0;7m";
+static const char butcol_dw[] = "\033[0m";
+
+static const char hlcol[] = "\033[0;4m";
+static const char hlcol_w[] = "\033[0;4;7m";
+static const char hlcol_f[] = "\033[0;1;4m";
+static const char hlcol_fw[] = "\033[0;1;4;7m";
+static const char hlcol_d[] = "\033[0;4;7m";
+static const char hlcol_dw[] = "\033[0;4m";
+
+static const char iconcol[] = "\033[0m";
+static const char iconcol_w[] = "\033[0;7m";
+
+static const char menucolor[] = "\033[0;7m";
+static const char activemenucolor[] = "\033[0m";
+
+#endif
+
+static const char* const colortheme[] =
+{
+    backgroundcolor,
+    
+    /* Window colors */
+    wincol, wincol, wincol_f, wincol_f, wincol_d, wincol_d,
+
+    /* Separator colors. */
+    sepcol, sepcol, sepcol_f, sepcol_f, sepcol_d, sepcol_d,    
+
+    /* Label colors. */
+    labcol, labcol, labcol_f, labcol_f, labcol_d, labcol_d,    
+
+    /* Button colors. */
+    butcol, butcol_w, butcol_f, butcol_fw, butcol_d, butcol_dw,    
+
+    /* Hyperlink colors. */
+    hlcol, hlcol_w, hlcol_f, hlcol_fw, hlcol_d, hlcol_dw,
+
+    /* Textentry colors. */
+    butcol, butcol_w, butcol_f, butcol_fw, butcol_d, butcol_dw,
+
+    /* Icon colors */
+    iconcol, iconcol_w, iconcol, iconcol_w, iconcol, iconcol_w,
+    
+    /* Menu colors. */
+    menucolor, activemenucolor, activemenucolor
+  };
+
+static unsigned char  
+  screen[CHARS_WIDTH * CHARS_HEIGHT],
+  colorscreen[CHARS_WIDTH * CHARS_HEIGHT];
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Add a character to the screen buffer 
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_term_out_update_screen(unsigned char  xpos, 
+			   unsigned char  ypos, 
+			   unsigned char  c, 
+			   unsigned char  color)
+{
+  if (c < 0x20) c = 0x20;
+  screen[xpos + ypos * CHARS_WIDTH] = c;
+  colorscreen[xpos + ypos * CHARS_WIDTH] = color;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Check if there are any updated pending. If so, make the first one current
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+check_updates(struct ctk_term_state* ts)
+{
+  if (ts->updates_current != NULL) return;
+  ts->updates_current = ctk_term_update_dequeue(ts);
+  if (ts->updates_current != NULL) {
+    ts->x = ts->updates_current->x;
+    ts->y = ts->updates_current->y;
+    ts->w = ts->updates_current->w;
+    ts->h = ts->updates_current->h;
+    ts->x1 = ts->x2 = ts->x;
+    ts->y1 = ts->y2 = ts->y;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Adds a cursor position change to buffer. Returns 0 if string doesn't fit else
+ * number of bytes actually written is returned.
+ *
+ * \param x X coordinate (screen coordinates)
+ * \param y Y coordinate (screen coordinates)
+ * \param buf Output buffer
+ * \param maxlen Maximum number of bytes to store in buffer
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+move_to(unsigned char x, unsigned char y, unsigned char* buf, unsigned short maxlen)
+{
+  if (maxlen < 14) return 0;
+  return (unsigned short)sprintf((char*)buf, "\033[%d;%dH", y+1, x+1);
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Adds a attribute string to buffer. Returns 0 if string doesn't fit else
+ * number of bytes actually written is returned.
+ *
+ * \param c Color number
+ * \param buf Output buffer
+ * \param maxlen Maximum number of bytes to store in buffer
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+set_color(unsigned char c, unsigned char* buf, unsigned short maxlen)
+{
+  int len = strlen((const char*)colortheme[c]);
+  if (maxlen < len) return 0;
+  memcpy(buf, colortheme[c], len);
+  return len;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Stores terminal data in buffer provided by caller. Returns number of bytes written
+ * to the output buffer.
+ *
+ * \param ts State information
+ * \param buf Output buffer
+ * \param maxlen Maximum number of bytes to store in buffer
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned short 
+ctk_term_send(struct ctk_term_state* ts, 
+	      unsigned char* buf, 
+	      unsigned short maxlen)
+{
+  unsigned char x, y, x0;
+  unsigned char col, c;
+  unsigned short tmp;
+  unsigned short totlen;
+  
+  check_updates(ts);
+  
+  if (ts->updates_current == NULL) return 0;
+
+  x0 = ts->x1;
+  col = ts->c1;
+  totlen = 0;
+  /* Loop across the update region starting at (x1,y1) */
+  for(y = ts->y1; y < ts->y + ts->h; ++y) {
+    for(x = x0; x < ts->x + ts->w; ++x) {
+      /* New line ? */
+      if (x == ts->x) {
+	/* Move cursor to start of line */
+	tmp = move_to(x,y,buf,maxlen);
+	if (tmp == 0) goto loopend;
+	buf += tmp;
+	totlen += tmp;
+	maxlen -= tmp;
+      }
+      /* Check color */
+      c = colorscreen[x + y * CHARS_WIDTH];
+      if (c != col) {
+	PRINTF(("colorchange at (%d, %d) to %d\n", x,y,c));
+	/* Send new color information */
+	tmp = set_color(c, buf, maxlen);
+	if (tmp == 0) goto loopend;
+	col = c;
+	buf += tmp;
+	totlen += tmp;
+	maxlen -= tmp;
+      }
+      /* Check remaining space */
+      if (maxlen < 1) goto loopend;
+      /* Add character */
+      *buf = screen[x + y * CHARS_WIDTH];
+      buf++;
+      maxlen--;
+      totlen++;
+    }
+    x0 = ts->x;
+  }
+loopend:
+  /* Always save current color state */
+  ts->c2 = col;  
+  PRINTF(("ending loop at (%d, %d)\n", x,y));
+  /* Check if done */
+  if (x == ts->x+ts->w && y == ts->y+ts->h) {
+    /* Signal done with this update */
+    ts->x2 = ts->y2 = 0;
+  }
+  else {
+    /* Not done. Save state */
+    ts->x2 = x;
+    ts->y2 = y;
+  }
+  return totlen;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Called by client when the data returned by ctk_term_send() are successfully sent.
+ *
+ * \param ts State information
+ */
+/*-----------------------------------------------------------------------------------*/
+void ctk_term_sent(struct ctk_term_state* ts)
+{
+  if (ts->updates_current != NULL) {
+    /* Check if current update done */
+    if (ts->x2 == 0 && ts->y2 == 0) {
+      /* Yes, free it */
+      ctk_term_update_free(ts, ts->updates_current);
+      ts->updates_current = NULL;
+    }
+    else {
+      /* Nop. Update start posititions */
+      ts->x1 = ts->x2;
+      ts->y1 = ts->y2;
+    }
+    ts->c1 = ts->c2;
+  }
+}
diff --git a/contiki/ctk/ctk-term-out.h b/contiki/ctk/ctk-term-out.h
new file mode 100644
index 0000000..6db7544
--- /dev/null
+++ b/contiki/ctk/ctk-term-out.h
@@ -0,0 +1,10 @@
+#ifndef __CTK_TERM_OUT_H__
+#define __CTK_TERM_OUT_H__
+
+void
+ctk_term_out_update_screen(unsigned char  xpos, 
+			   unsigned char  ypos, 
+			   unsigned char  c, 
+			   unsigned char  color);
+
+#endif /* __CTK_TERM_OUT_H__ */
diff --git a/contiki/ctk/ctk-term.c b/contiki/ctk/ctk-term.c
new file mode 100644
index 0000000..cd9bbfe
--- /dev/null
+++ b/contiki/ctk/ctk-term.c
@@ -0,0 +1,996 @@
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "contiki.h"
+#include "loader.h"
+#include "ctk-term.h"
+#include "ctk-term-int.h"
+#include "ctk-term-out.h"
+#include "ctk-term-conf.h"
+#include "libconio.h"
+
+#define PRINTF(x)
+
+#define reverse(x)
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * #defines and enums
+ */
+/*-----------------------------------------------------------------------------------*/
+#define CH_ULCORNER '+' //0x00
+#define CH_TITLEBAR '-' //0x01
+#define CH_URCORNER '+' //0x02
+#define CH_WINDOWRBORDER '|' //0x03
+#define CH_LRCORNER '+' //0x04
+#define CH_WINDOWLOWERBORDER '-' //0x05
+#define CH_LLCORNER '+' //0x06
+#define CH_WINDOWLBORDER '|' //0x07
+
+#define CH_DIALOG_ULCORNER '+' //0x12
+#define CH_DIALOGUPPERBORDER '-' //0x09
+#define CH_DIALOG_URCORNER '+' //0x0a
+#define CH_DIALOGRBORDER '|' //0x0b
+#define CH_DIALOG_LRCORNER '+' //0x0c
+#define CH_DIALOGLOWERBORDER '-' //0x0d
+#define CH_DIALOG_LLCORNER '+' //0x0e
+#define CH_DIALOGLBORDER '|' //0x0f
+
+#define CH_BUTTONLEFT  '[' //0x10
+#define CH_BUTTONRIGHT ']' //0x11
+
+#define CH_SEPARATOR   '=' //0x13
+
+#ifdef CTK_TERM_CONF_MAX_CLIENTS
+#define CTK_TERM_NUMCONNS CTK_TERM_CONF_MAX_CLIENTS
+#else
+#define CTK_TERM_NUMCONNS 1
+#endif
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+
+/* Term context states */
+enum {
+  TERM_DEALLOCATED,
+  TERM_ALLOCATED
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Local variables
+ */
+/*-----------------------------------------------------------------------------------*/
+
+static unsigned char sizex, sizey;
+static struct ctk_term_state conns[CTK_TERM_NUMCONNS];
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Unconditionally add an update
+ */
+/*-----------------------------------------------------------------------------------*/
+void ctk_term_update_add(struct ctk_term_state *ts, struct ctk_term_update *a)
+{
+  /* XXX: test both head and tail placement!*/
+  a->next = ts->updates_pending;
+  ts->updates_pending = a;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Allocate an update from the update pool
+ */
+/*-----------------------------------------------------------------------------------*/
+struct ctk_term_update *
+ctk_term_update_alloc(struct ctk_term_state *vs)
+{
+  struct ctk_term_update *a;
+
+  a = vs->updates_free;
+  if(a == NULL) {
+    return NULL;
+  }
+  vs->updates_free = a->next;
+  a->next = NULL;
+  return a;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Return an update to the pool
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_term_update_free(struct ctk_term_state *ts, struct ctk_term_update *a)
+{
+  a->next = ts->updates_free;
+  ts->updates_free = a;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Fetch update from the update list
+ */
+/*-----------------------------------------------------------------------------------*/
+struct ctk_term_update *
+ctk_term_update_dequeue(struct ctk_term_state *ts)
+{
+  struct ctk_term_update *a;
+
+  a = ts->updates_pending;
+  if(a == NULL) {
+    return a;
+  }
+  ts->updates_pending = a->next;
+  a->next = NULL;
+  return a;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Remove an update from the update list
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_term_update_remove(struct ctk_term_state *ts, struct ctk_term_update *a)
+{
+  struct ctk_term_update *b, *c;
+
+  if(a == ts->updates_pending) {
+    ts->updates_pending = a->next;
+  } else {
+    b = ts->updates_pending;
+    for(c = ts->updates_pending; c != a; b = c, c = c->next);
+
+    b->next = a->next;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Add an area update for a specific connection. Overlapping updates are merged
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+update_area_connection(struct ctk_term_state *ts,
+		    unsigned char  x, unsigned char  y, unsigned char  w, unsigned char  h)
+{
+  unsigned char  x2, y2, ax2, ay2;
+  struct ctk_term_update *a;
+
+  PRINTF(("update_area_connection: should update (%d:%d) (%d:%d)\n",
+	 x, y, w, h));
+  
+  /* First check if we already have a full update queued. If so, there
+     is no need to put this update on the list. If there is a full
+     update, it is always the first one on the list, so there is no
+     need to go step the list in search for it. */
+
+  if(ts->updates_pending != NULL &&
+     ts->updates_pending->type == UPDATE_FULL) {
+    PRINTF(("Update_area_connecion: full update already queued...\n"));
+    return;
+  }
+
+again:
+  
+  /* Check that we don't update the same area twice by going through
+     the list and search for an update with the same coordinates. */
+  for(a = ts->updates_pending; a != NULL; a = a->next) {
+    if(a->x == x && a->y == y &&
+       a->w == w && a->h == h) {
+      PRINTF(("Update_area_connecion: found equal area\n"));
+      return;
+    }    
+  }
+
+  /* Next we check if this update covers an existing update. If so, we
+     remove the old update, expand this update so that it covers both
+     areas to be updated and run through the process again. */
+  for(a = ts->updates_pending; a != NULL; a = a->next) {      
+    x2 = x + w;
+    y2 = y + h;
+    
+    ax2 = a->x + a->w;
+    ay2 = a->y + a->h;
+
+    /* Test if updates overlaps */
+    if(((x < ax2) && (a->x < x2)) &&
+      ((y < ay2) && (a->y < y2))) {
+
+      /* Remove the old update from the list. */
+      ctk_term_update_remove(ts, a);
+
+      /* Put it on the free list. */
+      ctk_term_update_free(ts, a);
+
+      PRINTF(("update_area_connection: inside (%d:%d, %d:%d)\n",
+	     a->x, a->y, ax2, ay2));
+      
+      /* Find the area that covers both updates. */
+#define MIN(a,b) ((a) < (b)? (a): (b))
+#define MAX(a,b) ((a) > (b)? (a): (b))
+      x = MIN(a->x, x);
+      y = MIN(a->y, y);
+      ax2 = MAX(ax2, x2);
+      ay2 = MAX(ay2, y2);
+      w = ax2 - x;
+      h = ay2 - y;
+
+      /* This should really be done by a recursive call to this
+	 function: update_area_connection(vs, x, y, w, h); but because
+	 some compilers might not be able to optimize away the
+	 recursive call, we do it using a goto instead. */
+      PRINTF(("Update_area_connecion: trying larger area (%d:%d) (%d:%d)\n", x, y, w, h));
+      goto again;
+    }
+  }
+  
+  /* Allocate an update object by pulling it off the free list. If
+     there are no free objects, we go for a full update instead. */
+
+  a = ctk_term_update_alloc(ts);
+  if(a == NULL) {
+    PRINTF(("Update_area_connecion: no free updates, doing full\n"));
+    /* Put all pending updates, except for one, on the free list. Use
+       the remaining update as a full update. */
+    while(ts->updates_pending != NULL) {
+      a = ts->updates_pending;
+      ctk_term_update_remove(ts, a);
+      ctk_term_update_free(ts, a);
+    }
+
+    a = ctk_term_update_alloc(ts);
+    a->type = UPDATE_FULL;
+    ctk_term_update_add(ts, a);
+					
+
+  } else {
+    
+    PRINTF(("Update_area_connecion: allocated update for (%d:%d) (%d:%d)\n", x, y, w, h));
+  /* Else, we put the update object at the end of the pending
+     list. */
+    a->type = UPDATE_PARTS;
+    a->x = x;
+    a->y = y;
+    a->w = w;
+    a->h = h;
+    ctk_term_update_add(ts, a);
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Update an area for all connections.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+update_area(unsigned char  x, unsigned char  y, unsigned char  w, unsigned char  h)
+{
+  unsigned char  i;
+  
+  if(h == 0 || w == 0) {
+    return;
+  }
+
+  if ((x+w) > sizex) {
+    w = sizex - x;
+  }
+
+  if ((y+h) > sizey) {
+    h = sizey - y;
+  }
+  
+  /* Update for all active terminal connections. */
+  for(i = 0; i < CTK_TERM_NUMCONNS; ++i) {
+    if(conns[i].state != TERM_DEALLOCATED) {
+      update_area_connection(&conns[i],x, y, w, h);
+    }
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Request a full update for a specific connections. Usefull when a new client is
+ * connected through telnet for example.
+ *
+ * \param ts Terminal connection state
+ */
+/*-----------------------------------------------------------------------------------*/
+void ctk_term_redraw(struct ctk_term_state *ts)
+{
+  update_area_connection(ts,0,0,ts->width, ts->height);
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Initialize a terminal state structure
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+init_state(struct ctk_term_state *ts)
+{
+  unsigned char i;
+  
+  ts->width = sizex;
+  ts->height = sizey;
+  ts->x = ts->y = ts->x1 = ts->y1 = ts->x2 = ts->y2 = 0;
+  ts->c1 = ts->c2 = 0;
+  ts->w = sizex;
+  ts->h = sizey;
+  ts->state = TERM_ALLOCATED;
+  ts->inputstate = ANS_IDLE;
+
+  /* Initialize the linked list of updates. */
+  for(i = 0; i < CTK_TERM_MAX_UPDATES - 1; ++i) {
+    ts->updates_pool[i].next = &(ts->updates_pool[i + 1]);    
+  }
+  ts->updates_pool[CTK_TERM_MAX_UPDATES-1].next = NULL;
+
+  ts->updates_free = &ts->updates_pool[0];
+  ts->updates_pending = ts->updates_current = NULL;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Allocate a new state structure. Returns NULL if none available
+ */
+/*-----------------------------------------------------------------------------------*/
+struct ctk_term_state *
+ctk_term_alloc_state(void)
+{
+  unsigned char i;
+  for(i = 0; i < CTK_TERM_NUMCONNS; ++i) {
+    if(conns[i].state == TERM_DEALLOCATED) {
+      init_state(&conns[i]);
+      return &conns[i];
+    }
+  }
+  return NULL;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Free a state structure.
+ *
+ * \param ts Terminal connection state
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_term_dealloc_state(struct ctk_term_state *s)
+{
+  s->state = TERM_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------------*/
+static char tmp[40];
+static void
+cputsn(char *str, unsigned char len)
+{
+  strncpy(tmp, str, len);
+  tmp[len] = 0;
+  cputs(tmp);
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Initialize the terminal ctk-draw module. Called by the CTK module.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  int i;
+  bgcolor(TERM_BACKGROUNDCOLOR);
+  screensize(&sizex, &sizey);
+  ctk_draw_clear(0, sizey);
+  ctk_term_input_init();
+  for(i = 0; i < CTK_TERM_NUMCONNS; ++i) {
+    conns[i].state = TERM_DEALLOCATED;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len;
+
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    textcolor((unsigned char)(TERM_SEPARATORCOLOR + focus));
+    if(ypos >= clipy1 && ypos < clipy2) {
+      gotoxy(xpos, ypos);
+      for(i = 0; i < w->w; ++i) {
+	cputc(CH_SEPARATOR);
+      }
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    textcolor((unsigned char)(TERM_LABELCOLOR + focus));
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear((unsigned char)(w->w - (wherex() - xpos)));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    textcolor((unsigned char)(TERM_BUTTONCOLOR + focus));
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(focus & CTK_FOCUS_WIDGET) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      cputcxy(xpos, ypos, CH_BUTTONLEFT);
+      cputsn(w->widget.button.text, w->w);
+      cputc(CH_BUTTONRIGHT);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    textcolor((unsigned char)(TERM_HYPERLINKCOLOR + focus));
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(focus & CTK_FOCUS_WIDGET) {
+	revers(0);	
+      } else {
+	revers(1);
+      }
+      gotoxy(xpos, ypos);
+      cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    textcolor((unsigned char)(TERM_TEXTENTRYCOLOR + focus));
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      textcolor((unsigned char)(TERM_TEXTENTRYCOLOR + (focus ^ 0x01)));
+	      revers(1);
+	    } else {
+	      revers(0);
+	    }
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	    revers(0);
+	    textcolor((unsigned char)(TERM_TEXTENTRYCOLOR + focus));
+	  }
+	  cputc('<');
+	} else {
+	  if(focus & CTK_FOCUS_WIDGET && j == w->widget.textentry.ypos) {
+	    revers(1);
+	  } else {
+	    revers(0);
+	  }
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy((unsigned char)(xpos + 1), ypos);          
+	  cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear((unsigned char)(w->w - (i - xpos) + 1));
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      textcolor((unsigned char)(TERM_ICONCOLOR + focus));
+      if(focus & 1) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= sizex) {
+	x = sizex - len;
+      }
+
+      gotoxy(x, (unsigned char)(ypos + 3));
+      if(ypos >= clipy1 && ypos < clipy2) {
+	cputs(w->widget.icon.title);
+      }
+
+      gotoxy(xpos, ypos);
+
+      if (w->widget.icon.textmap != NULL) {
+	for(i = 0; i < 3; ++i) {
+	  
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    gotoxy(xpos,ypos);
+	    cputc(w->widget.icon.textmap[0 + 3 * i]);
+	    cputc(w->widget.icon.textmap[1 + 3 * i]);
+	    cputc(w->widget.icon.textmap[2 + 3 * i]);
+	  }
+	  ++ypos;
+	}
+      }
+      x = xpos;
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a widget on the VNC screen. Called by the CTK module.
+ *
+ * \param w The widget to be drawn.
+ * \param focus The focus of the widget.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  struct ctk_icon *icon;
+  unsigned char posx, posy, x, len;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      (unsigned char)(posx + win->w),
+	      (unsigned char)(posy + win->h),
+	      clipy1, clipy2,
+	      focus);
+
+  if(w->type != CTK_WIDGET_ICON) {
+    update_area((unsigned char)(posx + w->x),
+		(unsigned char)(posy + w->y), 
+		(unsigned char)(w->w + 2), 
+		w->h);
+  } else {
+    icon = (struct ctk_icon *)w;
+
+    len = strlen(icon->title);
+    x = posx + w->x;
+    if(x + len >= sizex) {
+      x = sizex - len;
+    }
+
+    update_area(x, 
+      (unsigned char)(posy + w->y), 
+      (unsigned char)(len > 4? len: 4), 
+      w->h);    
+  }
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Clear a window on the terminal screen. Called by the CTK module.
+ *
+ * \param window The window to be cleared.
+ * \param focus The focus of the window.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+
+  textcolor((unsigned char)(TERM_WINDOWCOLOR + focus));
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      cclearxy((unsigned char)(window->x + 1), i, window->w);
+    }
+  }
+
+  update_area((unsigned char)(window->x + 1),
+    (unsigned char)(window->y + 2), 
+    window->w, window->h);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a window on the terminal screen. Called by the CTK module.
+ *
+ * \param window The window to be drawn.
+ * \param focus The focus of the window.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ * \param draw_borders The flag for border drawing.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+  unsigned char i;
+  
+
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x;
+  y = window->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  if(draw_borders) {
+
+    /* Draw window frame. */  
+    textcolor((unsigned char)(TERM_WINDOWCOLOR + focus));
+
+    if(y >= clipy1) {
+      cputcxy(x, y, CH_ULCORNER);
+      for(i = wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2; i < x2; ++i) {
+	cputcxy(i, y, CH_TITLEBAR);
+      }
+      cputcxy(x2, y, CH_URCORNER);
+    }
+
+    h = window->h;
+  
+    if(clipy1 > y1) {
+      if(clipy1 - y1 < h) {
+	h = clipy1 - y1;
+	y1 = clipy1;
+      } else {
+	h = 0;
+      }
+    }
+  
+    if(clipy2 < y1 + h) {
+      if(y1 >= clipy2) {
+	h = 0;
+      } else {
+	h = clipy2 - y1;
+      }
+    }
+  
+    for(i = y1; i < y1 + h; ++i) {
+      cputcxy(x, i, CH_WINDOWLBORDER);
+      cputcxy(x2, i, CH_WINDOWRBORDER);
+    }
+
+    if(y2 >= clipy1 &&
+       y2 < clipy2) {
+      cputcxy(x, y2, CH_LLCORNER);
+      for(i = x1; i < x2; ++i) {
+	cputcxy(i, y2, CH_WINDOWLOWERBORDER);
+      }
+      cputcxy(x2, y2, CH_LRCORNER);
+    }
+  }
+
+  draw_window_contents(window, focus, clipy1, clipy2,
+		       x1, x2, (unsigned char)(y + 1), y2);
+
+  update_area(window->x, window->y, 
+    (unsigned char)(window->w + 2), 
+    (unsigned char)(window->h + 2));
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a dialog on the terminal screen. Called by the CTK module.
+ *
+ * \param dialog The dialog to be drawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+
+  textcolor(TERM_WINDOWCOLOR + CTK_FOCUS_DIALOG);
+
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  for(i = y1; i < y1 + dialog->h; ++i) {
+    cputcxy(x, i, CH_DIALOGLBORDER);
+    cputcxy(x2, i, CH_DIALOGRBORDER);
+  }
+  
+  for(i = x1; i < x2; ++i) {
+    cputcxy(i, y, CH_DIALOGUPPERBORDER);
+    cputcxy(i, y2, CH_DIALOGLOWERBORDER);
+  }
+
+  cputcxy(x, y, CH_DIALOG_ULCORNER);
+  cputcxy(x, y2, CH_DIALOG_LLCORNER);
+  cputcxy(x2, y, CH_DIALOG_URCORNER);
+  cputcxy(x2, y2, CH_DIALOG_LRCORNER);
+  
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
+		       x1, x2, y1, y2);
+
+  update_area(dialog->x, dialog->y, 
+    (unsigned char)(dialog->w + 4), 
+    (unsigned char)(dialog->h + 4));
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Clear parts of the terminal desktop. Called by the CTK module.
+ *
+ * \param y1 The lower y coordinate bound.
+ * \param y2 The upped y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+
+  textcolor(TERM_BACKGROUNDCOLOR);
+  for(i = y1; i < y2; ++i) {
+    cclearxy(0, i, sizex);
+  }
+
+  update_area(0, y1, sizex, (unsigned char)(y2 - y1));
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Draw one menu on the termainl desktop.
+ *
+ * \param m The CTK menu to be drawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+
+  textcolor(TERM_MENUCOLOR);
+  x = wherex();
+  cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > sizex) {
+    x = sizex - CTK_CONF_MENUWIDTH;
+  }
+  
+  
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      textcolor(TERM_ACTIVEMENUCOLOR);
+      revers(0);
+    } else {
+      textcolor(TERM_MENUCOLOR);	  
+    }
+    gotoxy(x, (unsigned char)(y + 1));
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      cputs(m->items[y].title);
+    }
+    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear((unsigned char)(x + CTK_CONF_MENUWIDTH - wherex()));
+    }
+    revers(1);
+  }
+  
+  gotoxy(x2, 0);
+  textcolor(TERM_MENUCOLOR);  
+
+  update_area(x, 0, CTK_CONF_MENUWIDTH, (unsigned char)(m->nitems + 1));
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw the menus on the terminal desktop. Called by the CTK module.
+ *
+ * \param menus The CTK menubar.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+
+  
+  /* Draw menus */
+  textcolor(TERM_MENUCOLOR);
+  gotoxy(0, 0);
+  revers(1);
+  cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      update_area(wherex(), 0, (unsigned char)(strlen(m->title) + 1), 1);
+      cputs(m->title);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+
+  if(wherex() + strlen(menus->desktopmenu->title) + 1>= sizex) {
+    gotoxy((unsigned char)(sizex - strlen(menus->desktopmenu->title) - 1), 0);
+  } else {
+    cclear((unsigned char)(sizex - wherex() - strlen(menus->desktopmenu->title) - 1));
+    update_area(wherex(), 0, 
+      (unsigned char)(sizex - wherex() -strlen(menus->desktopmenu->title) - 1), 
+      1);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    update_area(wherex(), 0, (unsigned char)(strlen(menus->desktopmenu->title) + 1), 1);
+    cputs(menus->desktopmenu->title);
+    cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  revers(0);
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Obtain the height of the terminal desktop. Called by the CTK module.
+ *
+ * \return The height of the terminal desktop, in characters.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return sizey;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Obtain the height of the terminal desktop. Called by the CTK module.
+ *
+ * \return The height of the terminal desktop, in characters.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return sizex;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Draws a character on the virtual screen. Called by the libconio module.
+ *
+ * \param c The character to be drawn.
+ * \param xpos The x position of the character.
+ * \param ypos The y position of the character.
+ * \param reversedflag Determines if the character should be reversed or not.
+ * \param color The color of the character.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_arch_draw_char(char c,
+		   unsigned char xpos,
+		   unsigned char ypos,
+		   unsigned char reversedflag,
+		   unsigned char color)
+{
+  /* Check if out of bounds */
+  if (xpos >= sizex || ypos >= sizey) {
+    return;
+  }
+  ctk_term_out_update_screen(xpos,ypos, (unsigned char)(c & 0x7f), color);
+}
diff --git a/contiki/ctk/ctk-term.h b/contiki/ctk/ctk-term.h
new file mode 100644
index 0000000..e3bebd5
--- /dev/null
+++ b/contiki/ctk/ctk-term.h
@@ -0,0 +1,14 @@
+#ifndef __CTK_TERM_H__
+#define __CTK_TERM_H__
+
+struct ctk_term_state* ctk_term_alloc_state(void);
+void ctk_term_dealloc_state(struct ctk_term_state *s);
+void ctk_term_redraw(struct ctk_term_state *s);
+void ctk_term_sent(struct ctk_term_state* ts);
+unsigned short ctk_term_send(struct ctk_term_state* ts, 
+				 unsigned char* buf, 
+				 unsigned short maxlen);
+
+void ctk_term_input(struct ctk_term_state* ts, unsigned char b);
+
+#endif /* __CTK_TERM_H__ */
diff --git a/contiki/ctk/ctk-termarch.h b/contiki/ctk/ctk-termarch.h
new file mode 100644
index 0000000..317bbf6
--- /dev/null
+++ b/contiki/ctk/ctk-termarch.h
@@ -0,0 +1,26 @@
+#ifndef __CTK_TERMARCH_H__
+#define __CTK_TERMARCH_H__
+
+
+typedef char ctk_arch_key_t;
+
+unsigned char ctk_arch_keyavail(void);
+ctk_arch_key_t ctk_arch_getkey(void);
+
+#define CH_ENTER 0x0d
+#define CH_DEL 0x08
+
+#define CH_TAB  0x09
+
+#define CH_CURS_LEFT  0x11
+#define CH_CURS_UP    0x12
+#define CH_CURS_RIGHT 0x13
+#define CH_CURS_DOWN  0x14
+
+
+#define CH_F1 0x15
+#define CH_F2 0x16
+#define CH_F3 0x17
+#define CH_F4 0x18
+
+#endif /* __CTK_TERMARCH_H__ */
diff --git a/contiki/ctk/ctk-termserial.c b/contiki/ctk/ctk-termserial.c
new file mode 100644
index 0000000..2246f68
--- /dev/null
+++ b/contiki/ctk/ctk-termserial.c
@@ -0,0 +1,78 @@
+#include "contiki.h"
+#include "loader.h"
+#include "ctk-term.h"
+#include "serial32.h"
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * #defines and enums
+ */
+/*-----------------------------------------------------------------------------------*/
+#define SIO_POLL(c)  (SerialRead(&c) == 1)
+#define SIO_SEND(c)  SerialWrite(c)
+#define SIO_INIT     SerialOpenPort("COM1")
+
+#ifdef CTK_TERM_CONF_SERIAL_BUFFER_SIZE
+#define OUTPUT_BUFFER_SIZE CTK_TERM_CONF_SERIAL_BUFFER_SIZE
+#else
+#define OUTPUT_BUFFER_SIZE 200
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Local variables
+ */
+/*-----------------------------------------------------------------------------------*/
+static ek_id_t id = EK_ID_NONE;
+
+static struct ctk_term_state* termstate;
+static unsigned char outbuffer[OUTPUT_BUFFER_SIZE];
+
+EK_POLLHANDLER(pollhandler);
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "CTK serial server", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, NULL);
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Idle function
+ */
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  unsigned char c;
+  unsigned short len;
+  while(SIO_POLL(c)) {
+    ctk_term_input(termstate, c);
+  }
+
+  len = ctk_term_send(termstate, outbuffer, OUTPUT_BUFFER_SIZE);
+  if (len > 0) {
+    unsigned short i;
+    for (i=0; i < len; ++i) {
+      SIO_SEND(outbuffer[i]);
+    }
+    ctk_term_sent(termstate);
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Init function
+ */
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_termserial_init, arg)
+{
+  arg_free(arg);
+  SIO_INIT;
+  termstate = ctk_term_alloc_state();
+  if (termstate == NULL) return;
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+
+}
diff --git a/contiki/ctk/ctk-termserial.h b/contiki/ctk/ctk-termserial.h
new file mode 100644
index 0000000..55dcd4e
--- /dev/null
+++ b/contiki/ctk/ctk-termserial.h
@@ -0,0 +1,6 @@
+#ifndef __CTK_TERMSERIAL_H__
+#define __CTK_TERMSERIAL_H__
+
+void ctk_termserial_init(char *arg);
+
+#endif /* __CTK_TERMSERIAL_H__ */
diff --git a/contiki/ctk/ctk-termtelnet.c b/contiki/ctk/ctk-termtelnet.c
new file mode 100644
index 0000000..6531de0
--- /dev/null
+++ b/contiki/ctk/ctk-termtelnet.c
@@ -0,0 +1,620 @@
+#include "contiki.h"
+#include "loader.h"
+#include "memb.h"
+#include "ctk-term.h"
+#include "ctk-term-conf.h"
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * #defines and enums
+ */
+/*-----------------------------------------------------------------------------------*/
+/* Telnet special characters */
+#define TN_NULL   0
+#define TN_BL    7
+#define TN_BS     8
+#define TN_HT     9
+#define TN_LF    10
+#define TN_VT    11
+#define TN_FF    12
+#define TN_CR    13
+
+/* Commands preceeded by TN_IAC */
+#define TN_SE   240
+#define TN_NOP  241
+#define TN_DM   242
+#define TN_BRK  243
+#define TN_IP   244
+#define TN_AO   245
+#define TN_AYT  246
+#define TN_EC   247
+#define TN_EL   248
+#define TN_GA   249
+#define TN_SB   250
+#define TN_WILL 251
+#define TN_WONT 252
+#define TN_DO   253
+#define TN_DONT 254
+#define TN_IAC  255
+
+#define TNO_BIN   0
+#define TNO_ECHO  1
+#define TNO_SGA   3
+#define TNO_NAWS 31
+
+/* Telnet parsing states */
+enum { 
+  TNS_IDLE, 
+  TNS_IAC, 
+  TNS_OPT, 
+  TNS_SB, 
+  TNS_SBIAC 
+};
+
+/* Telnet option negotiation states */
+enum { 
+  TNOS_NO, 
+  TNOS_WANTNO_EMPTY, 
+  TNOS_WANTNO_OPPOSITE, 
+  TNOS_WANTYES_EMPTY, 
+  TNOS_WANTYES_OPPOSITE, 
+  TNOS_YES 
+};
+
+/* Telnet session states */
+enum {
+  TTS_FREE,        /* Not allocated */
+  TTS_IDLE,        /* No data to send and nothing sent */
+  TTS_SEND_TNDATA, /* Sending telnet data */
+  TTS_SEND_APPDATA /* Sending data from upper layers */
+};
+
+/* Number of options supported (we only need ECHO(1) and SGA(3) options) */
+#define TNSM_MAX_OPTIONS 4
+
+/* Max option replies in output queue */
+#define TNQLEN 20
+
+/* Number of option buffer */
+#define OPTION_POOL_SIZE 20
+
+/* Maximum number of telnet sessions */
+#ifdef CTK_TERM_CONF_MAX_TELNET_CLIENTS
+#define NUM_CONNS CTK_TERM_CONF_MAX_TELNET_CLIENTS
+#else
+#define NUM_CONNS 1
+#endif
+
+#ifdef CTK_TERM_CONF_TELNET_PORT
+#define PORT CTK_TERM_CONF_TELNET_PORT
+#else
+#define PORT 23
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Structures
+ */
+/*-----------------------------------------------------------------------------------*/
+/* Telnet option state structure */
+struct TNOption {
+  unsigned char state;
+  unsigned char wants;
+};
+
+/* Telnet handling state structure */
+struct TNSMState
+{
+  struct TNOption myOpt[TNSM_MAX_OPTIONS];
+  struct TNOption hisOpt[TNSM_MAX_OPTIONS];
+  unsigned char cmd;
+  unsigned char state;
+};
+
+/* Telnet session state */
+struct telnet_state
+{
+  unsigned char state;
+  unsigned char* sendq[TNQLEN];
+  struct TNSMState tnsm;
+  struct ctk_term_state* termstate;
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Local variables
+ */
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_UIPCALL(ctk_termtelnet_appcall, state);*/
+static void ctk_termtelnet_appcall(void *state);
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "CTK telnet server", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+/*static struct dispatcher_proc p =
+  {DISPATCHER_PROC("CTK telnet server", NULL, NULL,
+  ctk_termtelnet_appcall)};*/
+
+static ek_id_t id = EK_ID_NONE;
+
+/* Option negotiation buffer pool */
+MEMB(telnetbuf, 3, OPTION_POOL_SIZE);
+
+static int i,j;
+static struct telnet_state states[NUM_CONNS];
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Send an option reply on a connection
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+Reply(struct telnet_state* tns, unsigned char cmd, unsigned char opt)
+{
+  unsigned char* buf = (unsigned char*)memb_alloc(&telnetbuf);
+  if (buf != 0) {
+    buf[0]=TN_IAC;
+    buf[1]=cmd;
+    buf[2]=opt;
+    for (i=0; i < TNQLEN; i++) {
+      if (tns->sendq[i] == 0) {
+	tns->sendq[i] = buf;
+	return;
+      }
+    }
+    /* Queue is full. Drop it */
+    memb_free(&telnetbuf, (char*)buf);
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Prepare for enabling one of remote side options.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+EnableHisOpt(struct telnet_state* tns, unsigned char opt)
+{
+  switch(tns->tnsm.hisOpt[opt].state) {
+  case TNOS_NO:
+    tns->tnsm.hisOpt[opt].wants = 1;
+    tns->tnsm.hisOpt[opt].state = TNOS_WANTYES_EMPTY;
+    Reply(tns, TN_DO, opt);
+    break;
+  case TNOS_WANTNO_EMPTY:
+    tns->tnsm.hisOpt[opt].state = TNOS_WANTNO_OPPOSITE;
+    break;
+  case TNOS_WANTNO_OPPOSITE:
+    break;
+  case TNOS_WANTYES_EMPTY:
+    tns->tnsm.hisOpt[opt].state = TNOS_YES;
+    break;
+  case TNOS_WANTYES_OPPOSITE:
+    tns->tnsm.hisOpt[opt].state = TNOS_WANTYES_EMPTY;
+    break;
+  case TNOS_YES:
+    break;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Prepare for enabling one of my options 
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+EnableMyOpt(struct telnet_state* tns, unsigned char opt)
+{
+  if (opt < TNSM_MAX_OPTIONS) {
+    switch(tns->tnsm.myOpt[opt].state) {
+    case TNOS_NO:
+      tns->tnsm.myOpt[opt].wants = 1;
+      tns->tnsm.myOpt[opt].state = TNOS_WANTYES_EMPTY;
+      Reply(tns, TN_WILL, opt);
+      break;
+    case TNOS_WANTNO_EMPTY:
+      tns->tnsm.myOpt[opt].state = TNOS_WANTNO_OPPOSITE;
+      break;
+    case TNOS_WANTNO_OPPOSITE:
+      break;
+    case TNOS_WANTYES_EMPTY:
+      tns->tnsm.myOpt[opt].state = TNOS_YES;
+      break;
+    case TNOS_WANTYES_OPPOSITE:
+      tns->tnsm.myOpt[opt].state = TNOS_WANTYES_EMPTY;
+      break;
+    case TNOS_YES:
+      break;
+    }
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Implementation of option negotiation using the Q-method 
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+HandleCommand(struct telnet_state* tns, unsigned char cmd, unsigned char opt)
+{
+  if (opt < TNSM_MAX_OPTIONS) {
+    /* Handling according to RFC 1143 "Q Method" */
+    switch(cmd) {
+    case TN_WILL: 
+      switch(tns->tnsm.hisOpt[opt].state) {
+      case TNOS_NO:
+	if (tns->tnsm.hisOpt[opt].wants) {
+	  tns->tnsm.hisOpt[opt].state = TNOS_YES;
+	  Reply(tns, TN_DO, opt);
+	}
+	else {
+	  Reply(tns, TN_DONT, opt);
+	}
+	break;
+      case TNOS_WANTNO_EMPTY:
+	tns->tnsm.hisOpt[opt].state = TNOS_NO;
+	break;
+      case TNOS_WANTNO_OPPOSITE:
+	tns->tnsm.hisOpt[opt].state = TNOS_YES;
+	break;
+      case TNOS_WANTYES_EMPTY:
+	tns->tnsm.hisOpt[opt].state = TNOS_YES;
+	break;
+      case TNOS_WANTYES_OPPOSITE:
+	tns->tnsm.hisOpt[opt].state = TNOS_WANTNO_EMPTY;
+	Reply(tns, TN_DONT, opt);
+	break;
+      case TNOS_YES:
+	break;
+      }
+      break;
+      case TN_WONT:
+	switch(tns->tnsm.hisOpt[opt].state) {
+	case TNOS_NO:
+	  break;
+	case TNOS_WANTNO_EMPTY:
+	case TNOS_WANTYES_EMPTY:
+	case TNOS_WANTYES_OPPOSITE:
+	  tns->tnsm.hisOpt[opt].state = TNOS_NO;
+	  break;
+	case TNOS_WANTNO_OPPOSITE:
+	  tns->tnsm.hisOpt[opt].state = TNOS_WANTYES_EMPTY;
+	  Reply(tns, TN_DO, opt);
+	  break;
+	case TNOS_YES:
+	  tns->tnsm.hisOpt[opt].state = TNOS_NO;
+	  Reply(tns, TN_DONT, opt);
+	  break;
+	}
+	break;
+	case TN_DO:
+	  switch(tns->tnsm.myOpt[opt].state) {
+	  case TNOS_NO:
+	    if (tns->tnsm.myOpt[opt].wants) {
+	      tns->tnsm.myOpt[opt].state = TNOS_YES;
+	      Reply(tns, TN_WILL, opt);
+	    }
+	    else {
+	      Reply(tns, TN_WONT, opt);
+	    }
+	    break;
+	  case TNOS_WANTNO_EMPTY:
+	    tns->tnsm.myOpt[opt].state = TNOS_NO;
+	    break;
+	  case TNOS_WANTNO_OPPOSITE:
+	    tns->tnsm.myOpt[opt].state = TNOS_YES;
+	    break;
+	  case TNOS_WANTYES_EMPTY:
+	    tns->tnsm.myOpt[opt].state = TNOS_YES;
+	    break;
+	  case TNOS_WANTYES_OPPOSITE:
+	    tns->tnsm.myOpt[opt].state = TNOS_WANTNO_EMPTY;
+	    Reply(tns, TN_WONT, opt);
+	    break;
+	  case TNOS_YES:
+	    break;
+	  }
+	  break;
+	  case TN_DONT:
+	    switch(tns->tnsm.myOpt[opt].state) {
+	    case TNOS_NO:
+	      break;
+	    case TNOS_WANTNO_EMPTY:
+	    case TNOS_WANTYES_EMPTY:
+	    case TNOS_WANTYES_OPPOSITE:
+	      tns->tnsm.myOpt[opt].state = TNOS_NO;
+	      break;
+	    case TNOS_WANTNO_OPPOSITE:
+	      tns->tnsm.myOpt[opt].state = TNOS_WANTYES_EMPTY;
+	      Reply(tns, TN_WILL, opt);
+	      break;
+	    case TNOS_YES:
+	      tns->tnsm.myOpt[opt].state = TNOS_NO;
+	      Reply(tns, TN_WONT, opt);
+	      break;
+	    }
+	    break;
+    }
+  }
+  else {
+    switch(cmd) {
+    case TN_WILL: 
+      Reply(tns, TN_DONT, opt);
+      break;
+    case TN_WONT:
+      break;
+    case TN_DO:
+      Reply(tns, TN_WONT, opt);
+      break;
+    case TN_DONT:
+      break;
+    }
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Telnet data parsing
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char 
+parse_input(struct telnet_state* tns, unsigned char b)
+{
+  unsigned char ret = 0;
+  switch(tns->tnsm.state) {
+  case TNS_IDLE:
+    if (b == TN_IAC) tns->tnsm.state = TNS_IAC;
+    else ret = 1;
+    break;
+  case TNS_IAC:
+    switch(b) {
+    case TN_SE:
+    case TN_NOP:
+    case TN_DM:
+    case TN_BRK:
+    case TN_IP:
+    case TN_AO:
+    case TN_AYT:
+    case TN_EC:
+    case TN_EL:
+    case TN_GA:
+      tns->tnsm.state = TNS_IDLE;
+      break;
+    case TN_SB:
+      tns->tnsm.state = TNS_SB;
+      break;
+    case TN_WILL:
+    case TN_WONT:
+    case TN_DO:
+    case TN_DONT:
+      tns->tnsm.cmd = b;
+      tns->tnsm.state = TNS_OPT;
+      break;
+    case TN_IAC:
+      tns->tnsm.state = TNS_IDLE;
+      ret = 1;
+      break;
+    default:
+      /* Drop unknown IACs */
+      tns->tnsm.state = TNS_IDLE;
+      break;
+    }
+    break;
+    case TNS_OPT:
+      HandleCommand(tns, tns->tnsm.cmd, b);
+      tns->tnsm.state = TNS_IDLE;
+      break;
+    case TNS_SB:
+      if (b == TN_IAC) {
+	tns->tnsm.state = TNS_SBIAC;
+      }
+      break;
+    case TNS_SBIAC:
+      if (b == TN_IAC) {
+	tns->tnsm.state = TNS_SB;
+      }
+      else if (b == TN_SE) {
+	tns->tnsm.state = TNS_IDLE;
+      }
+      else {
+	tns->tnsm.state = TNS_IDLE;
+      }
+      break;
+  }
+  return ret;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Initialize telnet machine
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+telnet_init(struct telnet_state* tns)
+{
+  int i;
+  for (i = 0; i < TNSM_MAX_OPTIONS; i++) {
+    tns->tnsm.myOpt[i].state = TNOS_NO;
+    tns->tnsm.myOpt[i].wants = 0;
+    tns->tnsm.hisOpt[i].state = TNOS_NO;
+    tns->tnsm.hisOpt[i].wants = 0;
+  }
+  tns->tnsm.state = TNS_IDLE;
+}
+
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Allocate a telnet session structure (including terminal state)
+ */
+/*-----------------------------------------------------------------------------------*/
+static struct telnet_state*
+alloc_state()
+{
+  for (i=0; i < NUM_CONNS; i++) {
+    if (states[i].state == TTS_FREE) {
+      states[i].termstate = ctk_term_alloc_state();
+      if (states[i].termstate != NULL) {
+	for (j = 0; j < TNQLEN; j++) {
+	  states[i].sendq[j] = 0;
+	}
+	telnet_init(&states[i]);
+        states[i].state = TTS_IDLE;
+        return &(states[i]);
+      }
+    }
+  }
+  return NULL;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Free a telnet session structure (including terminal state)
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+free_state(struct telnet_state* tns)
+{
+  if (tns != NULL) {
+    ctk_term_dealloc_state(tns->termstate);
+    tns->state = TTS_FREE;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * A packet is successfully sent
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+acked(struct telnet_state* tns)
+{
+  /* Were we sending a telnet option packet? */
+  if (tns->state == TTS_SEND_TNDATA) {
+    /* Yes, free it and update queue */
+    if (tns->sendq[0] != 0) {
+      memb_free(&telnetbuf, (char*)(tns->sendq[0]));
+      for (i=1; i < TNQLEN; i++) {
+	tns->sendq[i-1] = tns->sendq[i];
+      }
+      tns->sendq[TNQLEN-1] = 0;
+      /* No options left. Go idle */
+      if (tns->sendq[0] == 0) {
+	tns->state = TTS_IDLE;
+      }
+    }
+  }
+  /* Or were we sending application date ? */
+  else if (tns->state == TTS_SEND_APPDATA) {
+    /* Inform application that data is sent successfully */
+    ctk_term_sent(tns->termstate);
+    tns->state = TTS_IDLE;
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Send data on a connections
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+senddata(struct telnet_state* tns)
+{
+  /* Check if there are any option packets to send */
+  if (tns->state == TTS_IDLE || tns->state == TTS_SEND_TNDATA) {
+    if (tns->sendq[0] != 0) {
+      tns->state = TTS_SEND_TNDATA;
+      uip_send(tns->sendq[0],3);
+    }
+  }
+  /* Check if terminal wants to send any data */
+  if (tns->state == TTS_IDLE || tns->state == TTS_SEND_APPDATA) {
+    u16_t len = ctk_term_send(tns->termstate, (unsigned char*)uip_appdata, (unsigned short)uip_mss());
+    if (len > 0) {
+      tns->state = TTS_SEND_APPDATA;
+      uip_send(uip_appdata, len);
+    }
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * uIP callback
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+ctk_termtelnet_appcall(void *state)
+{
+  struct telnet_state *tns;
+
+  tns = (struct telnet_state*)(state);
+
+  if(uip_connected()) {
+    if(tns == NULL) {
+      tns = alloc_state();
+      if(tns == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)tns);
+    }
+    /* Try to negotiate some options */
+    EnableHisOpt(tns, TNO_SGA);
+    EnableMyOpt(tns,TNO_SGA);
+    EnableMyOpt(tns,TNO_ECHO);
+    /* Request update of screen */
+    ctk_term_redraw(tns->termstate);
+    senddata(tns);
+  } else if(uip_closed() || uip_aborted()) {
+    free_state(tns);
+    return;
+  }
+
+  if (uip_acked()) {
+    acked(tns);
+  }
+
+  if (uip_newdata()) {
+    for(j = 0; j < uip_datalen(); j++) {
+      if (parse_input(tns, uip_appdata[j])) {
+	/* Pass it uppwards */
+	ctk_term_input(tns->termstate, uip_appdata[j]);
+      }
+    }
+  }
+
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata(tns);
+  } else if(uip_poll()) {
+    if (tns->state == TTS_IDLE) {
+      senddata(tns);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* 
+ * Init function
+ */
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_termtelnet_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    memb_init(&telnetbuf);
+    for (i=0; i < NUM_CONNS; i++) {
+      states[i].state = TTS_FREE;
+    }
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  if(ev == EK_EVENT_INIT) {
+    tcp_listen(HTONS(PORT));
+  } else if(ev == tcpip_event) {
+    ctk_termtelnet_appcall(data);
+  }
+}
diff --git a/contiki/ctk/ctk-termtelnet.h b/contiki/ctk/ctk-termtelnet.h
new file mode 100644
index 0000000..0c1cd5f
--- /dev/null
+++ b/contiki/ctk/ctk-termtelnet.h
@@ -0,0 +1,6 @@
+#ifndef __CTK_TERMTELNET_H__
+#define __CTK_TERMTELNET_H__
+
+void ctk_termtelnet_init(char *arg);
+
+#endif /* __CTK_TERMTELNET_H__ */
diff --git a/contiki/ctk/ctk-vncarch.h b/contiki/ctk/ctk-vncarch.h
new file mode 100644
index 0000000..6b2a480
--- /dev/null
+++ b/contiki/ctk/ctk-vncarch.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-vncarch.h,v 1.4 2004/08/09 20:24:17 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_VNCARCH_H__
+#define __CTK_VNCARCH_H__
+
+
+typedef char ctk_arch_key_t;
+
+unsigned char ctk_arch_keyavail(void);
+ctk_arch_key_t ctk_arch_getkey(void);
+
+#define CH_ENTER 0x0d
+#define CH_DEL 0x08
+
+#define CH_ESC 0x1b
+
+#define CH_HOME 0x50
+
+#define CH_TAB  0x09
+
+#define CH_CURS_LEFT  0x51
+#define CH_CURS_UP    0x52
+#define CH_CURS_RIGHT 0x53
+#define CH_CURS_DOWN  0x54
+
+
+#define CH_F1 0xbe
+#define CH_F2 0xbf
+#define CH_F3 0xc0
+#define CH_F4 0xc1
+#define CH_F5 0xc2
+#define CH_F6 0xc3
+#define CH_F7 0xc4
+
+
+
+#endif /* __CTK_VNCARCH_H__ */
diff --git a/contiki/ctk/ctk-vncfont.c b/contiki/ctk/ctk-vncfont.c
new file mode 100644
index 0000000..daa4a66
--- /dev/null
+++ b/contiki/ctk/ctk-vncfont.c
@@ -0,0 +1,1205 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC server
+ *
+ * $Id: ctk-vncfont.c,v 1.5 2004/08/09 20:25:45 adamdunkels Exp $
+ *
+ */
+
+#define _ 0x00
+#define o 0x01 /* 1001 0010 */
+#define X 0x02 /* 1111 0110 */
+
+#ifdef WITH_AVR
+#include <avr/pgmspace.h>
+#else
+#define prog_char const unsigned char
+#endif
+
+prog_char ctk_vncfont[] = {
+/* char 0 */
+X,o,_,_,_,_,
+o,X,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 1 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,X,X,o,_,_,
+_,o,o,X,_,_,
+o,X,X,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 2 */
+X,_,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+X,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 3 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,o,_,_,
+X,o,o,X,_,_,
+o,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 4 */
+_,_,_,X,_,_,
+_,_,o,X,_,_,
+o,X,X,X,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 5 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,o,_,_,
+X,o,o,X,_,_,
+X,X,X,X,_,_,
+X,o,o,_,_,_,
+o,X,X,_,_,_,
+_,_,_,_,_,_,
+/* char 6 */
+_,o,X,X,_,_,
+o,X,o,_,_,_,
+X,X,X,_,_,_,
+o,X,o,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,_,_,_,_,_,
+/* char 7 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,X,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,o,o,X,_,_,
+/* char 8 */
+X,_,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+_,_,_,_,_,_,
+/* char 9 */
+_,X,_,_,_,_,
+_,o,_,_,_,_,
+X,X,_,_,_,_,
+o,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,_,_,_,_,_,
+/* char 10 */
+_,_,X,_,_,_,
+_,_,o,_,_,_,
+_,X,X,_,_,_,
+_,o,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,o,X,_,_,_,
+/* char 11 */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,o,X,_,_,
+X,o,X,o,_,_,
+X,X,o,_,_,_,
+X,o,X,o,_,_,
+X,_,o,X,_,_,
+_,_,_,_,_,_,
+/* char 12 */
+_,X,X,_,_,_,
+_,o,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 13 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,o,X,o,
+X,o,o,X,o,X,
+X,_,_,X,_,X,
+X,_,_,X,_,X,
+X,_,_,X,_,X,
+_,_,_,_,_,_,
+/* char 14 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+_,_,_,_,_,_,
+/* char 15 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 16 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,o,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+X,X,X,o,_,_,
+X,o,_,_,_,_,
+/* char 17 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,X,_,_,
+X,o,o,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,_,o,X,_,_,
+/* char 18 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,o,X,X,_,_,
+X,X,o,_,_,_,
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 19 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+o,X,X,X,_,_,
+X,o,o,_,_,_,
+o,X,X,o,_,_,
+_,o,o,X,_,_,
+X,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 20 */
+_,_,X,_,_,_,
+_,o,X,o,_,_,
+_,X,X,X,_,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,X,o,_,_,
+_,_,o,X,_,_,
+_,_,_,_,_,_,
+/* char 21 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 22 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,o,_,o,X,_,
+o,X,o,X,o,_,
+_,X,o,X,_,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 23 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,o,_,_,o,X,
+o,X,o,X,o,X,
+o,X,o,X,o,X,
+_,o,X,o,X,o,
+_,_,X,o,X,_,
+_,_,_,_,_,_,
+/* char 24 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,o,_,o,X,_,
+o,X,o,X,o,_,
+_,o,X,o,_,_,
+o,X,o,X,o,_,
+X,o,_,o,X,_,
+_,_,_,_,_,_,
+/* char 25 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,_,_,X,_,_,
+X,o,o,X,_,_,
+o,X,X,X,_,_,
+_,o,o,X,_,_,
+/* char 26 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,_,_,
+_,o,X,o,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 27 */
+_,X,o,_,_,_,
+_,X,_,_,_,_,
+o,X,_,_,_,_,
+X,o,_,_,_,_,
+o,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,o,_,_,_,
+_,o,X,_,_,_,
+/* char 28 */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+/* char 29 */
+o,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,o,_,_,_,
+_,o,X,_,_,_,
+_,X,o,_,_,_,
+_,X,_,_,_,_,
+o,X,_,_,_,_,
+X,o,_,_,_,_,
+/* char 30 */
+o,X,X,o,X,_,
+X,o,X,X,o,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 31 */
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+_,X,X,_,_,_,
+/* char 32 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 33 */
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,o,_,_,_,_,
+_,X,_,_,_,_,
+_,_,_,_,_,_,
+/* char 34 */
+X,o,X,_,_,_,
+X,o,X,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 35 */
+X,X,X,X,X,_,
+o,X,o,X,o,_,
+X,X,X,X,X,_,
+o,X,o,X,o,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 36 */
+o,X,X,X,o,_,
+X,o,X,o,X,_,
+X,o,X,o,_,_,
+o,X,X,X,o,_,
+_,o,X,o,X,_,
+X,o,X,o,X,_,
+o,X,X,X,o,_,
+_,o,X,o,_,_,
+/* char 37 */
+o,X,X,X,X,X,
+X,o,o,X,o,o,
+X,o,o,X,o,X,
+o,X,X,o,X,X,
+_,_,o,X,X,o,
+_,o,X,o,X,o,
+o,X,o,_,o,X,
+_,_,_,_,_,_,
+/* char 38 */
+_,X,o,o,X,_,
+_,X,o,X,o,_,
+_,o,X,o,_,_,
+o,X,o,X,o,X,
+X,o,_,o,X,o,
+X,o,o,X,o,X,
+o,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 39 */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 40 */
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,o,_,_,_,_,
+o,X,o,_,_,_,
+_,o,X,_,_,_,
+/* char 41 */
+o,X,o,_,_,_,
+_,o,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,o,X,_,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+/* char 42 */
+_,X,o,X,_,_,
+_,o,X,o,_,_,
+X,X,X,X,X,_,
+_,o,X,o,_,_,
+_,X,o,X,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 43 */
+_,_,X,_,_,_,
+_,o,X,o,_,_,
+X,X,X,X,X,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 44 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,X,_,_,_,_,
+o,X,_,_,_,_,
+/* char 45 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 46 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 47 */
+_,_,o,X,_,_,
+_,_,X,o,_,_,
+_,o,X,_,_,_,
+_,X,o,_,_,_,
+o,X,_,_,_,_,
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 48 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 49 */
+_,o,X,_,_,_,
+_,X,X,_,_,_,
+_,o,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 50 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+_,_,_,o,X,_,
+_,_,o,X,o,_,
+_,o,X,o,_,_,
+o,X,o,_,_,_,
+X,X,X,X,X,_,
+_,_,_,_,_,_,
+/* char 51 */
+X,X,X,X,X,_,
+_,_,o,X,o,_,
+_,o,X,o,_,_,
+_,X,X,X,o,_,
+_,_,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 52 */
+_,_,o,X,_,_,
+_,o,X,X,_,_,
+o,X,o,X,_,_,
+X,o,o,X,o,_,
+X,X,X,X,X,_,
+_,_,o,X,o,_,
+_,_,_,X,_,_,
+_,_,_,_,_,_,
+/* char 53 */
+X,X,X,X,X,_,
+X,o,o,o,_,_,
+X,X,X,X,o,_,
+_,_,_,o,X,_,
+_,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 54 */
+_,o,X,X,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+X,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 55 */
+X,X,X,X,X,_,
+_,_,_,o,X,_,
+_,_,_,X,o,_,
+_,_,o,X,_,_,
+_,_,X,o,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 56 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 57 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,X,_,
+_,_,_,o,X,_,
+_,_,o,X,o,_,
+_,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 58 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 59 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,X,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,X,_,_,_,_,
+o,X,_,_,_,_,
+/* char 60 */
+_,_,_,_,_,_,
+_,o,X,_,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+o,X,o,_,_,_,
+_,o,X,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 61 */
+_,_,_,_,_,_,
+X,X,X,X,X,_,
+o,o,o,o,o,_,
+X,X,X,X,X,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 62 */
+_,_,_,_,_,_,
+X,o,_,_,_,_,
+o,X,o,_,_,_,
+_,o,X,_,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 63 */
+o,X,X,o,_,_,
+X,o,o,X,_,_,
+_,_,o,X,_,_,
+_,o,X,o,_,_,
+_,X,o,_,_,_,
+_,o,_,_,_,_,
+_,X,_,_,_,_,
+_,_,_,_,_,_,
+/* char 64 */
+_,o,X,X,X,o,
+o,X,o,o,o,X,
+X,o,o,X,X,o,
+X,o,X,o,X,_,
+X,o,X,o,X,o,
+X,o,o,X,X,X,
+o,X,o,o,o,_,
+_,o,X,X,X,_,
+/* char 65 */
+_,_,X,_,_,_,
+_,o,X,o,_,_,
+_,X,o,X,_,_,
+o,X,o,X,o,_,
+X,X,X,X,X,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+_,_,_,_,_,_,
+/* char 66 */
+X,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+X,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+X,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 67 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 68 */
+X,X,X,o,_,_,
+X,o,o,X,o,_,
+X,_,_,o,X,_,
+X,_,_,_,X,_,
+X,_,_,o,X,_,
+X,o,o,X,o,_,
+X,X,X,o,_,_,
+_,_,_,_,_,_,
+/* char 69 */
+X,X,X,X,_,_,
+X,o,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,_,_,_,
+X,o,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 70 */
+X,X,X,X,_,_,
+X,o,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,_,_,_,
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 71 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,o,_,
+X,_,_,X,X,_,
+X,_,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 72 */
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+X,X,X,X,X,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+_,_,_,_,_,_,
+/* char 73 */
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 74 */
+_,_,_,_,X,_,
+_,_,_,_,X,_,
+_,_,_,_,X,_,
+_,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 75 */
+X,_,_,o,X,_,
+X,_,o,X,o,_,
+X,o,X,o,_,_,
+X,X,o,_,_,_,
+X,o,X,o,_,_,
+X,_,o,X,o,_,
+X,_,_,o,X,_,
+_,_,_,_,_,_,
+/* char 76 */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 77 */
+X,o,_,_,o,X,
+X,X,o,_,o,X,
+X,o,X,o,X,X,
+X,_,o,X,o,X,
+X,_,_,_,_,X,
+X,_,_,_,_,X,
+X,_,_,_,_,X,
+_,_,_,_,_,_,
+/* char 78 */
+X,X,_,_,X,_,
+X,X,o,_,X,_,
+X,o,X,o,X,_,
+X,o,X,o,X,_,
+X,_,o,X,X,_,
+X,_,_,X,X,_,
+X,_,_,o,X,_,
+_,_,_,_,_,_,
+/* char 79 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 80 */
+X,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+X,X,X,X,o,_,
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 81 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,X,o,X,_,
+o,X,X,X,o,_,
+_,_,o,X,_,_,
+/* char 82 */
+X,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,o,X,_,
+X,X,X,X,o,_,
+X,o,X,o,_,_,
+X,_,o,X,o,_,
+X,_,_,o,X,_,
+_,_,_,_,_,_,
+/* char 83 */
+o,X,X,X,o,_,
+X,o,_,o,X,_,
+X,o,_,_,_,_,
+o,X,X,X,o,_,
+_,_,_,o,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 84 */
+X,X,X,X,X,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 85 */
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,X,X,o,_,
+_,_,_,_,_,_,
+/* char 86 */
+X,_,_,_,X,_,
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,o,X,o,_,
+_,X,o,X,_,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 87 */
+X,_,_,_,_,X,
+X,o,_,_,_,X,
+o,X,o,X,o,X,
+o,X,o,X,o,X,
+_,o,X,o,X,o,
+_,_,X,o,X,_,
+_,_,X,o,X,_,
+_,_,_,_,_,_,
+/* char 88 */
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,o,X,o,_,
+_,o,X,o,_,_,
+o,X,o,X,o,_,
+X,o,_,o,X,_,
+X,_,_,_,X,_,
+_,_,_,_,_,_,
+/* char 89 */
+X,_,_,_,X,_,
+X,o,_,o,X,_,
+o,X,o,X,o,_,
+_,o,X,o,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,_,_,_,_,
+/* char 90 */
+X,X,X,X,_,_,
+_,_,o,X,_,_,
+_,o,X,o,_,_,
+o,X,o,_,_,_,
+X,o,_,_,_,_,
+X,o,_,_,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+/* char 91 */
+X,o,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,o,_,_,_,_,
+X,X,_,_,_,_,
+/* char 92 */
+X,o,_,_,_,_,
+o,X,_,_,_,_,
+_,X,o,_,_,_,
+_,o,X,_,_,_,
+_,_,X,o,_,_,
+_,_,o,X,_,_,
+_,_,_,X,_,_,
+_,_,_,_,_,_,
+/* char 93 */
+o,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+_,X,_,_,_,_,
+o,X,_,_,_,_,
+X,X,_,_,_,_,
+/* char 94 */
+o,X,o,_,_,_,
+X,o,X,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* char 95 */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+
+
+
+
+  
+/* Char 0x60 '`' */
+X,3,3,3,3,3,
+X,4,4,4,4,4,
+X,3,3,3,3,3,
+X,4,4,4,4,4,
+X,3,3,3,3,3,
+X,4,4,4,4,4,
+X,3,3,3,3,3,
+X,5,5,5,5,5,
+/* Char 0x61 'a' */
+3,3,3,3,3,3,
+4,4,4,4,4,4,
+3,3,3,3,3,3,
+4,4,4,4,4,4,
+3,3,3,3,3,3,
+4,4,4,4,4,4,
+3,3,3,3,3,3,
+5,5,5,5,5,5,
+/* Char 0x62 'b' */
+3,3,3,3,3,X,
+4,4,4,4,4,X,
+3,3,3,3,3,X,
+4,4,4,4,4,X,
+3,3,3,3,3,X,
+4,4,4,4,4,X,
+3,3,3,3,3,X,
+5,5,5,5,5,X,
+/* Char 0x63 'c' */
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+/* Char 0x64 'd' */
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+_,_,_,_,5,X,
+5,5,5,5,5,X,
+X,X,X,X,X,X,
+/* Char 0x65 'e' */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+5,5,5,5,5,5,
+X,X,X,X,X,X,
+/* Char 0x66 'f' */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,5,5,5,5,5,
+X,X,X,X,X,X,
+/* Char 0x67 'g' */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+/* Char 0x68 'h' */
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+_,_,X,_,_,_,
+/* Char 0x69 'i' */
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x6a 'j' */
+X,X,X,X,X,X,
+_,_,_,_,_,X,
+X,X,X,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+/* Char 0x6b 'k' */
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+/* Char 0x6c 'l' */
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+_,_,_,X,_,X,
+X,X,X,X,_,X,
+_,_,_,_,_,X,
+X,X,X,X,X,X,
+/* Char 0x6d 'm' */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+/* Char 0x6e 'n' */
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,X,X,X,
+X,_,_,_,_,_,
+X,X,X,X,X,X,
+/* Char 0x6f 'o' */
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+/* Char 0x70 'p' */
+5,5,5,5,5,5,
+5,6,6,6,6,_,
+5,6,_,_,_,_,
+5,6,_,_,_,_,
+5,6,_,_,_,_,
+5,6,_,_,_,_,
+5,6,_,_,_,_,
+5,_,_,_,_,_,
+/* Char 0x71 'q' */
+_,_,_,_,_,4,
+_,_,_,_,3,4,
+_,_,_,_,3,4,
+_,_,_,_,3,4,
+_,_,_,_,3,4,
+_,_,_,_,3,4,
+_,3,3,3,3,4,
+4,4,4,4,4,4,
+/* Char 0x72 'r' */
+X,X,X,X,X,X,
+X,_,_,_,_,_,
+X,_,X,X,X,X,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+X,_,X,_,_,_,
+/* Char 0x73 's' */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x74 't' */
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+X,_,_,_,_,_,
+/* Char 0x75 'u' */
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+X,X,_,_,_,_,
+/* Char 0x76 'v' */
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+_,_,_,_,X,X,
+/* Char 0x77 'w' */
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x78 'x' */
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x79 'y' */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+X,X,X,X,X,X,
+/* Char 0x7a 'z' */
+_,_,_,_,_,_,
+_,_,_,_,o,X,
+_,_,_,o,X,X,
+X,X,o,X,X,o,
+X,X,X,X,o,_,
+X,X,X,o,_,_,
+X,X,o,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x7b '{' */
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+/* Char 0x7c '|' */
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x7d '}' */
+_,_,X,X,_,_,
+_,_,X,X,_,_,
+_,o,X,X,_,_,
+X,X,X,X,_,_,
+X,X,X,X,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x7e '~' */
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+_,_,_,_,_,_,
+/* Char 0x7f '?' */
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+X,X,X,_,_,_,
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+_,_,_,X,X,X,
+
+};
diff --git a/contiki/ctk/ctk-vncfont.h b/contiki/ctk/ctk-vncfont.h
new file mode 100644
index 0000000..e39127f
--- /dev/null
+++ b/contiki/ctk/ctk-vncfont.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC server
+ *
+ * $Id: ctk-vncfont.h,v 1.4 2004/08/09 20:26:06 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_VNCFONT_H__
+#define __CTK_VNCFONT_H__
+
+#define CTK_VNCFONT_WIDTH 6
+#define CTK_VNCFONT_HEIGHT 8
+
+
+extern unsigned char ctk_vncfont[CTK_VNCFONT_WIDTH *
+				 CTK_VNCFONT_HEIGHT *
+				 128];
+
+#endif /* __CTK_VNCFONT_H__ */
diff --git a/contiki/ctk/ctk-vncserver.c b/contiki/ctk/ctk-vncserver.c
new file mode 100644
index 0000000..74ba31f
--- /dev/null
+++ b/contiki/ctk/ctk-vncserver.c
@@ -0,0 +1,1112 @@
+/**
+ * \file
+ * The ctk-draw implementation for the CTK VNC server.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/**
+ * \defgroup CTKVNCServer The CTK VNC server
+ * @{
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-vncserver.c,v 1.17 2006/05/28 20:38:19 oliverschmidt Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "contiki.h"
+
+#include "ek.h"
+#include "loader.h"
+#include "vnc-server.h"
+#include "vnc-out.h"
+
+#include "ctk-vncfont.h"
+#include "ctk-vncserver.h"
+#include "ctk-vncserver-conf.h"
+
+static unsigned char sizex, sizey;
+
+#define CH_ULCORNER 0x00
+#define CH_TITLEBAR 0x01
+#define CH_URCORNER 0x02
+#define CH_WINDOWRBORDER 0x03
+#define CH_LRCORNER 0x04
+#define CH_WINDOWLOWERBORDER 0x05
+#define CH_LLCORNER 0x06
+#define CH_WINDOWLBORDER 0x07
+
+#define CH_DIALOG_ULCORNER 0x12
+#define CH_DIALOGUPPERBORDER 0x09
+#define CH_DIALOG_URCORNER 0x0a
+#define CH_DIALOGRBORDER 0x0b
+#define CH_DIALOG_LRCORNER 0x0c
+#define CH_DIALOGLOWERBORDER 0x0d
+#define CH_DIALOG_LLCORNER 0x0e
+#define CH_DIALOGLBORDER 0x0f
+
+#define CH_BUTTONLEFT  0x10
+#define CH_BUTTONRIGHT 0x11
+
+#define CH_SEPARATOR   0x13
+
+#include "libconio.h"
+
+#define SCREENCOLOR         0
+#define BORDERCOLOR         1
+
+#define WIDGETCOLOR         2
+#define WIDGETCOLOR_FWIN    3
+#define WIDGETCOLOR_FOCUS   4
+#define WIDGETCOLOR_DIALOG  5
+#define WIDGETCOLOR_HLINK   6
+#define WIDGETCOLOR_HLINK_FOCUS   7
+
+#define WINDOWCOLOR         8
+#define WINDOWCOLOR_FOCUS   9
+
+#define WINDOWBORDER        10
+#define WINDOWBORDER_FOCUS  11
+
+#define DIALOGCOLOR         12
+
+#define OPENMENUCOLOR       13
+
+#define ACTIVEMENUITEMCOLOR 14
+
+#define MENUCOLOR           15
+
+/*static DISPATCHER_UIPCALL(ctk_vncserver_appcall, state);
+
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("CTK VNC server", NULL, NULL,
+		   ctk_vncserver_appcall)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "CTK VNC server", EK_PRIO_NORMAL,
+	   eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static struct vnc_server_state conns[CTK_VNCSERVER_CONF_NUMCONNS];
+
+#define PRINTF(x) 
+
+#define revers(x)
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Add an update request from a client to the list of pending updates
+ * for the connection.
+ *
+ * This function is called from the vnc-out module.
+ *
+ * \param vs The VNC connection state.
+ * \param a The area that is requested to be updated.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_update_add(struct vnc_server_state *vs,
+		      struct vnc_server_update *a)
+{
+  /* XXX: test both head and tail placement!*/
+  a->next = vs->updates_pending;
+  vs->updates_pending = a;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Allocate an update request from the VNC connection state.
+ *
+ * This function is called from the vnc-out module.
+ *
+ * \param vs The VNC connection state.
+ *
+ * \return Memory for an update structure, or NULL if no update could
+ * be allocated.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct vnc_server_update *
+vnc_server_update_alloc(struct vnc_server_state *vs)
+{
+  struct vnc_server_update *a;
+
+  a = vs->updates_free;
+  if(a == NULL) {
+    return NULL;
+  }
+  vs->updates_free = a->next;
+  a->next = NULL;
+  return a;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Deallocate an update request from the VNC connection state.
+ *
+ * This function is called from the vnc-out module.
+ *
+ * \param vs The VNC connection state.
+ *
+ * \param a The update structure to be deallocated.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_update_free(struct vnc_server_state *vs,
+		       struct vnc_server_update *a)
+{
+  a->next = vs->updates_free;
+  vs->updates_free = a;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Dequeue the first update on the queue of updates.
+ *
+ * This function is called from the vnc-out module.
+ *
+ * \param vs The VNC connection state.
+ *
+ * \return The first update on the queue, or NULL if the queue is empty.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct vnc_server_update *
+vnc_server_update_dequeue(struct vnc_server_state *vs)
+{
+  struct vnc_server_update *a;
+
+  a = vs->updates_pending;
+  if(a == NULL) {
+    return a;
+  }
+  vs->updates_pending = a->next;
+  a->next = NULL;
+  return a;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Remove a specific update on the queue of updates.
+ *
+ * \param vs The VNC connection state.
+ * \param a The update to be removed.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_update_remove(struct vnc_server_state *vs,
+			 struct vnc_server_update *a)
+{
+  struct vnc_server_update *b, *c;
+
+  if(a == vs->updates_pending) {
+    vs->updates_pending = a->next;
+  } else {
+    b = vs->updates_pending;
+    for(c = vs->updates_pending; c != a; b = c, c = c->next);
+
+    b->next = a->next;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Flag an area to be updated for all open VNC server connections.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+update_area(u8_t x, u8_t y, u8_t w, u8_t h)
+{
+  u8_t i;
+  
+  if(h == 0 || w == 0) {
+    return;
+  }
+  
+  /* Update for all active VNC connections. */
+  for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) {
+    if(conns[i].state != VNC_DEALLOCATED) {
+      vnc_out_update_area(&conns[i],
+			  x, y, w, h);
+    }
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Allocate a VNC server connection state from the array of available
+ * VNC connection states.
+ */
+/*-----------------------------------------------------------------------------------*/
+static struct vnc_server_state *
+alloc_state(void)
+{
+  u8_t i;
+  for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) {
+    if(conns[i].state == VNC_DEALLOCATED) {
+      return &conns[i];
+    }
+  }
+
+  /* We are overloaded! XXX: we'll just kick all other connections! */
+  for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) {
+    conns[i].state = VNC_DEALLOCATED;
+  }
+  
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Deallocate a VNC connection state.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+dealloc_state(struct vnc_server_state *s)
+{
+  s->state = VNC_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+cputsn(char *str, unsigned char len)
+{
+  char c;
+
+  while(len > 0) {
+    --len;
+    c = *str;
+    if(c == 0) {
+      break;
+    }
+    cputc(c);
+    ++str;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Initialize the VNC ctk-draw module. Called by the CTK module.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  bgcolor(SCREENCOLOR);
+  bordercolor(BORDERCOLOR);
+  screensize(&sizex, &sizey);
+  ctk_draw_clear(0, sizey);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  unsigned char iconnum;
+  char c, *text;
+  unsigned char len;
+
+  /*
+  if(focus & CTK_FOCUS_WINDOW) {    
+    textcolor(WIDGETCOLOR_FWIN);
+    if(focus & CTK_FOCUS_WIDGET) {
+      textcolor(WIDGETCOLOR_FOCUS);
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    textcolor(WIDGETCOLOR_DIALOG);
+    if(focus & CTK_FOCUS_WIDGET) {
+      textcolor(WIDGETCOLOR_FOCUS);
+    }
+  } else {
+    textcolor(WIDGETCOLOR);
+  }
+*/  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    textcolor(VNC_OUT_SEPARATORCOLOR + focus);
+    if(ypos >= clipy1 && ypos < clipy2) {
+      /*      chlinexy(xpos, ypos, w->w);*/
+      gotoxy(xpos, ypos);
+      for(i = 0; i < w->w; ++i) {
+	cputc(CH_SEPARATOR);
+      }
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    textcolor(VNC_OUT_LABELCOLOR + focus);
+    text = w->widget.label.text;
+    for(i = 0; i < w->h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	gotoxy(xpos, ypos);
+	cputsn(text, w->w);
+	if(w->w - (wherex() - xpos) > 0) {
+	  cclear(w->w - (wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    textcolor(VNC_OUT_BUTTONCOLOR + focus);
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(focus & CTK_FOCUS_WIDGET) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      cputcxy(xpos, ypos, CH_BUTTONLEFT);
+      cputsn(w->widget.button.text, w->w);
+      cputc(CH_BUTTONRIGHT);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    textcolor(VNC_OUT_HYPERLINKCOLOR + focus);
+    if(ypos >= clipy1 && ypos < clipy2) {
+      /*      if(focus & CTK_FOCUS_WIDGET) {
+	textcolor(WIDGETCOLOR_HLINK_FOCUS);
+	revers(0);	
+      } else {
+	textcolor(WIDGETCOLOR_HLINK);
+	revers(1);
+	}*/
+      gotoxy(xpos, ypos);
+      cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    textcolor(VNC_OUT_TEXTENTRYCOLOR + focus);
+    text = w->widget.textentry.text;
+    xscroll = 0;
+    if(w->widget.textentry.xpos >= w->w - 1) {
+      xscroll = w->widget.textentry.xpos - w->w + 1;
+    }
+    for(j = 0; j < w->h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  revers(0);
+	  cputcxy(xpos, ypos, '>');
+	  c = 1;
+	  for(i = 0; i < w->w; ++i) {
+	    if(c != 0) {
+	      c = text[i + xscroll];
+	    }
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      textcolor(VNC_OUT_TEXTENTRYCOLOR + (focus ^ 0x01));
+	      revers(1);
+	    } else {
+	      revers(0);
+	    }
+	    if(c == 0) {
+	      cputc(' ');
+	    } else {
+	      cputc(c);
+	    }
+	    revers(0);
+	    textcolor(VNC_OUT_TEXTENTRYCOLOR + focus);
+	  }
+	  cputc('<');
+	} else {
+	  if(focus & CTK_FOCUS_WIDGET && j == w->widget.textentry.ypos) {
+	    revers(1);
+	  } else {
+	    revers(0);
+	  }
+	  cvlinexy(xpos, ypos, 1);
+	  gotoxy(xpos + 1, ypos);          
+	  cputsn(text, w->w);
+	  i = wherex();
+	  if(i - xpos - 1 < w->w) {
+	    cclear(w->w - (i - xpos) + 1);
+	  }
+	  cvline(1);
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len + 1;
+    }
+    revers(0);
+    break;
+#if CTK_CONF_ICONS
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      textcolor(VNC_OUT_ICONCOLOR + focus);
+      if(focus & 1) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+
+      x = xpos;
+      len = strlen(w->widget.icon.title);
+      if(x + len >= sizex) {
+	x = sizex - len;
+      }
+
+      gotoxy(x, ypos + 3);
+      if(ypos >= clipy1 && ypos < clipy2) {
+	cputs(w->widget.icon.title);
+      }
+
+#if CTK_CONF_ICON_BITMAPS
+      if(w->widget.icon.bitmap != NULL) {
+	iconnum = vnc_out_add_icon((struct ctk_icon *)w);
+	textcolor(iconnum | (focus << 6));
+	gotoxy(xpos, ypos);
+	cputc(0x80);
+	cputc(0x81);
+	cputc(0x82);
+	cputc(0x83);
+	++ypos;
+	gotoxy(xpos, ypos);
+	cputc(0x90);
+	cputc(0x91);
+	cputc(0x92);
+	cputc(0x93);
+	++ypos;
+	gotoxy(xpos, ypos);
+	cputc(0xa0);
+	cputc(0xa1);
+	cputc(0xa2);
+	cputc(0xa3);
+	++ypos;
+	textcolor(0);
+	/*	for(i = 0; i < 3; ++i) {
+
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    cputc(w->widget.icon.textmap[0 + 3 * i]);
+	    cputc(w->widget.icon.textmap[1 + 3 * i]);
+	    cputc(w->widget.icon.textmap[2 + 3 * i]);
+	  }
+	  ++ypos;
+	  }*/
+      }
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+      revers(0);
+    }
+    break;
+#endif /* CTK_CONF_ICONS */
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a widget on the VNC screen. Called by the CTK module.
+ *
+ * \param w The widget to be drawn.
+ * \param focus The focus of the widget.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  struct ctk_icon *icon;
+  unsigned char posx, posy, x, len;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+
+  if(w->type != CTK_WIDGET_ICON) {
+    update_area(posx + w->x,
+		posy + w->y, w->w + 2, w->h);
+  } else {
+    icon = (struct ctk_icon *)w;
+
+    len = strlen(icon->title);
+    x = posx + w->x;
+    if(x + len >= sizex) {
+      x = sizex - len;
+    }
+
+    update_area(x, posy + w->y, len > 4? len: 4, w->h);    
+  }
+  
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Clear a window on the VNC screen. Called by the CTK module.
+ *
+ * \param window The window to be cleared.
+ * \param focus The focus of the window.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+  /*
+  if(focus & CTK_FOCUS_WINDOW){
+    textcolor(WINDOWCOLOR_FOCUS);
+  } else {
+    textcolor(WINDOWCOLOR);
+    }*/
+  textcolor(VNC_OUT_WINDOWCOLOR + focus);
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      cclearxy(window->x + 1, i, window->w);
+    }
+  }
+
+  update_area(window->x + 1, window->y + 2, window->w, window->h);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+		     unsigned char clipy1, unsigned char clipy2,
+		     unsigned char x1, unsigned char x2,
+		     unsigned char y1, unsigned char y2)
+{
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  
+  /* Draw inactive widgets. */
+  for(w = window->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		clipy1, clipy2,
+		focus);
+  }
+  
+  /* Draw active widgets. */
+  for(w = window->active; w != NULL; w = w->next) {  
+    wfocus = focus;
+    if(w == window->focused) {
+      wfocus |= CTK_FOCUS_WIDGET;
+    }
+
+   draw_widget(w, x1, y1, x2, y2, 
+	       clipy1, clipy2,
+	       wfocus);
+  }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+  CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a window on the VNC screen. Called by the CTK module.
+ *
+ * \param window The window to be drawn.
+ * \param focus The focus of the window.
+ * \param clipy1 The lower y coordinate bound.
+ * \param clipy2 The upper y coordinate bound.
+ * \param draw_borders The flag for border drawing.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2,
+		unsigned char draw_borders)
+{
+  unsigned char x, y;
+  unsigned char h;
+  unsigned char x1, y1, x2, y2;
+  unsigned char i;
+  
+
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x;
+  y = window->y + 1;
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  if(draw_borders) {
+
+    /* Draw window frame. */  
+    textcolor(VNC_OUT_WINDOWCOLOR + focus);
+    /*  if(focus & CTK_FOCUS_WINDOW) {
+      textcolor(WINDOWCOLOR_FOCUS);
+    } else {
+      textcolor(WINDOWCOLOR);
+      }*/
+
+    if(y >= clipy1) {
+      cputcxy(x, y, CH_ULCORNER);
+      for(i = wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2; i < x2; ++i) {
+	cputcxy(i, y, CH_TITLEBAR);
+      }
+      cputcxy(x2, y, CH_URCORNER);
+    }
+
+    h = window->h;
+  
+    if(clipy1 > y1) {
+      if(clipy1 - y1 < h) {
+	h = clipy1 - y1;
+	      y1 = clipy1;
+      } else {
+	h = 0;
+      }
+    }
+
+    if(clipy2 < y1 + h) {
+      if(y1 >= clipy2) {
+	h = 0;
+      } else {
+	h = clipy2 - y1;
+      }
+    }
+  
+    for(i = y1; i < y1 + h; ++i) {
+      cputcxy(x, i, CH_WINDOWLBORDER);
+      cputcxy(x2, i, CH_WINDOWRBORDER);
+    }
+
+    /*  cvlinexy(x, y1, h);
+	cvlinexy(x2, y1, h);  */
+
+    if(y + window->h >= clipy1 &&
+       y + window->h < clipy2) {
+      cputcxy(x, y2, CH_LLCORNER);
+      for(i = x1; i < x2; ++i) {
+	cputcxy(i, y2, CH_WINDOWLOWERBORDER);
+      }
+      /*    chlinexy(x1, y2, window->w);*/
+      cputcxy(x2, y2, CH_LRCORNER);
+    }
+  }
+
+  draw_window_contents(window, focus, clipy1, clipy2,
+		       x1, x2, y + 1, y2);
+
+  update_area(window->x, window->y, window->w + 2, window->h + 2);
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw a dialog on the VNC screen. Called by the CTK module.
+ *
+ * \param dialog The dialog to be drawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  unsigned char x1, y1, x2, y2;
+
+  /*  textcolor(DIALOGCOLOR);*/
+  textcolor(VNC_OUT_WINDOWCOLOR + CTK_FOCUS_DIALOG);
+
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  for(i = y1; i < y1 + dialog->h; ++i) {
+    cputcxy(x, i, CH_DIALOGLBORDER);
+    cputcxy(x2, i, CH_DIALOGRBORDER);
+  }
+  /*  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+  dialog->h);*/
+
+  
+  for(i = x1; i < x2; ++i) {
+    cputcxy(i, y, CH_DIALOGUPPERBORDER);
+    cputcxy(i, y2, CH_DIALOGLOWERBORDER);
+  }
+    /*  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+  dialog->w);*/
+
+  cputcxy(x, y, CH_DIALOG_ULCORNER);
+  cputcxy(x, y2, CH_DIALOG_LLCORNER);
+  cputcxy(x2, y, CH_DIALOG_URCORNER);
+  cputcxy(x2, y2, CH_DIALOG_LRCORNER);
+  
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
+		       x1, x2, y1, y2);
+
+  update_area(dialog->x, dialog->y, dialog->w + 4, dialog->h + 4);
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Clear parts of the VNC desktop. Called by the CTK module.
+ *
+ * \param y1 The lower y coordinate bound.
+ * \param y2 The upped y coordinate bound.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+
+  textcolor(VNC_OUT_BACKGROUNDCOLOR);
+  for(i = y1; i < y2; ++i) {
+    cclearxy(0, i, sizex);
+  }
+
+  update_area(0, y1, sizex, y2 - y1);
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Draw one menu on the VNC desktop.
+ *
+ * \param m The CTK menu to be drawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+
+  textcolor(VNC_OUT_MENUCOLOR);
+  x = wherex();
+  cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > sizex) {
+    x = sizex - CTK_CONF_MENUWIDTH;
+  }
+  
+  
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      textcolor(VNC_OUT_ACTIVEMENUCOLOR);
+      revers(0);
+    } else {
+      textcolor(VNC_OUT_MENUCOLOR);	  
+    }
+    gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      cputs(m->items[y].title);
+    }
+    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear(x + CTK_CONF_MENUWIDTH - wherex());
+    }
+    revers(1);
+  }
+  
+  gotoxy(x2, 0);
+  textcolor(VNC_OUT_MENUCOLOR);  
+
+  update_area(x, 0, CTK_CONF_MENUWIDTH, m->nitems + 1);
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Draw the menus on the virtual VNC desktop. Called by the CTK module.
+ *
+ * \param menus The CTK menubar.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+
+  
+  /* Draw menus */
+  textcolor(VNC_OUT_MENUCOLOR);
+  gotoxy(0, 0);
+  revers(1);
+  cputc(' ');
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      update_area(wherex(), 0, strlen(m->title) + 1, 1);
+      cputs(m->title);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+
+  if(wherex() + strlen(menus->desktopmenu->title) + 1>= sizex) {
+    gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
+  } else {
+    cclear(sizex - wherex() -
+	   strlen(menus->desktopmenu->title) - 1);
+    update_area(wherex(), 0, sizex - wherex() -
+		strlen(menus->desktopmenu->title) - 1, 1);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    update_area(wherex(), 0, strlen(menus->desktopmenu->title) + 1, 1);
+    cputs(menus->desktopmenu->title);
+    cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  revers(0);
+
+
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Obtain the height of the VNC desktop. Called by the CTK module.
+ *
+ * \return The height of the VNC desktop, in characters.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return sizey;
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Obtain the height of the VNC desktop. Called by the CTK module.
+ *
+ * \return The height of the VNC desktop, in characters.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return sizex;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+  return x / CTK_VNCFONT_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+  return y / CTK_VNCFONT_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Converts between ASCII and the VNC screen character encoding.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+ascii2screen(unsigned char c)
+{
+  if(c == '|') {
+    return 0x68;
+  }
+  if(c < 0x20) {
+    return c + 0x60;
+  }
+  if(c > 0x20 && c < 0x40) {
+    return c;
+  }
+  if(c >= 0x40 && c < 0x60) {
+    return c;
+  }
+  if(c >= 0x60 && c < 0x80) {
+    return c - 0x60;
+  }
+  if(c >= 0x80) {
+    return c;
+  }
+
+  return 32;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Draws a character on the virtual VNC screen. Called by the libconio module.
+ *
+ * \param c The character to be drawn.
+ * \param xpos The x position of the character.
+ * \param ypos The y position of the character.
+ * \param reversedflag Determines if the character should be reversed or not.
+ * \param color The color of the character.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_arch_draw_char(char c,
+		   unsigned char xpos,
+		   unsigned char ypos,
+		   unsigned char reversedflag,
+		   unsigned char color)
+{
+
+  vnc_out_update_screen(xpos, ypos, ascii2screen(c),
+			color);
+  /*  vnc_out_update_screen(xpos, ypos, c |
+      (reversedflag? 0x80: 0));*/
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Checks the key press input queue to see if there are pending
+ * keys. Called by the CTK module.
+ *
+ * \return Zero if no key presses are in buffer, non-zero if there are
+ * key presses in input buffer.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_arch_keyavail(void)
+{
+  return vnc_out_keyavail();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Retrieves key presses from the VNC client. Called by the CTK
+ * module.
+ *
+ * \return The next key in the input queue.
+ */
+/*-----------------------------------------------------------------------------------*/
+ctk_arch_key_t
+ctk_arch_getkey(void)
+{
+  return vnc_out_getkey() & 0x7f;
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * The uIP event handler.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_vncserver_appcall(void *state)
+{
+  static struct vnc_server_state *vs;
+
+  vs = (struct vnc_server_state *)(state);
+
+  if(uip_connected()) {
+
+    /* Since we've just been connected, the state pointer should be
+       NULL and we need to allocate a new state object. If we have run
+       out of memory for state objects, we'll have to abort the
+       connection and return. */
+    if(vs == NULL) {
+      vs = alloc_state();
+      if(vs == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)vs);
+    }
+  } else if(uip_closed() || uip_aborted()) {
+    if(vs != NULL) {
+      dealloc_state(vs);
+    }
+    return;
+  }
+  vnc_server_appcall(vs);
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_vncserver_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u8_t i;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    tcp_listen(HTONS(5900));
+    
+    for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) {
+      conns[i].state = VNC_DEALLOCATED;
+    }
+  } else if(ev == tcpip_event) {
+    ctk_vncserver_appcall(data);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki/ctk/ctk-vncserver.h b/contiki/ctk/ctk-vncserver.h
new file mode 100644
index 0000000..1663748
--- /dev/null
+++ b/contiki/ctk/ctk-vncserver.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-vncserver.h,v 1.4 2004/09/12 20:24:55 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_VNCSERVER_H__
+#define __CTK_VNCSERVER_H__
+
+void ctk_vncserver_init(char *arg);
+
+#endif /* __CTK_VNCSERVER_H__ */
diff --git a/contiki/ctk/ctk.c b/contiki/ctk/ctk.c
new file mode 100644
index 0000000..2523d1e
--- /dev/null
+++ b/contiki/ctk/ctk.c
@@ -0,0 +1,1900 @@
+/**
+ * \defgroup ctk The CTK graphical user interface.
+ * @{
+ * The Contiki Toolkit (CTK) provides the graphical user interface for
+ * the Contiki system.
+ *
+ */
+
+/**
+ * \file
+ * The Contiki Toolkit CTK, the Contiki GUI.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * $Id: ctk.c,v 1.50 2005/05/05 20:54:16 oliverschmidt Exp $
+ *
+ */
+
+#include "ek.h"
+#include "cc.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-conf.h"
+#include "ctk-mouse.h"
+
+#include "timer.h"
+
+#include <string.h>
+
+static unsigned char height, width;
+
+static unsigned char mode;
+
+static struct ctk_window desktop_window;
+static struct ctk_window *windows;
+static struct ctk_window *dialog;
+
+#if CTK_CONF_MENUS
+static struct ctk_menus menus;
+static struct ctk_menu *lastmenu;
+static struct ctk_menu desktopmenu;
+#endif /* CTK_CONF_MENUS */
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define REDRAW_NONE         0
+#define REDRAW_ALL          1
+#define REDRAW_FOCUS        2
+#define REDRAW_WIDGETS      4
+#define REDRAW_MENUS        8
+#define REDRAW_MENUPART     16
+
+#define MAX_REDRAWWIDGETS 4
+static unsigned char redraw;
+static struct ctk_widget *redraw_widgets[MAX_REDRAWWIDGETS];
+static unsigned char redraw_widgetptr;
+static unsigned char maxnitems;
+
+static unsigned char iconx, icony;
+#define ICONX_START  (width - 6)
+#define ICONY_START  (height - 7)
+#define ICONX_DELTA  -16
+#define ICONY_DELTA  -5
+#define ICONY_MAX    height
+#define ICONY_MIN    0
+
+#ifndef ctk_arch_isprint
+unsigned char ctk_arch_isprint(char c);
+#endif /* ctk_arch_isprint */
+
+EK_POLLHANDLER(ctk_poll);
+EK_EVENTHANDLER(ctk_eventhandler, ev, data);
+EK_PROCESS(p, "CTK Contiki GUI", EK_PRIO_NORMAL, ctk_eventhandler,
+	   ctk_poll, NULL);
+/*static struct ek_proc p =
+  {DISPATCHER_PROC("CTK Contiki GUI", ctk_idle, NULL, NULL)};*/
+static ek_id_t ctkid;
+
+/** @} */
+
+/**
+ * \addtogroup signals System signals
+ * @{
+ */
+ek_event_t
+
+  /**
+   * Emitted for every key being pressed.
+   *
+   * The key is passed as signal data.*/
+  ctk_signal_keypress,
+  
+  /** Emitted when a widget is activated (pressed). A pointer to the
+      widget is passed as signal data. */
+  ctk_signal_widget_activate,
+  
+  /** Same as ctk_signal_widget_activate. */
+  ctk_signal_button_activate,
+
+  /** Emitted when a widget is selected. A pointer to the widget is
+      passed as signal data. */
+  ctk_signal_widget_select,
+  
+  /** Same as ctk_signal_widget_select. */  
+  ctk_signal_button_hover,
+
+  /** Emitted when a hyperlink is activated. The signal is broadcast
+      to all listeners. */
+  ctk_signal_hyperlink_activate,
+
+  /** Same as ctk_signal_widget_select. */  
+  ctk_signal_hyperlink_hover,
+
+  /** Emitted when a menu item is activated. The number of the menu
+      item is passed as signal data. */
+  ctk_signal_menu_activate,
+
+  /** Emitted when a window is closed. A pointer to the window is
+      passed as signal data. */
+  ctk_signal_window_close,
+
+  /** Emitted when the mouse pointer is moved. A NULL pointer is
+      passed as signal data and it is up to the listening process to
+      check the position of the mouse using the CTK mouse API.*/
+  ctk_signal_pointer_move,
+
+  /** Emitted when a mouse button is pressed. The button is passed as
+      signal data to the listening process. */
+  ctk_signal_pointer_button;
+
+#if CTK_CONF_SCREENSAVER
+/** Emitted when the user has been idle long enough for the
+    screensaver to start. */
+ek_event_t ctk_signal_screensaver_stop,
+  /** Emitted when the user presses a key or moves the mouse when the
+      screensaver is active. */
+  ctk_signal_screensaver_start;
+#endif /* CTK_CONF_SCREENSAVER */
+
+/** @} */
+
+/**
+ * \addtogroup ctk
+ * @{
+ */
+
+#if CTK_CONF_MOUSE_SUPPORT
+unsigned short mouse_x, mouse_y, mouse_button;
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+
+static unsigned short screensaver_timer = 0;
+unsigned short ctk_screensaver_timeout = (5*60);
+/*static ek_clock_t start, current;*/
+static struct timer timer;
+
+static void CC_FASTCALL 
+textentry_input(ctk_arch_key_t c,
+		CC_REGISTER_ARG struct ctk_textentry *t);
+#if CTK_CONF_MENUS
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Creates the Desktop menu.
+ *
+ * Creates the leftmost menu, "Desktop". Since the desktop menu
+ * contains the list of all open windows, this function will be called
+ * whenever a window is opened or closed.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+make_desktopmenu(void)
+{
+  struct ctk_window *w;
+  
+  desktopmenu.nitems = 0;
+  
+  if(windows == NULL) {
+    ctk_menuitem_add(&desktopmenu, "(No windows)");
+  } else {
+    for(w = windows; w != NULL; w = w->next) {
+      ctk_menuitem_add(&desktopmenu, w->title);
+    }
+  }
+}
+#endif /* CTK_CONF_MENUS */
+/*-----------------------------------------------------------------------------------*/
+static void
+arrange_icons(void)
+{
+  struct ctk_widget *icon;
+
+  iconx = ICONX_START;
+  icony = ICONY_START;
+  
+  for(icon = desktop_window.active; icon != NULL; icon = icon->next) {
+    
+    icon->x = iconx;
+    icon->y = icony;
+    
+    icony += ICONY_DELTA;
+    if(icony >= ICONY_MAX ||
+       icony < ICONY_MIN) {
+      icony = ICONY_START;
+      iconx += ICONX_DELTA;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/  
+void
+ctk_restore(void)
+{
+  ctk_draw_init();
+
+  height = ctk_draw_height();
+  width = ctk_draw_width();
+
+  arrange_icons();
+
+  redraw = REDRAW_ALL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initializes the Contiki Toolkit.
+ *
+ * This function must be called before any other CTK function, but
+ * after the inizialitation of the dispatcher module.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_init(void)
+{
+  ctkid = ek_start(&p);
+  
+  windows = NULL;
+  dialog = NULL;
+
+#if CTK_CONF_MENUS 
+  ctk_menu_new(&desktopmenu, "Desktop");
+  make_desktopmenu();
+  menus.menus = menus.desktopmenu = &desktopmenu;
+#endif /* CTK_CONF_MENUS */
+
+#if CTK_CONF_MOUSE_SUPPORT
+  ctk_mouse_init();
+  ctk_mouse_show();
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+  
+  ctk_draw_init();
+
+  height = ctk_draw_height();
+  width = ctk_draw_width();
+  
+  desktop_window.active = NULL;
+  desktop_window.owner = ctkid;
+  
+  ctk_signal_keypress = ek_alloc_event();
+  
+  ctk_signal_button_activate =
+    ctk_signal_widget_activate = ek_alloc_event();
+  
+  ctk_signal_button_hover =
+    ctk_signal_hyperlink_hover =
+    ctk_signal_widget_select = ek_alloc_event();
+  
+  ctk_signal_hyperlink_activate = ek_alloc_event();
+
+  ctk_signal_menu_activate = ek_alloc_event();
+  ctk_signal_window_close = ek_alloc_event();
+
+  ctk_signal_pointer_move = ek_alloc_event();
+  ctk_signal_pointer_button = ek_alloc_event();
+
+
+#if CTK_CONF_SCREENSAVER
+  ctk_signal_screensaver_start = ek_alloc_event();
+  ctk_signal_screensaver_stop = ek_alloc_event();
+#endif /* CTK_CONF_SCREENSAVER */
+    
+
+  mode = CTK_MODE_NORMAL;
+
+  iconx = ICONX_START;
+  icony = ICONY_START;
+
+  redraw = REDRAW_ALL;
+
+  /*  start = ek_clock();*/
+  timer_set(&timer, CLOCK_SECOND);
+}
+
+/**
+ * \addtogroup ctkappfunc
+ * @{
+ */
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Sets the current CTK mode.
+ *
+ * The CTK mode can be either CTK_MODE_NORMAL, CTK_MODE_SCREENSAVER or
+ * CTK_MODE_EXTERNAL. CTK_MODE_NORMAL is the normal mode, in which
+ * keypresses and mouse pointer movements are processed and the screen
+ * is redrawn. In CTK_MODE_SCREENSAVER, no screen redraws are
+ * performed and the first key press or pointer movement will cause
+ * the ctk_signal_screensaver_stop to be emitted. In the
+ * CTK_MODE_EXTERNAL mode, key presses and pointer movements are
+ * ignored and no screen redraws are made.
+ *
+ * \param m The mode. 
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mode_set(unsigned char m) {
+  mode = m;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Retrieves the current CTK mode.
+ *
+ * \return The current CTK mode.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mode_get(void) {
+  return mode;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Add an icon to the desktop.
+ *
+ * \param icon The icon to be added.
+ *
+ * \param id The process ID of the process that owns the icon.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_icon_add(CC_REGISTER_ARG struct ctk_widget *icon, ek_id_t id)
+{
+#if CTK_CONF_ICONS 
+  /*  icon->x = iconx;
+  icon->y = icony;
+  icon->widget.icon.owner = id;
+
+  icony += ICONY_DELTA;
+  if(icony >= ICONY_MAX) {
+    icony = ICONY_START;
+    iconx += ICONX_DELTA;
+    }*/
+  icon->widget.icon.owner = id;
+  ctk_widget_add(&desktop_window, icon);
+  arrange_icons();
+#endif /* CTK_CONF_ICONS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a dialog box.
+ *
+ * \param d The dialog to be opened.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_dialog_open(struct ctk_window *d)
+{
+  dialog = d;
+  redraw |= REDRAW_FOCUS;
+} 
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close the dialog box, if one is open.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_dialog_close(void)
+{
+  dialog = NULL;
+  redraw |= REDRAW_ALL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a window, or bring window to front if already open.
+ *
+ * \param w The window to be opened.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_window_open(CC_REGISTER_ARG struct ctk_window *w)
+{
+  struct ctk_window *w2;
+  
+  /* Check if already open. */
+  for(w2 = windows; w2 != w && w2 != NULL; w2 = w2->next);
+  if(w2 == NULL) {
+   /* Not open, so we add it at the head of the list of open
+       windows. */
+    w->next = windows;
+    if(windows != NULL) {
+      windows->prev = w;
+    }
+    windows = w;
+    w->prev = NULL;
+  } else {
+    /* Window already open, so we move it to the front of the windows
+       list. */
+    if(w != windows) {
+      if(w->next != NULL) {
+	w->next->prev = w->prev;
+      }
+      if(w->prev != NULL) {
+	w->prev->next = w->next;
+      }
+      w->next = windows;
+      windows->prev = w;
+      windows = w;
+      w->prev = NULL;
+    }
+  }
+  
+#if CTK_CONF_MENUS
+  /* Recreate the Desktop menu's window entries.*/
+  make_desktopmenu();
+#endif /* CTK_CONF_MENUS */
+
+  redraw |= REDRAW_ALL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close a window if it is open.
+ *
+ * If the window is not open, this function does nothing.
+ *
+ * \param w The window to be closed.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_window_close(struct ctk_window *w)
+{
+  static struct ctk_window *w2;
+
+  if(w == NULL) {
+    return;
+  }
+  
+  /* Check if the window to be closed is the first window on the
+     list. */
+  if(w == windows) {
+    windows = w->next;
+    if(windows != NULL) {
+      windows->prev = NULL;
+    }
+    w->next = w->prev = NULL;
+  } else {
+    /* Otherwise we step through the list until we find the window
+       before the one to be closed. We then redirect its ->next
+       pointer and its ->next->prev. */
+    for(w2 = windows; w2 != NULL && w2->next != w; w2 = w2->next);
+
+    if(w2 == NULL) {
+      /* The window wasn't open, so there is nothing more for us to
+	 do. */
+      return;
+    }
+
+    if(w->next != NULL) {
+      w->next->prev = w->prev;
+    }
+    w2->next = w->next;
+    
+    w->next = w->prev = NULL;
+  }
+  
+#if CTK_CONF_MENUS
+  /* Recreate the Desktop menu's window entries.*/
+  make_desktopmenu();
+#endif /* CTK_CONF_MENUS */
+  redraw |= REDRAW_ALL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Create the move and close buttons on the window titlebar.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+make_windowbuttons(CC_REGISTER_ARG struct ctk_window *window)
+{
+  unsigned char placement;
+
+  if(ctk_draw_windowtitle_height >= 2) {
+    placement = -1 - ctk_draw_windowtitle_height/2;
+  } else {
+    placement = -1;
+  }
+#if CTK_CONF_WINDOWMOVE
+  CTK_BUTTON_NEW(&window->titlebutton, 0, placement,
+		 window->titlelen, window->title);
+#else
+  CTK_LABEL_NEW(&window->titlebutton, 0, placement,
+		window->titlelen, 1, window->title);
+#endif /* CTK_CONF_WINDOWMOVE */
+  CTK_WIDGET_ADD(window, &window->titlebutton);
+
+
+#if CTK_CONF_WINDOWCLOSE
+  CTK_BUTTON_NEW(&window->closebutton, window->w - 3, placement,
+		 1, "x");
+#else
+  CTK_LABEL_NEW(&window->closebutton, window->w - 4, placement,
+		3, 1, "   ");
+#endif /* CTK_CONF_WINDOWCLOSE */  
+  CTK_WIDGET_ADD(window, &window->closebutton);
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Remove all widgets from a window.
+ *
+ * \param w The window to be cleared.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_window_clear(struct ctk_window *w)
+{
+  w->active = w->inactive = w->focused = NULL;
+  
+  make_windowbuttons(w);
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Add a menu to the menu bar.
+ *
+ * \param menu The menu to be added.
+ *
+ * \note Do not call this function multiple times for the same menu,
+ * as no check is made to see if the menu already is in the menu bar.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_menu_add(struct ctk_menu *menu)
+{
+#if CTK_CONF_MENUS
+  struct ctk_menu *m;
+
+  if(lastmenu == NULL) {
+    lastmenu = menu;
+  }
+    
+  for(m = menus.menus; m->next != NULL; m = m->next) {
+    if(m == menu) {
+      return;
+    }
+  }
+  m->next = menu;
+  menu->next = NULL;
+
+  redraw |= REDRAW_MENUPART;
+#endif /* CTK_CONF_MENUS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Remove a menu from the menu bar.
+ *
+ * \param menu The menu to be removed.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_menu_remove(struct ctk_menu *menu)
+{
+#if CTK_CONF_MENUS
+  struct ctk_menu *m;
+
+  for(m = menus.menus; m->next != NULL; m = m->next) {
+    if(m->next == menu) {
+      m->next = menu->next;
+      if(menu == lastmenu) {
+	lastmenu = NULL;
+      }
+      redraw |= REDRAW_MENUPART;      
+      return;
+    }
+  }
+#endif /* CTK_CONF_MENUS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Redraws everything on the screen within the clip
+ * interval.
+ *
+ * \param clipy1 The upper bound of the clip interval
+ * \param clipy2 The lower bound of the clip interval 
+ */
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+do_redraw_all(unsigned char clipy1, unsigned char clipy2)
+{
+  struct ctk_window *w;
+  static struct ctk_widget *widget;
+  unsigned char focus;
+
+  if(mode != CTK_MODE_NORMAL &&
+     mode != CTK_MODE_WINDOWMOVE) {
+    return;
+  }
+  
+  ctk_draw_clear(clipy1, clipy2);
+
+  /* Draw widgets in root window */
+  for(widget = desktop_window.active;
+      widget != NULL; widget = widget->next) {
+    ctk_draw_widget(widget, windows != NULL? 0: CTK_FOCUS_WINDOW, clipy1, clipy2);
+  }
+  
+  /* Draw windows */
+  if(windows != NULL) {
+    /* Find the last window.*/
+    for(w = windows; w->next != NULL; w = w->next);
+
+    /* Draw the windows from back to front. */
+    for(; w != windows; w = w->prev) {
+      ctk_draw_clear_window(w, 0, clipy1, clipy2);
+      ctk_draw_window(w, 0, clipy1, clipy2, 1);
+    }
+
+    /* Draw focused window */
+    focus = mode == CTK_MODE_WINDOWMOVE?
+	    CTK_FOCUS_WIDGET|CTK_FOCUS_WINDOW:
+	    CTK_FOCUS_WINDOW;
+    ctk_draw_clear_window(windows, focus, clipy1, clipy2);
+    ctk_draw_window(windows, focus, clipy1, clipy2, 1);
+  }
+
+  /* Draw dialog (if any) */
+  if(dialog != NULL) {
+    ctk_draw_dialog(dialog);
+  }
+
+#if CTK_CONF_MENUS
+  ctk_draw_menus(&menus);
+#endif /* CTK_CONF_MENUS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Redraw the entire desktop.
+ *
+ * \param d The desktop to be redrawn.
+ *
+ * \note Currently the parameter d is not used, but must be set to
+ * NULL.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_desktop_redraw(struct ctk_desktop *d)
+{
+  if(EK_CURRENT() == &p) {
+    if(mode == CTK_MODE_NORMAL ||
+       mode == CTK_MODE_WINDOWMOVE) {
+      do_redraw_all(1, height);
+    }
+  } else {
+    redraw |= REDRAW_ALL;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Redraw a window.
+ *
+ * This function redraws the window, but only if it is the foremost
+ * one on the desktop.
+ *
+ * \param w The window to be redrawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+void 
+ctk_window_redraw(struct ctk_window *w)
+{
+  /* Only redraw the window if it is a dialog or if it is the foremost
+     window. */
+  if(mode != CTK_MODE_NORMAL) {
+    return;
+  }
+  
+  if(w == dialog) {
+    ctk_draw_dialog(w);
+  } else if(dialog == NULL &&
+#if CTK_CONF_MENUS
+	    menus.open == NULL &&
+#endif /* CTK_CONF_MENUS */		    
+	    windows == w) {
+    ctk_draw_window(w, CTK_FOCUS_WINDOW,
+		    0, height, 0);
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Creates a new window.
+ *
+ * \param window The window to be created.
+ * \param w The width of the window.
+ * \param h The height of the window.
+ * \param title The title of the window.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void 
+window_new(CC_REGISTER_ARG struct ctk_window *window,
+	   unsigned char w, unsigned char h,
+	   char *title)
+{
+  
+  if(w >= width - 2) {
+    window->x = 0;
+  } else {
+    window->x = (width - w - 2) / 2;
+  }
+  if(h >= height - 2 - ctk_draw_windowtitle_height) {
+    window->y = 0;
+  } else {
+    window->y = (height - h - 2 - ctk_draw_windowtitle_height) / 2;
+  }
+
+  window->w = w;
+  window->h = h;
+  window->title = title;
+  if(title != NULL) {
+    window->titlelen = strlen(title);
+  } else {
+    window->titlelen = 0;
+  }
+  window->next = window->prev = NULL;
+  /*  window->owner = DISPATCHER_CURRENT();*/
+  window->owner = EK_PROC_ID(EK_CURRENT());
+  window->active = window->inactive = window->focused = NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Create a new window.
+ *
+ * Creates a new window. The memory for the window structure must
+ * already be allocated by the caller, and is usually done with a
+ * static declaration.
+ *
+ * This function sets up the internal structure of the ctk_window
+ * struct and creates the move and close buttons, but it does not open
+ * the window. The window must be explicitly opened by calling the
+ * ctk_window_open() function.
+ *
+ * \param window The window to be created.
+ * \param w The width of the new window.
+ * \param h The height of the new window.
+ * \param title The title of the new window.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_window_new(struct ctk_window *window,
+	       unsigned char w, unsigned char h,
+	       char *title)
+{
+  window_new(window, w, h, title);
+
+  make_windowbuttons(window);  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Creates a new dialog.
+ *
+ * This function only sets up the internal structure of the ctk_window
+ * struct but does not open the dialog. The dialog must be explicitly
+ * opened by calling the ctk_dialog_open() function.
+ *
+ * \param dialog The dialog to be created.
+ * \param w The width of the dialog.
+ * \param h The height of the dialog.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_dialog_new(CC_REGISTER_ARG struct ctk_window *dialog,
+	       unsigned char w, unsigned char h)
+{
+  window_new(dialog, w, h, NULL);
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Creates a new menu.
+ *
+ * This function sets up the internal structure of the menu, but does
+ * not add it to the menubar. Use the function ctk_menu_add() for that
+ * purpose.
+ *
+ * \param menu The menu to be created.
+ * \param title The title of the menu.
+ */
+/*-----------------------------------------------------------------------------------*/
+void 
+ctk_menu_new(CC_REGISTER_ARG struct ctk_menu *menu,
+	     char *title)
+{
+#if CTK_CONF_MENUS
+  menu->next = NULL;
+  menu->title = title;
+  menu->titlelen = strlen(title);
+  menu->active = 0;
+  menu->nitems = 0;
+#endif /* CTK_CONF_MENUS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Adds a menu item to a menu.
+ *
+ * In CTK, each menu item is identified by a number which is unique
+ * within each menu. When a menu item is selected, a
+ * ctk_menuitem_activated signal is emitted and the menu item number
+ * is passed as signal data with the signal.
+ *
+ * \param menu The menu to which the menu item should be added.
+ * \param name The name of the menu item.
+ * \return The number of the menu item.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_menuitem_add(CC_REGISTER_ARG struct ctk_menu *menu,
+		 char *name)
+{
+#if CTK_CONF_MENUS
+  if(menu->nitems == CTK_CONF_MAXMENUITEMS) {
+    return 0;
+  }
+  menu->items[menu->nitems].title = name;
+  menu->items[menu->nitems].titlelen = strlen(name); 
+  return menu->nitems++;
+#else
+  return 0;
+#endif /* CTK_CONF_MENUS */
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Adds a widget to the list of widgets that should be
+ * redrawn.
+ *
+ * \param w The widget that should be redrawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+add_redrawwidget(struct ctk_widget *w)
+{
+  static unsigned char i;
+  
+  if(redraw_widgetptr == MAX_REDRAWWIDGETS) {
+    redraw |= REDRAW_FOCUS;
+  } else {
+    redraw |= REDRAW_WIDGETS;
+    /* Check if it is in the queue already. If so, we don't add it
+       again. */
+    for(i = 0; i < redraw_widgetptr; ++i) {
+      if(redraw_widgets[i] == w) {
+	return;
+      }
+    }
+    redraw_widgets[redraw_widgetptr++] = w;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Checks if a widget redrawn and adds it to the list of
+ * widgets to be redrawn.
+ *
+ * A widget can be redrawn only if the current CTK mode is
+ * CTK_MODE_NORMAL, if no menu is open, and the widget is in the
+ * foremost window.
+ *
+ * \param widget The widget that should be redrawn.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+widget_redraw(struct ctk_widget *widget)
+{
+  struct ctk_window *window;
+
+  if(mode != CTK_MODE_NORMAL || widget == NULL) {
+    return;
+  }
+
+  /* Only redraw widgets that are in the foremost window. If we would
+     allow redrawing widgets in non-focused windows, we would have to
+     redraw all the windows that cover the non-focused window as well,
+     which would lead to flickering.
+
+     Also, we avoid drawing any widgets when the menus are active.
+    */
+    
+#if CTK_CONF_MENUS
+  if(menus.open == NULL)
+#endif /* CTK_CONF_MENUS */
+    {
+      window = widget->window;
+      if(window == dialog) {
+	ctk_draw_widget(widget, CTK_FOCUS_DIALOG, 0, height);
+      } else if(dialog == NULL &&
+		(window == windows ||
+		 window == &desktop_window)) {
+	ctk_draw_widget(widget, CTK_FOCUS_WINDOW, 0, height);
+      }
+    }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Redraws a widget.
+ *
+ * This function will set a flag which causes the widget to be redrawn
+ * next time the CTK process is scheduled.
+ *
+ * \param widget The widget that is to be redrawn.
+ *
+ * \note This function should usually not be called directly since it
+ * requires typecasting of the widget parameter. The wrapper macro
+ * CTK_WIDGET_REDRAW() does the required typecast and should be used
+ * instead.
+ */
+/*-----------------------------------------------------------------------------------*/
+void 
+ctk_widget_redraw(struct ctk_widget *widget)
+{
+  if(mode != CTK_MODE_NORMAL || widget == NULL) {
+    return;
+  }
+
+  /* Since this function isn't called by CTK itself, we only queue the
+     redraw request. */
+  add_redrawwidget(widget);
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Adds a widget to a window.
+ *
+ * This function adds a widget to a window. The order of which the
+ * widgets are added is important, as it sets the order to which
+ * widgets are cycled with the widget selection keys.
+ *
+ * \param window The window to which the widhet should be added.
+ * \param widget The widget to be added.
+ */
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+ctk_widget_add(CC_REGISTER_ARG struct ctk_window *window,
+	       CC_REGISTER_ARG struct ctk_widget *widget)
+{  
+  if(widget->type == CTK_WIDGET_LABEL ||
+     widget->type == CTK_WIDGET_SEPARATOR) {
+    widget->next = window->inactive;
+    window->inactive = widget;
+    widget->window = window;
+  } else {
+    widget->next = window->active;
+    window->active = widget;
+    widget->window = window;
+    /*    if(window->focused == NULL) {
+      window->focused = widget;
+      }*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Gets the width of the desktop.
+ *
+ * \param d The desktop.
+ * \return The width of the desktop, in characters.
+ *
+ * \note The d parameter is currently unused and must be set to NULL.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_desktop_width(struct ctk_desktop *d)
+{
+  return ctk_draw_width();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Gets the height of the desktop.
+ *
+ * \param d The desktop.
+ * \return The height of the desktop, in characters.
+ *
+ * \note The d parameter is currently unused and must be set to NULL.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_desktop_height(struct ctk_desktop *d)
+{
+  return ctk_draw_height();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Selects a widget in the window of the widget.
+ *
+ * \param focus The widget to be focused.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+select_widget(struct ctk_widget *focus)
+{
+  struct ctk_window *window;
+
+  window = focus->window;
+  
+  if(focus != window->focused) {
+    window->focused = focus;
+    /* The operation changed the focus, so we emit a "hover" signal
+       for those widgets that support it. */
+    
+    if(window->focused->type == CTK_WIDGET_HYPERLINK) {    
+      ek_post(window->owner, ctk_signal_hyperlink_hover, window->focused);
+    } else if(window->focused->type == CTK_WIDGET_BUTTON) {    
+      ek_post(window->owner, ctk_signal_button_hover, window->focused);      
+    } 
+    
+    add_redrawwidget(window->focused);
+
+    ek_post(focus->window->owner, ctk_signal_widget_select, focus);
+
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+#define UP 0
+#define DOWN 1
+#define LEFT 2
+#define RIGHT 3
+static void CC_FASTCALL 
+switch_focus_widget(unsigned char direction)
+{
+  register struct ctk_window *window;
+  register struct ctk_widget *focus;
+  struct ctk_widget *widget;
+  
+  
+  if(dialog != NULL) {
+    window = dialog;
+  } else {
+    window = windows;
+  }
+
+  /* If there are no windows open, we move focus around between the
+     icons on the root window instead. */
+  if(window == NULL) {
+    window = &desktop_window;
+  }
+ 
+  focus = window->focused;
+  if(focus == NULL) {
+    focus = window->active;
+    if(focus == NULL) {
+      return;
+    }
+  }
+  add_redrawwidget(focus);
+  
+  if((direction & 1) == 0) {
+    /* Move focus "up" */
+    focus = focus->next;
+  } else {
+    /* Move focus "down" */
+    for(widget = window->active;
+	widget != NULL; widget = widget->next) {
+	if(widget->next == focus) {
+	  break;
+	}      
+    }    
+    focus = widget;
+    if(focus == NULL) {
+      if(window->active != NULL) {	
+	for(focus = window->active;
+	    focus->next != NULL; focus = focus->next);
+      }
+    }
+  }
+  if(focus == NULL) {
+    focus = window->active;
+  }
+
+  select_widget(focus);
+}
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_MENUS
+static void 
+switch_open_menu(unsigned char rightleft)
+{
+  struct ctk_menu *menu;
+  
+  if(rightleft == 0) {
+    /* Move right */
+    for(menu = menus.menus; menu != NULL; menu = menu->next) {
+      if(menu->next == menus.open) {
+	break;
+      }
+    }
+    lastmenu = menus.open;
+    menus.open = menu;
+    if(menus.open == NULL) {
+      for(menu = menus.menus;
+	  menu->next != NULL; menu = menu->next);
+      menus.open = menu;
+    }
+  } else {
+    /* Move to left */
+    lastmenu = menus.open;
+    menus.open = menus.open->next;
+    if(menus.open == NULL) {
+      menus.open = menus.menus;
+    }
+  }
+
+  menus.open->active = 0;
+
+  /*  if(menus.open->nitems > maxnitems) {
+    maxnitems = menus.open->nitems;
+    }*/
+
+  /*  ctk_desktop_redraw();*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void 
+switch_menu_item(unsigned char updown)
+{
+  register struct ctk_menu *m;
+
+  m = menus.open;
+  
+  if(updown == 0) {
+    /* Move up */
+    if(m->active == 0) {
+      m->active = m->nitems - 1;
+    } else {
+      --m->active;
+      if(m->items[m->active].title[0] == '-') {
+	--m->active;
+      }
+    }
+  } else {
+    /* Move down */
+    if(m->active >= m->nitems - 1) {
+      m->active = 0;
+    } else {      
+      ++m->active;
+      if(m->items[m->active].title[0] == '-') {
+	++m->active;
+      }
+    }
+  }
+  
+}
+#endif /* CTK_CONF_MENUS */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char CC_FASTCALL 
+activate(CC_REGISTER_ARG struct ctk_widget *w)
+{
+  if(w->type == CTK_WIDGET_BUTTON) {
+    if(w == (struct ctk_widget *)&windows->closebutton) {
+#if CTK_CONF_WINDOWCLOSE
+      ek_post(w->window->owner, ctk_signal_window_close, windows);
+      ctk_window_close(windows);
+      return REDRAW_ALL;
+#endif /* CTK_CONF_WINDOWCLOSE */
+    } else if(w == (struct ctk_widget *)&windows->titlebutton) {
+#if CTK_CONF_WINDOWMOVE
+      mode = CTK_MODE_WINDOWMOVE;
+      return REDRAW_ALL;
+#endif /* CTK_CONF_WINDOWMOVE */
+    } else {
+      ek_post(w->window->owner, ctk_signal_widget_activate, w);
+    }
+#if CTK_CONF_ICONS
+  } else if(w->type == CTK_WIDGET_ICON) {
+    if(w->widget.icon.owner != EK_ID_NONE) {
+      ek_post(w->widget.icon.owner, ctk_signal_widget_activate, w);
+    } else {
+      ek_post(w->window->owner, ctk_signal_widget_activate, w);
+    }
+#endif /* CTK_CONF_ICONS */
+  } else if(w->type == CTK_WIDGET_HYPERLINK) {    
+    ek_post(EK_BROADCAST, ctk_signal_hyperlink_activate, w);
+  } else if(w->type == CTK_WIDGET_TEXTENTRY) {
+    if(w->widget.textentry.state == CTK_TEXTENTRY_NORMAL) {      
+      w->widget.textentry.state = CTK_TEXTENTRY_EDIT;
+      textentry_input(0, (struct ctk_textentry *)w);
+    } else {
+      w->widget.textentry.state = CTK_TEXTENTRY_NORMAL;
+      ek_post(w->window->owner, ctk_signal_widget_activate, w);
+    }
+    add_redrawwidget(w);
+    return REDRAW_WIDGETS;
+  } else {
+    ek_post(w->window->owner, ctk_signal_widget_activate, w);
+  }
+  return REDRAW_NONE;
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL 
+textentry_input(ctk_arch_key_t c,
+		CC_REGISTER_ARG struct ctk_textentry *t)
+{
+  register char *cptr, *cptr2;
+  static unsigned char len, txpos, typos, tlen;
+
+  if(t->input != NULL && t->input(c, t)) {
+    return;
+  }
+
+  txpos = t->xpos;
+  typos = t->ypos;
+  tlen = t->len;
+
+  cptr = &t->text[txpos + typos * (tlen + 1)];
+      
+  switch(c) {
+  case CH_CURS_LEFT:
+    if(txpos > 0) {
+      --txpos;
+    }
+    break;
+    
+  case CH_CURS_RIGHT:    
+    if(txpos < tlen - 1 && *cptr != 0) {
+      ++txpos;
+    }
+    break;
+
+  case CH_CURS_UP:
+    txpos = 0;
+    break;
+    
+  case 0:
+  case CH_CURS_DOWN:
+    txpos = strlen(t->text);
+    if(txpos == tlen) {
+      --txpos;
+    }
+    break;
+    
+  case CH_ENTER:
+    /*    t->state = CTK_TEXTENTRY_NORMAL;*/
+    activate((struct ctk_widget *)t);
+    switch_focus_widget(DOWN);
+    break;
+    
+  case CTK_CONF_WIDGETDOWN_KEY:
+    t->state = CTK_TEXTENTRY_NORMAL;
+    switch_focus_widget(DOWN);
+    break;
+  case CTK_CONF_WIDGETUP_KEY:
+    t->state = CTK_TEXTENTRY_NORMAL;
+    switch_focus_widget(UP);
+    break;
+    
+  default:
+    len = tlen - txpos;
+    if(c == CH_DEL) {
+      if(len == 1 && *cptr != 0) {
+	*cptr = 0;
+      } else {
+        if(txpos > 0) {
+	  --txpos;
+	  strcpy(cptr - 1, cptr);
+	}
+      }
+    } else {
+      if(ctk_arch_isprint(c)) {
+	if(len > 1) {
+	  cptr2 = cptr + len - 1;
+	  while(cptr2 > cptr) {
+	    *cptr2 = *(cptr2 - 1);
+	    --cptr2;
+	  }
+	  ++txpos;
+	}
+	*cptr = c;
+      }
+    }
+    break;
+  }
+
+  t->xpos = txpos;
+  t->ypos = typos;
+}
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_MENUS
+static unsigned char 
+activate_menu(void)
+{
+  struct ctk_window *w;
+  
+  lastmenu = menus.open;
+  if(menus.open == &desktopmenu) {
+    for(w = windows; w != NULL; w = w->next) {
+      if(w->title == desktopmenu.items[desktopmenu.active].title) {
+	ctk_window_open(w);
+	menus.open = NULL;
+	return REDRAW_ALL;
+      }
+    }
+  } else {
+    ek_post(EK_BROADCAST, ctk_signal_menu_activate, menus.open);
+  }
+  menus.open = NULL;
+  return REDRAW_MENUPART;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char 
+menus_input(ctk_arch_key_t c)
+{
+
+  if(menus.open->nitems > maxnitems) {
+    maxnitems = menus.open->nitems;
+  }
+
+  
+  switch(c) {
+  case CH_CURS_RIGHT:
+    switch_open_menu(1);
+	
+    return REDRAW_MENUPART;
+
+  case CH_CURS_DOWN:
+    switch_menu_item(1);
+    return REDRAW_MENUS;
+
+  case CH_CURS_LEFT:
+    switch_open_menu(0);
+    return REDRAW_MENUPART;
+
+  case CH_CURS_UP:
+    switch_menu_item(0);
+    return REDRAW_MENUS;
+    
+  case CH_ENTER:
+    return activate_menu();
+
+  case CTK_CONF_MENU_KEY:
+    lastmenu = menus.open;
+    menus.open = NULL;
+    return REDRAW_MENUPART;
+  }
+
+  return REDRAW_NONE;
+}
+#endif /* CTK_CONF_MENUS */
+/*-----------------------------------------------------------------------------------*/
+static void
+handle_timer(void)
+{
+  if(mode == CTK_MODE_NORMAL) {
+    ++screensaver_timer;
+    if(screensaver_timer >= ctk_screensaver_timeout) {
+#if CTK_CONF_SCREENSAVER
+      ek_post(EK_BROADCAST, ctk_signal_screensaver_start, NULL);
+#ifdef CTK_SCREENSAVER_INIT
+      CTK_SCREENSAVER_INIT();
+#endif /* CTK_SCREENSAVER_INIT */
+
+#endif /* CTK_CONF_SCREENSAVER */
+      screensaver_timer = 0;
+    }
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+unfocus_widget(CC_REGISTER_ARG struct ctk_widget *w)
+{
+  if(w != NULL) {
+    redraw |= REDRAW_WIDGETS;
+    add_redrawwidget(w);
+    if(CTK_WIDGET_TYPE(w) == CTK_WIDGET_TEXTENTRY) {
+      ((struct ctk_textentry *)w)->state =
+	CTK_TEXTENTRY_NORMAL;
+    }
+    w->window->focused = NULL;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(ctk_poll)
+{
+  static ctk_arch_key_t c;
+  static unsigned char i;
+  register struct ctk_window *window;
+  register struct ctk_widget *widget;
+  register struct ctk_widget **widgetptr;
+#if CTK_CONF_MOUSE_SUPPORT 
+  static unsigned char mxc, myc, mouse_button_changed, mouse_moved,
+    mouse_clicked;
+  static unsigned char menux;
+  register struct ctk_menu *menu;
+
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+
+
+  /*  current = ek_clock();
+  
+  if((current - start) >= CLK_TCK) {
+    timer();
+    start = current;
+    } */
+  if(timer_expired(&timer)) {
+    timer_reset(&timer);
+    handle_timer();
+  }
+
+#if CTK_CONF_MENUS
+  if(menus.open != NULL) {
+    maxnitems = menus.open->nitems;
+  } else {
+    maxnitems = 0;
+  }
+#endif /* CTK_CONF_MENUS */
+
+#if CTK_CONF_MOUSE_SUPPORT
+  mouse_button_changed = mouse_moved = mouse_clicked = 0;
+
+  /* See if there is any change in the buttons. */
+  if(ctk_mouse_button() != mouse_button) {
+    mouse_button = ctk_mouse_button();
+    mouse_button_changed = 1;
+    if(mouse_button == 0) {
+      mouse_clicked = 1;
+    }
+  }
+  
+  /* Check if the mouse pointer has moved. */
+  if(ctk_mouse_x() != mouse_x ||
+     ctk_mouse_y() != mouse_y) {
+    mouse_x = ctk_mouse_x();
+    mouse_y = ctk_mouse_y();
+    mouse_moved = 1;
+  }
+
+  mxc = ctk_mouse_xtoc(mouse_x);
+  myc = ctk_mouse_ytoc(mouse_y); 
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+
+
+#if CTK_CONF_SCREENSAVER
+  if(mode == CTK_MODE_SCREENSAVER) {
+    if(ctk_arch_keyavail()
+#if CTK_CONF_MOUSE_SUPPORT
+       || mouse_moved || mouse_button_changed
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+       ) {      
+      ek_post(EK_BROADCAST, ctk_signal_screensaver_stop, NULL);
+      mode = CTK_MODE_NORMAL;
+    }
+  } else
+#endif /* CTK_CONF_SCREENSAVER */
+    if(mode == CTK_MODE_NORMAL) {
+#if CTK_CONF_MOUSE_SUPPORT 
+    /* If there is any change in the mouse conditions, find out in
+       which window the mouse pointer currently is in order to send
+       the correct signals, or bring a window to focus. */
+    if(mouse_moved || mouse_button_changed) {
+      ctk_mouse_show();
+      screensaver_timer = 0;
+      
+      if(myc == 0) {
+	/* Here we should do whatever needs to be done when the mouse
+	   moves around and clicks in the menubar. */
+	if(mouse_clicked) {
+	  static unsigned char titlelen;
+	  
+	  /* Find out which menu that the mouse pointer is in. Start
+	     with the ->next menu after the desktop menu. We assume
+	     that the menus start one character from the left screen
+	     side and that the desktop menu is farthest to the
+	     right. */
+	  menux = 1;
+	  for(menu = menus.menus->next;
+	      menu != NULL; menu = menu->next) {
+	    titlelen = menu->titlelen;
+	    if(mxc >= menux && mxc <= menux + titlelen) {
+	      break;
+	    }
+	    menux += titlelen;
+	  }
+	  
+	  /* Also check desktop menu. */
+	  if(mxc >= width - 7 &&
+	     mxc <= width - 1) {
+	    menu = &desktopmenu;
+	  }
+	  
+	  menus.open = menu;
+	  redraw |= REDRAW_MENUPART;
+	}
+      } else {
+	--myc;
+
+	if(menus.open != NULL) {
+	  static unsigned char nitems;
+	  
+	  /* Do whatever needs to be done when a menu is open. */
+
+	  /* First check if the mouse pointer is in the currently open
+	     menu. */
+	  if(menus.open == &desktopmenu) {
+	    menux = width - CTK_CONF_MENUWIDTH;
+	  } else {
+	    menux = 1;
+	    for(menu = menus.menus->next; menu != menus.open;
+		menu = menu->next) {
+	      menux += menu->titlelen;
+	    }
+	  }
+
+	  nitems = menus.open->nitems;
+	  /* Find out which of the menu items the mouse is pointing
+	     to. */
+	  if(mxc >= menux && mxc <= menux + CTK_CONF_MENUWIDTH) {    
+	    if(myc <= nitems) {
+	      menus.open->active = myc;
+	    } else {
+	      menus.open->active = nitems - 1;
+	    }
+	  }
+	  
+	  if(mouse_clicked) {
+	    if(mxc >= menux && mxc <= menux + CTK_CONF_MENUWIDTH &&
+	       myc <= nitems) {
+	      redraw |= activate_menu();
+	    } else {
+	      lastmenu = menus.open;
+	      menus.open = NULL;
+	      redraw |= REDRAW_MENUPART;
+	    }
+	  } else {
+	    redraw |= REDRAW_MENUS;	  
+	  }
+	} else {
+
+	  /* Walk through the windows from top to bottom to see in
+	     which window the mouse pointer is. */
+	  if(dialog != NULL) {
+	    window = dialog;
+	  } else {	  	 	  
+	    for(window = windows; window != NULL;
+		window = window->next) {
+	      
+	      /* Check if the mouse is within the window. */
+	      if(mxc >= window->x &&
+		 mxc <= window->x + window->w +
+		        2 * ctk_draw_windowborder_width &&
+		 myc >= window->y &&
+		 myc <= window->y + window->h +
+		 ctk_draw_windowtitle_height +
+		 ctk_draw_windowborder_height) {
+		break;       	
+	      }
+	    }
+	  }
+
+
+	  /* If we didn't find any window, and there are no windows
+	     open, the mouse pointer will definately be within the
+	     background desktop window. */
+	  if(window == NULL) {
+	    window = &desktop_window;
+	  }
+
+	  /* If the mouse pointer moves around outside of the
+	     currently focused window (or dialog), we should not have
+	     any focused widgets in the focused window so we make sure
+	     that there are none. */
+	  if(windows != NULL &&
+	     window != windows &&
+	     windows->focused != NULL){	  
+	    /*add_redrawwidget(windows->focused);
+	    windows->focused = NULL;
+	    redraw |= REDRAW_WIDGETS;*/
+	    unfocus_widget(windows->focused);
+	  }
+
+	  if(window != NULL) {
+	    /* If the mouse was clicked outside of the current window,
+	       we bring the clicked window to front. */
+	    if(dialog == NULL &&
+	       window != &desktop_window &&	   
+	       window != windows &&
+	       mouse_clicked) {
+	      /* Bring window to front. */
+	      ctk_window_open(window);
+	      redraw |= REDRAW_ALL;
+	    } else {
+	  
+	      /* Find out which widget currently is under the mouse
+		 pointer and give it focus, unless it already has
+		 focus. */
+	      mxc = mxc - window->x - ctk_draw_windowborder_width;
+	      myc = myc - window->y - ctk_draw_windowtitle_height;
+	    
+	      /* See if the mouse pointer is on a widget. If so, it
+		 should be selected and, if the button is clicked,
+		 activated. */
+	      for(widget = window->active; widget != NULL;
+		  widget = widget->next) {
+		
+		if(mxc >= widget->x &&
+		   mxc <= widget->x + widget->w &&
+		   (myc == widget->y ||
+		    ((widget->type == CTK_WIDGET_BITMAP ||
+		      /*widget->type == CTK_WIDGET_TEXTMAP ||*/
+		      widget->type == CTK_WIDGET_ICON) &&
+		     (myc >= widget->y &&
+		      myc <= widget->y +
+		      ((struct ctk_bitmap *)widget)->h)))) {
+		  break;
+		}
+	      }
+	    
+
+	      /* if the mouse is moved in the focused window, we emit
+		 a ctk_signal_pointer_move signal to the owner of the
+		 window. */
+	      if(mouse_moved &&
+		 (window != &desktop_window ||
+		  windows == NULL)) {
+
+		ek_post(window->owner, ctk_signal_pointer_move, NULL);
+
+		/* If there was a focused widget that is not below the
+		   mouse pointer, we remove focus from the widget and
+		   redraw it. */
+		if(window->focused != NULL &&
+		   widget != window->focused) {
+		  /*		  add_redrawwidget(window->focused);
+		  if(CTK_WIDGET_TYPE(window->focused) ==
+		     CTK_WIDGET_TEXTENTRY) {
+		    ((struct ctk_textentry *)(window->focused))->state =
+		      CTK_TEXTENTRY_NORMAL;
+		  }
+		  window->focused = NULL;*/
+		  unfocus_widget(window->focused);
+		}
+		redraw |= REDRAW_WIDGETS;
+		if(widget != NULL) {
+		  select_widget(widget);
+		}
+	      }
+	    
+	      if(mouse_button_changed) {
+		ek_post(window->owner, ctk_signal_pointer_button,
+			(ek_data_t)mouse_button);
+		if(mouse_clicked && widget != NULL) {
+		  select_widget(widget);
+		  redraw |= activate(widget);
+		}
+	      }
+	    }
+	  }    
+	}
+      }
+    }
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+    
+    while(ctk_arch_keyavail()) {
+
+      ctk_mouse_hide();
+      
+      screensaver_timer = 0;
+      
+      c = ctk_arch_getkey();      
+      
+      if(dialog != NULL) {
+	window = dialog;
+      } else if(windows != NULL) {
+	window = windows;
+      } else {
+	window = &desktop_window;
+      }
+      
+      widget = window->focused;
+	  
+      if(widget != NULL &&
+	 widget->type == CTK_WIDGET_TEXTENTRY &&
+	 widget->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+	textentry_input(c, (struct ctk_textentry *)widget);
+	add_redrawwidget(widget);
+#if CTK_CONF_MENUS
+      } else if(menus.open != NULL) {
+	redraw |= menus_input(c);
+#endif /* CTK_CONF_MENUS */
+      } else {      
+	switch(c) {
+	case CTK_CONF_WIDGETDOWN_KEY:
+	  switch_focus_widget(DOWN);
+	  break;
+	case CTK_CONF_WIDGETUP_KEY:
+	  switch_focus_widget(UP);
+	  break;
+#if CTK_CONF_MENUS
+	case CTK_CONF_MENU_KEY:
+	  if(dialog == NULL) {
+	    if(lastmenu == NULL) {
+	      menus.open = menus.menus;
+	    } else {
+	      menus.open = lastmenu;
+	    }
+	    menus.open->active = 0;
+	    redraw |= REDRAW_MENUS;
+	  } 
+	  break;
+#endif /* CTK_CONF_MENUS */
+	case CTK_CONF_WINDOWSWITCH_KEY:
+	  if(windows != NULL) {
+	    for(window = windows; window->next != NULL;
+		window = window->next);
+	    ctk_window_open(window);
+	  }
+	  break;
+	default:
+
+	  if(c == CH_ENTER &&
+	     widget != NULL) {
+	    redraw |= activate(widget);
+	  } else {
+	    if(widget != NULL &&
+	       widget->type == CTK_WIDGET_TEXTENTRY) {
+	      if(widget->widget.textentry.state == CTK_TEXTENTRY_NORMAL) {
+		widget->widget.textentry.state = CTK_TEXTENTRY_EDIT;
+		textentry_input(0, (struct ctk_textentry *)widget);
+	      }
+	      textentry_input(c, (struct ctk_textentry *)widget);
+	      add_redrawwidget(widget);
+	    } else {
+	      /*	      window->focused = NULL;*/
+	      unfocus_widget(window->focused);
+	      ek_post_synch(window->owner, ctk_signal_keypress, (ek_data_t)c);
+	    }
+	  }
+	  break;
+	}
+      }
+
+#if 0
+      if(redraw & REDRAW_WIDGETS) {
+	widgetptr = redraw_widgets;
+	for(i = 0; i < MAX_REDRAWWIDGETS; ++i) {
+	  widget_redraw(*widgetptr);
+	  *widgetptr = NULL;
+	  ++widgetptr;
+	}
+	redraw &= ~REDRAW_WIDGETS;
+	redraw_widgetptr = 0;
+      }
+#endif /* 0 */
+    }
+#if CTK_CONF_WINDOWMOVE
+  } else if(mode == CTK_MODE_WINDOWMOVE) {
+
+    redraw = 0;
+
+    window = windows;
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+    /* If the mouse has moved, we move the window as well. */
+    if(mouse_moved) {
+
+      if(window->w + mxc + 2 >= width) {
+	window->x = width - 2 - window->w;
+      } else {
+	window->x = mxc;
+      }
+
+      if(window->h + myc + ctk_draw_windowtitle_height +
+	 ctk_draw_windowborder_height >= height) {
+	window->y = height - window->h -
+	  ctk_draw_windowtitle_height - ctk_draw_windowborder_height;
+      } else {
+	window->y = myc;
+      }
+      if(window->y > 0) {
+	--window->y;
+      }
+
+      redraw = REDRAW_ALL;
+    }		  
+    
+    /* Check if the mouse has been clicked, and stop moving the window
+       if so. */
+    if(mouse_button_changed &&
+       mouse_button == 0) {
+      mode = CTK_MODE_NORMAL;
+      redraw = REDRAW_ALL;      
+    }
+#endif /* CTK_CONF_MOUSE_SUPPORT */
+    
+    while(mode == CTK_MODE_WINDOWMOVE && ctk_arch_keyavail()) {
+    
+      screensaver_timer = 0;
+      
+      c = ctk_arch_getkey();
+      
+      switch(c) {
+      case CH_CURS_RIGHT:
+	++window->x;
+	if(window->x + window->w + 1 >= width) {
+	  --window->x;
+	}
+	redraw = REDRAW_ALL;
+	break;
+      case CH_CURS_LEFT:
+	if(window->x > 0) {
+	  --window->x;
+	}
+	redraw = REDRAW_ALL;
+	break;
+      case CH_CURS_DOWN:
+	++window->y;
+	if(window->y + window->h + 2 >= height) {
+	  --window->y;
+	}
+	redraw = REDRAW_ALL;
+	break;
+      case CH_CURS_UP:
+	if(window->y > 0) {
+	  --window->y;
+	}
+	redraw = REDRAW_ALL;
+	break;
+      default:
+	mode = CTK_MODE_NORMAL;
+	redraw = REDRAW_ALL;
+	break;
+      }
+    }
+#endif /* CTK_CONF_WINDOWMOVE */
+  }
+
+  if(redraw & REDRAW_ALL) {
+    do_redraw_all(1, height);
+#if CTK_CONF_MENUS
+  } else if(redraw & REDRAW_MENUPART) {
+    do_redraw_all(1, maxnitems + 1);
+  } else if(redraw & REDRAW_MENUS) {
+    ctk_draw_menus(&menus);
+#endif /* CTK_CONF_MENUS */
+  } else if(redraw & REDRAW_FOCUS) {
+    if(dialog != NULL) {
+      ctk_window_redraw(dialog);
+    } else if(windows != NULL) {
+      ctk_window_redraw(windows);	
+    } else {
+      ctk_window_redraw(&desktop_window);	
+    }
+  } else if(redraw & REDRAW_WIDGETS) {
+    widgetptr = redraw_widgets;
+    for(i = 0; i < MAX_REDRAWWIDGETS; ++i) {
+      widget_redraw(*widgetptr);
+      *widgetptr = NULL;
+      ++widgetptr;
+    }
+  }    
+  redraw = 0;
+  redraw_widgetptr = 0;
+  
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ctk_eventhandler, ev, data)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
+/** @} */
+
diff --git a/contiki/ctk/ctk.h b/contiki/ctk/ctk.h
new file mode 100644
index 0000000..9707791
--- /dev/null
+++ b/contiki/ctk/ctk.h
@@ -0,0 +1,959 @@
+/**
+ * \addtogroup ctk
+ * @{
+ */
+
+/**
+ * \file
+ * CTK header file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The CTK header file contains functioin declarations and definitions
+ * of CTK structures and macros.
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: ctk.h,v 1.24 2005/05/05 20:54:16 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_H__
+#define __CTK_H__
+
+
+#include "ctk-conf.h"
+#include "ctk-arch.h"
+#include "ek.h"
+
+#include "cc.h"
+
+/* Defintions for the CTK widget types. */
+
+/**
+ * \addtogroup ctkdraw
+ * @{
+ */
+
+/** Widget number: The CTK separator widget. */
+#define CTK_WIDGET_SEPARATOR 1
+/** Widget number: The CTK label widget. */
+#define CTK_WIDGET_LABEL     2
+/** Widget number: The CTK button widget. */
+#define CTK_WIDGET_BUTTON    3
+/** Widget number: The CTK hyperlink widget. */
+#define CTK_WIDGET_HYPERLINK 4
+/** Widget number: The CTK textentry widget. */
+#define CTK_WIDGET_TEXTENTRY 5
+/** Widget number: The CTK bitmap widget. */
+#define CTK_WIDGET_BITMAP    6
+/** Widget number: The CTK icon widget. */
+#define CTK_WIDGET_ICON      7
+
+/** @} */
+
+struct ctk_widget;
+
+#if CTK_CONF_WIDGET_FLAGS
+#define CTK_WIDGET_FLAG_INITIALIZER(x) x,
+#else
+#define CTK_WIDGET_FLAG_INITIALIZER(x)
+#endif
+
+/**
+ * \defgroup ctkappfunc CTK application functions
+ * @{
+ *
+ * The CTK functions used by an application program.
+ */
+
+/**
+ * Instantiating macro for the ctk_separator widget.
+ *
+ * This macro is used when instantiating a ctk_separator widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_separator sep =
+         {CTK_SEPARATOR(0, 0, 23)};
+ \endcode
+ * \param x The x position of the widget, relative to the widget's
+ * window.
+ * \param y The y position of the widget, relative to the widget's
+ * window.
+ * \param w The widget's width.
+ */
+#define CTK_SEPARATOR(x, y, w) \
+ NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) 
+struct ctk_separator {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+};
+
+/**
+ * Instantiating macro for the ctk_button widget.
+ *
+ * This macro is used when instantiating a ctk_button widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_button but =
+         {CTK_BUTTON(0, 0, 2, "Ok")};
+ \endcode
+ * \param x The x position of the widget, relative to the widget's
+ * window.
+ * \param y The y position of the widget, relative to the widget's
+ * window.
+ * \param w The widget's width.
+ * \param text The button text.
+ */
+#define CTK_BUTTON(x, y, w, text) \
+ NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text
+struct ctk_button {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *text;
+};
+
+/**
+ * Instantiating macro for the ctk_label widget.
+ *
+ * This macro is used when instantiating a ctk_label widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_label lab =
+         {CTK_LABEL(0, 0, 5, 1, "Label")};
+ \endcode
+ * \param x The x position of the widget, relative to the widget's
+ * window.
+ * \param y The y position of the widget, relative to the widget's
+ * window.
+ * \param w The widget's width.
+ * \param h The height of the label. 
+ * \param text The label text.
+ */
+#define CTK_LABEL(x, y, w, h, text) \
+ NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text,
+struct ctk_label {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *text;
+};
+
+/**
+ * Instantiating macro for the ctk_hyperlink widget.
+ *
+ * This macro is used when instantiating a ctk_hyperlink widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_hyperlink hlink =
+         {CTK_HYPERLINK(0, 0, 7, "Contiki", "http://dunkels.com/adam/contiki/")};
+ \endcode
+ * \param x The x position of the widget, relative to the widget's
+ * window.
+ * \param y The y position of the widget, relative to the widget's
+ * window.
+ * \param w The widget's width.
+ * \param text The hyperlink text.
+ * \param url The hyperlink URL.
+ */
+#define CTK_HYPERLINK(x, y, w, text, url) \
+ NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url
+struct ctk_hyperlink {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *text;
+  char *url;
+};
+
+/* Editing modes of the CTK textentry widget. */
+#define CTK_TEXTENTRY_NORMAL 0 /**< \internal Textentry state: not
+				  edited. */
+#define CTK_TEXTENTRY_EDIT   1 /**< \internal Textentry state:
+				  currenly being edited. */
+
+/**
+ * Clears a text entry widget and sets the cursor to the start of the
+ * text line.
+ *
+ * \param e The text entry widget to be cleared.
+ */
+#define CTK_TEXTENTRY_CLEAR(e) \
+	do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \
+	     (e)->xpos = 0; (e)->ypos = 0; } while(0)
+
+typedef unsigned char (* ctk_textentry_input)(ctk_arch_key_t c,
+					      struct ctk_textentry *t);
+
+/**
+ * Instantiating macro for the ctk_textentry widget.
+ *
+ * This macro is used when instantiating a ctk_textentry widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_textentry tentry =
+         {CTK_TEXTENTRY(0, 0, 30, 1, textbuffer, 50)};
+ \endcode
+ * \note The height of the text entry widget is obsolete and not
+ * intended to be used.
+ *
+ * \param x The x position of the widget, relative to the widget's
+ * window.
+ * \param y The y position of the widget, relative to the widget's
+ * window.
+ * \param w The widget's width.
+ * \param h The text entry height (obsolete).
+ * \param text A pointer to the buffer that should be edited.
+ * \param len The length of the text buffer
+ */
+#define CTK_TEXTENTRY(x, y, w, h, text, len) \
+  NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
+  CTK_TEXTENTRY_NORMAL, 0, 0, NULL
+#define CTK_TEXTENTRY_INPUT(x, y, w, h, text, len, input) \
+  NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
+  CTK_TEXTENTRY_NORMAL, 0, 0, (ctk_textentry_input)input
+struct ctk_textentry {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *text;
+  unsigned char len;
+  unsigned char state;
+  unsigned char xpos, ypos;
+  ctk_textentry_input input;
+};
+
+
+#if CTK_CONF_ICON_BITMAPS
+#define CTK_ICON_BITMAP(bitmap)	  bitmap
+#else
+#define CTK_ICON_BITMAP(bitmap)	  NULL
+#endif
+
+#if CTK_CONF_ICON_TEXTMAPS
+#define CTK_ICON_TEXTMAP(textmap) textmap
+#else
+#define CTK_ICON_TEXTMAP(textmap) NULL
+#endif
+
+/**
+ * Instantiating macro for the ctk_icon widget.
+ *
+ * This macro is used when instantiating a ctk_icon widget and is
+ * intended to be used together with a struct assignment like this:
+ \code
+  struct ctk_icon icon =
+         {CTK_ICON("An icon", bitmapptr, textmapptr)};
+ \endcode
+ * \param title The icon's text.
+ * \param bitmap A pointer to the icon's bitmap image.
+ * \param textmap A pointer to the icon's text version of the bitmap.
+ */
+#define CTK_ICON(title, bitmap, textmap) \
+ NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, CTK_WIDGET_FLAG_INITIALIZER(0) \
+ title, EK_ID_NONE, \
+ CTK_ICON_BITMAP(bitmap), CTK_ICON_TEXTMAP(textmap)
+struct ctk_icon {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *title;
+  ek_id_t owner;
+  unsigned char *bitmap;
+  char *textmap;
+};
+
+#define CTK_BITMAP(x, y, w, h, bitmap, bitmap_width, bitmap_height) \
+  NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, \
+  CTK_WIDGET_FLAG_INITIALIZER(0) bitmap, bitmap_width, bitmap_height
+struct ctk_bitmap {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  unsigned char *bitmap;
+  unsigned short bw, bh;
+};
+
+#define CTK_TEXTMAP_NORMAL 0
+#define CTK_TEXTMAP_ACTIVE 1
+
+#define CTK_TEXTMAP(x, y, w, h, textmap) \
+ NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, CTK_TEXTMAP_NORMAL
+struct ctk_textmap {
+  struct ctk_widget *next;
+  struct ctk_window *window;
+  unsigned char x, y;
+  unsigned char type;
+  unsigned char w, h;
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  char *textmap;
+  unsigned char state;
+};
+
+
+/**
+ * \internal The CTK button widget structure.
+ */
+struct ctk_widget_button {
+  char *text;  /**< The button text. */
+};
+
+/**
+ * \internal The CTK label widget structure.
+ */
+struct ctk_widget_label {
+  char *text; /**< The label text. */
+};
+
+/**
+ * \internal The CTK hyperlink widget structure.
+ */
+struct ctk_widget_hyperlink {
+  char *text; /**< The text of the hyperlink. */
+  char *url;  /**< The hyperlink's URL. */
+};
+
+struct ctk_widget_textentry {
+  char *text;
+  unsigned char len;
+  unsigned char state;
+  unsigned char xpos, ypos;
+  ctk_textentry_input input;
+};
+
+struct ctk_widget_icon {
+  char *title;
+  ek_id_t owner;
+  unsigned char *bitmap;
+  char *textmap;
+};
+
+struct ctk_widget_bitmap {
+  unsigned char *bitmap;
+  unsigned short bw, bh;  
+};
+/** @} */
+
+/**
+ * \addtogroup ctkdraw
+ * @{
+ */
+
+/**
+ * The generic CTK widget structure that contains all other widget
+ * structures.
+ *
+ * Since the widgets of a window are arranged on a linked list, the
+ * widget structure contains a next pointer which is used for this
+ * purpose. The widget structure also contains the placement and the
+ * size of the widget.
+ *
+ * Finally, the actual per-widget structure is contained in this
+ * top-level widget structure.
+ */
+struct ctk_widget {
+  struct ctk_widget *next;   /**< The next widget in the linked list
+				of widgets that is contained in the
+				ctk_window structure. */
+  struct ctk_window *window; /**< The window in which the widget is
+				contained. */
+  unsigned char x,           /**< The x position of the widget within
+				the containing window, in character
+				coordinates. */
+    y;                       /**< The y position of the widget within
+				the containing window, in character
+				coordinates. */
+  unsigned char type;        /**< The type of the widget:
+				CTK_WIDGET_SEPARATOR,
+				CTK_WIDGET_LABEL, CTK_WIDGET_BUTTON,
+				CTK_WIDGET_HYPERLINK,
+				CTK_WIDGET_TEXTENTRY,
+				CTK_WIDGET_BITMAP or
+				CTK_WIDGET_ICON. */
+  unsigned char w,           /**< The width of the widget in character
+				coordinates. */
+    h;                       /**< The height of the widget in
+				character coordinates. */
+#if CTK_CONF_WIDGET_FLAGS
+  unsigned char flags;
+#endif /* CTK_CONF_WIDGET_FLAGS */
+  
+  union {
+    struct ctk_widget_label label;
+    struct ctk_widget_button button;
+    struct ctk_widget_hyperlink hyperlink;
+    struct ctk_widget_textentry textentry;
+    struct ctk_widget_icon icon;
+    struct ctk_widget_bitmap bitmap;
+  } widget;                  /**< The union which contains the actual
+				widget structure, as determined by the
+				type field. */
+};
+
+
+struct ctk_desktop;
+
+#define CTK_WIDGET_FLAG_NONE      0
+#define CTK_WIDGET_FLAG_MONOSPACE 1
+#define CTK_WIDGET_FLAG_CENTER    2
+
+#if CTK_CONF_WIDGET_FLAGS
+#define CTK_WIDGET_SET_FLAG(w, f) ((struct ctk_widget *)(w))->flags = (f)
+#else /* CTK_CONF_WIDGET_FLAGS */
+#define CTK_WIDGET_SET_FLAG(w, f)
+#endif /* CTK_CONF_WIDGET_FLAGS */
+
+/**
+ * Representation of a CTK window.
+ *
+ * For the CTK, each window is repessented by a ctk_window
+ * structure. All open windows are kept on a doubly linked list,
+ * linked by the next and prev fields in the ctk_window struct. The
+ * window structure holds all widgets that is contained in the window
+ * as well as a pointer to the currently selected widget.
+ * 
+ */
+struct ctk_window {
+  struct ctk_window *next,  /**< The next window in the doubly linked
+			       list of open windows. */
+
+    *prev;                  /**< The previous window in the doubly
+			       linked list of open windows. */
+  struct ctk_desktop *desktop;/**< The desktop on which this window is
+				 open. */
+  
+  ek_id_t owner;            /**< The process that owns the
+			       window. This process will be the
+			       receiver of all CTK signals that
+			       pertain to this window. */
+  
+  char *title;              /**< The title of the window. Used for
+			       constructing the "Dekstop" menu. */
+  unsigned char titlelen;   /**< The length of the title, cached for
+			       speed reasons. */
+
+#if CTK_CONF_WINDOWCLOSE
+  struct ctk_button closebutton; /**< The closebutton. This is also
+				    present in the list of active
+				    widgets. */
+#else /* CTK_CONF_WINDOWCLOSE */
+  struct ctk_label closebutton;
+#endif /* CTK_CONF_WINDOWCLOSE */
+  
+#if CTK_CONF_WINDOWMOVE
+  struct ctk_button titlebutton;/**< The titlebutton which is used for
+				     moving the window. This is also
+				     present in the list of active
+				     widgets. */
+#else /* CTK_CONF_WINDOWMOVE */
+  struct ctk_label titlebutton;
+#endif /* CTK_CONF_WINDOWMOVE */
+
+  unsigned char x,             /**< The x coordinate of the window, in
+				  characters. */    
+    y;                         /**< The y coordinate of the window, in
+				  characters. */
+  unsigned char w,             /**< The width of the window, excluding
+				  window borders. */
+    h;                         /**< The height of the window,
+				  excluding window borders. */
+
+
+  struct ctk_widget *inactive; /**< The list if widgets that cannot be
+				  selected by the user. Labels and
+				  separator widgets are placed on this
+				  list. */
+  struct ctk_widget *active;   /**< The list of widgets that can be
+				  selected by the user. Buttons,
+				  hyperlinks, text entry fields, etc.,
+				  are placed on this list. */
+  struct ctk_widget *focused;  /**< A pointer to the widget on the
+				  active list that is currently
+				  selected, or NULL if no widget is
+				  selected. */
+};
+
+/**
+ * Representation of an individual menu item.
+ */
+struct ctk_menuitem {
+  char *title;           /**< The menu items text. */
+  unsigned char titlelen;/**< The length of the item text, cached for
+			    speed. */
+};
+
+/**
+ * Representation of an individual menu.
+ */
+struct ctk_menu {
+  struct ctk_menu *next; /**< Apointer to the next menu, or is NULL if
+			    this is the last menu, and should be used
+			    by the ctk-draw module when stepping
+			    through the menus when drawing them on
+			    screen. */
+  char *title;           /**< The menu title. */
+  unsigned char titlelen;/**< The length of the title in
+			    characters. Cached for speed reasons. */
+#if CC_UNSIGNED_CHAR_BUGS
+  unsigned int nitems;
+  unsigned int active;
+#else /* CC_UNSIGNED_CHAR_BUGS */
+  unsigned char nitems;  /**< The total number of menu items in the
+			    menu. */
+  unsigned char active;  /**< The currently active menu item. */
+#endif /* CC_UNSIGNED_CHAR_BUGS */
+  struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS];
+                         /**< The array which contains all the menu
+			    items. */
+};
+
+/**
+ * Representation of the menu bar.
+ */
+struct ctk_menus {
+  struct ctk_menu *menus;       /**< A pointer to a linked list of all
+				   menus, including the open menu and
+				   the desktop menu.*/
+  struct ctk_menu *open;        /**< The currently open menu, if
+				   any. If all menus are closed, this
+				   item is NULL: */
+  struct ctk_menu *desktopmenu; /**< A pointer to the "Desktop" menu
+				   that can be used for drawing the
+				   desktop menu in a special way (such
+				   as drawing it at the rightmost
+				   position). */ 
+};
+
+/** @} */
+
+
+/**
+ * \internal The structure describing a Contiki desktop.
+ */
+struct ctk_desktop {
+  char *name; /**< The name of the desktop. */
+   
+  struct ctk_window desktop_window; /**< The background window which
+				       contains tha desktop icons. */
+  struct ctk_window *windows; /**< The list of open windows. */
+  struct ctk_window *dialog;  /**< A pointer to the open dialog, or
+				 NULL if no dialog is open. */
+  
+#if CTK_CONF_MENUS
+  struct ctk_menus menus;     /**< The list of desktop menus. */
+  struct ctk_menu *lastmenu;  /**< Pointer to the menu that was last open. */
+  struct ctk_menu desktopmenu;/**< The desktop menu. */
+#endif /* CTK_CONF_MENUS */
+
+  unsigned char height, /**< The height of the desktop, in characters. */
+    width; /**< The width of the desktop, in characters. */
+
+  
+#define CTK_REDRAW_NONE         0 /**< \internal Redraw flag: nothing
+				     to be redrawn. */
+#define CTK_REDRAW_ALL          1 /**< \internal Redraw flag:
+				     everything should be redrawn. */
+#define CTK_REDRAW_WINDOWS      2 /**< \internal Redraw flag: redraw
+				     windows in queue.*/
+#define CTK_REDRAW_WIDGETS      4 /**< \internal Redraw flag: redraw
+				     widgets in queue. */
+#define CTK_REDRAW_MENUS        8 /**< \internal Redraw flag: redraw
+				     menus. */
+#define CTK_REDRAW_PART        16 /**< \internal Redraw flag: redraw
+				     parts of the desktop. */
+
+#ifndef CTK_CONF_MAX_REDRAWWIDGETS
+#define CTK_CONF_MAX_REDRAWWIDGETS 8
+#endif /* CTK_CONF_MAX_REDRAWWIDGETS */
+#ifndef CTK_CONF_MAX_REDRAWWINDOWS
+#define CTK_CONF_MAX_REDRAWWINDOWS 8
+#endif /* CTK_CONF_MAX_REDRAWWINDOWS */
+  
+  unsigned char redraw; /**< The redraw flag. */
+  
+  struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS]; /**< The list of widgets to be redrawn. */
+  unsigned char redraw_widgetptr; /**< Pointer to the last widget on the redraw_widgets list. */
+
+  struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS]; /**< The list of windows to be redrawn. */
+  unsigned char redraw_windowptr; /**< Pointer to the last window on the redraw_windows list. */
+
+   unsigned char redraw_y1, /**< The lower y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */
+    redraw_y2; /**< The upper y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */
+};
+
+
+/* Global CTK modes. */
+#define CTK_MODE_NORMAL      0
+#define CTK_MODE_WINDOWMOVE  1
+#define CTK_MODE_SCREENSAVER 2
+#define CTK_MODE_EXTERNAL    3
+
+/* General ctk functions. */
+void ctk_init(void);
+void ctk_restore(void);
+
+void ctk_mode_set(unsigned char mode);
+unsigned char ctk_mode_get(void);
+/*void ctk_redraw(void);*/
+
+/* Functions for manipulating windows. */
+void ctk_window_new(struct ctk_window *window,
+		    unsigned char w, unsigned char h,
+		    char *title);
+void ctk_window_clear(struct ctk_window *w);
+void ctk_window_open(struct ctk_window *w);
+#define ctk_window_move(w,xpos,ypos) do { (w)->x=xpos; (w)->y=ypos; } while(0)
+void ctk_window_close(struct ctk_window *w);
+void ctk_window_redraw(struct ctk_window *w);
+#define ctk_window_isopen(w) ((w)->next != NULL)
+
+
+/* Functions for manipulating dialogs. */
+void ctk_dialog_new(struct ctk_window *window,
+		    unsigned char w, unsigned char h);
+void ctk_dialog_open(struct ctk_window *d);
+void ctk_dialog_close(void);
+
+/* Functions for manipulating menus. */
+void ctk_menu_new(struct ctk_menu *menu, char *title);
+void ctk_menu_add(struct ctk_menu *menu);
+void ctk_menu_remove(struct ctk_menu *menu);
+unsigned char ctk_menuitem_add(struct ctk_menu *menu, char *name);
+
+/* Functions for icons. */
+
+/**
+ * \addtogroup ctkappfunc
+ * @{
+ */
+/**
+ * Add an icon to the desktop.
+ *
+ * \param icon The icon to be added.
+ *
+ * \param id The process ID of the process that owns the icon.
+ */
+#define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id)
+void ctk_icon_add(struct ctk_widget *icon, ek_id_t id);
+
+/* Functions for manipulating widgets. */
+
+/**
+ * Add a widget to a window.
+ *
+ * \param win The window to which the widget should be added.
+ * \param widg The widget to be added.
+ */
+#define CTK_WIDGET_ADD(win, widg) \
+ ctk_widget_add(win, (struct ctk_widget *)widg)
+void CC_FASTCALL ctk_widget_add(struct ctk_window *window,
+				struct ctk_widget *widget);
+
+/**
+ * Set focus to a widget. 
+ *
+ * \param win The widget's window.
+ * \param widg The widget
+ */
+#define CTK_WIDGET_FOCUS(win, widg) \
+  (win)->focused = (struct ctk_widget *)(widg)
+
+/**
+ * Add a widget to the redraw queue.
+ *
+ * \param widg The widget to be redrawn.
+ */
+#define CTK_WIDGET_REDRAW(widg) \
+ ctk_widget_redraw((struct ctk_widget *)widg)
+void ctk_widget_redraw(struct ctk_widget *w);
+
+/**
+ * Obtain the type of a widget.
+ *
+ * \param w The widget.
+ */
+#define CTK_WIDGET_TYPE(w) ((w)->type)
+
+
+/**
+ * Sets the width of a widget.
+ *
+ * \param widget The widget.
+ * \param width The width of the widget, in characters.
+ */
+#define CTK_WIDGET_SET_WIDTH(widget, width) do { \
+    ((struct ctk_widget *)(widget))->w = (width); } while(0)
+
+/**
+ * Retrieves the x position of a widget, relative to the window in
+ * which the widget is contained.
+ *
+ * \param w The widget.
+ * \return The x position of the widget.
+ */
+#define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x)
+
+/**
+ * Sets the x position of a widget, relative to the window in
+ * which the widget is contained.
+ *
+ * \param w The widget.
+ * \param xpos The x position of the widget.
+ */
+#define CTK_WIDGET_SET_XPOS(w, xpos) \
+        ((struct ctk_widget *)(w))->x = (xpos)
+/**
+ * Retrieves the y position of a widget, relative to the window in
+ * which the widget is contained.
+ *
+ * \param w The widget.
+ * \return The y position of the widget.
+ */
+#define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y)
+
+/**
+ * Sets the y position of a widget, relative to the window in
+ * which the widget is contained.
+ *
+ * \param w The widget.
+ * \param ypos The y position of the widget.
+ */
+#define CTK_WIDGET_SET_YPOS(w, ypos) \
+        ((struct ctk_widget *)(w))->y = (ypos)
+
+/* XXX: should be removed.
+#define ctk_textentry_set_height(w, height) \
+                           (w)->widget.textentry.h = (height)
+*/
+
+/** \def ctk_label_set_height(w, height)
+ * \brief Set the height of a label.
+ *
+ * \param w The CTK label widget.
+ * \param height The new height of the label.
+ */
+#define ctk_label_set_height(w, height) \
+                           (w)->widget.label.h = (height)
+
+/**
+ * Set the text of a label.
+ *
+ * \param l The CTK label widget.
+ * \param t The new text of the label.
+ */
+#define ctk_label_set_text(l, t) (l)->text = (t)
+
+/**
+ * Set the text of a button.
+ *
+ * \param b The CTK button widget.
+ * \param t The new text of the button.
+ */
+#define ctk_button_set_text(b, t) (b)->text = (t)
+
+#define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m)
+
+#define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_BUTTON; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->h = 1; \
+ (widg)->text = (buttontext); \
+ } while(0)
+
+#define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_LABEL; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->h = (height); \
+ (widg)->text = (labeltext); \
+ } while(0)
+
+#define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_BITMAP; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->h = (height); \
+ (widg)->bitmap = (bmap); \
+ } while(0)
+
+#define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_TEXTENTRY; \
+ (widg)->x = (xxpos); \
+ (widg)->y = (yypos); \
+ (widg)->w = (width); \
+ (widg)->h = 1; \
+ (widg)->text = (textptr); \
+ (widg)->len = (textlen); \
+ (widg)->state = CTK_TEXTENTRY_NORMAL; \
+ (widg)->xpos = 0; \
+ (widg)->ypos = 0; \
+ (widg)->input = NULL; \
+ } while(0)
+
+#define CTK_TEXTENTRY_INPUT_NEW(widg, xxpos, yypos, width, height, textptr, textlen, iinput) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_TEXTENTRY; \
+ (widg)->x = (xxpos); \
+ (widg)->y = (yypos); \
+ (widg)->w = (width); \
+ (widg)->h = (height); \
+ (widg)->text = (textptr); \
+ (widg)->len = (textlen); \
+ (widg)->state = CTK_TEXTENTRY_NORMAL; \
+ (widg)->xpos = 0; \
+ (widg)->ypos = 0; \
+ (widg)->input = (ctk_textentry_input)(iinput); \
+ } while(0)
+
+#define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \
+ do { (widg)->window = NULL; \
+ (widg)->next = NULL; \
+ (widg)->type = CTK_WIDGET_HYPERLINK; \
+ (widg)->x = (xpos); \
+ (widg)->y = (ypos); \
+ (widg)->w = (width); \
+ (widg)->h = 1; \
+ (widg)->text = (linktext); \
+ (widg)->url = (linkurl); \
+ } while(0)
+
+/* Desktop interface. */
+void ctk_desktop_redraw(struct ctk_desktop *d);
+unsigned char ctk_desktop_width(struct ctk_desktop *d);
+unsigned char ctk_desktop_height(struct ctk_desktop *d);
+
+/* Signals. */
+extern ek_event_t ctk_signal_keypress,
+  ctk_signal_widget_activate,
+  ctk_signal_widget_select,
+  ctk_signal_timer,
+  ctk_signal_menu_activate,
+  ctk_signal_window_close,
+  ctk_signal_pointer_move,
+  ctk_signal_pointer_button;
+
+#if CTK_CONF_SCREENSAVER
+extern ek_event_t ctk_signal_screensaver_stop,
+  ctk_signal_screensaver_start;
+
+extern unsigned short ctk_screensaver_timeout;
+/**
+ * Set the screensaver timeout, in seconds.
+ *
+ * \param t The timeout in seconds.
+ */
+#define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t)
+/**
+ * Obtain the screensaver timeout, in seconds.
+ *
+ * \raturn The timeout in seconds.
+ */
+#define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout
+#endif /* CTK_CONF_SCREENSAVER */
+
+/* These should no longer be used: */
+extern ek_event_t ctk_signal_button_activate,
+  ctk_signal_button_hover,
+  ctk_signal_hyperlink_activate,
+  ctk_signal_hyperlink_hover;
+/** @} */
+
+/**
+ * \addtogroup ctkdraw
+ * @{
+ */
+
+/* Focus flags */
+/** Widget focus flag: no focus. */
+#define CTK_FOCUS_NONE     0
+/** Widget focus flag: widget has focus. */
+#define CTK_FOCUS_WIDGET   1
+/** Widget focus flag: widget's window is the foremost one. */
+#define CTK_FOCUS_WINDOW   2
+/** Widget focus flag: widget is in a dialog. */
+#define CTK_FOCUS_DIALOG   4
+
+/** @} */
+/** @} */
+#endif /* __CTK_H__ */
diff --git a/contiki/ctk/vnc-out.c b/contiki/ctk/vnc-out.c
new file mode 100644
index 0000000..efc46c1
--- /dev/null
+++ b/contiki/ctk/vnc-out.c
@@ -0,0 +1,983 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: vnc-out.c,v 1.7 2004/09/01 18:18:39 adamdunkels Exp $
+ *
+ */
+
+#include "uip.h"
+#include "vnc-server.h"
+#include "vnc-out.h"
+
+#include "libconio.h"
+
+#include "ctk-vncserver-conf.h"
+
+#include "ctk-vncfont.h"
+
+#include "ctk-arch.h"
+
+#include "ctk-mouse.h"
+
+#ifdef WITH_AVR
+#include <avr/pgmspace.h>
+#else
+#define memcpy_P memcpy
+#endif /* WITH_AVR */
+
+#define CHARS_WIDTH    LIBCONIO_CONF_SCREEN_WIDTH
+#define CHARS_HEIGHT   LIBCONIO_CONF_SCREEN_HEIGHT
+
+#define SCREEN_X       10
+#define SCREEN_Y       8
+
+#define SCREEN_WIDTH  (CHARS_WIDTH * CTK_VNCFONT_WIDTH + 2 * SCREEN_X) /*420*/
+#define SCREEN_HEIGHT (CHARS_HEIGHT * CTK_VNCFONT_HEIGHT + 2 * SCREEN_Y) /*300*/
+#define BORDER_COLOR 0x00
+#define SCREEN_COLOR 0x00 /*0xc0*/
+
+#ifndef CH_HOME
+#define CH_HOME 0x50
+#endif 
+
+#ifndef CH_TAB
+#define CH_TAB  0x09
+#endif
+
+
+#define BGR(b,g,r) (((b) << 6) | (g) << 3 | (r))
+
+
+static const u8_t menucolor[] = {
+  BGR(3,7,7), /* Background. */           
+  BGR(2,6,6), /* Anti-alias font color. */ 
+  BGR(0,0,0), /* Font color. */            
+};
+
+
+static const u8_t activemenucolor[] = {
+  BGR(0,0,0), /* Background. */           
+  BGR(2,5,5), /* Anti-alias font color. */ 
+  BGR(3,7,7), /* Font color. */            
+};
+
+#define W  BGR(3,7,7)
+#define B  BGR(0,0,0)
+#define G0 BGR(0,2,2)
+#define G1 BGR(1,2,2)
+#define G2 BGR(1,3,3)
+#define G3 BGR(2,4,4)
+#define G4 BGR(2,5,5)
+#define G5 BGR(2,6,6)
+
+#define BG BGR(3,4,4)
+
+static const unsigned char backgroundcolor[] = {BG};
+
+static const unsigned char wincol[] =
+  {BGR(2,5,5),BGR(2,2,2),BGR(0,1,1),G2,G3,G4};
+  /*  {BGR(2,5,5),BGR(2,2,2),BGR(0,1,1),BGR(1,0,0),BGR(2,0,0),BGR(2,1,1)}; */
+static const unsigned char wincol_f[] =
+  {BGR(3,7,7),BGR(1,2,2),BGR(0,1,1),G4,G5,W};
+  /*  {BGR(3,7,7),BGR(1,2,2),BGR(0,1,1),BGR(2,0,0),BGR(3,2,2),BGR(3,4,4)}; */
+static const unsigned char wincol_d[] =
+  {BGR(3,7,7),BGR(1,5,5),BGR(0,0,0),BGR(2,0,0),BGR(3,2,2),BGR(3,4,4)};
+
+static const unsigned char sepcol[] =
+ {BGR(2,5,5),BGR(2,6,6),BGR(3,6,6)};
+static const unsigned char sepcol_f[] =
+ {BGR(3,7,7),BGR(3,5,5),BGR(2,5,5)};
+static const unsigned char sepcol_d[] =
+ {BGR(3,7,7),BGR(1,5,7),BGR(0,0,0)};
+
+static const unsigned char labcol[] =
+ {BGR(2,5,5),BGR(1,3,3),BGR(0,1,1)};
+static const unsigned char labcol_f[] =
+ {BGR(3,7,7),BGR(3,6,6),BGR(0,0,0)};
+static const unsigned char labcol_d[] =
+ {BGR(3,7,7),BGR(3,6,6),BGR(0,0,0)};
+
+
+static const unsigned char butcol[] =
+ {BGR(2,4,4),BGR(1,3,3),BGR(0,1,1),BGR(2,4,4),BGR(2,4,4),BGR(2,4,4),
+  BGR(2,5,5),BGR(2,5,5)};
+static const unsigned char butcol_w[] =
+ {BGR(2,4,4),BGR(1,3,3),BGR(0,1,1),BGR(2,4,4),BGR(2,4,4),BGR(2,4,4),
+  BGR(2,5,5),BGR(2,5,5)};
+static const unsigned char butcol_f[] =
+ {G5,G4,B,BGR(3,5,5),BGR(3,6,6),BGR(3,7,7),
+  BGR(3,6,6),BGR(2,5,5)};
+static const unsigned char butcol_fw[] =
+ {BGR(3,7,7),BGR(3,6,6),BGR(0,0,0),BGR(1,3,3),BGR(2,7,7),BGR(3,7,7),
+  BGR(3,6,6),BGR(3,7,7)};
+static const unsigned char butcol_d[] =
+ {BGR(2,3,3),BGR(2,5,5),BGR(3,6,6),BGR(1,3,4),BGR(1,5,6),BGR(2,6,7),
+  BGR(3,7,7),BGR(2,5,5)};
+static const unsigned char butcol_dw[] =
+ {BGR(0,0,0),BGR(2,5,5),BGR(3,7,7),BGR(1,3,4),BGR(1,5,6),BGR(2,6,7),
+  BGR(3,7,7),BGR(2,5,5)};
+
+
+static const unsigned char hlcol[] =
+ {BGR(2,5,5),BGR(1,3,3),BGR(1,0,0)};
+static const unsigned char hlcol_w[] =
+ {BGR(2,5,5),BGR(1,3,3),BGR(1,0,0)};
+static const unsigned char hlcol_f[] =
+ {BGR(3,7,7),BGR(3,5,5),BGR(3,0,0)};
+static const unsigned char hlcol_fw[] =
+ {BGR(3,7,7),BGR(3,6,7),BGR(3,7,7)};
+static const unsigned char hlcol_d[] =
+ {BGR(3,7,7),BGR(3,5,5),BGR(2,0,0)};
+static const unsigned char hlcol_dw[] =
+ {BGR(3,7,7),BGR(1,5,5),BGR(0,0,0)};
+
+static const unsigned char iconcol[] =
+  {BG,G4,W,B,G1};
+static const unsigned char iconcol_w[] =
+ {BGR(0,1,1),BGR(1,3,3),BGR(3,7,7), B,W};
+
+
+
+static const u8_t * const colortheme[] =
+  {
+    backgroundcolor,
+    
+    /* Window colors */
+    wincol, wincol, wincol_f, wincol_f, wincol_d, wincol_d,
+
+    /* Separator colors. */
+    sepcol, sepcol, sepcol_f, sepcol_f, sepcol_d, sepcol_d,    
+
+    /* Label colors. */
+    labcol, labcol, labcol_f, labcol_f, labcol_d, labcol_d,    
+
+    /* Button colors. */
+    butcol, butcol_w, butcol_f, butcol_fw, butcol_d, butcol_dw,    
+
+    /* Hyperlink colors. */
+    hlcol, hlcol_w, hlcol_f, hlcol_fw, hlcol_d, hlcol_dw,
+
+    /* Textentry colors. */
+    butcol, butcol_w, butcol_f, butcol_fw, butcol_d, butcol_dw,
+
+    /* Icon colors */
+    iconcol, iconcol_w, iconcol, iconcol_w, iconcol, iconcol_w,
+    
+    /* Menu colors. */
+    menucolor, activemenucolor, activemenucolor
+  };
+
+
+static int mouse_x, mouse_y, mouse_button;
+
+#ifdef CTK_VNCSERVER_CONF_SCREEN
+static u8_t *screen = CTK_VNCSERVER_CONF_SCREEN;
+#else
+static u8_t screen[CHARS_WIDTH * CHARS_HEIGHT];
+#endif
+
+#ifdef CTK_VNCSERVER_CONF_COLORSCREEN
+staitc u8_t *colorscreen = CTK_VNCSERVER_CONF_COLORSCREEN;
+#else
+static u8_t colorscreen[CHARS_WIDTH * CHARS_HEIGHT];
+#endif
+
+
+#define PRINTF(x)
+
+/*-----------------------------------------------------------------------------------*/
+#define MAX_ICONS CTK_VNCSERVER_CONF_MAX_ICONS
+struct ctk_icon *icons[MAX_ICONS];
+
+unsigned char
+vnc_out_add_icon(struct ctk_icon *icon)
+{
+  u8_t i;
+  signed int empty;
+
+  empty = -1;
+  for(i = 0; i < MAX_ICONS; ++i) {
+    if(icon == icons[i]) {
+      return i;
+    }
+    if(icons[i] == NULL && empty < 0){
+      empty = i;
+    }
+  }
+
+  if(empty == -1) {
+    empty = 0;
+  }
+  icons[empty] = icon;
+  return empty;
+}
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_init(void)
+{
+  u16_t i;
+  for(i = 0; i < CHARS_WIDTH * CHARS_HEIGHT; ++i) {
+    screen[i] = 0x20;
+  }
+}
+
+void
+vnc_out_update_screen(u8_t xpos, u8_t ypos, u8_t c, u8_t color)
+{
+  screen[xpos + ypos * CHARS_WIDTH] = c;
+  colorscreen[xpos + ypos * CHARS_WIDTH] = color;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_update_area(struct vnc_server_state *vs,
+		    u8_t x, u8_t y, u8_t w, u8_t h)
+{
+  u8_t x2, y2, ax2, ay2;
+  register struct vnc_server_update *a, *b;
+
+  PRINTF(("update_area_connection: should update (%d:%d) (%d:%d)\n",
+	 x, y, w, h));
+  
+  /* First check if we already have a full update queued. If so, there
+     is no need to put this update on the list. If there is a full
+     update, it is always the first one on the list, so there is no
+     need to go step the list in search for it. */
+
+  if(vs->updates_pending != NULL &&
+     vs->updates_pending->type == VNC_SERVER_UPDATE_FULL) {
+    PRINTF(("Update_area_connecion: full update already queued...\n"));
+    return;
+  }
+
+ again:
+  
+  /* Check that we don't update the same area twice by going through
+     the list and search for an update with the same coordinates. */
+  for(a = vs->updates_pending; a != NULL; a = a->next) {
+    if(a->x == x && a->y == y &&
+       a->w == w && a->h == h) {
+      PRINTF(("Update_area_connecion: found equal area\n"));
+      return;
+    }    
+  }
+
+  /* Next we check if this update covers an existing update. If so, we
+     remove the old update, expand this update so that it covers both
+     areas to be updated and run through the process again. */
+  b = NULL;
+  for(a = vs->updates_pending; a != NULL; a = a->next) {      
+    x2 = x + w;
+    y2 = y + h;
+    
+    ax2 = a->x + a->w;
+    ay2 = a->y + a->h;
+
+    /* Test the corners of both updates to see if they are inside the
+       other area. */
+#define INSIDE(x,y,x1,y1,x2,y2) ((x1) <= (x) && \
+                                 (x2) >= (x) && \
+                                 (y1) <= (y) && \
+                                 (y2) >= (y))
+    if(INSIDE(x, y, a->x, a->y, ax2, ay2) ||
+       INSIDE(x, y2, a->x, a->y, ax2, ay2) ||
+       INSIDE(x2, y2, a->x, a->y, ax2, ay2) ||
+       INSIDE(x2, y, a->x, a->y, ax2, ay2) ||
+       INSIDE(a->x, a->y, x, y, x2, y2) ||
+       INSIDE(a->x, ay2, x, y, x2, y2) ||
+       INSIDE(ax2, ay2, x, y, x2, y2) ||
+       INSIDE(ax2, a->y, x, y, x2, y2)) {
+
+      /* Remove the old update from the list. */
+      vnc_server_update_remove(vs, a);
+
+      /* Put it on the free list. */
+      vnc_server_update_free(vs, a);
+
+      PRINTF(("update_area_connection: inside (%d:%d, %d:%d)\n",
+	     a->x, a->y, ax2, ay2));
+      
+      /* Find the area that covers both updates. */
+#define MIN(a,b) ((a) < (b)? (a): (b))
+#define MAX(a,b) ((a) > (b)? (a): (b))
+      x = MIN(a->x, x);
+      y = MIN(a->y, y);
+      ax2 = MAX(ax2, x2);
+      ay2 = MAX(ay2, y2);
+      w = ax2 - x;
+      h = ay2 - y;
+
+      /* This should really be done by a recursive call to this
+	 function: update_area_connection(vs, x, y, w, h); but because
+	 some compilers might not be able to optimize away the
+	 recursive call, we do it using a goto instead. */
+      PRINTF(("Update_area_connecion: trying larger area (%d:%d) (%d:%d)\n", x, y, w, h));
+      goto again;
+    }
+    if(b != NULL) {
+      b = b->next;
+    }
+  }
+  
+  /* Allocate an update object by pulling it off the free list. If
+     there are no free objects, we go for a full update instead. */
+
+  /*  a = vs->updates_free;*/
+  a = vnc_server_update_alloc(vs);
+  if(a == NULL) {
+    PRINTF(("Update_area_connecion: no free updates, doing full\n"));
+    /* Put all pending updates, except for one, on the free list. Use
+       the remaining update as a full update. */
+    while(vs->updates_pending != NULL) {
+      a = vs->updates_pending;
+      vnc_server_update_remove(vs, a);
+      vnc_server_update_free(vs, a);
+    }
+
+    a = vnc_server_update_alloc(vs);
+    a->type = VNC_SERVER_UPDATE_FULL;
+    vnc_server_update_add(vs, a);
+					
+
+  } else {
+    
+    PRINTF(("Update_area_connecion: allocated update for (%d:%d) (%d:%d)\n", x, y, w, h));
+  /* Else, we put the update object at the end of the pending
+     list. */
+    a->type = VNC_SERVER_UPDATE_PARTS;
+    a->x = x;
+    a->y = y;
+    a->w = w;
+    a->h = h;
+    vnc_server_update_add(vs, a);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+init_send_screen(register struct vnc_server_state *vs)
+{
+  vs->sendmsg = SEND_SCREEN;
+  vs->x = vs->y = 0;
+  vs->x1 = vs->y1 = 0;
+  vs->x2 = vs->y2 = 0;
+  vs->w = CHARS_WIDTH;
+  vs->h = CHARS_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+check_updates(register struct vnc_server_state *vs)
+{
+  
+  if(vs->state == VNC_RUNNING &&
+     vs->sendmsg == SEND_NONE &&
+     vs->updates_current == NULL) {
+    if(vs->updates_pending != NULL &&
+       vs->update_requested != 0) {
+      vs->update_requested = 0;
+      /*      vs->updates_current = vs->updates_pending;
+      vs->updates_pending = vs->updates_pending->next;
+      vs->updates_current->next = NULL;*/
+
+      vs->updates_current = vnc_server_update_dequeue(vs);
+      
+      if(vs->updates_current->type == VNC_SERVER_UPDATE_PARTS) {
+	vs->x = vs->x1 = vs->x2 = vs->updates_current->x;
+	vs->y = vs->y1 = vs->y2 = vs->updates_current->y;
+	vs->w = vs->updates_current->w;
+	vs->h = vs->updates_current->h;
+	vs->sendmsg = SEND_UPDATE;
+	
+	PRINTF(("New update from (%d:%d) (%d:%d) to (%d:%d)\n",
+	       vs->x, vs->y, vs->x1, vs->y1, vs->x + vs->w,
+	       vs->y + vs->h));
+      } else if(vs->updates_current->type == VNC_SERVER_UPDATE_FULL) {
+	init_send_screen(vs);
+	PRINTF(("New full update\n"));
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t tmp[CTK_VNCFONT_WIDTH * CTK_VNCFONT_HEIGHT];
+static void
+makechar(CC_REGISTER_ARG char *ptr, u8_t x, u8_t y)
+{
+  u8_t i, *tmpptr;
+  register u8_t *colorscheme;
+  unsigned char *bitmap;
+  u8_t b, b2;
+  u8_t xmove, ymove;
+  unsigned char c, color;
+
+  color = colorscreen[x + y * CHARS_WIDTH];
+  c = screen[x + y * CHARS_WIDTH];
+
+  colorscheme = (u8_t *)colortheme[color];
+      
+  /* First check if the character is a special icon character. These
+     are to be interpreted in a special manner: the first character of
+     the icon (the top left corner) has the highest bit set, but not
+     bit 6. All other characters have bit 6 set, and also count the
+     number of positions away from the top left corner. Only the top
+     left corner contains enough information to identify the icon, all
+     other chars only contain the number of steps to reach the
+     identifying icon. */
+  if((c & 0x80) != 0) {
+    xmove = c & 0x0f;
+    ymove = (c & 0x30) >> 4;
+    
+    c = colorscreen[x + y * CHARS_WIDTH];
+
+    if(icons[c % MAX_ICONS] == NULL) {
+      c = 0;
+    }
+    bitmap = icons[c % MAX_ICONS]->bitmap;
+
+    if(bitmap != NULL) {
+      bitmap = bitmap + ymove * 8*3;
+      colorscheme = (u8_t *)colortheme[VNC_OUT_ICONCOLOR + (c >> 6)];
+      switch(xmove) {
+      case 0:
+	for(i = 0; i < CTK_VNCFONT_HEIGHT; ++i) {
+	  b = bitmap[i];
+	  *ptr++ = colorscheme[((b >> 7) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 6) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 5) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 4) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 3) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 2) & 0x01) << 2];		
+	}
+	break;
+      case 1:
+	for(i = 0; i < CTK_VNCFONT_HEIGHT; ++i) {
+	  b = bitmap[i];
+	  b2 = bitmap[i + 8];
+	  *ptr++ = colorscheme[((b >> 1) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 0) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 7) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 6) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 5) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 4) & 0x01) << 2];		
+	}
+	break;
+      case 2:
+	for(i = 0; i < CTK_VNCFONT_HEIGHT; ++i) {
+	  b = bitmap[i + 8];
+	  b2 = bitmap[i + 16];
+	  *ptr++ = colorscheme[((b >> 3) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 2) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 1) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 0) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 7) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b2 >> 6) & 0x01) << 2];		
+	}
+	break;
+      case 3:
+	for(i = 0; i < CTK_VNCFONT_HEIGHT; ++i) {
+	  b = bitmap[i + 16];
+	  *ptr++ = colorscheme[((b >> 5) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 4) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 3) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 2) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 1) & 0x01) << 2];
+	  *ptr++ = colorscheme[((b >> 0) & 0x01) << 2];		
+	}
+	break;
+      }
+    }
+  } else {
+    memcpy_P(tmp, &ctk_vncfont[c * (CTK_VNCFONT_WIDTH * CTK_VNCFONT_HEIGHT)],
+	     CTK_VNCFONT_WIDTH * CTK_VNCFONT_HEIGHT);
+    
+    tmpptr = tmp;
+
+    
+    for(i = 0; i < CTK_VNCFONT_HEIGHT * CTK_VNCFONT_WIDTH; ++i) {
+      *ptr++ = colorscheme[*tmpptr++];
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_new(register struct vnc_server_state *vs)
+{
+  u8_t i;
+  
+  vs->width = SCREEN_WIDTH;
+  vs->height = SCREEN_HEIGHT;
+  vs->x = vs->y = vs->x1 = vs->y1 = vs->x2 = vs->y2 = 0;
+  vs->w = CHARS_WIDTH;
+  vs->h = CHARS_HEIGHT;
+
+  /* Initialize the linked list of updates. */
+  for(i = 0; i < VNC_SERVER_MAX_UPDATES - 1; ++i) {
+    vs->updates_pool[i].next = &vs->updates_pool[i + 1];    
+  }
+  vs->updates_pool[VNC_SERVER_MAX_UPDATES].next = NULL;
+
+  vs->updates_free = &vs->updates_pool[0];
+  vs->updates_pending = vs->updates_current = NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_send_blank(register struct vnc_server_state *vs)
+{
+  register struct rfb_fb_update *umsg;
+  u8_t *ptr;
+  u16_t len;
+  u8_t msglen;
+      
+  vs->x = vs->y = 0;
+  vs->x2 = vs->y2 = 0;
+	  
+  umsg = (struct rfb_fb_update *)uip_appdata;
+  
+  umsg->type = RFB_FB_UPDATE;
+  umsg->rects = HTONS(2);
+
+  ptr = (u8_t *)umsg + sizeof(struct rfb_fb_update);
+  len = sizeof(struct rfb_fb_update);
+  
+  msglen = vnc_server_draw_rect(ptr, 0, 0,
+				HTONS(SCREEN_WIDTH),
+				HTONS(SCREEN_HEIGHT),
+				BORDER_COLOR);
+
+  
+  ptr += msglen;
+  len += msglen;
+
+  msglen = vnc_server_draw_rect(ptr,
+				HTONS(SCREEN_X), HTONS(SCREEN_Y),
+				HTONS(SCREEN_WIDTH - SCREEN_X * 2),
+				HTONS(SCREEN_HEIGHT - SCREEN_Y * 2),
+				SCREEN_COLOR);
+
+  uip_send(uip_appdata, len + msglen);
+
+  vs->sendmsg = SENT_BLANK;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_send_screen(struct vnc_server_state *vs)
+{
+  vnc_out_send_update(vs);
+}
+/*-----------------------------------------------------------------------------------*/
+static short tmpbuf[30];
+void
+vnc_out_send_update(register struct vnc_server_state *vs)
+{
+  u8_t x, y, x0;
+  u8_t msglen;
+  u16_t len, n;
+  u8_t *ptr;
+  struct rfb_fb_update *umsg;
+  register struct rfb_fb_update_rect_hdr *recthdr;
+  struct rfb_rre_hdr *rrehdr;
+  u8_t c, color, lastcolor;
+  u8_t numblanks;
+
+  /* First, check if we need to feed the update function with a new
+     pending update. */
+  check_updates(vs);
+
+  /*  PRINTF(("Sending Update from (%d:%d) (%d:%d) to (%d:%d)\n",
+	 vs->x, vs->y, vs->x1, vs->y1, vs->x + vs->w,
+	 vs->y + vs->h));*/
+  
+  umsg = (struct rfb_fb_update *)uip_appdata;
+
+  umsg->type = RFB_FB_UPDATE;
+
+  x0 = vs->x1;
+  n = 0;
+  msglen = 0;
+  ptr = (u8_t *)umsg + sizeof(struct rfb_fb_update);
+  len = sizeof(struct rfb_fb_update);
+  
+  /* Loop over all characters that are covered by this update. */
+  for(y = vs->y1; y < vs->y + vs->h; ++y) {
+    for(x = x0; x < vs->x + vs->w; ++x) {
+
+
+      /* First check if there are any blank space characters, and if
+	 so, find out how many of them there are in a row. Instead of
+	 sending the individual space characters as raw bitmaps, we
+	 can send the entire string of blanks as a single color
+	 rectangle instead. */
+      
+      c = screen[x + y * CHARS_WIDTH];
+      numblanks = 0;
+      lastcolor = color = colorscreen[x + y * CHARS_WIDTH];
+
+      /* If the character is a blank, we continue reading characters
+	 until we find one that has a different color, or one that is
+	 not a blank. We must keep within the update rectangle, so we
+	 make sure that the "x" variable does not increase beyond the
+	 edge. The "numblanks" variable is used to keep track of how
+	 many blank characters we have found. */
+      while(lastcolor == color &&
+	    c == 0x20 &&
+	    x < vs->x + vs->w) {
+	++numblanks;
+
+	
+	++x;
+	lastcolor = color;
+	color = colorscreen[x + y * CHARS_WIDTH];
+	c = screen[x + y * CHARS_WIDTH];
+      }
+
+      if(numblanks > 0) {
+	
+	/*	PRINTF(("Found %d blanks (%d:%d -> %d:%d)\n",
+		numblanks, x - numblanks, y, x, y));*/
+	
+	/* There were one or more blank characters, so we send out a
+	   single color rectangle with the right width. But first we
+	   make sure that there is enough space in the current TCP
+	   segment to put the rectangle. If there isn't we have to
+	   backtrack the "x" variable to where we found the first
+	   blank character so that the next TCP segment will be able
+	   to update this area instead. */	
+
+	msglen = sizeof(struct rfb_fb_update_rect_hdr) +
+	  /*sizeof(struct rfb_rre_hdr)*/5;
+
+	if(msglen >= uip_mss() - len) {
+	  /*	  PRINTF(("Not enouch space for blanks (%d, left %d)\n",
+		  msglen, uip_mss() - len));*/
+	  /* There is not enough space in the segment, so we remember
+	     where we were ... */
+	  vs->x2 = x - numblanks;
+	  vs->y2 = y;
+
+	  /* ... and we break out of the loop. */
+	  goto loopend;	  
+	}
+
+	/* We construct a rectangle with the right width and color. */
+	/*	recthdr = (struct rfb_fb_update_rect_hdr *)ptr;*/
+	recthdr = (struct rfb_fb_update_rect_hdr *)tmpbuf;
+	rrehdr = (struct rfb_rre_hdr *)((char *)recthdr +
+		 sizeof(struct rfb_fb_update_rect_hdr));
+
+	/*	PRINTF(("Blankign (%d:%d) to (%d:%d)\n",
+	       (x - numblanks) * CTK_VNCFONT_WIDTH,
+	       y * CTK_VNCFONT_HEIGHT,
+	       CTK_VNCFONT_WIDTH * numblanks,
+	       CTK_VNCFONT_HEIGHT));*/
+	recthdr->rect.x = htons(SCREEN_X + (x - numblanks) *
+				CTK_VNCFONT_WIDTH);
+	recthdr->rect.y = htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT);
+	recthdr->rect.w = htons(CTK_VNCFONT_WIDTH * numblanks);
+	recthdr->rect.h = HTONS(CTK_VNCFONT_HEIGHT);
+	recthdr->encoding[0] =
+	  recthdr->encoding[1] =
+	  recthdr->encoding[2] = 0;
+	recthdr->encoding[3] = RFB_ENC_RRE;
+	
+	rrehdr->subrects[0] =
+	  rrehdr->subrects[1] = 0;
+	rrehdr->bgpixel = colortheme[lastcolor][0];
+
+	--x;
+      } else {
+
+	/* So there were no blank characters. */
+
+	/*	PRINTF(("An char at (%d:%d)\n", x, y));*/
+	/* First we must make sure that there is enough space in the
+	   outgoing TCP segment. */
+
+	msglen = sizeof(struct rfb_fb_update_rect_hdr) +
+	  CTK_VNCFONT_HEIGHT * CTK_VNCFONT_WIDTH;
+	if(msglen >= uip_mss() - len) {
+	  /*	  PRINTF(("Not enouch space for char (%d, left %d)\n",
+		  msglen, uip_mss() - len));*/
+	  
+	  /* There is not enough space in the segment, so we remember
+	     where we were ... */
+	  vs->x2 = x;
+	  vs->y2 = y;
+
+	  /* ... and we break out of the loop. */
+	  goto loopend;	  
+	}
+
+	/*	PRINTF(("ptr %p\n",ptr);*/
+	/*	recthdr = (struct rfb_fb_update_rect_hdr *)ptr;*/
+	recthdr = (struct rfb_fb_update_rect_hdr *)tmpbuf;
+
+	recthdr->rect.x = htons(SCREEN_X + x * CTK_VNCFONT_WIDTH);
+	recthdr->rect.y = htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT);
+	recthdr->rect.w = HTONS(CTK_VNCFONT_WIDTH);
+	recthdr->rect.h = HTONS(CTK_VNCFONT_HEIGHT);
+	recthdr->encoding[0] =
+	  recthdr->encoding[1] =
+	  recthdr->encoding[2] = 0;
+	recthdr->encoding[3] = RFB_ENC_RAW;
+
+	makechar((u8_t *)recthdr +
+		 sizeof(struct rfb_fb_update_rect_hdr),
+		 x, y);
+      }
+      memcpy(ptr, tmpbuf, msglen);
+      PRINTF(("Msglen %d (%d:%d)\n", msglen, x, y));
+      len += msglen;
+      ptr += msglen;
+      ++n;
+    }
+    x0 = vs->x;
+  }
+  
+ loopend:
+
+  umsg->rects = htons(n);
+	
+  if(y == vs->y + vs->h && x == vs->x + vs->w) {
+    vs->x2 = vs->y2 = 0;
+  }
+
+  if(n > 0) {
+    /*    printf("Sending %d rects, %d bytes (%p, %p, %p)\n", n, len,
+	  uip_appdata, umsg, ptr);*/
+    uip_send(uip_appdata, len);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+#define NUMKEYS 20
+static char keys[NUMKEYS];
+static int firstkey, lastkey;
+
+
+char
+vnc_out_keyavail(void)
+{
+  return firstkey != lastkey;
+}
+
+char
+vnc_out_getkey(void)
+{
+  char key;
+  key = keys[firstkey];
+  
+  if(firstkey != lastkey) {
+    ++firstkey;
+    if(firstkey >= NUMKEYS) {
+      firstkey = 0;
+    }
+  }
+  
+  return key;  
+}
+
+void
+vnc_out_key_event(struct vnc_server_state *vs)
+{
+  register struct rfb_key_event *ev;
+  
+  ev = (struct rfb_key_event *)uip_appdata;
+
+  if(ev->down != 0) {
+    if(vs->sendmsg == SEND_NONE) {
+      vs->sendmsg = SEND_UPDATE;
+    }
+
+
+    if(ev->key[2] == 0 ||
+       (ev->key[2] == 0xff &&	
+	(ev->key[3] == CH_HOME ||
+	 ev->key[3] == CH_TAB ||
+	 ev->key[3] == CH_ESC ||
+	 ev->key[3] == CH_DEL ||
+	 ev->key[3] == CH_ENTER ||
+	 ev->key[3] == CH_CURS_LEFT ||
+	 ev->key[3] == CH_CURS_UP ||
+	 ev->key[3] == CH_CURS_RIGHT ||
+	 ev->key[3] == CH_CURS_DOWN))) {
+      
+      keys[lastkey] = ev->key[3];
+      ++lastkey;
+      if(lastkey >= NUMKEYS) {
+	lastkey = 0;
+      }
+    }
+  }
+
+  check_updates(vs);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_pointer_event(struct vnc_server_state *vs)
+{
+  struct rfb_pointer_event *ev;
+  u16_t evx, evy;
+  
+  ev = (struct rfb_pointer_event *)uip_appdata;
+
+  evx = htons(ev->x);
+  evy = htons(ev->y);
+  
+  if(evx > SCREEN_X && evx < SCREEN_WIDTH - 2 * SCREEN_X &&
+     evy > SCREEN_Y && evy < SCREEN_HEIGHT - 2 * SCREEN_Y) {
+
+    mouse_button = ev->buttonmask & RFB_BUTTON_MASK1;
+    
+    mouse_x = evx - SCREEN_X;
+    mouse_y = evy - SCREEN_Y;
+
+    check_updates(vs);    
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_acked(register struct vnc_server_state *vs)
+{
+  if(vs->state != VNC_RUNNING) {
+    return;
+  }
+  if(vs->sendmsg == SENT_BLANK) {
+    init_send_screen(vs);
+  } else if(vs->sendmsg == SEND_BLANK) {
+    /* Do nothing until sendmsg == SENT_BLANK. */
+  } else if(vs->sendmsg == SEND_SCREEN) {
+    /* When the screen has been fully drawn, ->x2 and ->y2 are both
+       set to 0 to indicate this.*/
+    if(vs->x2 == 0 && vs->y2 == 0) {
+      vs->sendmsg = SEND_NONE;
+      
+      /* If there was an updaterequest for the entire screen, we can
+	 clear that flag now. */
+      if(vs->updates_current != NULL) {	
+	vnc_server_update_free(vs, vs->updates_current);
+	vs->updates_current = NULL;
+      }
+      check_updates(vs);
+    } else {
+      vs->x1 = vs->x2;
+      vs->y1 = vs->y2;
+    }
+	      
+  } else if(vs->sendmsg == SEND_UPDATE) {
+    if(vs->x2 == 0 && vs->y2 == 0) {
+      /* So, we have updated the area that we needed. We now check if
+	 there have been any recent full screen update requests. If
+	 so, we need to go to the SEND_SCREEN state. Else, we see if
+	 there were more areas that needed to be updated and if so,
+	 we'll continue with those. */
+
+      vs->sendmsg = SEND_NONE;
+
+      if(vs->updates_current != NULL) {
+	vnc_server_update_free(vs, vs->updates_current);
+	vs->updates_current = NULL;
+
+      }
+      check_updates(vs);
+#if 0
+      if(vs->updaterequest == VNC_SERVER_UPDATE_FULL) {
+	check_updates(vs);
+      } else {
+	vs->updatesptr2 = (vs->updatesptr2 + 1) %
+	  VNC_SERVER_MAX_UPDATES;
+
+	/* If there are no more updates to do, we'll go back to the
+	   SEND_NONE state. */	
+	if(vs->updatesptr2 == vs->updatesptr) {
+	  vs->updatetype = VNC_SERVER_UPDATE_NONE;
+	} else {	 
+	  /* Otherwise, we continue to update the next area. */
+	  vs->updaterequest = VNC_SERVER_UPDATE_PARTS;
+	  check_updates(vs);
+	}
+      }
+#endif /* 0 */
+    } else {	     
+      vs->x1 = vs->x2;
+      vs->y1 = vs->y2;
+    }    
+  } else {
+    vs->sendmsg = SEND_NONE;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_out_poll(struct vnc_server_state *vs)
+{
+  /*  PRINTF(("vs->state %d, sendmsg %d, updatetype %d, updatereq %d\n",
+      vs->state, vs->sendmsg, vs->updatetype, vs->updaterequest);*/
+  
+  if(vs->state == VNC_RUNNING &&
+     vs->sendmsg == SEND_NONE) {
+    check_updates(vs);
+    vnc_server_send_data(vs);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_MOUSE_SUPPORT
+void
+ctk_mouse_init(void)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+  return mouse_x;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+  return mouse_y;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+  return mouse_button;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mouse_hide(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_mouse_show(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki/ctk/vnc-out.h b/contiki/ctk/vnc-out.h
new file mode 100644
index 0000000..94cfb95
--- /dev/null
+++ b/contiki/ctk/vnc-out.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: vnc-out.h,v 1.4 2004/09/12 20:24:55 adamdunkels Exp $
+ *
+ */
+
+#ifndef __VNC_OUT_H__
+#define __VNC_OUT_H__
+
+
+void vnc_out_init(void);
+void vnc_out_new(struct vnc_server_state *vs);
+
+void vnc_out_send_blank(struct vnc_server_state *vs);
+void vnc_out_send_screen(struct vnc_server_state *vs);
+void vnc_out_send_update(struct vnc_server_state *vs);
+
+void vnc_out_key_event(struct vnc_server_state *vs);
+void vnc_out_pointer_event(struct vnc_server_state *vs);
+
+void vnc_out_acked(struct vnc_server_state *vs);
+
+void vnc_out_poll(struct vnc_server_state *vs);
+
+
+void vnc_out_update_screen(u8_t x, u8_t y, u8_t c, u8_t color);
+char vnc_out_getkey(void);
+char vnc_out_keyavail(void);
+
+void vnc_out_update_area(struct vnc_server_state *vs,
+			 u8_t x, u8_t y, u8_t w, u8_t h);
+
+#include "ctk.h"
+
+unsigned char vnc_out_add_icon(struct ctk_icon *icon);
+
+#if 1
+#define VNC_OUT_BACKGROUNDCOLOR 0
+#define VNC_OUT_WINDOWCOLOR    1
+#define VNC_OUT_SEPARATORCOLOR 7 /*(VNC_OUT_WINDOWCOLOR + 6)*/
+#define VNC_OUT_LABELCOLOR     13 /*(VNC_OUT_SEPARATORCOLOR + 6)*/
+#define VNC_OUT_BUTTONCOLOR    19 /*(VNC_OUT_LABELCOLOR + 6)*/
+#define VNC_OUT_HYPERLINKCOLOR 25 /*(VNC_OUT_BUTTONCOLOR + 6)*/
+#define VNC_OUT_TEXTENTRYCOLOR 31 /*(VNC_OUT_HYPERLINKCOLOR + 6)*/
+#define VNC_OUT_ICONCOLOR      37 /*(VNC_OUT_TEXTENTRYCOLOR + 6)*/
+#define VNC_OUT_MENUCOLOR      43 /*(VNC_OUT_ICONCOLOR + 6)*/
+#define VNC_OUT_OPENMENUCOLOR  44/*(VNC_OUT_MENUCOLOR + 1)*/
+#define VNC_OUT_ACTIVEMENUCOLOR 45 /*(VNC_OUT_OPENMENUCOLOR + 1) */
+#else
+#define VNC_OUT_BACKGROUNDCOLOR 0
+#define VNC_OUT_WINDOWCOLOR    1
+#define VNC_OUT_SEPARATORCOLOR (VNC_OUT_WINDOWCOLOR + 6)
+#define VNC_OUT_LABELCOLOR     (VNC_OUT_SEPARATORCOLOR + 6)
+#define VNC_OUT_BUTTONCOLOR    (VNC_OUT_LABELCOLOR + 6)
+#define VNC_OUT_HYPERLINKCOLOR (VNC_OUT_BUTTONCOLOR + 6)
+#define VNC_OUT_TEXTENTRYCOLOR (VNC_OUT_HYPERLINKCOLOR + 6)
+#define VNC_OUT_ICONCOLOR      (VNC_OUT_TEXTENTRYCOLOR + 6)
+#define VNC_OUT_MENUCOLOR      (VNC_OUT_ICONCOLOR + 6)
+#define VNC_OUT_OPENMENUCOLOR  (VNC_OUT_MENUCOLOR + 1)
+#define VNC_OUT_ACTIVEMENUCOLOR (VNC_OUT_OPENMENUCOLOR + 1)
+
+#endif
+
+#endif /* __VNC_OUT_H__ */
diff --git a/contiki/ctk/vnc-server.c b/contiki/ctk/vnc-server.c
new file mode 100644
index 0000000..62a4680
--- /dev/null
+++ b/contiki/ctk/vnc-server.c
@@ -0,0 +1,487 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: vnc-server.c,v 1.4 2004/08/09 20:32:28 adamdunkels Exp $
+ *
+ */
+
+/* A micro implementation of a VNC server. VNC is a protocol for
+   remote network displays. See http://www.uk.research.att.com/vnc/
+   for information about VNC.
+
+   Initialization states:
+
+   VNC_VERSION (send version string)
+   VNC_AUTH    (send auth message)
+   VNC_INIT    (send init message)
+
+   Steady state:
+   
+   VNC_RUNNING (send RFB updates, parse incoming messages)
+
+   What kind of message should be sent:
+
+   SEND_NONE   (No message)
+   SEND_BLANK  (Blank screen initially)
+   SEND_SCREEN (Send entire screen, initially)
+   SEND_UPDATE (Send incremental update)
+
+*/
+
+#include "uip.h"
+#include "vnc-server.h"
+#include "vnc-out.h"
+
+#include <string.h>
+
+/* RFB server initial handshaking string. */
+#define RFB_SERVER_VERSION_STRING rfb_server_version_string
+
+/* "RFB 003.003" */
+static u8_t rfb_server_version_string[12] = {82,70,66,32,48,48,51,46,48,48,51,10};
+
+/* uVNC */
+static u8_t uvnc_name[4] = {117,86,78,67};
+#if 1
+#define PRINTF(x)
+#else
+#define PRINTF(x) printf x
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+u8_t
+vnc_server_draw_rect(u8_t *ptr, u16_t x, u16_t y, u16_t w, u16_t h, u8_t c)
+{
+  register struct rfb_fb_update_rect_hdr *recthdr;
+  struct rfb_rre_hdr *rrehdr;
+
+  recthdr = (struct rfb_fb_update_rect_hdr *)ptr;
+  rrehdr = (struct rfb_rre_hdr *)(ptr + sizeof(struct rfb_fb_update_rect_hdr));
+  
+  recthdr->rect.x = x;
+  recthdr->rect.y = y;
+  recthdr->rect.w = w;
+  recthdr->rect.h = h; 
+  recthdr->encoding[0] =
+    recthdr->encoding[1] =
+    recthdr->encoding[2] = 0;
+  recthdr->encoding[3] = RFB_ENC_RRE;
+      
+  rrehdr->subrects[0] =
+    rrehdr->subrects[1] = 0;
+  rrehdr->bgpixel = c;
+      
+  return sizeof(struct rfb_fb_update_rect_hdr) + sizeof(struct rfb_rre_hdr);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_init(void)
+{
+  vnc_out_init();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_send_blank(struct vnc_server_state *vs)
+{
+  switch(vs->type) {
+  case 0:	
+    vnc_out_send_blank(vs);
+    break;
+    /*  case 1:
+    vnc_stats_send_blank(vs);
+    break;   */
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_send_screen(struct vnc_server_state *vs)
+{
+  switch(vs->type) {
+  case 0:	
+    vnc_out_send_screen(vs);
+    break;
+    /*  case 1:
+    vnc_stats_send_screen(vs);
+    break;*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_send_update(struct vnc_server_state *vs)
+{
+  switch(vs->type) {
+  case 0:	
+    vnc_out_send_update(vs);
+    break;
+    /*  case 1:
+    vnc_stats_send_update(vs);
+    break;*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_send_data(struct vnc_server_state *vs)
+{
+  register struct rfb_server_init *initmsg;
+  
+  switch(vs->state) {
+  case VNC_VERSION:
+    uip_send(RFB_SERVER_VERSION_STRING, sizeof(RFB_SERVER_VERSION_STRING));
+    break;
+  case VNC_AUTH:
+    uip_appdata[0] = 0;
+    uip_appdata[1] = 0;
+    uip_appdata[2] = 0;
+    uip_appdata[3] = RFB_AUTH_NONE;
+    uip_send(uip_appdata, 4);
+    break;
+  case VNC_INIT:
+    initmsg = (struct rfb_server_init *)uip_appdata;
+    initmsg->width = htons(vs->width);
+    initmsg->height = htons(vs->height);
+    /* BGR233 pixel format. */
+    initmsg->format.bps = 8;
+    initmsg->format.depth = 8;
+    initmsg->format.endian = 1;
+    initmsg->format.truecolor = 1;
+    initmsg->format.red_max = htons(7);
+    initmsg->format.green_max = htons(7);
+    initmsg->format.blue_max = htons(3);
+    initmsg->format.red_shift = 0;
+    initmsg->format.green_shift = 3;
+    initmsg->format.blue_shift = 6;
+    initmsg->namelength[0] = 0;
+    initmsg->namelength[1] = 0;
+    initmsg->namelength[2] = 0;	    
+    initmsg->namelength[3] = 4;
+    memcpy(&uip_appdata[sizeof(struct rfb_server_init)], uvnc_name, 4);
+    /*    uip_appdata[sizeof(struct rfb_server_init)+0] = 'u';
+    uip_appdata[sizeof(struct rfb_server_init)+1] = 'V';
+    uip_appdata[sizeof(struct rfb_server_init)+2] = 'N';
+    uip_appdata[sizeof(struct rfb_server_init)+3] = 'C';*/
+    uip_send(uip_appdata, sizeof(struct rfb_server_init) + 4);
+    break;
+  case VNC_RUNNING:
+    switch(vs->sendmsg) {
+    case SEND_NONE:
+      PRINTF(("Sending none\n"));
+      break;
+      
+    case SEND_BLANK:
+    case SENT_BLANK:
+      PRINTF(("Sending blank\n"));
+      vnc_send_blank(vs);
+      break;
+      
+    case SEND_SCREEN:
+      PRINTF(("Sending screen\n"));
+      vnc_send_screen(vs);
+      break;
+
+    case SEND_UPDATE:
+      PRINTF(("Sending update\n"));
+      vnc_send_update(vs);
+      break;
+    }
+    break;
+    
+  default:
+    break;
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_key_event(struct vnc_server_state *vs)
+{
+  switch(vs->type) {
+  case 0:	
+    vnc_out_key_event(vs);
+    break;
+    /*  case 1:
+    vnc_stats_key_event(vs);
+    break;*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_pointer_event(struct vnc_server_state *vs)
+{
+  switch(vs->type) {
+  case 0:	
+    vnc_out_pointer_event(vs);
+    break;
+    /*  case 1:
+    vnc_stats_pointer_event(vs);
+    break;*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+vnc_read_data(register struct vnc_server_state *vs)
+{
+  u8_t *appdata;
+  u16_t len;
+  struct rfb_fb_update_request *req;
+  /*  u8_t niter;*/
+  
+  len = uip_datalen();
+  appdata = (u8_t *)uip_appdata;
+  
+  /* First, check if there is data left to discard since last read. */
+  if(vs->readlen > 0) {
+    appdata += vs->readlen;
+    if(len > vs->readlen) {
+      len -= vs->readlen;
+      vs->readlen = 0;
+    } else {
+      vs->readlen -= len;
+      len = 0;
+    }
+  }
+
+  if(vs->readlen != 0) {
+    return 1;
+  }
+
+  /* All data read and ignored, parse next message. */
+  /*  for(niter = 32; niter > 0 && len > 0; --niter) {*/
+  while(len > 0) {
+    switch(vs->state) {
+    case VNC_VERSION:
+    case VNC_VERSION2:
+      PRINTF(("Read in version\n"));
+      /* Receive and ignore client version string (12 bytes). */
+      vs->state = VNC_AUTH;
+      vs->readlen = 12;
+      break;
+      
+    case VNC_AUTH:
+    case VNC_AUTH2:
+      PRINTF(("Read in auth \n"));
+      /* Read and discard initialization from client (1 byte). */
+      vs->readlen = 1;
+      vs->state = VNC_INIT;
+      break;
+      
+    case VNC_INIT:
+    case VNC_INIT2:
+      PRINTF(("Read in init \n"));
+      vs->readlen = 0;
+      vs->state = VNC_RUNNING;
+      
+    case VNC_RUNNING:
+      /* Handle all client events. */
+      switch(*appdata) {
+      case RFB_SET_PIXEL_FORMAT:
+	PRINTF(("Set pixel format\n"));
+	vs->readlen = sizeof(struct rfb_set_pixel_format);
+	/* Check if client runs with BGR233 format. If not, abort the
+	   connection. */
+	/* XXX: not implemented yet. */
+	break;
+	
+      case RFB_FIX_COLORMAP_ENTRIES:
+	PRINTF(("Fix colormap entries\n"));
+	return 0;
+	
+      case RFB_SET_ENCODINGS:
+	PRINTF(("Set encodings\n"));
+	vs->readlen = sizeof(struct rfb_set_encoding);
+	vs->readlen += htons(((struct rfb_set_encoding *)appdata)->encodings) * 4;
+	/* Make sure that client supports the encodings we use. */
+	/* XXX: not implemented yet. */
+	break;
+	
+      case RFB_FB_UPDATE_REQ:
+	PRINTF(("Update request\n"));
+	vs->update_requested = 1;
+	vs->readlen = sizeof(struct rfb_fb_update_request);
+	/* blank the screen initially */
+	req = (struct rfb_fb_update_request *)appdata;
+	if(req->incremental == 0) {
+	  /*	  vs->sendmsg = SEND_BLANK;*/
+	  vnc_out_update_area(vs, 0, 0, vs->w, vs->h);
+	}
+	break;
+	
+      case RFB_KEY_EVENT:
+	vs->readlen = sizeof(struct rfb_key_event);
+	vnc_key_event(vs);
+	break;
+	
+      case RFB_POINTER_EVENT:
+	vs->readlen = sizeof(struct rfb_pointer_event);
+	vnc_pointer_event(vs);
+	break;
+	
+      case RFB_CLIENT_CUT_TEXT:
+	PRINTF(("Client cut text\n"));
+
+	if(((struct rfb_client_cut_text *)appdata)->len[0] != 0 ||
+	   ((struct rfb_client_cut_text *)appdata)->len[1] != 0) {
+	  return 0;
+	  
+	}
+	vs->readlen = sizeof(struct rfb_client_cut_text) +
+	  (((struct rfb_client_cut_text *)appdata)->len[2] << 8) +
+	  ((struct rfb_client_cut_text *)appdata)->len[3];
+	/*	return 0;*/
+	break;
+	
+      default:
+	PRINTF(("Unknown message %d\n", *appdata));
+	return 0;
+      }
+      break;
+      
+    default:
+      return 0;
+    }
+
+    if(vs->readlen > 0) {
+      if(len > vs->readlen) {
+	len -= vs->readlen;
+	appdata += vs->readlen;
+	vs->readlen = 0;
+      } else {
+	vs->readlen -= len;
+	len = 0;
+      }
+    } else {
+      /* Lost data. */
+      break;
+    }
+    
+  }
+
+  /*  if(vs->readlen > 0) {
+    printf("More data %d\n", vs->readlen);
+    }*/
+  
+  /*  uip_appdata = appdata;*/
+
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_new(register struct vnc_server_state *vs)
+{
+  vs->counter = 0;
+  vs->readlen = 0;
+  vs->sendmsg = SEND_NONE;
+  vs->update_requested = 1;
+  switch(vs->type) {
+  case 0:	
+    vnc_out_new(vs);
+    break;
+    /*  case 1:
+    vnc_stats_new(vs);
+    break;*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+vnc_acked(register struct vnc_server_state *vs)
+{
+  switch(vs->state) {
+  case VNC_VERSION:
+    vs->state = VNC_VERSION2;
+    break;
+    
+  case VNC_AUTH:
+    vs->state = VNC_AUTH2;
+    break;
+    
+  case VNC_INIT:
+    vs->state = VNC_INIT2;
+    break;
+
+  case VNC_RUNNING:
+    switch(vs->type) {
+    case 0:	
+      vnc_out_acked(vs);
+      break;
+      /*    case 1:
+      vnc_stats_acked(vs);
+      break;*/
+    }
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_server_appcall(struct vnc_server_state *vs)
+{
+  
+  vs->type = htons(uip_conn->lport) - 5900;
+  
+  if(uip_connected()) {      
+    vnc_new(vs);
+    vs->state = VNC_VERSION;
+    vnc_server_send_data(vs);
+    return;
+  }
+  if(uip_acked()) {
+    PRINTF(("Acked\n"));
+    vnc_acked(vs);
+  }
+  
+  if(uip_newdata()) {
+    PRINTF(("Newdata\n"));
+    vs->counter = 0;
+    if(vnc_read_data(vs) == 0) {
+      uip_abort();
+      return;
+    }
+  }
+  
+  if(uip_rexmit()) {
+    PRINTF(("Rexmit\n"));
+  }
+  
+  
+  if(uip_newdata() ||
+     uip_rexmit() ||
+     uip_acked()) {
+    vnc_server_send_data(vs);
+  } else if(uip_poll()) {
+    ++vs->counter;
+    /* Abort connection after about 20 seconds of inactivity. */
+    if(vs->counter >= 40) {
+      uip_abort();
+      return;
+    }
+    
+    vnc_out_poll(vs);
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/ctk/vnc-server.h b/contiki/ctk/vnc-server.h
new file mode 100644
index 0000000..79cd033
--- /dev/null
+++ b/contiki/ctk/vnc-server.h
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: vnc-server.h,v 1.4 2004/09/12 20:24:55 adamdunkels Exp $
+ *
+ */
+
+#ifndef __VNC_SERVER_H__
+#define __VNC_SERVER_H__
+
+
+/*struct vnc_server_updatearea {
+  u8_t active;
+  u8_t x, y;
+  u8_t w, h;
+  };*/
+
+struct vnc_server_update {
+  struct vnc_server_update *next;
+
+#define VNC_SERVER_UPDATE_NONE  0
+#define VNC_SERVER_UPDATE_PARTS 1
+#define VNC_SERVER_UPDATE_FULL  2
+
+  u8_t type;
+
+  u8_t x, y;
+  u8_t w, h;  
+};
+
+struct vnc_server_state {
+  u16_t counter;
+  u8_t type;
+  u8_t state;
+  u16_t height, width;
+
+  u8_t update_requested;
+  
+  /* Variables used when sending screen updates. */
+  u8_t x, y, x1, y1, x2, y2;
+  u8_t w, h;
+
+  
+
+  u16_t readlen;
+  u8_t sendmsg;
+  u8_t button;
+
+  
+  struct vnc_server_update *updates_current;
+  struct vnc_server_update *updates_pending;
+  struct vnc_server_update *updates_free;
+
+#define VNC_SERVER_MAX_UPDATES 8  
+  struct vnc_server_update updates_pool[VNC_SERVER_MAX_UPDATES];
+
+};
+
+struct vnc_server_update *
+     vnc_server_update_alloc(struct vnc_server_state *vs);
+void vnc_server_update_free(struct vnc_server_state *vs,
+			    struct vnc_server_update *a);
+void vnc_server_update_remove(struct vnc_server_state *vs,
+			      struct vnc_server_update *a);
+
+void vnc_server_update_add(struct vnc_server_state *vs,
+			   struct vnc_server_update *a);
+struct vnc_server_update *
+     vnc_server_update_dequeue(struct vnc_server_state *vs);
+
+
+
+
+void vnc_server_init(void);
+void vnc_server_appcall(struct vnc_server_state *state);
+
+
+extern struct vnc_server_state *vs;
+
+enum {
+  VNC_DEALLOCATED,
+  VNC_VERSION,
+  VNC_VERSION2,
+  VNC_AUTH,
+  VNC_AUTH2,
+  VNC_INIT,
+  VNC_INIT2,
+  VNC_RUNNING
+};
+
+/* Sendmsg */
+enum {
+  SEND_NONE,
+  SEND_BLANK,
+  SENT_BLANK,
+  SEND_SCREEN,
+  SEND_UPDATE
+};
+
+
+/* Definitions of the RFB (Remote Frame Buffer) protocol
+   structures and constants. */
+
+#include "uipopt.h"
+
+void vnc_server_send_data(struct vnc_server_state *vs);
+u8_t vnc_server_draw_rect(u8_t *ptr, u16_t x, u16_t y, u16_t w, u16_t h, u8_t c);
+
+
+/* Generic rectangle - x, y coordinates, width and height. */
+struct rfb_rect {
+  u16_t x;
+  u16_t y;
+  u16_t w;
+  u16_t h;
+};
+
+/* Pixel format definition. */
+struct rfb_pixel_format {
+  u8_t bps;       /* Bits per pixel: 8, 16 or 32. */
+  u8_t depth;     /* Color depth: 8-32 */
+  u8_t endian;    /* 1 - big endian (motorola), 0 - little endian
+		     (x86) */
+  u8_t truecolor; /* 1 - true color is used, 0 - true color is not used. */
+
+  /* The following fields are only used if true color is used. */
+  u16_t red_max, green_max, blue_max;
+  u8_t red_shift, green_shift, blue_shift;
+  u8_t pad1;
+  u16_t pad2;
+};
+
+
+/* RFB authentication constants. */
+
+#define RFB_AUTH_FAILED      0
+#define RFB_AUTH_NONE        1
+#define RFB_AUTH_VNC         2
+
+#define RFB_VNC_AUTH_OK      0
+#define RFB_VNC_AUTH_FAILED  1
+#define RFB_VNC_AUTH_TOOMANY 2
+
+/* RFB message types. */
+
+/* From server to client: */
+#define RFB_FB_UPDATE            0
+#define RFB_SET_COLORMAP_ENTRIES 1
+#define RFB_BELL                 2
+#define RFB_SERVER_CUT_TEXT      3
+
+/* From client to server. */
+#define RFB_SET_PIXEL_FORMAT     0
+#define RFB_FIX_COLORMAP_ENTRIES 1
+#define RFB_SET_ENCODINGS        2
+#define RFB_FB_UPDATE_REQ        3
+#define RFB_KEY_EVENT            4
+#define RFB_POINTER_EVENT        5
+#define RFB_CLIENT_CUT_TEXT      6
+
+/* Encoding types. */
+#define RFB_ENC_RAW      0
+#define RFB_ENC_COPYRECT 1
+#define RFB_ENC_RRE      2
+#define RFB_ENC_CORRE    3
+#define RFB_ENC_HEXTILE  4
+
+/* Message definitions. */
+
+/* Server to client messages. */
+
+struct rfb_server_init {
+  u16_t width;
+  u16_t height;
+  struct rfb_pixel_format format;
+  u8_t namelength[4];
+  /* Followed by name. */
+};
+
+struct rfb_fb_update {
+  u8_t type;
+  u8_t pad;
+  u16_t rects; /* Number of rectanges (struct rfb_fb_update_rect_hdr +
+		  data) that follows. */
+};
+
+struct rfb_fb_update_rect_hdr {
+  struct rfb_rect rect;
+  u8_t encoding[4];
+};
+
+struct rfb_copy_rect {
+  u16_t srcx;
+  u16_t srcy;
+};
+
+struct rfb_rre_hdr {
+  u16_t subrects[2];  /* Number of subrectangles (struct
+			 rfb_rre_subrect) to follow. */
+  u8_t bgpixel;
+};
+
+struct rfb_rre_subrect {
+  u8_t pixel;
+  struct rfb_rect rect;
+};
+
+struct rfb_corre_rect {
+  u8_t x;
+  u8_t y;
+  u8_t w;
+  u8_t h;
+};
+
+/* Client to server messages. */
+
+struct rfb_set_pixel_format {
+  u8_t type;
+  u8_t pad;
+  u16_t pad2;
+  struct rfb_pixel_format format;
+};
+
+struct rfb_fix_colormap_entries {
+  u8_t type;
+  u8_t pad;
+  u16_t firstcolor;
+  u16_t colors;
+};
+
+struct rfb_set_encoding {
+  u8_t type;
+  u8_t pad;
+  u16_t encodings;
+};
+
+struct rfb_fb_update_request {
+  u8_t type;
+  u8_t incremental;
+  u16_t x;
+  u16_t y;
+  u16_t w;
+  u16_t h;
+};
+
+struct rfb_key_event {
+  u8_t type;
+  u8_t down;
+  u16_t pad;
+  u8_t key[4];
+};
+
+#define RFB_BUTTON_MASK1 1
+#define RFB_BUTTON_MASK2 2
+#define RFB_BUTTON_MASK3 4
+struct rfb_pointer_event {
+  u8_t type;
+  u8_t buttonmask;
+  u16_t x;
+  u16_t y;
+};
+
+struct rfb_client_cut_text {
+  u8_t type;
+  u8_t pad[3];
+  u8_t len[4];
+};
+
+#endif /* __VNC_SERVER_H__ */
diff --git a/contiki/doc/Doxyfile b/contiki/doc/Doxyfile
new file mode 100644
index 0000000..33ce07e
--- /dev/null
+++ b/contiki/doc/Doxyfile
@@ -0,0 +1,1147 @@
+# Doxyfile 1.3.5
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "Contiki 1.2"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = .
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
+# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
+# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
+# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# This tag can be used to specify the encoding used in the generated output. 
+# The encoding is not always determined by the language that is chosen, 
+# but also whether or not the output is meant for Windows or non-Windows users. 
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
+# forces the Windows encoding (this is the default for the Windows binary), 
+# whereas setting the tag to NO uses a Unix-style encoding (the default for 
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING   = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is used 
+# as the annotated text. Otherwise, the brief description is used as-is. If left 
+# blank, the following values are used ("$name" is automatically replaced with the 
+# name of the entity): "The $name class" "The $name widget" "The $name file" 
+# "is" "provides" "specifies" "contains" "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
+# members of a class in the documentation of that class as if those members were 
+# ordinary class members. Constructors, destructors and assignment operators of 
+# the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH        = ../
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = YES
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = YES
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = YES
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
+# only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
+# only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = YES
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = NO
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= NO
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = ../ek/ek.c \
+                         ../ek/arg.c \
+                         ../ek/ek.h \
+                         ../ek/ek-service.h \
+                         ../ek/dsc.h \
+                         ../ek/loader.h \
+			 pt-doc.txt \
+                         ../ek/pt.h \
+                         ../ek/lc.h \
+                         ../ek/lc-switch.h \
+                         ../ek/lc-addrlabels.h \
+                         ../ek/pt-sem.h \
+                         ../apps/program-handler.c \
+                         ../ctk/ctk.h \
+                         ../ctk/ctk.c \
+                         ../ctk/ctk-draw.h \
+                         uip-doc.txt \
+                         ../uip/uip.h \
+                         ../uip/uip.c \
+                         ../uip/uip_arp.h \
+                         ../uip/uip_arp.c \
+                         ../uip/uip-split.h \
+                         ../uip/uip-split.c \
+                         ../uip/uip-fw.h \
+                         ../uip/uip-fw.c \
+                         ../uip/uiplib.h \
+                         ../uip/uiplib.c \
+                         ../uip/resolv.h \
+                         ../uip/resolv.c \
+                         ../uip/psock.h \
+                         ../uip/tcpip.h \
+                         ../lib/cc.h \
+                         ../lib/petsciiconv.h \
+                         ../lib/ctk-textedit.h \
+                         ../lib/ctk-textedit.c \
+                         ../lib/memb.h \
+                         ../lib/memb.c \
+                         ../lib/timer.h \
+                         ../lib/timer.c \
+                         ../lib/list.h \
+                         ../lib/list.c \
+                         ../lib/clock.h \
+                         ../ek/mt.h \
+                         ../ek/mt.c \
+                         ../conf/uip-conf.h.example \
+                         ../conf/www-conf.h.example \
+                         contiki-mainpage.txt
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
+# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories.
+
+EXCLUDE_PATTERNS       = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.
+
+INPUT_FILTER           = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed.
+
+PREDEFINED             = CC_FUNCTION_POINTER_ARGS \
+                         UIP_UDP \
+                         WITH_LOADER_ARCH \
+			 DOXYGEN
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse the 
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
+# super classes. Setting the tag to NO turns the diagrams off. Note that this 
+# option is superseded by the HAVE_DOT option below. This is only a fallback. It is 
+# recommended to install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = NO
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_WIDTH    = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT   = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes that 
+# lay further from the root node will be omitted. Note that setting this option to 
+# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
+# note that a graph may be further truncated if the graph's image dimensions are 
+# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
+# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
diff --git a/contiki/doc/FILES b/contiki/doc/FILES
new file mode 100644
index 0000000..8c22d12
--- /dev/null
+++ b/contiki/doc/FILES
@@ -0,0 +1,25 @@
+The contiki/doc/ directory contains files for automatic generation of
+documentation from the Contiki source code. Documentation is generated
+with the doxygen tool (http://www.doxygen.org/).
+
+Doxyfile
+
+  Configuration file for the doxygen tool.
+
+contiki-mainpage.txt
+
+  The text for the first page in the documentation.
+
+ctk.txt
+
+  General documentation about CTK, the Contiki GUI toolkit. This file
+  is mostly obsolete, as the information has been moved into the
+  source code.
+
+release.txt
+
+  Release checklist.
+
+uip-doc.txt
+
+  Documentation for the uIP TCP/IP stack.
diff --git a/contiki/doc/contiki-mainpage.txt b/contiki/doc/contiki-mainpage.txt
new file mode 100644
index 0000000..b8825af
--- /dev/null
+++ b/contiki/doc/contiki-mainpage.txt
@@ -0,0 +1,52 @@
+/**
+
+\mainpage The Contiki Operating System
+
+\author Adam Dunkels <adam@dunkels.com>
+
+The Contiki operating system is a highly portable, minimalistic
+operating system for a variety of constrained systems ranging from
+modern 8-bit microcontrollers for embedded systems to old 8-bit
+homecomputers. Contiki provides a simple event driven kernel with
+optional preemptive multithreading, interprocess communication using
+message passing signals, a dynamic process structure and support for
+loading and unloading programs, native TCP/IP support using the uIP
+TCP/IP stack, and a graphical subsystem with either direct graphic
+support for directly connected terminals or networked virtual display
+with VNC or Telnet.
+
+Contiki is written in the C programming language and is freely
+available as open source under a BSD-style license. More information
+about Contiki can be found at the Contiki home page:
+http://www.sics.se/~adam/contiki/
+
+\section contiki-mainpage-tcpip TCP/IP support
+
+Contiki includes the uIP TCP/IP stack (http://www.sics.se/~adam/uip/)
+that provides Contiki with TCP/IP networking support. uIP provides the
+protocols TCP, UDP, IP, and ARP.
+
+\sa \ref uip "The uIP TCP/IP stack documentation"
+\sa \ref tcpip "The Contiki/uIP interface"
+\sa \ref socket "Socket-like library"
+
+\section contiki-mainpage-threads Multi-threading and protothreads
+
+Contiki is based on an event-driven kernel but provides support for
+both multi-threading and a lightweight stackless thread-like construct
+called protothreads.
+
+\sa \ref ek "The Contiki event-driven kernel"
+\sa \ref mt "Contiki multi-threading"
+\sa \ref pt "Protothreads"
+
+\section contiki-mainpage-lib Libraries
+
+Contiki provides a set of convenience libraries for memory management
+and linked list operations.
+
+\sa \ref timer "Timer library"
+\sa \ref memb "Memory block management"
+\sa \ref list "Linked list library"
+
+*/
\ No newline at end of file
diff --git a/contiki/doc/ctk.txt b/contiki/doc/ctk.txt
new file mode 100644
index 0000000..a2fa85c
--- /dev/null
+++ b/contiki/doc/ctk.txt
@@ -0,0 +1,557 @@
+This file describes the interface between the generic part of the
+Contiki toolkit (CTK) and the architecture specific parts of CTK (the
+so-called ctk-draw and ctk-arch layers).
+
+Author: Adam Dunkels <adam@dunkels.com>
+Version: $Id: ctk.txt,v 1.3 2005/03/15 15:53:51 oliverschmidt Exp $
+
+
+* Introduction *
+----------------
+
+The purpose of the ctk-arch and the ctk-draw is to act as an interface
+between the CTK and the actual hardware of the system on which Contiki
+is run. The ctk-arch takes care of the keyboard input from the user,
+and the ctk-draw is responsible for drawing the CTK desktop, windows
+and user interface widgets onto the actual screen.
+
+In order to aid in implementing a ctk-draw module, a text-based
+ctk-draw called ctk-conio has already been implemented. It conforms to
+the Borland conio C library, and a skeleton implementation of said
+library exists in lib/libconio.c. If a more machine specific ctk-draw
+module is to be implemented, the instructions in this file should be
+followed.
+
+
+* Keyboard input *
+------------------
+
+Keyboard input is implemented using two functions:
+
+  unsigned char ctk_arch_keyavail(void);
+
+and
+
+  ctk_arch_key_t ctk_arch_getkey(void);
+
+The ctk_arch_keyavail() function should return zero if there are no
+keys in the keyboard input queue, and non-zero if there are key presses
+waiting in the input queue. The ctk_arch_getkey() function should
+remove the first key press on the input queue, and return it to the
+caller. The ctk_arch_key_t type should usually be typedef'ed to be
+"char", but some architectures use other C types for representing
+key presses (such as the 16-bit short type).
+
+The usual typedef looks like the following:
+
+   typedef char ctk_arch_key_t;
+
+and should be put into a file named "ctk-arch.h", together with the C
+#defines described below.
+
+Apart from the C functions that handles keyboard input, CTK requires a
+few special characters such as the cursor keys and the enter
+key. These are #defined as C macros in the "ctk-arch.h" file. The
+following macros must be defined:
+
+   CH_CURS_DOWN
+   CH_CURS_LEFT
+   CH_CURS_RIGHT
+   CH_CURS_UP
+   CH_DEL
+   CH_ENTER
+   CH_ESC
+   CH_KEY
+
+
+* Screen drawing *
+------------------
+
+The ctk-draw module takes care of the actual screen drawing for CTK by
+implementing a handful of functions that are called by CTK. The
+functions will be described in detail below, but are listed here for
+convenience:
+
+   void ctk_draw_init(void);
+   unsigned char ctk_draw_width(void);
+   unsigned char ctk_draw_height(void);
+   void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2);
+   void ctk_draw_menus(struct ctk_menus *menus);
+   void ctk_draw_clear_window(struct ctk_window *window,
+                              unsigned char focus,
+                              unsigned char clipy1, unsigned char clipy2);
+   void ctk_draw_window(struct ctk_window *window,
+                        unsigned char focus,
+                        unsigned char clipy1,
+                        unsigned char clipy2,
+			unsigned char draw_borders);
+   void ctk_draw_dialog(struct ctk_window *dialog);
+   void ctk_draw_widget(struct ctk_widget *w,
+                        unsigned char focus,
+                        unsigned char clipy1,
+                        unsigned char clipy2);
+
+
+* Initialization *
+------------------
+
+The ctk-draw initializes itself by the function:
+
+   void ctk_draw_init(void);
+
+This function is supposed to get the screen ready for drawing, and may
+be called at more than one time during the operation of the system.
+
+
+* Screen coordinates *
+----------------------
+
+In order to work efficiently even on limited systems, CTK uses a
+simple coordinate system, where the screen is addressed using
+character coordinates instead of pixel coordinates. This makes it
+trivial to implement the coordinate system on a text-based screen,
+and significantly reduces complexity for pixel based screen systems.
+
+The top left of the screen is (0,0) with x and y coordinates growing
+downwards and to the right.
+
+It is the responsibility of the ctk-draw module to keep track of the
+screen size and must implement two functions which are used by the CTK
+for querying the screen size:
+
+   unsigned char ctk_draw_width(void);
+   unsigned char ctk_draw_height(void);
+
+The functions must return the width and the height of the ctk-draw
+screen in character coordinates.
+
+
+* Clearing the screen *
+-----------------------
+
+The ctk-draw is required to implement a function for clearing parts of
+the screen. This function is called by the CTK before an area of the
+screen is to be redrawn. The function prototype is:
+
+   void ctk_draw_clear(unsigned char clipy1, unsigned char clipy2);
+
+The function should clear the screen between the y coordinates
+"clipy1" and "clipy2", including the line at y coordinate "clipy1",
+but not the line at y coordinate "clipy2".
+
+Note that this function may be used to draw a background image
+(wallpaper) on the desktop; it does not necessarily "clear" the
+screen. 
+
+
+* Drawing menus *
+-----------------
+
+Drawing the menus is the responsibility of the ctk-draw, and is done
+from the function:
+
+   void ctk_draw_menus(struct ctk_menus *menus);
+
+The ctk_draw_menus() function takes a pointer to a struct ctk_menus as
+its argument and draws the menus at the top of the screen. The struct
+ctk_menus is defined in the file ctk/ctk.h as:
+
+   struct ctk_menus {
+     struct ctk_menu *menus;
+     struct ctk_menu *open;
+     struct ctk_menu *desktopmenu;
+   };
+
+The "open" item points to the currently active menu, if any. If all
+menus are closed, the "open" item is NULL. The "desktopmenu" item
+points to the "Desktop" menu, and can be used for drawing the desktop
+menu in a special way (such as drawing it at the rightmost
+position). The "menus" item points to a linked list of all menus,
+including the open menu and the desktop menu.
+
+The struct ctk_menu is also defined in ctk/ctk.h:
+
+   struct ctk_menu {
+     struct ctk_menu *next;
+     char *title;
+     unsigned char titlelen;
+     unsigned char nitems;
+     unsigned char active;
+     struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS];
+   };
+
+The "next" pointer points to the next menu, or is NULL if this is the
+last menu, and should be used for stepping through the menus when
+drawing them on screen. The "title" is the title of the menu, and the
+length of the title is given in the "titlelen" field. The "nitems"
+field specifies the total number of menu items in the menu and the
+"active" item specifies the active item in the menu. The active item
+should be drawn differently from the other items (it usually is drawn
+inverted). Finally, the list of menu items is present in the "items"
+list. This list consists of struct ctk_menuitem items; the struct
+ctk_menuitem is defined in the file ctk/ctk.h as:
+
+   struct ctk_menuitem {
+     char *title;
+     unsigned char titlelen;
+   };
+
+Where the "title" field is the title of the menu item and the
+"titlelen" the length of the title in characters.
+
+
+* Drawing window background *
+-----------------------------
+
+The ctk-draw layer must implement a function for "clearing" the
+window, i.e., draw the window background. This function will be called
+by the CTK before a window will be completely redrawn, and looks like:
+
+   void ctk_draw_clear_window(struct ctk_window *window,
+                              unsigned char focus,
+                              unsigned char clipy1, unsigned char clipy2);
+
+The function is supposed to draw the window background, excluding
+window borders as these should be drawn by the function that actually
+draws the window, between "clipy1" and "clipy2".
+
+
+* Drawing windows *
+-------------------
+
+The CTK will call upon the ctk-draw layer to actually draw windows
+onto the screen. The ctk-draw layer is free to choose how the window
+will appear on screen; with or without window borders and the style of
+the borders, with or without transparent window background and how the
+background shall look, etc.
+
+The function called by the CTK for drawing a window is:
+
+   void ctk_draw_window(struct ctk_window *window,
+                        unsigned char focus,
+                        unsigned char clipy1,
+                        unsigned char clipy2,
+			unsigned char draw_borders);
+
+The "clipy1" and "clipy2" parameters specify the first and last + 1
+lines on screen that actually should be drawn (if clipy1 = 2 and
+clipy2 = 3, only line 2 should be drawn). The clip parameters are
+given in screen coordinates, so line 1 is the first line below the
+menus.
+
+The focus parameter specifies if the window should be drawn in
+foreground or background colors and can be either CTK_FOCUS_NONE or
+CTK_FOCUS_WINDOW. Windows with a focus of CTK_FOCUS_WINDOW is usually
+drawn in a brighter color than those with CTK_FOCUS_NONE.
+
+The draw_borders parameter specifies if the window frame should be drawn.
+
+Finally, the "window" parameter gives the actual window to be
+drawn. This is specified as a struct ctk_window, which is defined in
+the file ctk/ctk.h as:
+
+   struct ctk_window {
+     struct ctk_window *next, *prev;
+     ek_id_t owner;
+     char *title;
+     unsigned char titlelen;
+     struct ctk_button closebutton;
+     struct ctk_button titlebutton;
+
+     unsigned char x, y;
+     unsigned char w, h;
+
+     struct ctk_widget *inactive;
+     struct ctk_widget *active;
+     struct ctk_widget *focused;
+   };
+
+The first "next" and "prev" fields are pointers used by the CTK for
+keeping the windows on a doubly linked list and are not used by the
+ctk-draw. Likewise, the "owner" field is used by the CTK to keep track
+of the process that created the window, and is not used by
+ctk-draw. The "title" and "titlelen" fields are used by the CTK when
+constructing the desktop menu, and should usually not be used by the
+ctk-draw.
+
+The "closebutton" and "titlebutton" fields are the CTK buttons used in
+the title bar. These should not be used directly by the ctk-draw
+module, as they are already present in the "active" widgets field
+described below. They may be used as a comparison to give special
+treatment to these two widgets however (e.g., if the close button
+should be drawn at the upper left corner instead of the default upper
+right corner), but may otherwise be ignored by the ctk-draw module.
+
+The "x" and "y" fields specify the x and y coordinates of the top left
+corner of the window and the "w" and "h" fields give the width and
+height of the window (excluding any window borders).
+
+Finally, the "inactive" and "active" widget pointers points to linked
+lists of CTK widgets. The "focused" pointer points either to one of
+the widgets in the "active" list, or is NULL if no widget is
+focused. How CTK widgets are drawn is explained below.
+
+A pseudo-code implementation of a ctk_draw_window() function might
+look like this:
+
+   ctk_draw_window(window, focus, clipy1, clipy2, draw_borders) {
+      if(draw_borders) {
+         draw_window_borders(window, focus, clipy1, clipy2);
+      }
+      foreach(widget, window->inactive) {
+         draw_widget(widget, focus, clipy1, clipy2);
+      }
+      foreach(widget, window->active) {
+         if(widget == window->focused) {
+	    draw_widget(widget, focus | CTK_FOCUS_WIDGET,
+	                    clipy1, clipy2);
+	 } else {
+	    draw_widget(widget, focus, clipy1, clipy2);
+	 }
+      }
+   }
+
+Where draw_window_borders() draws the window borders (also between
+clipy1 and clipy2). The draw_widget() function used may the same
+function as ctk_draw_widget() explained later. Notice how the clipy1
+and clipy2 parameters are passed to all other functions; every
+function needs to know the boundaries within which they are allowed to
+draw.
+
+
+* Drawing dialogs *
+-------------------
+
+In CTK, a dialog is similar to a window, with the only exception being
+that they are drawn in a different style. Also, since dialogs always
+are drawn on top of everything else, they do not need to be drawn
+within any special boundaries.
+
+The ctk-draw function that draws a dialog on screen is as follows:
+
+   void ctk_draw_dialog(struct ctk_window *dialog);
+
+It can usually be implemented together with the ctk_draw_window()
+function, which is explained above.
+
+
+* Drawing widgets *
+-------------------
+
+The function that draws the CTK widgets is likely to be the most
+complex function in the ctk-draw module. Still, it is straightforward
+to implement as it can be written in an incremental fashion, starting
+with a single widget type and adding more widget types, one at a time.
+
+The function for drawing widgets is:
+
+   void ctk_draw_widget(struct ctk_widget *widget,
+                        unsigned char focus,
+                        unsigned char clipy1,
+                        unsigned char clipy2);
+
+The "clipy1" and "clipy2" parameters specify the upper and lower
+bounds for the widget. The "focus" parameter specifies how the widget
+is focused and usually is used to decide in what colors the widget is
+to be drawn. The focus is a logical "or" combination of
+CTK_FOCUS_WIDGET and either CTK_FOCUS_WINDOW, CTK_FOCUS_DIALOG or
+CTK_FOCUS_NONE. A non-focused widget in a background window will have
+focus == CTK_FOCUS_NONE, a focused widget in a foreground window will
+have focus == CTK_FOCUS_WIDGET | CTK_FOCUS_WINDOW, and so on.
+
+The ctk-draw module may exploit how the CTK focus constants are
+defined in order to use a look-up table for the colors. The CTK focus
+constants are defined in the file ctk/ctk.h as follows:
+
+   #define CTK_FOCUS_NONE     0
+   #define CTK_FOCUS_WIDGET   1
+   #define CTK_FOCUS_WINDOW   2
+   #define CTK_FOCUS_DIALOG   4
+
+This gives the following table:
+
+   0: CTK_FOCUS_NONE      (Background window, non-focused widget)
+   1: CTK_FOCUS_WIDGET    (Background window, focused widget)
+   2: CTK_FOCUS_WINDOW    (Foreground window, non-focused widget)
+   3: CTK_FOCUS_WINDOW | CTK_FOCUS_WIDGET
+                          (Foreground window, focused widget)
+   4: CTK_FOCUS_DIALOG    (Dialog, non-focused widget)
+   5: CTK_FOCUS_DIALOG | CTK_FOCUS_WIDGET
+                          (Dialog, focused widget)
+
+Finally, the "widget" parameter gives the actual widget that is to be
+drawn. The struct ctk_widget is defined in ctk/ctk.h and looks like:
+
+   struct ctk_widget {
+     struct ctk_widget *next;
+     struct ctk_window *window;
+     unsigned char x, y;
+     unsigned char type;
+     unsigned char w;
+     union {
+       struct ctk_widget_label label;
+       struct ctk_widget_button button;
+       struct ctk_widget_hyperlink hyperlink;
+       struct ctk_widget_textentry textentry;
+       struct ctk_widget_icon icon;
+       struct ctk_widget_bitmap bitmap;
+     } widget;
+   };
+
+The "next" pointer points to the next widget in the linked list of
+widgets and should be used by the ctk_draw_window() function when
+stepping through the widgets. It should not be used by the
+ctk_draw_widget() function, however. The "window" pointer points to
+the window in which the widget is contained, and should be used to
+obtain the coordinates for the window.
+
+The "x" and "y" fields are the x and y coordinates of the widget,
+relative to the x and y coordinates of the window in which the widget
+is contained (the "window" pointer). The "type" field specifies what
+kind of widget this is, and the "w" field has the width of the widget.
+
+Finally, the "widget" union holds the actual widget structure. These
+are described below.
+
+
+* The separator widget *
+------------------------
+
+The separator widget is the simplest of all widgets, and do not need
+any more information than what already is present in the struct
+ctk_widget structure: it has x and y coordinates and a width.
+
+
+* The label widget *
+--------------------
+
+The label widget is defined by the struct ctk_widget_label structure
+(accessible from the struct ctk_widget *widget as
+widget->widget.label), which is found in ctk/ctk.h:
+
+   struct ctk_widget_label {
+     char *text;
+     unsigned char h;
+   };
+
+The "text" points to an array of text, and the "h" specifies the
+height of the label. Each line of text in the "text" array is found at
+"w" distance from each other (the "w" is found in the struct
+ctk_widget).
+
+
+* The button widget *
+---------------------
+
+The struct ctk_widget_button looks like:
+
+   struct ctk_widget_button {
+     char *text;
+   };
+
+Where the "text" is the text that is to be displayed on the
+button. The CTK assumes that the button widget will have one character
+of space to the left and right of it (this is usually where the button
+borders are drawn).
+
+
+* The hyperlink widget *
+------------------------
+
+The hyperlink widget is defined by the struct ctk_widget_hyperlink
+structure:
+
+   struct ctk_widget_hyperlink {
+     char *text;
+     char *url;
+   };
+
+The "text" pointer points to the text of the hyperlink, and the "url"
+is the URL to which the hyperlink points. The ctk-draw usually will
+not need to bother with the "url" field. The hyperlink widget usually
+is drawn in a different color than the label widget, preferably
+underlined.
+
+
+* The text entry widget *
+-------------------------
+
+The text entry widget is a little more complicated to draw than the
+other widgets because it has a number of state variables which
+influence the way it should be drawn. The struct ctk_widget_textentry
+looks like this:
+
+   struct ctk_widget_textentry {
+     char *text;
+     unsigned char h;
+     unsigned char len;
+     unsigned char xpos, ypos;
+     unsigned char state;
+   };
+
+Where "text" is the text which is to be edited, "h" is the height of
+the text edit widget, "len" is the length of the line(s) that is being
+edited (which may be different from the width "w" of the
+widget). "xpos" and "ypos" is the position of the cursor in the text
+edit widget and "state" is the state in which the widget is. The state
+can be
+
+   CTK_TEXTENTRY_NORMAL
+
+or
+
+   CTK_TEXTENTRY_EDIT
+
+In the CTK_TEXTENTRY_EDIT state, the text is currenly being edited,
+while in the CTK_TEXTENTRY_NORMAL, the text is not being edited. Text
+entry widgets where the text is being edited should be drawn
+differently than when in the normal state.
+
+
+* The bitmap widget *
+---------------------
+
+The bitmap widget is different from the other CTK widgets because it
+is architecture dependant; there is no standard bitmap format
+specified for Contiki, but this is up to the architecture. (This means
+that application programs that use the bitmap widget must be able to
+draw in the architecture specific format as well.)
+
+The struct ctk_widget_bitmap looks like:
+
+   struct ctk_widget_bitmap {
+     unsigned char *bitmap;
+     unsigned char h;
+   };
+
+Where "h" is the height of the bitmap widget, and "bitmap" is a
+generic pointer that points to an architecture specific
+repressentation of the bitmap.
+
+* The icon widget *
+-------------------
+
+The icon widget is similar to the bitmap widget in that it uses an
+architecture specific bitmap format for the repressentation of the
+graphical icon. It also includes a text version of the icon. XXX: the
+icon widget format is likely to change in the near future!
+
+The struct ctk_widget_icon is defined as:
+
+   struct ctk_widget_icon {
+     char *title;
+     ek_id_t owner;
+     unsigned char *bitmap;
+     char *textmap;
+   };
+
+The "title" field is the name of the icon, and should be drawn below
+the icon picture. The "owner" is the process that created the icon,
+and should normally be ignored by the ctk-draw. The "bitmap" is a
+pointer to an architecture specific repressentation of the icon; the
+same on-screen drawing function can be used for this bitmap as for the
+bitmap widget. Finally, the "textmap" is a text based icon.
+
+Currently, icons are 24x24 pixels large (the text based versions are
+3x3 characters).
+
diff --git a/contiki/doc/pt-doc.txt b/contiki/doc/pt-doc.txt
new file mode 100644
index 0000000..75c80fa
--- /dev/null
+++ b/contiki/doc/pt-doc.txt
@@ -0,0 +1,171 @@
+/**
+\defgroup pt Protothreads 
+@{ 
+
+
+Protothreads are a type of lightweight stackless threads designed for
+severly memory constrained systems such as deeply embedded systems or
+sensor network nodes. Protothreads provides linear code execution for
+event-driven systems implemented in C. Protothreads can be used with
+or without an RTOS.
+
+Protothreads are a extremely lightweight, stackless type of threads
+that provides a blocking context on top of an event-driven system,
+without the overhead of per-thread stacks. The purpose of protothreads
+is to implement sequential flow of control without complex state
+machines or full multi-threading. Protothreads provides conditional
+blocking inside C functions.
+
+The advantage of protothreads over a purely event-driven approach is
+that protothreads provides a sequential code structure that allows for
+blocking functions. In purely event-driven systems, blocking must be
+implemented by manually breaking the function into two pieces - one
+for the piece of code before the blocking call and one for the code
+after the blocking call. This makes it hard to use control structures
+such as if() conditionals and while() loops.
+
+The advantage of protothreads over ordinary threads is that a
+protothread do not require a separate stack. In memory constrained
+systems, the overhead of allocating multiple stacks can consume large
+amounts of the available memory. In contrast, each protothread only
+requires between two and twelve bytes of state, depending on the
+architecture.
+
+\note Because protothreads do not save the stack context across a
+blocking call, <b>local variables are not preserved when the
+protothread blocks</b>. This means that local variables should be used
+with utmost care - <b>if in doubt, do not use local variables inside a
+protothread!</b>
+
+
+Main features:
+
+    - No machine specific code - the protothreads library is pure C
+
+    - Does not use error-prone functions such as longjmp()
+        
+    - Very small RAM overhead - only two bytes per protothread
+    
+    - Can be used with or without an OS
+    
+    - Provides blocking wait without full multi-threading or
+      stack-switching
+
+Examples applications:
+
+    - Memory constrained systems
+    
+    - Event-driven protocol stacks
+    
+    - Deeply embedded systems
+    
+    - Sensor network nodes
+
+The protothreads API consists of four basic operations:
+initialization: PT_INIT(), execution: PT_BEGIN(), conditional
+blocking: PT_WAIT_UNTIL() and exit: PT_END(). On top of these, two
+convenience functions are built: reversed condition blocking:
+PT_WAIT_WHILE() and protothread blocking: PT_WAIT_THREAD().
+
+\sa \ref pt "Protothreads API documentation"
+    
+The protothreads library is released under a BSD-style license that
+allows for both non-commercial and commercial usage. The only
+requirement is that credit is given.
+
+\section authors Authors
+
+The protothreads library was written by Adam Dunkels <adam@sics.se>
+with support from Oliver Schmidt <ol.sc@web.de>.
+
+\section pt-desc Protothreads
+
+Protothreads are a extremely lightweight, stackless threads that
+provides a blocking context on top of an event-driven system, without
+the overhead of per-thread stacks. The purpose of protothreads is to
+implement sequential flow of control without using complex state
+machines or full multi-threading. Protothreads provides conditional
+blocking inside a C function.
+
+In memory constrained systems, such as deeply embedded systems,
+traditional multi-threading may have a too large memory overhead. In
+traditional multi-threading, each thread requires its own stack, that
+typically is over-provisioned. The stacks may use large parts of the
+available memory.
+
+The main advantage of protothreads over ordinary threads is that
+protothreads are very lightweight: a protothread does not require its
+own stack. Rather, all protothreads run on the same stack and context
+switching is done by stack rewinding. This is advantageous in memory
+constrained systems, where a stack for a thread might use a large part
+of the available memory. A protothread only requires only two bytes of
+memory per protothread. Moreover, protothreads are implemented in pure
+C and do not require any machine-specific assembler code.
+
+A protothread runs within a single C function and cannot span over
+other functions. A protothread may call normal C functions, but cannot
+block inside a called function. Blocking inside nested function calls
+is instead made by spawning a separate protothread for each
+potentially blocking function. The advantage of this approach is that
+blocking is explicit: the programmer knows exactly which functions
+that block that which functions the never blocks.
+
+Protothreads are similar to asymmetric co-routines. The main
+difference is that co-routines uses a separate stack for each
+co-routine, whereas protothreads are stackless. The most similar
+mechanism to protothreads are Python generators. These are also
+stackless constructs, but have a different purpose. Protothreads
+provides blocking contexts inside a C function, whereas Python
+generators provide multiple exit points from a generator function.
+
+\section pt-autovars Local variables
+
+\note 
+Because protothreads do not save the stack context across a blocking
+call, local variables are not preserved when the protothread
+blocks. This means that local variables should be used with utmost
+care - if in doubt, do not use local variables inside a protothread!
+
+\section pt-scheduling Scheduling
+
+A protothread is driven by repeated calls to the function in which the
+protothread is running. Each time the function is called, the
+protothread will run until it blocks or exits. Thus the scheduling of
+protothreads is done by the application that uses protothreads.
+
+\section pt-impl Implementation
+
+Protothreads are implemented using \ref lc "local continuations". A
+local continuation represents the current state of execution at a
+particular place in the program, but does not provide any call history
+or local variables. A local continuation can be set in a specific
+function to capture the state of the function. After a local
+continuation has been set can be resumed in order to restore the state
+of the function at the point where the local continuation was set.
+
+
+Local continuations can be implemented in a variety of ways:
+
+   -# by using machine specific assembler code,
+   -# by using standard C constructs, or
+   -# by using compiler extensions. 
+
+The first way works by saving and restoring the processor state,
+except for stack pointers, and requires between 16 and 32 bytes of
+memory per protothread. The exact amount of memory required depends on
+the architecture.
+
+The standard C implementation requires only two bytes of state per
+protothread and utilizes the C switch() statement in a non-obvious way
+that is similar to Duff's device. This implementation does, however,
+impose a slight restriction to the code that uses protothreads in that
+the code cannot use switch() statements itself.
+
+Certain compilers has C extensions that can be used to implement
+protothreads. GCC supports label pointers that can be used for this
+purpose. With this implementation, protothreads require 4 bytes of RAM
+per protothread.
+
+
+*/
+
diff --git a/contiki/doc/release.txt b/contiki/doc/release.txt
new file mode 100644
index 0000000..066c914
--- /dev/null
+++ b/contiki/doc/release.txt
@@ -0,0 +1,74 @@
+This document is a checklist for what steps to take for a Contiki
+release.
+
+Version: $Id: release.txt,v 1.2 2003/04/09 13:45:08 adamdunkels Exp $
+Author: Adam Dunkels
+
+* Update version number for web browser user-agent string:
+- Update version number in apps/http-strings
+- Run ./makestrings in apps/
+
+* Make sure everything is commited by checking out a separate version,
+  compile and run. 
+
+* Tag base code and ports with CONTIKI-MAJOR-MINOR tag.
+
+* Export a version of the base code and ports with the
+  CONTIKI-MAJOR-MINOR tag.
+
+* Copy include files to contiki-devel-environment:
+ - ctk/ctk-draw.h
+ - ctk/ctk-mouse.h
+ - ctk/ctk.h
+ - ek/dispatcher.h
+ - ek/ek.h
+ - ek/loader.h
+ - lib/petsciiconv.h
+ - uip/resolv.h
+ - uip/uip.h
+ - uip/uip_main.h
+ - uip/uipopt.h
+ From port:
+ - ctk/ctk-conf.h
+ - ctk/ek-conf.h
+ - loader/loader-arch.h
+
+* Compile the rs232-eyecandy module and programs in contiki-c64
+ - gmake clean rs232-eyecandy programs
+
+* Make D64 image in contiki-c64
+ - gmake d64
+
+* Rename D64 image to contiki-minor.major.d64
+
+* Copy .prg programs from port to contiki-devel-environment
+
+* Copy contiki, contiki-labels.o and loader-arch-module.o into
+  contiki-devel-environment
+
+* Rename contiki to contiki-minor.major and contiki-labels.o to
+  contiki-labels-minor.major.o
+
+* Update Makefile in contiki-devel-environment to use
+  contiki-labels-minor.major.o 
+
+* Compile and run test program in contiki-devel-environment
+
+* Commit in contiki-devel-environment
+
+* Tag contiki-devel-environment with CONTIKI-MAJOR-MINOR tag.
+
+* Export clean CONTIKI-MAJOR-MINOR sources for base, ports and
+  contiki-devel-enviroment 
+
+* Copy contiki, contiki-labels.o and loader-arch-module.o into
+  clean contiki-devel-environment
+
+* Rename directories to <dirname>-major.minor
+
+* Create tarball and zip of the clean base code and ports.
+
+* Create tarball and zip of the contiki-devel-environment with
+  contiki, contiki-labels.o and loader-arch-module.o
+
+* Create zip and gz of the D64 image.
diff --git a/contiki/doc/uip-doc.txt b/contiki/doc/uip-doc.txt
new file mode 100644
index 0000000..c4203d6
--- /dev/null
+++ b/contiki/doc/uip-doc.txt
@@ -0,0 +1,393 @@
+/**
+\defgroup uip The uIP TCP/IP stack
+@{
+
+The uIP TCP/IP stack provides Internet communication abilities to
+Contiki.
+
+\section uip-introduction uIP introduction
+
+With the success of the Internet, the TCP/IP protocol suite has become
+a global standard for communication. TCP/IP is the underlying protocol
+used for web page transfers, e-mail transmissions, file transfers, and
+peer-to-peer networking over the Internet. For embedded systems, being
+able to run native TCP/IP makes it possible to connect the system
+directly to an intranet or even the global Internet. Embedded devices
+with full TCP/IP support will be first-class network citizens, thus
+being able to fully communicate with other hosts in the network.
+
+Traditional TCP/IP implementations have required far too much
+resources both in terms of code size and memory usage to be useful in
+small 8 or 16-bit systems. Code size of a few hundred kilobytes and
+RAM requirements of several hundreds of kilobytes have made it
+impossible to fit the full TCP/IP stack into systems with a few tens
+of kilobytes of RAM and room for less than 100 kilobytes of
+code.
+
+The uIP implementation is designed to have only the absolute minimal
+set of features needed for a full TCP/IP stack. It can only handle a
+single network interface and does not implement UDP, but focuses on
+the IP, ICMP and TCP protocols. uIP is written in the C programming
+language.
+
+Many other TCP/IP implementations for small systems assume that the
+embedded device always will communicate with a full-scale TCP/IP
+implementation running on a workstation-class machine. Under this
+assumption, it is possible to remove certain TCP/IP mechanisms that
+are very rarely used in such situations. Many of those mechanisms are
+essential, however, if the embedded device is to communicate with
+another equally limited device, e.g., when running distributed
+peer-to-peer services and protocols. uIP is designed to be RFC
+compliant in order to let the embedded devices to act as first-class
+network citizens. The uIP TCP/IP implementation that is not tailored
+for any specific application.
+
+
+\section uip-tcpip TCP/IP communication
+
+The full TCP/IP suite consists of numerous protocols, ranging from low
+level protocols such as ARP which translates IP addresses to MAC
+addresses, to application level protocols such as SMTP that is used to
+transfer e-mail. The uIP is mostly concerned with the TCP and IP
+protocols and upper layer protocols will be refered to as ``the
+application''. Lower layer protocols are often implemented in hardware
+or firmware and will be referred to as ``the network device'' that are
+controlled by the network device driver.
+
+TCP provides a reliable byte stream to the upper layer protocols. It
+breaks the byte stream into appropriately sized segments and each
+segment is sent in its own IP packet. The IP packets are sent out on
+the network by the network device driver. If the destination is not on
+the physically connected network, the IP packet is forwarded onto
+another network by a router that is situated between the two
+networks. If the maximum packet size of the other network is smaller
+than the size of the IP packet, the packet is fragmented into smaller
+packets by the router. If possible, the size of the TCP segments are
+chosen so that fragmentation is minimized. The final recipient of the
+packet will have to reassemble any fragmented IP packets before they
+can be passed to higher layers.
+
+The formal requirements for the protocols in the TCP/IP stack is
+specified in a number of RFC documents published by the Internet
+Engineering Task Force, IETF. Each of the protocols in the stack is
+defined in one more RFC documents and RFC1122 collects
+all requirements and updates the previous RFCs. 
+
+The RFC1122 requirements can be divided into two categories; those
+that deal with the host to host communication and those that deal with
+communication between the application and the networking stack. An
+example of the first kind is "A TCP MUST be able to receive a TCP
+option in any segment" and an example of the second kind is "There
+MUST be a mechanism for reporting soft TCP error conditions to the
+application." A TCP/IP implementation that violates requirements of
+the first kind may not be able to communicate with other TCP/IP
+implementations and may even lead to network failures. Violation of
+the second kind of requirements will only affect the communication
+within the system and will not affect host-to-host communication.
+
+In our implementations, we have implemented all RFC requirements that
+affect host-to-host communication. However, in order to reduce code
+size, we have removed certain mechanisms in the interface between the
+application and the stack, such as the soft error reporting mechanism
+and dynamically configurable type-of-service bits for TCP
+connections. Since there are only very few applications that make use
+of those features they can be removed without loss of generality.
+
+\section uip-memory Memory management
+
+In the architectures for which uIP is intended, RAM is the most
+scarce resource. With only a few kilobytes of RAM available for the
+TCP/IP stack to use, mechanisms used in traditional TCP/IP cannot be
+directly applied.
+
+
+The uIP stack does not use explicit dynamic memory
+allocation. Instead, it uses a single global buffer for holding
+packets and has a fixed table for holding connection state. The global
+packet buffer is large enough to contain one packet of maximum
+size. When a packet arrives from the network, the device driver places
+it in the global buffer and calls the TCP/IP stack. If the packet
+contains data, the TCP/IP stack will notify the corresponding
+application. Because the data in the buffer will be overwritten by the
+next incoming packet, the application will either have to act
+immediately on the data or copy the data into a secondary buffer for
+later processing. The packet buffer will not be overwritten by new
+packets before the application has processed the data. Packets that
+arrive when the application is processing the data must be queued,
+either by the network device or by the device driver. Most single-chip
+Ethernet controllers have on-chip buffers that are large enough to
+contain at least 4 maximum sized Ethernet frames. Devices that are
+handled by the processor, such as RS-232 ports, can copy incoming
+bytes to a separate buffer during application processing. If the
+buffers are full, the incoming packet is dropped. This will cause
+performance degradation, but only when multiple connections are
+running in parallel. This is because uIP advertises a very small
+receiver window, which means that only a single TCP segment will be in
+the network per connection.
+
+In uIP, the same global packet buffer that is used for incoming
+packets is also used for the TCP/IP headers of outgoing data. If the
+application sends dynamic data, it may use the parts of the global
+packet buffer that are not used for headers as a temporary storage
+buffer. To send the data, the application passes a pointer to the data
+as well as the length of the data to the stack. The TCP/IP headers are
+written into the global buffer and once the headers have been
+produced, the device driver sends the headers and the application data
+out on the network. The data is not queued for
+retransmissions. Instead, the application will have to reproduce the
+data if a retransmission is necessary.
+
+The total amount of memory usage for uIP depends heavily on the
+applications of the particular device in which the implementations are
+to be run. The memory configuration determines both the amount of
+traffic the system should be able to handle and the maximum amount of
+simultaneous connections. A device that will be sending large e-mails
+while at the same time running a web server with highly dynamic web
+pages and multiple simultaneous clients, will require more RAM than a
+simple Telnet server. It is possible to run the uIP implementation
+with as little as 200 bytes of RAM, but such a configuration will
+provide extremely low throughput and will only allow a small number of
+simultaneous connections.
+
+\section uip-api Application program interface (API)
+
+The Application Program Interface (API) defines the way the
+application program interacts with the TCP/IP stack. The most commonly
+used API for TCP/IP is the BSD socket API which is used in most Unix
+systems and has heavily influenced the Microsoft Windows WinSock
+API. Because the socket API uses stop-and-wait semantics, it requires
+support from an underlying multitasking operating system. Since the
+overhead of task management, context switching and allocation of stack
+space for the tasks might be too high in the intended uIP target
+architectures, the BSD socket interface is not suitable for our
+purposes.
+
+Instead, uIP uses an event driven interface where the application is
+invoked in response to certain events. An application running on top
+of uIP is implemented as a C function that is called by uIP in
+response to certain events. uIP calls the application when data is
+received, when data has been successfully delivered to the other end
+of the connection, when a new connection has been set up, or when data
+has to be retransmitted. The application is also periodically polled
+for new data. The application program provides only one callback
+function; it is up to the application to deal with mapping different
+network services to different ports and connections. Because the
+application is able to act on incoming data and connection requests as
+soon as the TCP/IP stack receives the packet, low response times can
+be achieved even in low-end systems.
+
+uIP is different from other TCP/IP stacks in that it requires help
+from the application when doing retransmissions. Other TCP/IP stacks
+buffer the transmitted data in memory until the data is known to be
+successfully delivered to the remote end of the connection. If the
+data needs to be retransmitted, the stack takes care of the
+retransmission without notifying the application. With this approach,
+the data has to be buffered in memory while waiting for an
+acknowledgment even if the application might be able to quickly
+regenerate the data if a retransmission has to be made.
+
+In order to reduce memory usage, uIP utilizes the fact that the
+application may be able to regenerate sent data and lets the
+application take part in retransmissions. uIP does not keep track of
+packet contents after they have been sent by the device driver, and
+uIP requires that the application takes an active part in performing
+the retransmission. When uIP decides that a segment should be
+retransmitted, it calls the application with a flag set indicating
+that a retransmission is required. The application checks the
+retransmission flag and produces the same data that was previously
+sent. From the application's standpoint, performing a retransmission
+is not different from how the data originally was sent. Therefore the
+application can be written in such a way that the same code is used
+both for sending data and retransmitting data. Also, it is important
+to note that even though the actual retransmission operation is
+carried out by the application, it is the responsibility of the stack
+to know when the retransmission should be made. Thus the complexity of
+the application does not necessarily increase because it takes an
+active part in doing retransmissions.
+
+\subsection uip-appevents Application events
+
+The application must be implemented as a C function, UIP_APPCALL(),
+that uIP calls whenever an event occurs. Each event has a corresponing
+test function that is used to distinguish between different
+events. The functions are implemented as C macros that will evaluate
+to either zero or non-zero. Note that certain events can happen in
+conjunction with each other (i.e., new data can arrive at the same
+time as data is acknowledged).
+
+\subsection uip-connstate The connection pointer
+
+When the application is called by uIP, the global variable uip_conn is
+set to point to the uip_conn structure for the current
+connection. This can be used to distinguish between different
+services. A typical use would be to inspect the uip_conn->lport (the
+local TCP port number) to decide which service the connection should
+provide. For instance, an application might decide to act as an HTTP
+server if the value of uip_conn->lport is equal to 80 and act as a
+TELNET server if the value is 23.
+
+\subsection uip-recvdata Receiving data
+
+If the uIP test function uip_newdata() is non-zero, the remote host of
+the connection has sent new data. The uip_appdata pointer point to the
+actual data. The size of the data is obtained through the uIP function
+uip_datalen(). The data is not buffered by uIP, but will be
+overwritten after the application function returns, and the
+application will therefor have to either act directly on the incoming
+data, or by itself copy the incoming data into a buffer for later
+processing.
+
+\subsection uip-senddata Sending data
+
+When sending data, the application must check the number of available
+bytes in the send window and adjust the length of the data to be sent
+accordingly. The size of the send window is dictated by the memory
+configuration as well as the buffer space announced by the remote
+host. If no buffer space is available, the application has to defer
+the send and wait until later.
+
+The application sends data by using the uIP function uip_send(). The
+uip_send() function takes two arguments; a pointer to the data to be
+sent and the length of the data. If the application needs RAM space
+for producing the actual data that should be sent, the packet buffer
+(pointed to by the uip_appdata pointer) can be used for this purpose.
+
+The application can send only one chunk of data at a time on a
+connection and it is not possible to call uip_send() more than once
+per application invocation; only the data from the last call will be
+sent.
+
+\subsection uip-rexmitdata Retransmitting data
+
+Retransmissions are driven by the periodic TCP timer. Every time the
+periodic timer is invoked, the retransmission timer for each
+connection is decremented. If the timer reaches zero, a retransmission
+should be made. As uIP does not keep track of packet contents after they have
+been sent by the device driver, uIP requires that the
+application takes an active part in performing the
+retransmission. When uIP decides that a segment should be
+retransmitted, the application function is called with the
+uip_rexmit() flag set, indicating that a retransmission is
+required.
+
+The application must check the uip_rexmit() flag and produce the same
+data that was previously sent. From the application's standpoint,
+performing a retransmission is not different from how the data
+originally was sent. Therefor, the application can be written in such
+a way that the same code is used both for sending data and
+retransmitting data. Also, it is important to note that even though
+the actual retransmission operation is carried out by the application,
+it is the responsibility of the stack to know when the retransmission
+should be made. Thus the complexity of the application does not
+necessarily increase because it takes an active part in doing
+retransmissions.
+
+\subsection uip-closing Closing connections
+
+The application closes the current connection by calling the
+uip_close() during an application call. This will cause the connection
+to be cleanly closed. In order to indicate a fatal error, the
+application might want to abort the connection and does so by calling
+the uip_abort() function.
+
+If the connection has been closed by the remote end, the test function
+uip_closed() is true. The application may then do any necessary
+cleanups.
+
+\subsection uip-errors Reporting errors
+
+There are two fatal errors that can happen to a connection, either
+that the connection was aborted by the remote host, or that the
+connection retransmitted the last data too many times and has been
+aborted. uIP reports this by calling the application function. The
+application can use the two test functions uip_aborted() and
+uip_timedout() to test for those error conditions.
+
+\subsection uip-polling Polling
+
+When a connection is idle, uIP polls the application every time the
+periodic timer fires. The application uses the test function
+uip_poll() to check if it is being polled by uIP.
+
+The polling event has two purposes. The first is to let the
+application periodically know that a connection is idle, which allows
+the application to close connections that have been idle for too
+long. The other purpose is to let the application send new data that
+has been produced. The application can only send data when invoked by
+uIP, and therefore the poll event is the only way to send data on an
+otherwise idle connection.
+
+\subsection uip-listen Listening ports
+
+uIP maintains a list of listening TCP ports. A new port is opened for
+listening with the uip_listen() function. When a connection request
+arrives on a listening port, uIP creates a new connection and calls
+the application function. The test function uip_connected() is true if
+the application was invoked because a new connection was created.
+
+The application can check the lport field in the uip_conn structure to
+check to which port the new connection was connected.
+
+\subsection uip-connect Opening connections
+
+New connections can be opened from within
+uIP by the function uip_connect(). This function
+allocates a new connection and sets a flag in the connection state
+which will open a TCP connection to the specified IP address and port
+the next time the connection is polled by uIP. The uip_connect()
+function returns
+a pointer to the uip_conn structure for the new
+connection. If there are no free connection slots, the function
+returns NULL. 
+
+The function uip_ipaddr() may be used to pack an IP address into the
+two element 16-bit array used by uIP to represent IP addresses.
+
+Two examples of usage are shown below. The first example shows how to
+open a connection to TCP port 8080 of the remote end of the current
+connection. If there are not enough TCP connection slots to allow a
+new connection to be opened, the uip_connect() function returns NULL
+and the current connection is aborted by uip_abort(). 
+
+\code
+void connect_example1_app(void) {
+   if(uip_connect(uip_conn->ripaddr, 8080) == NULL) {
+      uip_abort();
+   }
+}   
+\endcode
+
+The second example shows how to open a new connection to a specific IP
+address. No error checks are made in this example.
+
+\code
+void connect_example2(void) {
+   u16_t ipaddr[2];
+
+   uip_ipaddr(ipaddr, 192,168,0,1);
+   uip_connect(ipaddr, 8080);
+}
+\endcode
+
+\section uip-drivers uIP device drivers
+
+From the network device driver's standpoint, uIP consists of two C
+functions: uip_input() and uip_periodic(). The uip_input() function
+should be called by the device driver when an IP packet has been
+received and put into the uip_buf packet buffer. The uip_input()
+function will process the packet, and when it returns an outbound
+packet may have been placed in the same uip_buf packet buffer
+(indicated by the uip_len variable being non-zero). The device driver
+should then send out this packet onto the network.
+
+The uip_periodic() function should be invoked periodically once per
+connection by the device driver, typically one per second. This
+function is used by uIP to drive protocol timers and retransmissions,
+and when it returns it may have placed an outbound packet in the
+uip_buf buffer.
+
+
+
+*/
+
+/** @} */
\ No newline at end of file
diff --git a/contiki/ek/FILES b/contiki/ek/FILES
new file mode 100644
index 0000000..ad859d6
--- /dev/null
+++ b/contiki/ek/FILES
@@ -0,0 +1,46 @@
+The contiki/ek/ directory contains the source code for the Contiki
+kernel and the concurrency libraries (multithreading, protothreads).
+
+arc.[ch]
+
+  Implementation of the argument buffer.
+
+contiki-version.h
+
+  A string holding the current version of Contiki.
+
+contiki.h
+
+  Header file which includes the core Contiki includes.
+
+dsc.h
+
+  Header file for the DSC file description format used by Contiki.
+
+ek-service.[ch]
+
+  The Contiki service layer.
+
+ek.[ch]
+
+  The Contiki event-driven kernel.
+
+loader.h
+
+  Header file for the program loader.
+
+log.h
+
+  Header file for the system logging facility.
+
+mt.[ch]
+
+  Multithreading library.
+
+pt.h
+
+  Protothreads implementation.
+
+pt-sem.h
+
+  Semaphores for protothreads.              
diff --git a/contiki/ek/arg.c b/contiki/ek/arg.c
new file mode 100644
index 0000000..6d533b2
--- /dev/null
+++ b/contiki/ek/arg.c
@@ -0,0 +1,131 @@
+/**
+ * \file
+ * Argument buffer for passing arguments when starting processes
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/**
+ * \addtogroup kernel
+ * @{
+ */
+
+/**
+ * \page arg Argument buffer
+ *
+ * The argument buffer can be used when passing an argument from an
+ * exiting process to a process that has not been created yet. Since
+ * the exiting process will have exited when the new process is
+ * started, the argument cannot be passed in any of the processes'
+ * addres spaces. In such situations, the argument buffer can be used.
+ *
+ * The argument buffer is statically allocated in memory and is
+ * globally accessible to all processes.
+ *
+ * An argument buffer is allocated with the arg_alloc() function and
+ * deallocated with the arg_free() function. The arg_free() function
+ * is designed so that it can take any pointer, not just an argument
+ * buffer pointer. If the pointer to arg_free() is not an argument
+ * buffer, the function does nothing.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: arg.c,v 1.3 2003/10/01 07:53:57 adamdunkels Exp $
+ *
+ */
+
+#include "arg.h"
+
+/**
+ * \internal Structure used for holding an argument buffer.
+ */
+struct argbuf {
+  char buf[128];
+  char used;
+};
+
+static struct argbuf bufs[1];
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal Initalizer, called by the dispatcher module.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+arg_init(void)
+{
+  bufs[0].used = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Allocates an argument buffer.
+ *
+ * \param size The requested size of the buffer, in bytes.
+ *
+ * \return Pointer to allocated buffer, or NULL if no buffer could be
+ * allocated.
+ *
+ * \note It currently is not possible to allocate argument buffers of
+ * any other size than 128 bytes.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+char *
+arg_alloc(char size)
+{
+  if(bufs[0].used == 0) {
+    bufs[0].used = 1;
+    return bufs[0].buf;
+  } 
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Deallocates an argument buffer.
+ *
+ * This function deallocates the argument buffer pointed to by the
+ * parameter, but only if the buffer actually is an argument buffer
+ * and is allocated. It is perfectly safe to call this function with
+ * any pointer.
+ *
+ * \param arg A pointer.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+arg_free(char *arg)
+{
+  if(arg == bufs[0].buf) {
+    bufs[0].used = 0;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki/ek/arg.h b/contiki/ek/arg.h
new file mode 100644
index 0000000..aed23f8
--- /dev/null
+++ b/contiki/ek/arg.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: arg.h,v 1.2 2004/06/06 06:06:34 adamdunkels Exp $
+ *
+ */
+#ifndef __ARG_H__
+#define __ARG_H__
+
+void arg_init(void);
+
+char *arg_alloc(char size);
+void arg_free(char *arg);
+
+#endif /* __ARG_H__ */
diff --git a/contiki/ek/contiki-version.h b/contiki/ek/contiki-version.h
new file mode 100644
index 0000000..f739f97
--- /dev/null
+++ b/contiki/ek/contiki-version.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: contiki-version.h,v 1.6 2006/05/30 21:04:47 oliverschmidt Exp $
+ */
+#ifndef __CONTIKI_VERSION__
+#define __CONTIKI_VERSION__
+
+#ifndef CONTIKI_VERSION_STRING
+#define CONTIKI_VERSION_STRING "Contiki 1.3"
+#endif /* CONTIKI_VERSION_STRING */
+
+#endif /* __CONTIKI_VERSION__ */
diff --git a/contiki/ek/contiki.h b/contiki/ek/contiki.h
new file mode 100644
index 0000000..b6ea092
--- /dev/null
+++ b/contiki/ek/contiki.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: contiki.h,v 1.5 2005/02/22 22:43:36 adamdunkels Exp $
+ */
+#ifndef __CONTIKI_H__
+#define __CONTIKI_H__
+
+#include "contiki-version.h"
+
+#include "ek.h"
+#include "ek-service.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "resolv.h"
+#include "tcpip.h"
+#include "memb.h"
+#include "timer.h"
+
+
+#endif /* __CONTIKI_H__ */
diff --git a/contiki/ek/dsc.h b/contiki/ek/dsc.h
new file mode 100644
index 0000000..15f408c
--- /dev/null
+++ b/contiki/ek/dsc.h
@@ -0,0 +1,135 @@
+/**
+ * \file
+ * Declaration of the DSC program description structure.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/**
+ * \addtogroup loader
+ * @{
+ */
+
+/**
+ * \page dsc The program description structure
+ *
+ * The Contiki DSC structure is used for describing programs. It
+ * includes a string describing the program, the name of the program
+ * file on disk (or a pointer to the programs initialization function
+ * for systems without disk support), a bitmap icon and a text version
+ * of the same icon.
+ *
+ * The DSC is saved into a file which can be loaded by programs such
+ * as the "Directory" application which reads all DSC files on disk
+ * and presents the icons and descriptions in a window.
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: dsc.h,v 1.7 2005/03/18 00:40:30 oliverschmidt Exp $
+ *
+ */
+#ifndef __DSC_H__
+#define __DSC_H__
+
+#include "ctk.h"
+
+/**
+ * The DSC program description structure.
+ *
+ * The DSC structure is used for describing a Contiki program. It
+ * includes a short textual description of the program, either the
+ * name of the program on disk, or a pointer to the init() function,
+ * and an icon for the program.
+ */
+struct dsc {
+  char *description; /**< A text string containing a one-line
+			description of the program */
+  
+#if WITH_LOADER_ARCH
+  char *prgname;     /**< The name of the program on disk. */
+#else /* WITH_LOADER_ARCH */
+  void (*init)(char *arg); /**< A pointer to the initialization
+			      function of the program .*/
+#endif /* WITH_LOADER_ARCH */
+  
+  struct ctk_icon *icon;  /**< A pointer to the ctk_icon structure for
+			     the DSC. */
+ 
+#if WITH_LOADER_ARCH
+  void *loadaddr;         /**< The loading address of the DSC. Used by
+			     the LOADER_UNLOAD() function when
+			     deallocating the memory allocated for the
+			     DSC when loading it. */
+#endif /* WITH_LOADER_ARCH */
+};
+
+#if CTK_CONF_ICONS
+#define DSC_ICON(icon) icon
+#else
+#define DSC_ICON(icon) NULL
+#endif
+
+/**
+ * Intantiating macro for the DSC structure.
+ *
+ * \param dscname The name of the C variable which is to contain the
+ * DSC.
+ *
+ * \param description A one-line text describing the program.
+ *
+ * \param prgname The name of the program on disk.
+ *
+ * \param initfunc A pointer to the initialization function of the
+ * program.
+ *
+ * \param icon A pointer to the CTK icon.
+ */
+#if WITH_LOADER_ARCH
+#define DSC(dscname, description, prgname, initfunc, icon) \
+        const struct dsc dscname = {description, prgname, DSC_ICON(icon)}
+#else /* WITH_LOADER_ARCH */
+#define DSC(dscname, description, prgname, initfunc, icon) \
+    void initfunc(char *arg); \
+    const struct dsc dscname = {description, initfunc, DSC_ICON(icon)}
+#endif /* WITH_LOADER_ARCH */
+
+#define DSC_HEADER(name) extern struct dsc name;
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+
+/** @} */
+
+#endif /* _DSC_H__ */
diff --git a/contiki/ek/ek-service.c b/contiki/ek/ek-service.c
new file mode 100644
index 0000000..e77b754
--- /dev/null
+++ b/contiki/ek/ek-service.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ek-service.c,v 1.6 2005/02/07 07:50:35 adamdunkels Exp $
+ */
+
+#include "ek-service.h"
+
+#include "log.h"
+
+/*---------------------------------------------------------------------------*/
+ek_id_t
+ek_service_start(const char *name, struct ek_proc *p)
+{
+  ek_id_t service;
+  
+  service = ek_find(name);
+
+  if(service == EK_ID_NONE) {
+    log_message("ek-service: starting ", name);
+    return ek_start(p);
+  } else {
+    log_message("ek-service: replacing ", name);
+    ek_post_synch(service, EK_EVENT_REQUEST_REPLACE, p);
+    return service;
+  } 
+
+}
+/*---------------------------------------------------------------------------*/
+ek_err_t
+ek_service_find(struct ek_service *s)
+{
+  ek_id_t id;
+  id = ek_find(s->name);
+  s->id = id;
+  if(s->id == EK_ID_NONE) {
+    return EK_ERR_NOTFOUND;
+  }
+  return EK_ERR_OK;
+}
+/*---------------------------------------------------------------------------*/
+void *
+ek_service_state(struct ek_service *s)
+{
+  if(s->id == EK_ID_NONE) {
+    if(ek_service_find(s) == EK_ERR_NOTFOUND) {
+      return NULL;
+    }
+  }
+  return ek_procstate(s->id);  
+}
+/*---------------------------------------------------------------------------*/
+void
+ek_service_reset(struct ek_service *s)
+{
+  log_message("ek-service: reseting ", s->name);
+  s->id = EK_ID_NONE;
+}
+/*---------------------------------------------------------------------------*/
+#if 0
+unsigned char
+ek_service_ref(struct ek_service *s)
+{
+}
+/*---------------------------------------------------------------------------*/
+unsigned char
+ek_service_unref(struct ek_service *s)
+{
+}
+#endif 
+/*---------------------------------------------------------------------------*/
+
diff --git a/contiki/ek/ek-service.h b/contiki/ek/ek-service.h
new file mode 100644
index 0000000..ebede37
--- /dev/null
+++ b/contiki/ek/ek-service.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ek-service.h,v 1.4 2005/02/07 07:50:35 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup ek
+ * @{
+ */
+
+/**
+ * \defgroup ekservice The service layer
+ * @{
+ */
+
+/**
+ * \file
+ * Service layer header file.
+ * \author Adam Dunkels <adam@sics.se>
+ */
+
+#ifndef __EK_SERVICE_H__
+#define __EK_SERVICE_H__
+
+#include "ek.h"
+
+struct ek_service {
+  const char *name;
+  ek_id_t id;
+};
+
+/**
+ * Declare a service state.
+ *
+ * This macro declares a service state. The service state is used to
+ * access a particular service. The declared service state serves as
+ * the input to all other service functions.
+ *
+ * \param service The name of the service state.
+ * \param name The name of the service - this is defined in the header file of the service.
+ *
+ * \hideinitializer
+ */
+#define EK_SERVICE(service, name) \
+ static struct ek_service service = {name, EK_ID_NONE}
+
+/**
+ * Start a service.
+ *
+ * This function is called from within a service in order to start the
+ * service process and to register the service with Contiki. If
+ * another instance of the same service is running, it is requested to
+ * shut itself down before the current service is started.
+ *
+ * This function is the equivalent of ek_start() but for services.
+ *
+ * \note Do not call the function ek_start() from a service, use
+ * ek_service_start() instead.
+ *
+ * \param name The name of the service. The first part of the name
+ * must be indentical for all services of the same kind.
+ *
+ * \param p The process structure for the service.
+ *
+ * \return The process ID of the service.
+ */ 
+ek_id_t ek_service_start(const char *name, struct ek_proc *p);
+
+/**
+ * Find a running service.
+ *
+ * This function finds a running service. The function is called from
+ * programs that utilize the service, not from within a service process.
+ *
+ * Example:
+ \code
+ #include "packet-service.h"
+ 
+ EK_SERVICE(packetservice, PACKET_SERVICE_NAME);
+
+ void stop_packetservice(void) {
+   if(ek_service_find(&packetservice) == EK_ERR_OK) {
+     ek_service_post(&packetservice, EK_EVENT_REQUEST_EXIT, NULL);
+     ek_service_reset(&packetservice);
+   }
+ }
+ \endcode
+ *
+ * \param s The service state. This state is filled in with
+ * information by the ek_service_find() function.
+ *
+ * \retval EK_ERR_OK The requested service was found.
+ * \retval EK_ERR_NOTFOUND The requested service was not found.
+ */
+ek_err_t ek_service_find(struct ek_service *s);
+
+/**
+ * Retrieve the service interface for a running service.
+ *
+ * This function retrieves the service interface (the API for the
+ * service) for a running service. The service state must first have
+ * been looked up using the ek_service_find() function.
+ *
+ * This function is used in the service stub.
+ *
+ * Example
+ \code
+ #include "packet-service.h"
+  
+ EK_SERVICE(packetservice, PACKET_SERVICE_NAME);
+
+ static struct packet_service_interface *
+ find_interface(void)
+ {
+   struct packet_service_interface *interface;
+   interface = (struct packet_service_interface *)ek_service_state(&service);
+   if(interface != NULL &&
+      interface->version == PACKET_SERVICE_VERSION) {
+     return interface;
+   } else {
+     return NULL;
+   }
+ }
+ \endcode
+ *
+ * \param s The service state that previously has been looked up with
+ * ek_service_find().
+ *
+ * \return A pointer to the service interface if the requested service
+ * is running, or NULL if no such service was found.
+ */
+void *ek_service_state(struct ek_service *s);
+
+/**
+ * Reset a service.
+ *
+ * When a service is looked up by Contiki, the process ID of the
+ * service is cached. This function resets the cache so that a running
+ * service can be removed from the system.
+ *
+ * Example:
+ \code
+ #include "packet-service.h"
+ 
+ EK_SERVICE(packetservice, PACKET_SERVICE_NAME);
+
+ void stop_packetservice(void) {
+   if(ek_service_find(&packetservice) == EK_ERR_OK) {
+     ek_service_post(&packetservice, EK_EVENT_REQUEST_EXIT, NULL);
+     ek_service_reset(&packetservice);
+   }
+ }
+ \endcode
+ *
+ * \param s The service state.
+ */
+void ek_service_reset(struct ek_service *s);
+
+/**
+ * Post an event to a running service.
+ *
+ * This macro posts an event to a running service. The service must
+ * first be looked up using ek_service_find().
+ *
+ * \sa ek_post().
+ *
+ * \param s The service state
+ * \param ev The event to be posted.
+ * \param data An opaque pointer to be posted with the event.
+ * 
+ * \hideinitializer
+ */
+#define ek_service_post(s, ev, data) ek_post((s)->id, (ev), (data))
+
+/*ek_err_t ek_service_call(struct ek_service *s,
+  ek_event_t ev, ek_data_t data);*/
+
+/** @} */
+/** @} */
+
+#endif /* __EK_SERVICE_H__ */
+
diff --git a/contiki/ek/ek.c b/contiki/ek/ek.c
new file mode 100644
index 0000000..c570dc6
--- /dev/null
+++ b/contiki/ek/ek.c
@@ -0,0 +1,601 @@
+/**
+ * \defgroup ek The Contiki event kernel
+ * @{
+ *
+ * At the heart of the Contiki desktop environment is the event driven
+ * Contiki kernel. Using non-preemptive multitasking, the Contiki
+ * event kernel makes it possible to run several programs in
+ * parallel. It also provides message passing mechanisms to the
+ * running programs.
+ *
+ * The Contiki kernel is a simple event driven dispatcher which
+ * handles processes and events. All code execution is
+ * initiated by the kernel, and applications are implemented as C
+ * functions that must return within a short time after being
+ * called.
+ *
+ * The kernel does not provide multi-threading. Rather, this is
+ * implemented as an application library. For threads, see the
+ * \ref mt "Multithreading library" and \ref pt "Protothreads".
+ *
+ * The kernel is the initiator of all program execution in
+ * Contiki. After the system has been initialized by the boot up code,
+ * the ek_run() function is called. This function never
+ * returns, but will sit in a loop in which it does two things.
+ * 
+ * - Pulls the first event of the event queue and dispatches this to
+ *   all listening processes (ek_process_event()).
+ *
+ * - Executes the "poll" handlers of all processes that have
+ *   registered (ek_process_poll()).
+ *
+ * Only one event is processes at a time, and the poll handlers of
+ * all processes are called between two events are handled.
+ *
+ * 
+ * A process is defined by an initialization function, a event
+ * handler, a uIP event handler, and an poll handler. The event
+ * handler is called when a event has been posted, for which the
+ * process is currently listening. The uIP event handler is called
+ * when the uIP TCP/IP stack has an event to deliver to the
+ * process. Such events can be that new data has arrived on a
+ * connection, that previously sent data has been acknowledged or that
+ * a connection has been closed. The poll handler is periodically
+ * called by the system.
+ *
+ * A process is started by calling the ek_start()
+ * function. This function must be called by the initialization
+ * function before any other kernel function is called. When the
+ * function returns, the new process is running. 
+ *
+ * The initialization function is declared with the special
+ * LOADER_INIT() macro. The initializaition function takes a single
+ * argument; a char * pointer.
+ *
+ * The function ek_exit() is used to tell the kernel that
+ * a process has exited. This function must be called by the process
+ * itself, and must be called the process unloads itself.
+ *
+ * \note It is not possible to call ek_exit() on behalf of
+ * another process - instead, post the event ek_event_quit
+ * with the process as a receiver. The other process should then
+ * listen for this event, and call ek_exit() when the event
+ * is received. 
+ *
+ *
+ * The kernel can pass events between different
+ * processes. Events are simple messages that consist of a event
+ * number and a generic data pointer called the event data. The
+ * event data can be used to pass messages between processes. In
+ * order for a event to be delivered to a process, the process must
+ * be listening for the event number.
+ *
+ * If a process has registered an poll handler, the kernel will
+ * call it as often as possible. The poll handler can be used to
+ * implement timer based functionality (by checking the ek_clock()
+ * function), or other background processing. The poll handler must
+ * return to the caller within a short time, or otherwise the system
+ * will become sluggish.
+ *
+ *
+ */
+
+
+/**
+ * \file
+ * Event kernel.
+ * \author Adam Dunkels <adam@dunkels.com> 
+ *
+ * The kernel in Contiki handles processes and events. All process
+ * execution is initiated by the kernel.
+ */
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek.c,v 1.9 2007/06/02 07:32:05 ryohji Exp $
+ *
+ */
+
+#include "ek.h"
+
+#include <string.h> /* for strncmp() */
+
+/**
+ * \internal Pointer to the currently running process structure.
+ *
+ */
+struct ek_proc *ek_procs = NULL;
+struct ek_proc *ek_proclist[EK_CONF_MAXPROCS];
+struct ek_proc *ek_current = NULL;
+ 
+ek_event_t ek_event_quit;
+ek_event_t ek_event_msg;
+
+static ek_event_t lastevent;
+
+#if CC_FUNCTION_POINTER_ARGS
+
+#else /* CC_FUNCTION_POINTER_ARGS */
+ek_event_t ek_eventhandler_s;
+ek_data_t ek_eventhandler_data;
+#endif /* CC_FUNCTION_POINTER_ARGS */      
+
+
+/**
+ * \internal Structure used for keeping the queue of active events.
+ */
+struct event_data {
+  ek_event_t s;
+  ek_data_t data;
+  ek_id_t id;
+};
+
+static ek_num_events_t nevents, fevent;
+static struct event_data events[EK_CONF_NUMEVENTS];
+
+volatile unsigned char ek_poll_request;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Allocates a event number.
+ *
+ * \return The allocated event number or EK_EVENT_NONE if no event
+ * number could be allocated.
+ */
+/*-----------------------------------------------------------------------------------*/
+ek_event_t
+ek_alloc_event(void)
+{
+  return lastevent++;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+procs_add(struct ek_proc *p)
+{
+  static struct ek_proc *q, *r;
+  
+  /* The process should be placed on the process list according to the
+     process' priority. The higher the priority, the earlier on the
+     list. */
+  r = NULL;
+  for(q = ek_procs; q != NULL; q = q->next) {
+    if(p->prio >= q->prio) {
+      p->next = q;
+      if(r == NULL) {
+	ek_procs = p;
+      } else {
+	r->next = p;       
+      }
+      return;
+    }
+    r = q;
+  }
+
+  if(q == NULL) {
+    if(r == NULL) {
+      p->next = ek_procs;
+      ek_procs = p;
+    } else {
+      r->next = p;
+      p->next = NULL;
+    } 
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Starts a new process.
+ *
+ * Is called by a program in order to start a new process for the
+ * program. This function should be called quite early in the
+ * initialization procedure of a new process. In partcular, it must be
+ * called before any other dispatcher functions, or functions of other
+ * modules that make use of dispatcher functions. Most CTK functions
+ * call dispatcher functions, and should therefore not be called
+ * before ek_start() is called.
+ *
+ * Example:
+ \code
+static void app_poll(void);
+static EK_EVENTHANDLER(app_eventhandler, s, data);
+static struct ek_proc p =
+  {EK_PROC("Generic applications", app_poll, app_eventhandler, NULL)};
+static ek_id_t id = EK_ID_NONE;
+ 
+LOADER_INIT_FUNC(app_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+    rest_of_initialization();
+  }
+}
+ \endcode
+ *
+ * \param p A pointer to a ek_proc struct that must be found
+ * in the process own memory space.
+ *
+ * \return The process identifier for the new process or EK_ID_NONE
+ * if the process could not be started.
+ */
+/*-----------------------------------------------------------------------------------*/
+ek_id_t
+ek_start(CC_REGISTER_ARG struct ek_proc *p)
+{
+  ek_id_t id;
+
+  for(id = 0; id < EK_CONF_MAXPROCS; ++id) {
+    if(ek_proclist[id] == NULL) {
+      break;
+    }
+  }
+  if(id == EK_CONF_MAXPROCS) {
+    return EK_ID_NONE;
+  }
+
+  ek_proclist[id] = p;
+  
+  /* Put on the procs list.*/
+  procs_add(p);
+  
+  p->id = id;
+
+  /* Post an asynchronous event to the process. */
+  ek_post(id, EK_EVENT_INIT, p);
+
+  return id;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Exit the currently running process
+ *
+ * This function causes the currently running process to exit. The
+ * function must be called by the process before it unloads itself, or
+ * the system will crash.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ek_exit(void)
+{
+  register struct ek_proc *q, *p;
+  
+  p = ek_current;
+
+  /* Post a synchronous event to all processes to inform them that
+     this process is about to exit. This will allow services to
+     dealloc state associated with this process. */
+  for(q = ek_procs; q != NULL; q = q->next) {
+    if(p != q) {
+      ek_current = q;
+      if(q->eventhandler != NULL) {
+	q->eventhandler(EK_EVENT_EXITED, (ek_data_t)p->id);
+      }
+    }    
+  }
+  
+  /* Remove process from the process lists. */
+  ek_proclist[p->id] = NULL;
+  
+  if(p == ek_procs) {
+    ek_procs = ek_procs->next;    
+  } else {
+    for(q = ek_procs; q != NULL; q = q->next) {
+      if(q->next == p) {
+	q->next = p->next;
+	break;
+      }
+    }
+  }
+  
+  ek_current = NULL;
+}
+/**
+ * \addtogroup kernel
+ * @{
+ */
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Finds the process structure for a specific process ID.
+ *
+ * \param id The process ID for the process.
+ *
+ * \return The process structure for the process, or NULL if there
+ * process ID was not found.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct ek_proc *
+ek_process(ek_id_t id)
+{
+  struct ek_proc *p;
+  for(p = ek_procs; p != NULL; p = p->next) {
+    if(p->id == id) {
+      return p;
+    }
+  }
+  return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initializes the dispatcher module.
+ *
+ * Must be called during the initialization of Contiki.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ek_init(void)
+{
+  int i;
+  
+  lastevent = EK_EVENT_MAX;
+
+  nevents = fevent = 0;
+
+  ek_current = ek_procs = NULL;
+
+  arg_init();
+
+  for(i = 0; i < EK_CONF_MAXPROCS; ++i) {
+    ek_proclist[i] = NULL;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Process the next event in the event queue and deliver it to
+ * listening processes.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ek_process_event(void)
+{ 
+  static ek_event_t s;
+  static ek_data_t data;
+  static ek_id_t id;
+  static struct ek_proc *p;
+  
+  /* If there are any events in the queue, take the first one and
+     walk through the list of processes to see if the event should be
+     delivered to any of them. If so, we call the event handler
+     function for the process. We only process one event at a time
+     and call the poll handlers inbetween. */
+
+  if(nevents > 0) {
+    
+    /* There are events that we should deliver. */
+    s = events[fevent].s;
+    
+    data = events[fevent].data;
+    id = events[fevent].id;
+
+    /* Since we have seen the new event, we move pointer upwards
+       and decrese number. */
+    fevent = (fevent + 1) % EK_CONF_NUMEVENTS;
+    --nevents;
+
+    /* If this is a broadcast event, we deliver it to all events, in
+       order of their priority. */
+    if(id == EK_BROADCAST) {
+      for(p = ek_procs; p != NULL; p = p->next) {
+
+	if(ek_poll_request) {
+	  ek_poll_request = 0;
+	  ek_process_poll();
+	}
+	
+	ek_current = p;
+	if(p->eventhandler != NULL) {
+	  p->eventhandler(s, data);
+	}
+      }
+    } else {
+      /* This is not a broadcast event, so we deliver it to the
+	 specified process. */
+      if(ek_poll_request) {
+	ek_poll_request = 0;
+	ek_process_poll();
+      }
+      
+      p = ek_proclist[id];
+      if(p != NULL &&
+	 p->eventhandler != NULL) {
+	ek_current = p;
+	p->eventhandler(s, data);
+
+	/* If the event was an INIT event, we should also put the
+	   process on the process list. */
+	/*	procs_add(p);*/
+      }
+    }    
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Call each process' poll handler.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ek_process_poll(void)
+{
+  struct ek_proc *p;
+  
+  /* Call poll handlers. */
+  for(p = ek_procs; p != NULL; p = p->next) {
+    
+    if(ek_poll_request) {
+      ek_poll_request = 0;
+      p = ek_procs;
+    }
+
+    if(p->pollhandler != NULL) {
+      ek_current = p;
+      p->pollhandler();
+    }
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Run the system once - call poll handlers and process one event.
+ *
+ * This function should be called repeatedly from the main() program
+ * to actuall run the Contiki system. It calls the necessary poll
+ * handlers, and processes one event. The function returns the number
+ * of events that are waiting in the event queue so that the caller
+ * may choose to put the CPU to sleep when there are no pending
+ * events.
+ *
+ * \return The number of events that are currently waiting in the
+ * event queue.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+ek_run(void)
+{
+  /* Process "poll" events. */
+  do {
+    ek_poll_request = 0;
+    ek_process_poll();
+  } while(ek_poll_request != 0);
+  
+  /* Process one event */
+  ek_process_event();
+
+  return nevents;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Post an asynchronous event.
+ *
+ * This function posts an asynchronous event to one or more
+ * processes. The handing of the event is deferred until the target
+ * process is scheduled by the kernel. An event can be broadcast to
+ * all processes, in which case all processes in the system will be
+ * scheduled to handle the event.
+ * 
+ * \param s The event to be posted.
+ *
+ * \param data The auxillary data to be sent with the event
+ *
+ * \param id The process ID to which the event should be posted, or
+ * EK_BROADCAST if the event should be posted to all
+ * processes.
+ *
+ * \retval EK_ERR_OK The event could be posted.
+ *
+ * \retval EK_ERR_FULL The event queue was full and the event could
+ * not be posted.
+ */
+/*-----------------------------------------------------------------------------------*/
+ek_err_t
+ek_post(ek_id_t id, ek_event_t s, ek_data_t data)
+{
+  static unsigned char snum;
+  
+  if(nevents == EK_CONF_NUMEVENTS) {
+    return EK_ERR_FULL;
+  }
+  
+  snum = (fevent + nevents) % EK_CONF_NUMEVENTS;
+  events[snum].s = s;
+  events[snum].data = data;
+  events[snum].id = id;
+  ++nevents;
+  
+  return EK_ERR_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ek_post_synch(ek_id_t id, ek_event_t ev, ek_data_t data)
+{
+  struct ek_proc *p = ek_current;
+  
+  ek_current = ek_proclist[id]; 
+  ek_current->eventhandler(ev, data); 
+  ek_current = p;
+}
+/*-----------------------------------------------------------------------------------*/
+ek_id_t
+ek_find(const char *prefix)
+{
+  struct ek_proc *p;
+  unsigned short len;
+
+  /* Search through all processes and search for the specified process
+     name. */
+  len = strlen(prefix);
+  for(p = ek_procs; p != NULL; p = p->next) {
+    if(strncmp(prefix, p->name, len) == 0) {
+      return p->id;
+    }
+  }
+
+  return EK_ID_NONE;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ek_replace(struct ek_proc *newp, void *arg)
+{
+  register struct ek_proc *p = ek_current;
+
+  /* Remove the currently executing process. */
+  ek_exit();
+
+  ek_proclist[p->id] = newp;
+  
+  /* Put on the procs list.*/
+  procs_add(newp);
+  
+  newp->id = p->id;
+
+  /* Post an asynchronous event to the process. */
+  ek_post(p->id, EK_EVENT_REPLACE, arg);
+}
+/*-----------------------------------------------------------------------------------*/
+void *
+ek_procstate(ek_id_t id)
+{
+  struct ek_proc *p;
+
+  p = ek_proclist[id];
+  if(p == NULL) {
+    return NULL;
+  }
+  return p->procstate;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki/ek/ek.h b/contiki/ek/ek.h
new file mode 100644
index 0000000..1aaf5e3
--- /dev/null
+++ b/contiki/ek/ek.h
@@ -0,0 +1,426 @@
+/**
+ * \addtogroup ek
+ * @{
+ */
+
+/**
+ * \file
+ * Contiki Kernel header file.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ek.h,v 1.9 2006/05/17 15:27:43 oliverschmidt Exp $
+ */
+#ifndef __EK_H__
+#define __EK_H__
+
+#include "ek-conf.h"
+
+#include "cc.h"
+#include "arg.h"
+#include "loader.h"
+
+void ek_init(void);
+
+typedef unsigned char ek_err_t;
+
+
+/* Errors: */
+#define EK_ERR_OK        0
+#define EK_ERR_FULL      1
+#define EK_ERR_NOTUNIQUE 2
+#define EK_ERR_NOTFOUND  3
+
+/* Special IDs defined by ek: */
+
+/**
+ * Broadcast process ID.  
+ *
+ * Events emitted to the EK_BROADCAST process ID are
+ * delivered to all processes.
+ */
+#define EK_ID_NONE               EK_CONF_MAXPROCS
+#define EK_ID_ALL                EK_ID_NONE
+
+#define EK_BROADCAST             EK_ID_ALL
+
+/**
+ * \defgroup events System events
+ * @{
+ *
+ * The Contiki kernel defines a number of default events that can be
+ * delivered to processes. 
+ */
+
+#define EK_EVENT_NONE            0x80
+
+/**
+ * Initialization event.
+ *
+ * This event is posted by the kernel to a process in order to let the
+ * process to initialization.
+ *
+ */
+#define EK_EVENT_INIT            0x81
+
+/**
+ * Service replacement event.
+ *
+ * This event is posted by the kernel in order to inform a process
+ * that a service that the current process have requested to be
+ * replaced, is now replaced.
+ */
+#define EK_EVENT_REPLACE         0x82
+
+/**
+ * Continuation event.
+ *
+ * This event can be used to implement continuations.
+ */
+#define EK_EVENT_CONTINUE        0x83
+
+/**
+ * Generic message event.
+ *
+ * This event can be used to pass messages between processes.
+ */
+#define EK_EVENT_MSG             0x84
+
+/**
+ * A process has exited.
+ *
+ * This event is posted to all processes to inform that another
+ * process has exited.
+ */
+#define EK_EVENT_EXITED          0x85
+
+/**
+ * Request a process to exit itself.
+ *
+ * This event is posted to a process in order to tell it to remove
+ * itself from the system. Since each program may have allocated
+ * system resources that must be released before the process quits,
+ * each program must implement the event handler by itself. A process
+ * that receives this event must call LOADER_UNLOAD() to unload itself
+ * after doing all necessary clean ups (such as closing open windows,
+ * deallocate allocated memory, etc.).
+ */
+#define EK_EVENT_REQUEST_EXIT    0x86
+
+/**
+ * Request a service to be replaced.
+ *
+ * This event is posted by the kernel to a service that another
+ * process have requested to be replaced.
+ */
+#define EK_EVENT_REQUEST_REPLACE 0x87
+
+
+#define EK_EVENT_MAX             0x88
+
+/** @}*/
+
+/**
+ * Instantiating macro for the ek_proc struct.
+ *
+ * This macro is used when initializing a ek_proc structure
+ * for a process. It hides the internals of the ek_proc struct
+ * and provides an easy way to define process signature.
+ *
+ * \note Defining a ek_proc struct does not start the process and does
+ * not register the process with the kernel. Rather, the process'
+ * initialization function must explicitly call the ek_start()
+ * function with a pointer to the ek_proc struct containing the
+ * process definition.
+ *
+ * \param name The name of the \c struct \c ek_proc of the process.
+ *
+ * \param strname A textual repressentation of the process' name.
+ *
+ * \param prio The priority of the process.
+ *
+ * \param pollh A pointer to the poll function or NULL if no poll
+ * handler should be registered.
+ *
+ * \param eventh A pointer to the process' event handler. All
+ * processes are required to have a event handler.
+ *
+ * \param stateptr An opaque pointer that can be associated with the
+ * process.
+ *
+ * \hideinitializer
+ */
+#ifndef EK_PROCESS
+#define EK_PROCESS(name, strname, prio, eventh, pollh, stateptr)	\
+  static struct ek_proc name = {NULL, EK_ID_NONE, strname, prio, eventh, pollh, stateptr}
+#endif /* EK_PROCESS */
+
+struct ek_proc {
+  struct ek_proc *next;
+  ek_id_t id;
+  const char *name;
+  unsigned char prio;
+  void (* eventhandler)(ek_event_t ev, ek_data_t data);
+  void (* pollhandler)(void);
+  void *procstate;
+};
+
+/**
+ * Lowest priority.
+ *
+ * This value can be used in the \c prio field in the EK_PROCESS() macro.
+ */
+#define EK_PRIO_LOWEST  0x00
+/**
+ * Low priority.
+ *
+ * This value can be used in the \c prio field in the EK_PROCESS() macro.
+ */
+#define EK_PRIO_LOW     0x3f
+/**
+ * Normal priority.
+ *
+ * This value can be used in the \c prio field in the EK_PROCESS() macro.
+ */
+#define EK_PRIO_NORMAL  0x7f
+/**
+ * High priority.
+ *
+ * This value can be used in the \c prio field in the EK_PROCESS() macro.
+ */
+#define EK_PRIO_HIGH    0xbf
+/**
+ * Highest priority.
+ *
+ * This value can be used in the \c prio field in the EK_PROCESS() macro.
+ */
+#define EK_PRIO_HIGHEST 0xff
+
+/**
+ * Get the process state of a process.
+ *
+ * This function is used by the kernel service module, and is in most
+ * cased not used directly by user programs.
+ *
+ * \param id The process ID of the process,
+ */
+void *ek_procstate(ek_id_t id);
+
+/**
+ * Obtain a pointer to the list of processes.
+ */
+#define EK_PROCS()   ek_procs
+
+/**
+ * Obtain a pointer to the currently running process.
+ */
+#define EK_CURRENT() ek_current
+
+ek_event_t ek_alloc_event(void);
+
+ek_id_t ek_start(struct ek_proc *p);
+void ek_exit(void);
+
+ek_err_t ek_post(ek_id_t id, ek_event_t s, ek_data_t data);
+
+struct ek_proc *ek_process(ek_id_t id);
+
+/* We must do some C macro trickery to make things work with sdcc,
+   which doesn't support passing arguments to functions called as
+   function pointers. */
+#if CC_FUNCTION_POINTER_ARGS
+
+/**
+ * Declaration macro for a event handler function.
+ *
+ * This macro is used when declaring a process' event handler
+ * function. The reason why a macro is used for this instead of a
+ * regular C declaration is that certain C compilers cannot handle
+ * function pointers with arguments and therefore the
+ * EK_EVENTHANDLER() macro definition varies with different C
+ * compilers.
+ *
+ * The following example shows how to use the EK_EVENTHANDLER()
+ * declaration macro as well as the EK_EVENTHANDLER_ARGS() macro
+ * and how to handle the ek_event_quit event.
+ *
+ \code
+ static EK_EVENTHANDLER(example_eventhandler, s, data);
+
+ static
+ EK_EVENTHANDLER(example_eventhandler, s, data)
+ {
+   EK_EVENTHANDLER_ARGS(s, data);
+
+   if(s == ek_event_quit) {
+      ek_exit(&p);
+      LOADER_UNLOAD();
+   }
+ }
+ \endcode
+ *
+ * \param name The name of the event handler function.
+ *
+ * \param ev The name of the event number parameter.
+ *
+ * \param data The name of the event data parameter.
+ *
+ *
+ * \hideinitializer 
+ */
+#ifndef EK_EVENTHANDLER
+#define EK_EVENTHANDLER(name, ev, data) \
+        static void name(ek_event_t ev, ek_data_t data)
+#endif /* EK_EVENTHANDLER */
+
+#ifndef EK_POLLHANDLER
+#define EK_POLLHANDLER(name) \
+        static void name(void)
+#endif /* EK_POLLHANDLER */
+
+#ifndef EK_PROCESS_INIT
+#define EK_PROCESS_INIT(name, arg) \
+        void name(void *arg)
+#endif /* EK_PROCESS_INIT */
+
+#define EK_PROC_STATE(p) ((p)->procstate)
+#define EK_PROC_ID(p)    ((p)->id)
+
+/**
+ * Declaration macro for event handler arguments.
+ *
+ * This macro must be used for declaring the event handler function's
+ * arguments. The reason why this is needed is that some C compilers
+ * do not support function pointers with arguments and therefor a
+ * workaround has been made using C macros.
+ *
+ * \note This macro call must come after the declarations of the local
+ * variables but before the first program statement in the event
+ * handler function.
+ *
+ * The following example shows a event handler function with local
+ * variables.
+ *
+ \code
+ static
+ EK_EVENTHANDLER(example_eventhandler, s, data)
+ {
+   char c;
+   EK_EVENTHANDLER_ARGS(s, data);
+
+   if(s == ctk_event_keypress) {
+      c = (char)data;
+      process_key(c);
+   } else if(s == ek_event_quit) {
+      ek_exit(&p);
+      LOADER_UNLOAD();
+   }
+ }
+ \endcode
+ *
+ * \param ev The name of the event number argument. Must match the one
+ * in the EK_EVENTHANDLER() declaration.
+ *
+ * \param data The name of the event data argument. Must match the
+ * one in the EK_EVENTHANDLER() declaration.
+ *
+ */
+#define EK_EVENTHANDLER_ARGS(ev, data)
+
+/*
+#define EK_UIPCALL(name, state) \
+        void name(void *state)
+
+#define EK_UIPCALL_ARG(state)
+*/
+
+#else /* CC_FUNCTION_POINTER_ARGS */
+#define EK_EVENTHANDLER(s, data) \
+        void name(void)
+
+#define EK_EVENTHANDLER_ARGS(s, data) ek_event_t s = ek_eventhandler_s; \
+                                      ek_data_t data = ek_eventhandler_data
+
+extern ek_event_t ek_eventhandler_s;
+extern ek_data_t ek_eventhandler_data;
+
+#endif /* CC_FUNCTION_POINTER_ARGS */
+
+extern struct ek_proc *ek_current;
+extern struct ek_proc *ek_procs;
+extern struct ek_proc *ek_proclist[EK_CONF_MAXPROCS];
+
+void ek_process_event(void);
+void ek_process_poll(void);
+
+int ek_run(void);
+
+ek_id_t ek_find(const char *servicename);
+
+void ek_replace(struct ek_proc *newp, void *arg);
+
+/** @} */
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Post a synchronous event.
+ *
+ * This function emits a event and calls the listening processes'
+ * event handlers immediately, before returning to the caller. This
+ * function requires more call stack space than the ek_emit()
+ * function and should be used with care, and only in situtations
+ * where the exact implications are known.
+ *
+ * In most situations, the ek_emit() function should be used
+ * instead.
+ *
+ * \param ev The event to be emitted.
+ *
+ * \param data The auxillary data to be sent with the event
+ *
+ * \param id The process ID to which the event should be emitted, or
+ * EK_BROADCAST if the event should be emitted to all
+ * processes listening for the event.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void ek_post_synch(ek_id_t id, ek_event_t ev, ek_data_t data);
+
+extern volatile unsigned char ek_poll_request;
+#define EK_REQUEST_POLL() ek_poll_request = 1
+
+#endif /* __EK_H__ */
diff --git a/contiki/ek/lc-addrlabels.h b/contiki/ek/lc-addrlabels.h
new file mode 100644
index 0000000..b50c087
--- /dev/null
+++ b/contiki/ek/lc-addrlabels.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc-addrlabels.h,v 1.2 2005/04/01 08:12:36 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup lc
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of local continuations based on the "Labels as
+ * values" feature of gcc
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ * This implementation of local continuations is based on a special
+ * feature of the GCC C compiler called "labels as values". This
+ * feature allows assigning pointers with the address of the code
+ * corresponding to a particular C label.
+ *
+ * For more information, see the GCC documentation:
+ * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
+ *
+ */
+
+#ifndef __LC_ADDRLABELS_H__
+#define __LC_ADDRLABELS_H__
+
+/** \hideinitializer */
+typedef void * lc_t;
+
+#define LC_INIT(s) s = NULL
+
+#define LC_RESUME(s)				\
+  do {						\
+    if(s != NULL) {				\
+      goto *s;					\
+    }						\
+  } while(0)
+
+#define LC_CONCAT2(s1, s2) s1##s2
+#define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2)
+
+#define LC_SET(s)				\
+  do {						\
+    LC_CONCAT(LC_LABEL, __LINE__):   	        \
+    (s) = &&LC_CONCAT(LC_LABEL, __LINE__);	\
+  } while(0)
+
+#define LC_END(s)
+
+#endif /* __LC_ADDRLABELS_H__ */
diff --git a/contiki/ek/lc-switch.h b/contiki/ek/lc-switch.h
new file mode 100644
index 0000000..a559b8c
--- /dev/null
+++ b/contiki/ek/lc-switch.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc-switch.h,v 1.2 2005/04/01 08:12:37 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup lc
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of local continuations based on switch() statment
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ * This implementation of local continuations uses the C switch()
+ * statement to resume execution of a function somewhere inside the
+ * function's body. The implementation is based on the fact that
+ * switch() statements are able to jump directly into the bodies of
+ * control structures such as if() or while() statmenets.
+ *
+ * This implementation borrows heavily from Simon Tatham's coroutines
+ * implementation in C:
+ * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
+ */
+
+#ifndef __LC_SWITCH_H__
+#define __LC_SWTICH_H__
+
+/* WARNING! lc implementation using switch() does not work if an
+   LC_SET() is done within another switch() statement! */
+
+/** \hideinitializer */
+typedef unsigned short lc_t;
+
+#define LC_INIT(s) s = 0;
+
+#define LC_RESUME(s) switch(s) { case 0:
+
+#define LC_SET(s) s = __LINE__; case __LINE__: 
+
+#define LC_END(s) }
+
+#endif /* __LC_SWITCH_H__ */
+
+/** @} */
diff --git a/contiki/ek/lc.h b/contiki/ek/lc.h
new file mode 100644
index 0000000..24efb62
--- /dev/null
+++ b/contiki/ek/lc.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lc.h,v 1.1 2005/02/22 22:36:51 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup pt
+ * @{
+ */
+
+/**
+ * \defgroup lc Local continuations
+ * @{
+ *
+ * Local continuations form the basis for implementing protothreads. A
+ * local continuation can be <i>set</i> in a specific function to
+ * capture the state of the function. After a local continuation has
+ * been set can be <i>resumed</i> in order to restore the state of the
+ * function at the point where the local continuation was set.
+ *
+ *
+ */
+
+/**
+ * \file lc.h
+ * Local continuations
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifdef DOXYGEN
+/**
+ * Initialize a local continuation.
+ *
+ * This operation initializes the local continuation, thereby
+ * unsetting any previously set continuation state.
+ *
+ * \hideinitializer
+ */
+#define LC_INIT(lc)
+
+/**
+ * Set a local continuation.
+ *
+ * The set operation saves the state of the function at the point
+ * where the operation is executed. As far as the set operation is
+ * concerned, the state of the function does <b>not</b> include the
+ * call-stack or local (automatic) variables, but only the program
+ * counter and such CPU registers that needs to be saved.
+ *
+ * \hideinitializer
+ */
+#define LC_SET(lc)
+
+/**
+ * Resume a local continuation.
+ *
+ * The resume operation resumes a previously set local continuation, thus
+ * restoring the state in which the function was when the local
+ * continuation was set. If the local continuation has not been
+ * previously set, the resume operation does nothing.
+ *
+ * \hideinitializer
+ */
+#define LC_RESUME(lc)
+
+/**
+ * Mark the end of local continuation usage.
+ *
+ * The end operation signifies that local continuations should not be
+ * used any more in the function. This operation is not needed for
+ * most implementations of local continuation, but is required by a
+ * few implementations.
+ *
+ * \hideinitializer 
+ */
+#define LC_END(lc)
+
+/**
+ * \var typedef lc_t;
+ *
+ * The local continuation type.
+ *
+ * \hideinitializer
+ */
+#endif /* DOXYGEN */
+
+#ifndef __LC_H__
+#define __LC_H__
+
+
+#ifdef LC_INCLUDE
+#include LC_INCLUDE
+#else
+#include "lc-switch.h"
+#endif /* LC_INCLUDE */
+
+#endif /* __LC_H__ */
+
+/** @} */
+/** @} */
diff --git a/contiki/ek/loader.h b/contiki/ek/loader.h
new file mode 100644
index 0000000..ffc8c07
--- /dev/null
+++ b/contiki/ek/loader.h
@@ -0,0 +1,131 @@
+/**
+ * \file
+ * Default definitions and error values for the Contiki program loader.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/**
+ * \defgroup loader The Contiki program loader
+ * @{
+ *
+ * The Contiki program loader is an abstract interface for loading and
+ * starting programs.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader.h,v 1.10 2005/05/07 14:24:59 oliverschmidt Exp $
+ *
+ */
+#ifndef __LOADER_H__
+#define __LOADER_H__
+
+/* Errors that the LOADER_LOAD() function may return: */
+
+#define LOADER_OK                0       /**< No error. */
+#define LOADER_ERR_READ          1       /**< Read error. */
+#define LOADER_ERR_HDR           2       /**< Header error. */
+#define LOADER_ERR_OS            3       /**< Wrong OS. */
+#define LOADER_ERR_FMT           4       /**< Data format error. */
+#define LOADER_ERR_MEM           5       /**< Not enough memory. */
+#define LOADER_ERR_OPEN          6       /**< Could not open file. */
+#define LOADER_ERR_ARCH          7       /**< Wrong architecture. */
+#define LOADER_ERR_VERSION       8       /**< Wrong OS version. */
+#define LOADER_ERR_NOLOADER      9       /**< Program loading not supported. */
+
+#ifdef WITH_LOADER_ARCH
+#include "loader-arch.h"
+#include "loader-arch-dsc.h"
+#define LOADER_INIT_FUNC(name, arg) void loader_appinit(char *arg)
+#else /* WITH_LOADER_ARCH */
+#define LOADER_INIT_FUNC(name, arg) void name(char *arg)
+#endif /* WITH_LOADER_ARCH */
+
+/**
+ * Load and execute a program.
+ *
+ * This macro is used for loading and executing a program, and
+ * requires support from the architecture dependant code. The actual
+ * program loading is made by architecture specific functions.
+ *
+ * \note A program loaded with LOADER_LOAD() must call the
+ * LOADER_UNLOAD() function to unload itself.
+ *
+ * \param name The name of the program to be loaded.
+ *
+ * \param arg A pointer argument that is passed to the program.
+ *
+ * \return A loader error, or LOADER_OK if loading was successful.
+ */
+#ifndef LOADER_LOAD
+#define LOADER_LOAD(name, arg) LOADER_ERR_NOLOADER
+#endif /* LOADER_LOAD */
+
+/**
+ * Unload a program from memory.
+ *
+ * This macro is used for unloading a program and deallocating any
+ * memory that was allocated during the loading of the program. This
+ * function must be called by the program itself.
+ *
+ */
+#ifndef LOADER_UNLOAD
+#define LOADER_UNLOAD()
+#endif /* LOADER_UNLOAD */
+
+/**
+ * Load a DSC (program description).
+ *
+ * Loads a DSC (program description) into memory and returns a pointer
+ * to the dsc.
+ *
+ * \return A pointer to the DSC or NULL if it could not be loaded.
+ */
+#ifndef LOADER_LOAD_DSC
+#define LOADER_LOAD_DSC(name) NULL
+#endif /* LOADER_LOAD_DSC */
+
+/**
+ * Unload a DSC (program description).
+ *
+ * Unload a DSC from memory and deallocate any memory that was
+ * allocated when it was loaded.
+ */
+#ifndef LOADER_UNLOAD_DSC
+#define LOADER_UNLOAD_DSC(dsc)
+#endif /* LOADER_UNLOAD */
+
+
+
+
+#endif /* __LOADER_H__ */
diff --git a/contiki/ek/log.h b/contiki/ek/log.h
new file mode 100644
index 0000000..5f6f262
--- /dev/null
+++ b/contiki/ek/log.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: log.h,v 1.3 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __LOG_H__
+#define __LOG_H__
+
+#include "log-conf.h"
+
+#if LOG_CONF_ENABLED
+void log_message(const char *part1, const char *part2);
+#else /* LOG_CONF_ENABLED */
+#define log_message(p1, p2)
+#endif /* LOG_CONF_ENABLED */
+
+#endif /* __LOG_H__ */
diff --git a/contiki/ek/mt.c b/contiki/ek/mt.c
new file mode 100644
index 0000000..9a349d5
--- /dev/null
+++ b/contiki/ek/mt.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mt.c,v 1.3 2005/02/22 22:46:33 adamdunkels Exp $
+ */
+
+/**
+ * \file
+ * Implementation of the archtecture agnostic parts of the preemptive
+ * multithreading library for Contiki.
+ *
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#include "ek.h"
+#include "mt.h"
+#include "cc.h"
+
+#define MT_STATE_READY   1
+#define MT_STATE_RUNNING 2
+#define MT_STATE_WAITING 3
+#define MT_STATE_PEEK    4
+#define MT_STATE_EXITED  5
+
+static struct mt_thread *current;
+
+/*--------------------------------------------------------------------------*/
+void
+mt_init(void)
+{
+  mtarch_init();
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_remove(void)
+{
+  mtarch_remove();
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_start(struct mt_thread *thread, void (* function)(void *), void *data)
+{
+  /* Call the architecture dependant function to set up the processor
+     stack with the correct parameters. */
+  mtarch_start(&thread->thread, function, data);
+
+  thread->state = MT_STATE_READY;
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_exec(struct mt_thread *thread)
+{
+  if(thread->state == MT_STATE_READY ||
+     thread->state == MT_STATE_PEEK) {
+    thread->state = MT_STATE_RUNNING;
+    current = thread;
+    /* Switch context to the thread. The function call will not return
+       until the the thread has yielded, or is preempted. */
+    mtarch_exec(&thread->thread);
+  }
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_exit(void)
+{
+  current->state = MT_STATE_EXITED;
+  current = NULL;
+  mtarch_yield();
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_exec_event(struct mt_thread *thread, ek_event_t ev, ek_data_t data)
+{
+  if(thread->state == MT_STATE_WAITING ||
+     thread->state == MT_STATE_PEEK) {
+    *(thread->evptr) = ev;
+    *(thread->dataptr) = data;
+    thread->state = MT_STATE_RUNNING;
+    current = thread;    
+    /* Switch context to the thread. The function call will not return
+       until the the thread has yielded, or is preempted. */
+    mtarch_exec(&thread->thread);
+  }
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_yield(void)
+{    
+  mtarch_pstop();
+  current->state = MT_STATE_READY;
+  current = NULL;
+  /* This function is called from the running thread, and we call the
+     switch function in order to switch the thread to the main Contiki
+     program instead. For us, the switch function will not return
+     until the next time we are scheduled to run. */
+  mtarch_yield();
+  
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_post(ek_id_t id, ek_event_t ev, ek_data_t data)
+{  
+  /* Turn off preemption to ensure mutual exclusion of kernel. */
+  mtarch_pstop();
+
+  ek_post(id, ev, data);
+  
+  /* Turn preemption on again. */  
+  mtarch_pstart();  
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_wait(ek_event_t *ev, ek_data_t *data)
+{
+  mtarch_pstop();
+  current->evptr = ev;
+  current->dataptr = data;
+  current->state = MT_STATE_WAITING;
+  current = NULL;
+  mtarch_yield();
+}
+/*--------------------------------------------------------------------------*/
+void
+mt_peek(ek_event_t *ev, ek_data_t *data)
+{
+  mtarch_pstop();
+  *ev = EK_EVENT_NONE;
+  current->evptr = ev;
+  current->dataptr = data;
+  current->state = MT_STATE_PEEK;
+  current = NULL;
+  mtarch_yield();  
+}
+/*--------------------------------------------------------------------------*/
+void
+mtp_start(struct mtp_thread *t,
+	  void (* function)(void *), void *data)
+{
+  mt_start(&t->t, function, data);
+  ek_start(t->p);
+}
+/*--------------------------------------------------------------------------*/
+void
+mtp_exit(void)
+{
+  mtarch_pstop();
+  mt_exit();
+  mt_remove();
+}
+/*--------------------------------------------------------------------------*/
+void
+mtp_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  struct mtp_thread *thread = (struct mtp_thread *)EK_PROC_STATE(EK_CURRENT());
+
+  if(ev == EK_EVENT_REQUEST_EXIT) {
+    ek_exit();
+    LOADER_UNLOAD();
+    
+  } else if(ev == EK_EVENT_INIT) {
+    
+    ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+    
+  } else if(ev == EK_EVENT_CONTINUE) {
+
+    if(thread->t.state == MT_STATE_READY ||
+       thread->t.state == MT_STATE_PEEK) {
+      mt_exec(&thread->t);
+      if(thread->t.state == MT_STATE_EXITED) {
+	ek_exit();
+	LOADER_UNLOAD();
+      } else {
+	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+      }
+    }
+  } else {
+    mt_exec_event(&thread->t, ev, data);
+    if(thread->t.state == MT_STATE_EXITED) {
+      ek_exit();
+      LOADER_UNLOAD();
+    } else if(thread->t.state == MT_STATE_READY ||
+	      thread->t.state == MT_STATE_PEEK) {
+      ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+    }
+  }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki/ek/mt.h b/contiki/ek/mt.h
new file mode 100644
index 0000000..bbfbc34
--- /dev/null
+++ b/contiki/ek/mt.h
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mt.h,v 1.4 2005/02/22 22:46:33 adamdunkels Exp $
+ */
+
+/**
+ * \defgroup mt Multi-threading library
+ * @{
+ *
+ * The event driven Contiki kernel does not provide multi-threading
+ * by itself - instead, preemptive multi-threading is implemented
+ * as a library that optionally can be linked with applications. This
+ * library constists of two parts: a platform independent part, which is
+ * the same for all platforms on which Contiki runs, and a platform
+ * specific part, which must be implemented specifically for the
+ * platform that the multi-threading library should run.
+ */
+
+/**
+ * \defgroup mtarch Architecture support for multi-threading
+ * @{
+ *
+ * The Contiki multi-threading library requires some architecture
+ * specific support for seting up and switching stacks. This support
+ * requires three stack manipulation functions to be implemented:
+ * mtarch_start(), which sets up the stack frame for a new thread,
+ * mtarch_exec(), which switches in the stack of a thread, and
+ * mtarch_yield(), which restores the kernel stack from a thread's
+ * stack. Additionally, two functions for controlling the preemption
+ * (if any) must be implemented: mtarch_preemption_start() and
+ * mtarch_preemption_stop(). If no preemption is used, these functions
+ * can be implemented as empty functions. Finally, the function
+ * mtarch_init() is called by mt_init(), and can be used for
+ * initalization of timer interrupts, or any other mechanisms required
+ * for correct operation of the architecture specific support funcions.
+ *
+ */
+
+/**
+ * \file
+ * Header file for the preemptive multitasking library for Contiki.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __MT_H__
+#define __MT_H__
+
+#include "ek.h"
+
+
+/**
+ * An opaque structure that is used for holding the state of a thread.
+ *
+ * The structure should be defined in the "mtarch.h" file. This
+ * structure typically holds the entire stack for the thread.
+ */
+struct mtarch_thread;
+
+/**
+ * Initialize the architecture specific support functions for the
+ * multi-thread library.
+ *
+ * This function is implemented by the architecture specific functions
+ * for the multi-thread library and is called by the mt_init()
+ * function as part of the initialization of the library. The
+ * mtarch_init() function can be used for, e.g., starting preemtion
+ * timers or other architecture specific mechanisms required for the
+ * operation of the library.
+ */
+void mtarch_init(void);
+
+/**
+ * Uninstall library and clean up.
+ *
+ */
+void mtarch_remove(void);
+
+/**
+ * Setup the stack frame for a thread that is being started.
+ *
+ * This function is called by the mt_start() function in order to set
+ * up the architecture specific stack of the thread to be started.
+ *
+ * \param thread A pointer to a struct mtarch_thread for the thread to
+ * be started.
+ *
+ * \param function A pointer to the function that the thread will
+ * start executing the first time it is scheduled to run.
+ *
+ * \param data A pointer to the argument that the function should be
+ * passed.
+ */
+void mtarch_start(struct mtarch_thread *thread,
+		  void (* function)(void *data),
+		  void *data);
+
+/**
+ * Yield the processor.
+ *
+ * This function is called by the mt_yield() function, which is called
+ * from the running thread in order to give up the processor.
+ *
+ */
+void mtarch_yield(void);
+
+/**
+ * Start executing a thread.
+ *
+ * This function is called from mt_exec() and the purpose of the
+ * function is to start execution of the thread. The function should
+ * switch in the stack of the thread, and does not return until the
+ * thread has explicitly yielded (using mt_yield()) or until it is
+ * preempted.
+ *
+ */
+void mtarch_exec(struct mtarch_thread *thread);
+
+
+void mtarch_pstart(void);
+void mtarch_pstop(void);
+
+/** @} */
+
+
+#include "mtarch.h"
+#include "ek.h"
+
+struct mt_thread {
+  int state;
+  ek_event_t *evptr;
+  ek_data_t *dataptr;
+  struct mtarch_thread thread;
+};
+
+/**
+ * No error.
+ *
+ * \hideinitializer
+ */
+#define MT_OK 1
+
+/**
+ * Initializes the multithreading library.
+ *
+ */
+void mt_init(void);
+
+/**
+ * Uninstalls library and cleans up.
+ *
+ */
+void mt_remove(void);
+
+
+/**
+ * Starts a multithreading thread.
+ *
+ * \param thread Pointer to an mt_thread struct that must have been
+ * previously allocated by the caller.
+ *
+ * \param function A pointer to the entry function of the thread that is
+ * to be set up.
+ *
+ * \param data A pointer that will be passed to the entry function.
+ *
+ */
+void mt_start(struct mt_thread *thread, void (* function)(void *), void *data);
+
+/**
+ * Start executing a thread.
+ *
+ * This function is called by a Contiki process and starts running a
+ * thread. The function does not return until the thread has yielded,
+ * or is preempted.
+ *
+ * \note The thread must first be initialized with the mt_init() function.
+ *
+ * \param thread A pointer to a struct mt_thread block that must be
+ * allocated by the caller.
+ *
+ */
+void mt_exec(struct mt_thread *thread);
+
+/**
+ * Post an event to a thread.
+ *
+ * This function posts an event to a thread. The thread will be
+ * scheduled if the thread currently is waiting for the posted event
+ * number. If the thread is not waiting for the event, this function
+ * does nothing.
+ *
+ * \note The thread must first be initialized with the mt_init() function.
+ *
+ * \param thread A pointer to a struct mt_thread block that must be
+ * allocated by the caller.
+ *
+ * \param s The event that is posted to the thread.
+ *
+ * \param data An opaque pointer to a user specified structure
+ * containing additonal information, or NULL if no additional
+ * information is needed.
+ */
+void mt_exec_event(struct mt_thread *thread, ek_event_t s, ek_data_t data);
+
+/**
+ * Voluntarily give up the processor.
+ *
+ * This function is called by a running thread in order to give up
+ * control of the CPU.
+ *
+ */
+void mt_yield(void);
+
+/**
+ * Emit a signal to another process.
+ *
+ * This function is called by a running thread and will emit a signal
+ * to another Contiki process. This will cause the currently executing
+ * thread to yield.
+ *
+ * \param s The signal to be emitted.
+ * \param data A pointer to a message that is to be delivered together with the signal.
+ * \param id The process ID of the receiver of the signal, or EK_ID_ALL for a broadcast signal.
+ */
+void mt_post(ek_id_t id, ek_event_t s, ek_data_t data);
+
+/**
+ * Block and wait for an event to occur.
+ *
+ * This function can be called by a running thread in order to block
+ * and wait for an event. The function returns when an event has
+ * occured. The event number and the associated data are placed in the
+ * variables pointed to by the function arguments.
+ * 
+ */
+void mt_wait(ek_event_t *s, ek_data_t *data);
+
+/**
+ * Exit a thread.
+ *
+ * This function is called from within an executing thread in order to
+ * exit the thread. The function never returns.
+ *
+ */
+void mt_exit(void);
+
+/**
+ * \defgroup mtp Multi-threading library convenience functions
+ * @{
+ *
+ * The Contiki multi-threading library has an interface that might be
+ * hard to use. Therefore, the mtp module provides a simpler
+ * interface.
+ *
+ * Example:
+\code
+static void
+example_thread_code(void *data)
+{
+  while(1) {
+    printf("Test\n");
+    mt_yield();
+  }
+} 
+MTP(example_thread, "Example thread", p1, t1, t1_idle);
+
+int
+main(int argc, char *argv[])
+{
+  mtp_start(&example_thread, example_thread_code, NULL);
+}
+\endcode
+*
+*/
+
+#include "mt.h"
+
+/**
+ * Declare a thread.
+ *
+ * This macro is used to covneniently declare a thread, and the
+ * process in which the thread should execute. The names of the
+ * variables provided to the macro should be chosen to be unique
+ * within the file that the thread is used.
+ *
+ * Example:
+\code
+MTP(example_thread, example_proc, "Example thread");
+\endcode
+ *
+ * \param thread The variable name of the thread.
+ *
+ * \param proc The variable name of the process containing the thread.
+ *
+ * \param name A string that specifies the user-visible name of the
+ * process in which the thread will run.
+ *
+ * \hideinitializer
+ */
+#define MTP(thread, proc, name) \
+extern struct mtp_thread thread; \
+EK_PROCESS(proc, name, EK_PRIO_NORMAL, mtp_eventhandler, \
+           NULL, (void *)&thread); \
+static struct mtp_thread thread = {&proc}
+
+struct mtp_thread {
+  struct ek_proc *p;
+  struct mt_thread t;
+};
+
+/**
+ * Start a thread.
+ *
+ * This function starts the process in which the thread is to run, and
+ * also sets up the thread to run within the process. The function
+ * should be passed variable names declared with the MTP() macro.
+ *
+ * Example:
+\code
+mtp_start(&t, example_thread_code, NULL);
+\endcode
+ * \param t A pointer to a thread structure previously declared with MTP().
+ *
+ * \param function A pointer to the function that the thread should
+ * start executing.
+ *
+ * \param data A pointer that the function should be passed when first
+ * invocated.
+ */
+void mtp_start(struct mtp_thread *t,
+	       void (* function)(void *), void *data);
+
+void mtp_exit(void);
+
+
+void mtp_eventhandler(ek_event_t ev, ek_data_t data);
+
+/** @} */
+/** @} */
+#endif /* __MT_H__ */
+
diff --git a/contiki/ek/pt-sem.h b/contiki/ek/pt-sem.h
new file mode 100644
index 0000000..6d1907e
--- /dev/null
+++ b/contiki/ek/pt-sem.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: pt-sem.h,v 1.4 2005/02/28 09:02:41 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup pt
+ * @{
+ */
+
+/**
+ * \defgroup ptsem Protothread semaphores
+ * @{
+ *
+ * This module implements counting semaphores on top of
+ * protothreads. Semaphores are a synchronization primitive that
+ * provide two operations: "wait" and "signal". The "wait" operation
+ * checks the semaphore counter and blocks the thread if the counter
+ * is zero. The "signal" operation increases the semaphore counter but
+ * does not block. If another thread has blocked waiting for the
+ * semaphore that is signalled, the blocked thread will become
+ * runnable again.
+ *
+ * Semaphores can be used to implement other, more structured,
+ * synchronization primitives such as monitors and message
+ * queues/bounded buffers (see below).
+ *
+ * The following example shows how the producer-consumer problem, also
+ * known as the bounded buffer problem, can be solved using
+ * protothreads and semaphores. Notes on the program follow after the
+ * example.
+ *
+ \code
+#include "pt-sem.h"
+
+#define NUM_ITEMS 32
+#define BUFSIZE 8
+
+static struct pt_sem mutex, full, empty;
+
+PT_THREAD(producer(struct pt *pt))
+{
+  static int produced;
+  
+  PT_BEGIN(pt);
+  
+  for(produced = 0; produced < NUM_ITEMS; ++produced) {
+  
+    PT_SEM_WAIT(pt, &full);
+    
+    PT_SEM_WAIT(pt, &mutex);
+    add_to_buffer(produce_item());    
+    PT_SEM_SIGNAL(pt, &mutex);
+    
+    PT_SEM_SIGNAL(pt, &empty);
+  }
+
+  PT_END(pt);
+}
+
+PT_THREAD(consumer(struct pt *pt))
+{
+  static int consumed;
+  
+  PT_BEGIN(pt);
+
+  for(consumed = 0; consumed < NUM_ITEMS; ++consumed) {
+    
+    PT_SEM_WAIT(pt, &empty);
+    
+    PT_SEM_WAIT(pt, &mutex);    
+    consume_item(get_from_buffer());    
+    PT_SEM_SIGNAL(pt, &mutex);
+    
+    PT_SEM_SIGNAL(pt, &full);
+  }
+
+  PT_END(pt);
+}
+
+PT_THREAD(driver_thread(struct pt *pt))
+{
+  static struct pt pt_producer, pt_consumer;
+
+  PT_BEGIN(pt);
+  
+  PT_SEM_INIT(&empty, 0);
+  PT_SEM_INIT(&full, BUFSIZE);
+  PT_SEM_INIT(&mutex, 1);
+
+  PT_INIT(&pt_producer);
+  PT_INIT(&pt_consumer);
+
+  PT_WAIT_THREAD(pt, producer(&pt_producer) &
+		     consumer(&pt_consumer));
+
+  PT_END(pt);
+}
+ \endcode
+ *
+ * The program uses three protothreads: one protothread that
+ * implements the consumer, one thread that implements the producer,
+ * and one protothread that drives the two other protothreads. The
+ * program uses three semaphores: "full", "empty" and "mutex". The
+ * "mutex" semaphore is used to provide mutual exclusion for the
+ * buffer, the "empty" semaphore is used to block the consumer is the
+ * buffer is empty, and the "full" semaphore is used to block the
+ * producer is the buffer is full.
+ *
+ * The "driver_thread" holds two protothread state variables,
+ * "pt_producer" and "pt_consumer". It is important to note that both
+ * these variables are declared as <i>static</i>. If the static
+ * keyword is not used, both variables are stored on the stack. Since
+ * protothreads do not store the stack, these variables may be
+ * overwritten during a protothread wait operation. Similarly, both
+ * the "consumer" and "producer" protothreads declare their local
+ * variables as static, to avoid them being stored on the stack.
+ * 
+ *
+ */
+   
+/**
+ * \file
+ * Counting semaphores implemented on protothreads
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __PT_SEM_H__
+#define __PT_SEM_H__
+
+#include "pt.h"
+
+struct pt_sem {
+  unsigned int count;
+};
+
+/**
+ * Initialize a semaphore
+ *
+ * This macro initializes a semaphore with a value for the
+ * counter. Internally, the semaphores use an "unsigned int" to
+ * represent the counter, and therefore the "count" argument should be
+ * within range of an unsigned int.
+ *
+ * \param s (struct pt_sem *) A pointer to the pt_sem struct
+ * representing the semaphore
+ *
+ * \param c (unsigned int) The initial count of the semaphore.
+ * \hideinitializer
+ */
+#define PT_SEM_INIT(s, c) (s)->count = c
+
+/**
+ * Wait for a semaphore
+ *
+ * This macro carries out the "wait" operation on the semaphore. The
+ * wait operation causes the protothread to block while the counter is
+ * zero. When the counter reaches a value larger than zero, the
+ * protothread will continue.
+ *
+ * \param pt (struct pt *) A pointer to the protothread (struct pt) in
+ * which the operation is executed.
+ *
+ * \param s (struct pt_sem *) A pointer to the pt_sem struct
+ * representing the semaphore
+ *
+ * \hideinitializer
+ */
+#define PT_SEM_WAIT(pt, s)	\
+  do {						\
+    PT_WAIT_UNTIL(pt, (s)->count > 0);		\
+    --(s)->count;				\
+  } while(0)
+
+/**
+ * Signal a semaphore
+ *
+ * This macro carries out the "signal" operation on the semaphore. The
+ * signal operation increments the counter inside the semaphore, which
+ * eventually will cause waiting protothreads to continue executing.
+ *
+ * \param pt (struct pt *) A pointer to the protothread (struct pt) in
+ * which the operation is executed.
+ *
+ * \param s (struct pt_sem *) A pointer to the pt_sem struct
+ * representing the semaphore
+ *
+ * \hideinitializer
+ */
+#define PT_SEM_SIGNAL(pt, s) ++(s)->count
+
+#endif /* __PT_SEM_H__ */
+
+/** @} */
+/** @} */
+   
diff --git a/contiki/ek/pt.h b/contiki/ek/pt.h
new file mode 100644
index 0000000..bbadd02
--- /dev/null
+++ b/contiki/ek/pt.h
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: pt.h,v 1.10 2005/04/01 09:07:49 adamdunkels Exp $
+ */
+
+/**
+ * \addtogroup pt
+ * @{
+ */
+
+/**
+ * \file
+ * Protothreads implementation.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __PT_H__
+#define __PT_H__
+
+#include "lc.h"
+
+struct pt {
+  lc_t lc;
+};
+
+#define PT_THREAD_WAITING 0
+#define PT_THREAD_EXITED  1
+
+/**
+ * Declaration of a protothread.
+ *
+ * This macro is used to declare a protothread. All protothreads must
+ * be declared with this macro.
+ *
+ * Example:
+ \code
+ PT_THREAD(consumer(struct pt *p, int event)) {
+   PT_BEGIN(p);
+   while(1) {
+     PT_WAIT_UNTIL(p, event == AVAILABLE);
+     consume();
+     PT_WAIT_UNTIL(p, event == CONSUMED);
+     acknowledge_consumed();
+   }
+   PT_END(p);
+ }
+ \endcode
+ *
+ * \param name_args The name and arguments of the C function
+ * implementing the protothread.
+ *
+ * \hideinitializer
+ */
+#define PT_THREAD(name_args) char name_args
+
+/**
+ * Initialize a protothread.
+ *
+ * Initializes a protothread. Initialization must be done prior to
+ * starting to execute the protothread.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * Example:
+ *
+ \code
+ void main(void) {
+   struct pt p;
+   int event;
+   
+   PT_INIT(&p);
+   while(PT_SCHEDULE(consumer(&p, event))) {
+     event = get_event();
+   }
+ }
+ \endcode
+ *
+ * \sa PT_SPAWN()
+ *
+ * \hideinitializer
+ */
+#define PT_INIT(pt)   LC_INIT((pt)->lc)
+
+/**
+ * Declare the start of a protothread inside the C function
+ * implementing the protothread.
+ *
+ * This macro is used to declare the starting point of a
+ * protothread. It should be placed at the start of the function in
+ * which the protothread runs. All C statements above the PT_BEGIN()
+ * invokation will be executed each time the protothread is scheduled.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * Example:
+ *
+ \code
+ PT_THREAD(producer(struct pt *p, int event)) {
+   PT_BEGIN(p);
+   while(1) {
+     PT_WAIT_UNTIL(p, event == CONSUMED || event == DROPPED);
+     produce();
+     PT_WAIT_UNTIL(p, event == PRODUCED);
+   }
+   
+   PT_END(p);
+ }
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define PT_BEGIN(pt) LC_RESUME((pt)->lc)
+
+/**
+ * Block and wait until condition is true.
+ *
+ * This macro blocks the protothread until the specified condition is
+ * true.
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param condition The condition.
+ *
+ * Example:
+ \code
+ PT_THREAD(seconds(struct pt *p)) {
+   PT_BEGIN(p);
+
+   PT_WAIT_UNTIL(p, time >= 2 * SECOND);
+   printf("Two seconds have passed\n");
+   
+   PT_END(p);
+ }
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define PT_WAIT_UNTIL(pt, condition)	        \
+  do {						\
+    LC_SET((pt)->lc);				\
+    if(!(condition)) {				\
+      return PT_THREAD_WAITING;			\
+    }						\
+  } while(0)
+
+/**
+ * Block and wait while condition is true.
+ *
+ * This function blocks and waits while condition is true. See
+ * PT_WAIT_UNTIL().
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param cond The condition.
+ *
+ * \hideinitializer
+ */
+#define PT_WAIT_WHILE(pt, cond)  PT_WAIT_UNTIL((pt), !(cond))
+
+
+/**
+ * Block and wait until a child protothread completes.
+ *
+ * This macro schedules a child protothread. The current protothread
+ * will block until the child protothread completes.
+ *
+ * \note The child protothread must be manually initialized with the
+ * PT_INIT() function before this function is used.
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param thread The child protothread with arguments
+ *
+ * Example:
+ \code
+ PT_THREAD(child(struct pt *p, int event)) {
+   PT_BEGIN(p);
+
+   PT_WAIT_UNTIL(p, event == EVENT1);   
+   
+   PT_END(p);
+ }
+
+ PT_THREAD(parent(struct pt *p, struct pt *child_pt, int event)) {
+   PT_BEGIN(p);
+
+   PT_INIT(child_pt);
+   
+   PT_WAIT_THREAD(p, child(child_pt, event));
+   
+   PT_END(p);
+ }
+ \endcode
+ *
+ * \sa PT_SPAWN()
+ *
+ * \hideinitializer 
+ */
+#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
+
+/**
+ * Spawn a child protothread and wait until it exits.
+ *
+ * This macro spawns a child protothread and waits until it exits. The
+ * macro can only be used within a protothread.
+ *
+ * Example:
+ \code
+ static struct pt parent_pt, child_pt;
+ int should_spawn_flag;
+
+ PT_THREAD(child(struct pt *pt)) {
+   PT_BEGIN(pt);
+
+   while(all_items_processed()) {
+     process_item();
+     PT_WAIT_UNTIL(pt, item_processed());
+   }
+   
+   PT_END(pt);
+ }
+ 
+ PT_THREAD(parent(void)) {
+   PT_BEGIN(&parent_pt);
+
+   if(should_spawn_flag) {
+     PT_SPAWN(&parent_pt, &child_pt, child(&child_pt));
+   }
+   
+   PT_END(&parent_pt);
+ }
+ \endcode
+ *
+ *
+ * \param pt A pointer to the protothread control structure.
+ * \param child A pointer to the child protothread's control structure.
+ * \param thread The child protothread with arguments
+ *
+ * \hideinitializer
+ */
+#define PT_SPAWN(pt, child, thread)		\
+  do {						\
+    PT_INIT((child));				\
+    PT_WAIT_THREAD((pt), (thread));		\
+  } while(0)
+
+/**
+ * Restart the protothread.
+ *
+ * This macro will block and cause the running protothread to restart
+ * its execution at the place of the PT_BEGIN() call.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_RESTART(pt)				\
+  do {						\
+    PT_INIT(pt);				\
+    return PT_THREAD_WAITING;			\
+  } while(0)
+
+/**
+ * Exit the protothread.
+ *
+ * This macro causes the protothread to exit. If the protothread was
+ * spawned by another protothread, the parent protothread will become
+ * unblocked and can continue to run.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_EXIT(pt)				\
+  do {						\
+    PT_INIT(pt);				\
+    return PT_THREAD_EXITED;			\
+  } while(0)
+
+/**
+ * Declare the end of a protothread.
+ *
+ * This macro is used for declaring that a protothread ends. It should
+ * always be used together with a matching PT_BEGIN() macro.
+ *
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_END(pt) LC_END((pt)->lc); PT_EXIT(pt)
+
+
+/**
+ * Schedule a protothread.
+ *
+ * This function shedules a protothread. The return value of the
+ * function is non-zero if the protothread is running or zero if the
+ * protothread has exited.
+ *
+ * Example
+ \code
+ void main(void) {
+   struct pt p;
+   int event;
+   
+   PT_INIT(&p);
+   while(PT_SCHEDULE(consumer(&p, event))) {
+     event = get_event();
+   }   
+ }
+ \endcode
+ *
+ * \param f The call to the C function implementing the protothread to
+ * be scheduled
+ *
+ * \hideinitializer
+ */
+#define PT_SCHEDULE(f) (f == PT_THREAD_WAITING)
+
+/**
+ * Declarare that a protothread can yield.
+ *
+ * If a protothread should be able to yield with the PT_YIELD()
+ * statement, this flag must be placed first in the protothread's
+ * function body.
+ *
+ * Example:
+ \code
+ static
+ PT_THREAD(loop_thread(struct pt *pt))
+ {
+   PT_YIELDING();
+   static int i;
+
+   PT_BEGIN(pt);
+   
+   for(i = 0; i < 200; ++i) {
+     handle_item(i);
+     PT_YIELD(pt);
+   }
+   
+   PT_END(pt);
+ }
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define PT_YIELDING() char pt_yielded = 1
+
+/**
+ * Yield from the current protothread.
+ *
+ * This function will yield the protothread, thereby allowing other
+ * processing to take place in the system.
+ *
+ * \note The PT_YIELDING() flag must be placed first in the
+ * protothread's body if the PT_YIELD() function should be used.
+ *
+ * Example
+ \code
+static
+PT_THREAD(fade(struct pt *pt))
+{
+  PT_YIELDING();
+  static int delay;
+  
+  PT_BEGIN(pt);
+  
+  for(delay = 3980; delay > 20; delay -= 20) {
+    leds_red(LEDS_ON);
+    clock_delay(4000 - delay);
+    leds_red(LEDS_OFF);
+    clock_delay(delay);
+    PT_YIELD(pt);
+  }
+  
+  PT_END(pt);
+}
+ \endcode
+ * \param pt A pointer to the protothread control structure.
+ *
+ * \hideinitializer
+ */
+#define PT_YIELD(pt)				\
+  do {						\
+    pt_yielded = 0;				\
+    PT_WAIT_UNTIL(pt, pt_yielded);		\
+  } while(0)
+
+#endif /* __PT_H__ */
+
+
+/** @} */
diff --git a/contiki/lib/FILES b/contiki/lib/FILES
new file mode 100644
index 0000000..d27acbc
--- /dev/null
+++ b/contiki/lib/FILES
@@ -0,0 +1,48 @@
+The contiki/lib/ directory contains the source code for a number of
+utility function that are part of Contiki but are optional and not
+generally required.
+
+cc.h
+
+  Header file for C compiler tweaks.
+
+cfs.[ch], cfs-service.[ch]
+
+  The Contiki filesystem service interface.
+
+cfs-posix.[ch]
+
+  A CFS implementation using POSIX functions.
+
+ctk-filedialog.[ch]
+
+  A CTK file dialog widget.
+
+ctk-textedit.[ch]
+
+  A CTK text editor widget.
+
+libconio.[ch]
+
+  An implementation of selected parts of the Borland conio
+  interface. Used for easy porting of the ctk-conio.c CTK driver.
+
+list.[ch]
+
+  A generic list library.
+
+memb.[ch]
+
+  A generic memory block allocator library.
+
+petsciiconv.[ch]
+
+  Conversion routines between ASCII and PETSCII character encodings.
+
+strncasecmp.c
+
+  Implementation of the strncasecmp() function.
+
+timer.[ch]
+
+  A generic timer library.                  
\ No newline at end of file
diff --git a/contiki/lib/cc.h b/contiki/lib/cc.h
new file mode 100644
index 0000000..3f66649
--- /dev/null
+++ b/contiki/lib/cc.h
@@ -0,0 +1,102 @@
+/**
+ * \file
+ * Default definitions of C compiler quirk work-arounds.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file is used for making use of extra functionality of some C
+ * compilers used for Contiki, and defining work-arounds for various
+ * quirks and problems with some other C compilers.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc.h,v 1.6 2004/03/18 23:03:56 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_H__
+#define __CC_H__
+
+#include "cc-conf.h"
+
+/**
+ * Configure if the C compiler supports the "register" keyword for
+ * function arguments.
+ */
+#if CC_CONF_REGISTER_ARGS
+#define CC_REGISTER_ARG register
+#else /* CC_CONF_REGISTER_ARGS */
+#define CC_REGISTER_ARG
+#endif /* CC_CONF_REGISTER_ARGS */
+
+/**
+ * Configure if the C compiler supports the arguments for function
+ * pointers.
+ */
+#if CC_CONF_FUNCTION_POINTER_ARGS
+#define CC_FUNCTION_POINTER_ARGS 1
+#else /* CC_CONF_FUNCTION_POINTER_ARGS */
+#define CC_FUNCTION_POINTER_ARGS 0
+#endif /* CC_CONF_FUNCTION_POINTER_ARGS */
+
+/**
+ * Configure if the C compiler supports fastcall function
+ * declarations.
+ */
+#ifdef CC_CONF_FASTCALL
+#define CC_FASTCALL CC_CONF_FASTCALL
+#else /* CC_CONF_FASTCALL */
+#define CC_FASTCALL
+#endif /* CC_CONF_FASTCALL */
+
+/**
+ * Configure work-around for unsigned char bugs with sdcc.
+ */
+#if CC_CONF_UNSIGNED_CHAR_BUGS
+#define CC_UNSIGNED_CHAR_BUGS 1
+#else /* CC_CONF_UNSIGNED_CHAR_BUGS */
+#define CC_UNSIGNED_CHAR_BUGS 0
+#endif /* CC_CONF_UNSIGNED_CHAR_BUGS */
+
+/**
+ * Configure if C compiler supports double hash marks in C macros.
+ */
+#if CC_CONF_DOUBLE_HASH
+#define CC_DOUBLE_HASH 1
+#else /* CC_CONF_DOUBLE_HASH */
+#define CC_DOUBLE_HASH 0
+#endif /* CC_CONF_DOUBLE_HASH */
+
+#ifndef NULL
+#define NULL 0
+#endif /* NULL */
+#endif /* __CC_H__ */
+
diff --git a/contiki/lib/cfs-posix.c b/contiki/lib/cfs-posix.c
new file mode 100644
index 0000000..9bcc06f
--- /dev/null
+++ b/contiki/lib/cfs-posix.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-posix.c,v 1.4 2005/04/10 19:23:06 oliverschmidt Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <string.h>
+
+static int  s_open(const char *n, int f);
+static void s_close(int f);
+static int  s_read(int f, char *b, unsigned int l);
+static int  s_write(int f, char *b, unsigned int l);
+static int  s_opendir(struct cfs_dir *p, const char *n);
+static int  s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int  s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+  {
+    CFS_SERVICE_VERSION,
+    s_open,
+    s_close,
+    s_read,
+    s_write,
+    s_opendir,
+    s_readdir,
+    s_closedir
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": POSIX", EK_PRIO_NORMAL,
+           eventhandler, NULL, (void *)&interface);
+
+struct cfs_posix_dir {
+  DIR *dirp;
+};
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_posix_init, arg)
+{
+  arg_free(arg);
+  ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, &interface);
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+  char filename[255];
+  sprintf(filename, "cfs-root/%s", n);
+  if(f == CFS_READ) {
+    return open(filename, O_RDONLY);
+  } else {
+    return open(filename, O_CREAT|O_TRUNC|O_RDWR);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+  close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+  return read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+  return write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+  struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
+  char dirname[255];
+
+  if(n == NULL) {
+    n = "";
+  }
+  sprintf(dirname, "cfs-root/%s", n);
+  
+  dir->dirp = opendir(dirname);
+    
+  return dir->dirp == NULL;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+  struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
+  struct dirent *res;
+  int ret;
+  
+  res = readdir(dir->dirp);
+  if(res == NULL) {
+    return 1;
+  }
+  strncpy(e->name, res->d_name, sizeof(e->name));
+  e->size = 0;
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+  struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
+  closedir(dir->dirp);
+  return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/lib/cfs-posix.h b/contiki/lib/cfs-posix.h
new file mode 100644
index 0000000..df80f76
--- /dev/null
+++ b/contiki/lib/cfs-posix.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-posix.h,v 1.2 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __CFS_POSIX_H__
+#define __CFS_POSIX_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_posix_init, arg);
+
+#endif /* __CFS_POSIX_H__ */
diff --git a/contiki/lib/cfs-service.h b/contiki/lib/cfs-service.h
new file mode 100644
index 0000000..58d096b
--- /dev/null
+++ b/contiki/lib/cfs-service.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-service.h,v 1.3 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __CFS_SERVICE_H__
+#define __CFS_SERVICE_H__
+
+#include "ek-service.h"
+#include "cfs.h"
+
+
+#define CFS_SERVICE_VERSION 0x01
+#define CFS_SERVICE_NAME "Filesystem"
+
+struct cfs_dir {
+  unsigned char dummy_space[32];
+};
+
+struct cfs_dirent {
+  unsigned char name[32];
+  unsigned int size;
+};
+
+struct cfs_service_interface {
+  unsigned char version;
+  int  (* open)(const char *name, int flags);
+  void (* close)(int fd);
+  int  (* read)(int fd, char *buf, unsigned int len);
+  int  (* write)(int fd, char *buf, unsigned int len);
+
+  int  (* opendir)(struct cfs_dir *dir, const char *name);
+  int  (* readdir)(struct cfs_dir *dir, struct cfs_dirent *dirent);
+  int  (* closedir)(struct cfs_dir *dir);
+};
+
+#endif /* __CFS_SERVICE_H__ */
diff --git a/contiki/lib/cfs.c b/contiki/lib/cfs.c
new file mode 100644
index 0000000..eb5353d
--- /dev/null
+++ b/contiki/lib/cfs.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.c,v 1.3 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+
+static int  null_open(const char *n, int f)                       {return -1;}
+static void null_close(int f)                                     {return;}
+static int  null_read(int f, char *b, unsigned int l)             {return -1;}
+static int  null_write(int f, char *b, unsigned int l)            {return -1;}
+static int  null_opendir(struct cfs_dir *p, const char *n)        {return -1;}
+static int  null_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;}
+static int  null_closedir(struct cfs_dir *p)                      {return -1;}
+
+static const struct cfs_service_interface nullinterface =
+  {
+    CFS_SERVICE_VERSION,
+    null_open,
+    null_close,
+    null_read,
+    null_write,
+    null_opendir,
+    null_readdir,
+    null_closedir
+  };
+
+EK_SERVICE(service, CFS_SERVICE_NAME);
+
+/*---------------------------------------------------------------------------*/
+struct cfs_service_interface *
+cfs_find_service(void)
+{
+  struct cfs_service_interface *interface;
+  interface = (struct cfs_service_interface *)ek_service_state(&service);
+  if(interface != NULL &&
+     interface->version == CFS_SERVICE_VERSION) {
+    return interface;
+  } else {
+    return (struct cfs_service_interface *)&nullinterface;
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/lib/cfs.h b/contiki/lib/cfs.h
new file mode 100644
index 0000000..328d127
--- /dev/null
+++ b/contiki/lib/cfs.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.h,v 1.3 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __CFS_H__
+#define __CFS_H__
+
+#include "cfs-service.h"
+
+#define CFS_READ  0
+#define CFS_WRITE 1
+int cfs_open(const char *name, int flags);
+void cfs_close(int fd);
+int cfs_read(int fd, char *buf, unsigned int len);
+int cfs_write(int fd, char *buf, unsigned int len);
+
+int cfs_opendir(struct cfs_dir *dirp, const char *name);
+int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *dirent);
+int cfs_closedir(struct cfs_dir *dirp);
+
+struct cfs_service_interface *cfs_find_service(void);
+
+#define cfs_open(name, flags)   (cfs_find_service()->open(name, flags))
+#define cfs_close(fd)           (cfs_find_service()->close(fd))
+#define cfs_read(fd, buf, len)  (cfs_find_service()->read(fd, buf, len))
+#define cfs_write(fd, buf, len) (cfs_find_service()->write(fd, buf, len))
+
+#define cfs_opendir(dirp, name) (cfs_find_service()->opendir(dirp, name))
+#define cfs_readdir(dirp, ent)  (cfs_find_service()->readdir(dirp, ent))
+#define cfs_closedir(dirp)      (cfs_find_service()->closedir(dirp))
+
+
+#endif /* __CFS_H__ */
diff --git a/contiki/lib/clock.h b/contiki/lib/clock.h
new file mode 100644
index 0000000..594c2e9
--- /dev/null
+++ b/contiki/lib/clock.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock.h,v 1.2 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __CLOCK_H__
+#define __CLOCK_H__
+
+#include "clock-conf.h"
+
+void clock_init(void);
+
+clock_time_t clock_time(void);
+
+#ifdef CLOCK_CONF_SECOND
+#define CLOCK_SECOND CLOCK_CONF_SECOND
+#else
+#define CLOCK_SECOND (clock_time_t)32
+#endif
+
+#endif /* __CLOCK_H__ */
diff --git a/contiki/lib/ctk-filedialog.c b/contiki/lib/ctk-filedialog.c
new file mode 100644
index 0000000..41e887f
--- /dev/null
+++ b/contiki/lib/ctk-filedialog.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-filedialog.c,v 1.5 2005/05/08 10:40:10 oliverschmidt Exp $
+ */
+
+#include "contiki.h"
+#include "ctk-filedialog.h"
+#include "ctk.h"
+#include "cfs.h"
+
+#include <string.h>
+
+#define MAX_NUMFILES 40
+#define FILES_WIDTH 17
+#define FILES_HEIGHT 14
+
+static struct ctk_window dialog;
+static char leftptr[FILES_HEIGHT];
+static struct ctk_label leftptrlabel =
+  {CTK_LABEL(0, 1, 1, FILES_HEIGHT, leftptr)};
+
+static char files[FILES_WIDTH * MAX_NUMFILES];
+static struct ctk_label fileslabel =
+  {CTK_LABEL(1, 1,
+	     FILES_WIDTH, FILES_HEIGHT, files)};
+
+static char rightptr[FILES_HEIGHT];
+static struct ctk_label rightptrlabel =
+  {CTK_LABEL(1 + FILES_WIDTH, 1, 1, FILES_HEIGHT, rightptr)};
+
+static char filename[FILES_WIDTH + 1];
+static struct ctk_textentry filenameentry =
+  {CTK_TEXTENTRY(1, 2 + FILES_HEIGHT, FILES_WIDTH, 1, filename,
+		 FILES_WIDTH)};
+
+static struct ctk_button button;
+
+#define STATE_CLOSED 0
+#define STATE_OPEN 1
+static char state = STATE_CLOSED;
+static unsigned char fileptr, dirfileptr;
+static struct cfs_dir dir;
+/*---------------------------------------------------------------------------*/
+static void
+clearptr(void)
+{
+  leftptr[fileptr] = ' ';
+  rightptr[fileptr] = ' '; 
+}
+/*---------------------------------------------------------------------------*/
+static void
+showptr(void)
+{
+  leftptr[fileptr] = '>';
+  rightptr[fileptr] = '<';
+
+  strncpy(filename,
+	  &files[fileptr * FILES_WIDTH],
+	  FILES_WIDTH);
+  
+  CTK_WIDGET_REDRAW(&filenameentry);
+  CTK_WIDGET_REDRAW(&leftptrlabel);
+  CTK_WIDGET_REDRAW(&rightptrlabel);
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_filedialog_init(register struct ctk_filedialog_state *s)
+{
+  state = STATE_CLOSED;
+}
+/*---------------------------------------------------------------------------*/
+void
+ctk_filedialog_open(register struct ctk_filedialog_state *s,
+		    const char *buttontext, ek_event_t event)
+{
+  ctk_dialog_new(&dialog, 20, 5 + FILES_HEIGHT);
+  CTK_WIDGET_ADD(&dialog, &leftptrlabel);
+  CTK_WIDGET_ADD(&dialog, &fileslabel);
+  CTK_WIDGET_ADD(&dialog, &rightptrlabel);
+  CTK_WIDGET_ADD(&dialog, &filenameentry);
+  CTK_BUTTON_NEW(&button, 1, 4 + FILES_HEIGHT, strlen(buttontext), (char *)buttontext);
+  CTK_WIDGET_ADD(&dialog, &button);
+  ctk_dialog_open(&dialog);
+  state = STATE_OPEN;
+  memset(filename, 0, sizeof(filename));
+  memset(leftptr, ' ', sizeof(leftptr));
+  memset(rightptr, ' ', sizeof(rightptr));
+  memset(files, 0, sizeof(files));
+  
+  fileptr = 0;
+  dirfileptr = 0;
+  showptr();
+  cfs_opendir(&dir, ".");
+  ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, s);
+}
+/*---------------------------------------------------------------------------*/
+char
+ctk_filedialog_eventhandler(struct ctk_filedialog_state *s,
+			    ek_event_t ev, ek_data_t data)
+{
+  static struct cfs_dirent dirent;
+  
+  if(state == STATE_OPEN) {
+    if(ev == ctk_signal_widget_activate &&
+       data == (ek_data_t)&button) {
+      ctk_dialog_close();
+      state = STATE_CLOSED;
+      ek_post(EK_PROC_ID(EK_CURRENT()), s->ev, &filename);
+      return 1;
+    } else if(ev == EK_EVENT_CONTINUE &&
+	      (ek_data_t)s == data) {
+      if(cfs_readdir(&dir, &dirent) == 0 &&
+	 dirfileptr < MAX_NUMFILES) {
+	strncpy(&files[dirfileptr * FILES_WIDTH],
+		dirent.name, FILES_WIDTH);
+	CTK_WIDGET_REDRAW(&fileslabel);
+	++dirfileptr;
+	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, s);
+      } else {
+	fileptr = 0;	
+	cfs_closedir(&dir);
+      }
+      return 1; 
+    } else if(ev == ctk_signal_keypress) {
+      if((ctk_arch_key_t)data == CH_CURS_UP) {
+	clearptr();
+	if(fileptr > 0) {
+	  --fileptr;
+	}
+	showptr();
+	return 1;
+      } else if((ctk_arch_key_t)data == CH_CURS_DOWN) {
+	clearptr();
+	if(fileptr < FILES_HEIGHT - 1) {
+	  ++fileptr;
+	}
+	showptr();
+	return 1;
+      }
+    }
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/lib/ctk-filedialog.h b/contiki/lib/ctk-filedialog.h
new file mode 100644
index 0000000..6b00116
--- /dev/null
+++ b/contiki/lib/ctk-filedialog.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-filedialog.h,v 1.2 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+#ifndef __CTK_FILEDIALOG_H__
+#define __CTK_FILEDIALOG_H__
+
+#include "contiki.h"
+
+struct ctk_filedialog_state {
+  unsigned char fileptr;
+  ek_event_t ev;
+};
+
+void ctk_filedialog_init(register struct ctk_filedialog_state *s);
+void ctk_filedialog_open(register struct ctk_filedialog_state *s,
+			 const char *buttontext, ek_event_t event);
+char ctk_filedialog_eventhandler(struct ctk_filedialog_state *s,
+				 ek_event_t ev, ek_data_t data);
+
+#endif /* __CTK_FILEDIALOG_H__ */
diff --git a/contiki/lib/ctk-textedit.c b/contiki/lib/ctk-textedit.c
new file mode 100644
index 0000000..3a345ab
--- /dev/null
+++ b/contiki/lib/ctk-textedit.c
@@ -0,0 +1,181 @@
+/**
+ * \file
+ * An experimental CTK text edit widget.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This module contains an experimental CTK widget which is
+ * implemented in the application process rather than in the CTK
+ * process. The widget is instantiated in a similar fashion as other
+ * CTK widgets, but is different from other widgets in that it
+ * requires a signal handler function to be called by the process
+ * signal handler function.
+ * 
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ctk-textedit.c,v 1.4 2004/09/01 18:26:55 adamdunkels Exp $
+ *
+ */
+
+
+#include "ctk-textedit.h"
+
+#include <string.h>
+
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_textedit_init(struct ctk_textedit *t)
+{
+  t->xpos = t->ypos = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Add a CTK textedit widget to a window.
+ *
+ * \param w A pointer to the window to which the entry is to be added.
+ * \param t A pointer to the CTK textentry structure.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_textedit_add(struct ctk_window *w,
+		 struct ctk_textedit *t)
+{
+  CTK_WIDGET_SET_FLAG(t, CTK_WIDGET_FLAG_MONOSPACE);
+  CTK_WIDGET_ADD(w, t);
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * The CTK textedit signal handler.
+ *
+ * This function must be called as part of the normal signal handler
+ * of the process that contains the CTK textentry structure.
+ *
+ * \param t A pointer to the CTK textentry structure.
+ * \param s The signal number.
+ * \param data The signal data.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_textedit_eventhandler(struct ctk_textedit *t,
+			  ek_event_t s,
+			  ek_data_t data)
+{
+  char *textptr, *textptr2;
+  unsigned char len;
+  
+  if(s == ctk_signal_keypress) {
+    CTK_WIDGET_FOCUS(t->label.window, &t->label);
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr &= 0x7f;
+    switch((ctk_arch_key_t)data) {
+    case CH_CURS_DOWN:
+      if(t->ypos < t->label.h - 1) {
+	++t->ypos;
+      }
+      break; 
+    case CH_CURS_UP:
+      if(t->ypos > 0) {
+	--t->ypos;
+      }
+      break; 
+    case CH_CURS_RIGHT:
+      len = strlen(&t->label.text[t->ypos * t->label.w]);
+      if(t->xpos < len) {
+	/*      if(t->xpos < t->label.w) {*/
+	++t->xpos;
+      } else {
+	t->xpos = len;
+      }
+      break; 
+    case CH_CURS_LEFT:
+      if(t->xpos > 0) {
+	--t->xpos;
+      } else {
+	if(t->ypos > 0) {
+	  --t->ypos;
+	  t->xpos = t->label.w - 1;
+	}       
+      }
+      break;
+    case CH_ENTER:
+      t->xpos = 0;
+      if(t->ypos < t->label.h - 1) {
+	++t->ypos;
+      }
+      break;
+    case CH_DEL:
+      len = t->label.w - t->xpos;
+      if(t->xpos > 0 && len > 0) {
+	strncpy(textptr - 1, textptr,
+		len);
+	*(textptr + len - 1) = 0;
+	--t->xpos;
+      }
+      break;      
+    default:
+      len = t->label.w - t->xpos;
+      if(len > 0) {
+	textptr2 = textptr + len - 1;
+	while(textptr2 + 1 > textptr) {
+	  *(textptr2 + 1) = *textptr2;
+	  --textptr2;
+	}
+	
+	*textptr = (char)data;
+	++t->xpos;
+	if(t->xpos == t->label.w) {
+	  t->xpos = 0;
+	  if(t->ypos < t->label.h - 1) {
+	    ++t->ypos;
+	  }
+	}
+      }
+      break;
+    }
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr |= 0x80;
+    CTK_WIDGET_REDRAW(&t->label);
+  } else if(s == ctk_signal_widget_activate &&
+	    data == (ek_data_t)t) {
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr &= 0x7f;
+    t->xpos = 0;
+    if(t->ypos < t->label.h - 1) {
+      ++t->ypos;
+    }
+    textptr = &(t->label.text[t->ypos * t->label.w + t->xpos]);
+    *textptr |= 0x80;
+    CTK_WIDGET_REDRAW(&t->label);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/ctk-textedit.h b/contiki/lib/ctk-textedit.h
new file mode 100644
index 0000000..3668946
--- /dev/null
+++ b/contiki/lib/ctk-textedit.h
@@ -0,0 +1,73 @@
+/**
+ * \file
+ * Header file for the experimental application level CTK textedit widget.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ctk-textedit.h,v 1.4 2004/09/01 18:27:18 adamdunkels Exp $
+ *
+ */
+#ifndef __CTK_TEXTEDIT_H__
+#define __CTK_TEXTEDIT_H__
+
+#include "ctk.h"
+
+/**
+ * Instantiating macro for the CTK textedit widget.
+ *
+ *
+ * \param tx The x position of the widget.
+ * \param ty The y position of the widget.
+ * \param tw The width of the widget.
+ * \param th The height of the widget.
+ * \param ttext The text buffer to be edited.
+ */
+#define CTK_TEXTEDIT(tx, ty, tw, th, ttext) \
+  {CTK_LABEL(tx, ty, tw, th, ttext)}, 0, 0
+struct ctk_textedit {
+  struct ctk_label label;
+  unsigned char xpos, ypos;
+};
+
+void ctk_textedit_init(struct ctk_textedit *t);
+
+void ctk_textedit_add(struct ctk_window *w,
+		      struct ctk_textedit *t);
+
+void ctk_textedit_eventhandler(struct ctk_textedit *t,
+			       ek_event_t s,
+			       ek_data_t data);          
+
+#endif /* __CTK_TEXTEDIT_H__ */
diff --git a/contiki/lib/ctk-textentry-checkbox.c b/contiki/lib/ctk-textentry-checkbox.c
new file mode 100644
index 0000000..f8a73e5
--- /dev/null
+++ b/contiki/lib/ctk-textentry-checkbox.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * $Id: ctk-textentry-checkbox.c,v 1.1 2005/05/06 00:04:47 oliverschmidt Exp $
+ *
+ */
+
+#include "ctk.h"
+
+#include "ctk-textentry-checkbox.h"
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_textentry_checkbox_input(ctk_arch_key_t c,
+			     struct ctk_textentry *t)
+{
+  switch(c) {
+  case 'X':
+  case 'x':
+    *t->text = 'x';
+    return 1;
+
+  case ' ':
+    *t->text = *t->text == 'x'? 0:'x';
+    return 1;
+
+  case CH_DEL:
+  case CH_ENTER:
+  case CTK_CONF_WIDGETDOWN_KEY:
+  case CTK_CONF_WIDGETUP_KEY:
+    return 0;
+  }
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/ctk-textentry-checkbox.h b/contiki/lib/ctk-textentry-checkbox.h
new file mode 100644
index 0000000..473ec80
--- /dev/null
+++ b/contiki/lib/ctk-textentry-checkbox.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ctk-textentry-checkbox.h,v 1.1 2005/05/06 00:04:47 oliverschmidt Exp $
+ *
+ */
+#ifndef __CTK_TEXTENTRY_CHECKBOX_H__
+#define __CTK_TEXTENTRY_CHECKBOX_H__
+
+unsigned char ctk_textentry_checkbox_input(ctk_arch_key_t c,
+					   struct ctk_textentry *t);
+
+#endif /* __CTK_TEXTENTRY_CHECKBOX_H__ */
diff --git a/contiki/lib/ctk-textentry-cmdline.c b/contiki/lib/ctk-textentry-cmdline.c
new file mode 100644
index 0000000..01ed3b7
--- /dev/null
+++ b/contiki/lib/ctk-textentry-cmdline.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * $Id: ctk-textentry-cmdline.c,v 1.1 2005/05/05 23:29:50 oliverschmidt Exp $
+ *
+ */
+
+#include "ctk.h"
+
+#include "ctk-textentry-cmdline.h"
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_textentry_cmdline_input(ctk_arch_key_t c,
+			    struct ctk_textentry *t)
+{
+  if(c == CH_ENTER) {
+    ek_post(t->window->owner, ctk_signal_widget_activate, t);
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/ctk-textentry-cmdline.h b/contiki/lib/ctk-textentry-cmdline.h
new file mode 100644
index 0000000..38e7ad7
--- /dev/null
+++ b/contiki/lib/ctk-textentry-cmdline.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ctk-textentry-cmdline.h,v 1.1 2005/05/05 23:29:50 oliverschmidt Exp $
+ *
+ */
+#ifndef __CTK_TEXTENTRY_CMDLINE_H__
+#define __CTK_TEXTENTRY_CMDLINE_H__
+
+unsigned char ctk_textentry_cmdline_input(ctk_arch_key_t c,
+					  struct ctk_textentry *t);
+
+#endif /* __CTK_TEXTENTRY_CMDLINE_H__ */
diff --git a/contiki/lib/ctk-textentry-multiline.c b/contiki/lib/ctk-textentry-multiline.c
new file mode 100644
index 0000000..26ae0de
--- /dev/null
+++ b/contiki/lib/ctk-textentry-multiline.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * $Id: ctk-textentry-multiline.c,v 1.3 2005/05/05 20:55:50 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ctk.h"
+
+#include "ctk-textentry-multiline.h"
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_textentry_multiline_input(ctk_arch_key_t c,
+			      struct ctk_textentry *t)
+{
+  unsigned char len;
+
+  switch(c) {
+  case 0:
+    t->xpos = strlen(&t->text[t->ypos * (t->len + 1)]);
+    if(t->xpos == t->len) {
+      --t->xpos;
+    }
+    return 1;
+
+  case CH_CURS_UP:
+    if(t->ypos == 0) {
+      t->xpos = 0;
+      return 1;
+    }
+    --t->ypos;
+    break;
+
+  case CH_CURS_DOWN:
+    if(t->ypos == t->h - 1) {
+      t->xpos = strlen(&t->text[t->ypos * (t->len + 1)]);
+      if(t->xpos == t->len) {
+	--t->xpos;
+      }
+      return 1;
+    }
+    ++t->ypos;
+    break;
+
+  case CH_ENTER:
+    if(t->ypos == t->h - 1) {
+      return 0;
+    }
+    ++t->ypos;
+    t->xpos = 0;
+    return 1;
+
+  default:
+    return 0;
+  }
+
+  len = strlen(&t->text[t->ypos * (t->len + 1)]);
+  if(t->xpos > len) {
+    t->xpos = len;
+  }
+  return 1;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/ctk-textentry-multiline.h b/contiki/lib/ctk-textentry-multiline.h
new file mode 100644
index 0000000..68dc0bf
--- /dev/null
+++ b/contiki/lib/ctk-textentry-multiline.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ctk-textentry-multiline.h,v 1.1 2005/05/04 21:57:08 oliverschmidt Exp $
+ *
+ */
+#ifndef __CTK_TEXTENTRY_MULTILINE_H__
+#define __CTK_TEXTENTRY_MULTILINE_H__
+
+unsigned char ctk_textentry_multiline_input(ctk_arch_key_t c,
+					    struct ctk_textentry *t);
+
+#endif /* __CTK_TEXTENTRY_MULTILINE_H__ */
diff --git a/contiki/lib/libconio.c b/contiki/lib/libconio.c
new file mode 100644
index 0000000..07b8113
--- /dev/null
+++ b/contiki/lib/libconio.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: libconio.c,v 1.6 2004/09/12 20:24:55 adamdunkels Exp $
+ *
+ */
+
+#include <string.h>
+#include "libconio.h"
+
+static unsigned char cursx, cursy;
+static unsigned char reversed;
+static unsigned char color;
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+  return cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+  return cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+clrscr(void)
+{
+  unsigned char x, y;
+
+  for(x = 0; x < LIBCONIO_SCREEN_WIDTH; ++x) {
+    for(y = 0; y < LIBCONIO_SCREEN_HEIGHT; ++y) {
+      gotoxy(x, y);
+      cputc(' ');
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+revers(unsigned char c)
+{
+  reversed = c;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputc(char c)
+{
+  ctk_arch_draw_char(c, cursx, cursy, reversed, color);
+  ++cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputs(char *str)
+{
+  while(*str != 0) {
+    cputc(*str++);
+  }
+  
+  /*  int i;
+  for(i = 0; i < strlen(str); ++i) {
+    cputc(str[i]);
+    }*/
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cclear(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc(' ');
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+chline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('-');
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cvline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    cputc('|');
+    --cursx;
+    ++cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+gotoxy(unsigned char x, unsigned char y)
+{
+  cursx = x;
+  cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  gotoxy(x, y);
+  cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputsxy(unsigned char x, unsigned char y, char *str)
+{
+  gotoxy(x, y);
+  cputs(str);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputcxy(unsigned char x, unsigned char y, char c)
+{
+  gotoxy(x, y);
+  cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+textcolor(unsigned char c)
+{
+  color = c;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+bgcolor(unsigned char c)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+bordercolor(unsigned char c)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+screensize(unsigned char *x, unsigned char *y)
+{
+  *x = LIBCONIO_SCREEN_WIDTH;
+  *y = LIBCONIO_SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/libconio.h b/contiki/lib/libconio.h
new file mode 100644
index 0000000..cf9d4e3
--- /dev/null
+++ b/contiki/lib/libconio.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: libconio.h,v 1.5 2004/06/06 06:09:14 adamdunkels Exp $
+ *
+ */
+
+#ifndef __LIBCONIO_H__
+#define __LIBCONIO_H__
+
+#include "libconio-conf.h"
+
+/* This function must be implemented specifically for the
+   architecure: */
+void ctk_arch_draw_char(char c,
+			unsigned char xpos,
+			unsigned char ypos,
+			unsigned char reversedflag,
+			unsigned char color);
+
+/* Default definitions that should be overridden by calling module. */
+#ifndef LIBCONIO_CONF_SCREEN_WIDTH
+#define LIBCONIO_SCREEN_WIDTH 40
+#else
+#define LIBCONIO_SCREEN_WIDTH LIBCONIO_CONF_SCREEN_WIDTH
+#endif /* LIBCONIO_SCREEN_WIDTH */
+
+#ifndef LIBCONIO_CONF_SCREEN_HEIGHT
+#define LIBCONIO_SCREEN_HEIGHT 25
+#else
+#define LIBCONIO_SCREEN_HEIGHT LIBCONIO_CONF_SCREEN_HEIGHT
+#endif /* LIBCONIO_CONF_SCREEN_HEIGHT */
+
+
+
+/* These are function declarations for functions implemented in libconio.c */
+unsigned char wherex(void);
+unsigned char wherey(void);
+void clrscr(void);
+void bgcolor(unsigned char c);
+void bordercolor(unsigned char c);
+void screensize(unsigned char *x, unsigned char *y);
+void revers(unsigned char c);
+void cputc(char c);
+void cputs(char *str);
+void cclear(unsigned char length);
+void chline(unsigned char length);
+void cvline(unsigned char length);
+void gotoxy(unsigned char x, unsigned char y);
+void cclearxy(unsigned char x, unsigned char y, unsigned char length);
+void chlinexy(unsigned char x, unsigned char y, unsigned char length);
+void cvlinexy(unsigned char x, unsigned char y, unsigned char length);
+void cputsxy(unsigned char x, unsigned char y, char *str);
+void cputcxy(unsigned char x, unsigned char y, char c);
+void textcolor(unsigned char c);
+
+
+
+#endif /* __LIBCONIO_H__ */
diff --git a/contiki/lib/list.c b/contiki/lib/list.c
new file mode 100644
index 0000000..4d8b505
--- /dev/null
+++ b/contiki/lib/list.c
@@ -0,0 +1,323 @@
+/**
+ * \defgroup list Linked list library
+ * @{
+ *
+ * The linked list library provides a set of functions for
+ * manipulating linked lists.
+ *
+ * A linked list is made up of elements where the first element \b
+ * must be a pointer. This pointer is used by the linked list library
+ * to form lists of the elements.
+ *
+ * Lists are declared with the LIST() macro. The declaration specifies
+ * the name of the list that later is used with all list functions.
+ *
+ * Example:
+ \code
+
+struct packet {
+   struct packet *next;
+   char data[1500];
+   int len;
+};
+
+LIST(packets);
+
+static void
+init_function(void) {
+   list_init(packets);
+}
+
+static void
+another_function(struct packet *p) {
+   list_add(packets, p);
+
+   p = list_head(packets);
+
+   p = list_tail(packets);
+}
+ \endcode 
+ *
+ * Lists can be manipulated by inserting or removing elements from
+ * either sides of the list (list_push(), list_add(), list_pop(),
+ * list_chop()). A specified element can also be removed from inside a
+ * list with list_remove(). The head and tail of a list can be
+ * extracted using list_head() and list_tail(), respecitively.
+ */
+
+/**
+ * \file
+ * Linked list library implementation.
+ *
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: list.c,v 1.4 2005/02/07 07:52:31 adamdunkels Exp $
+ */
+#include "list.h"
+
+#define NULL 0
+
+struct list {
+  struct list *next;
+};
+
+/*---------------------------------------------------------------------------*/
+/**
+ * Initialize a list.
+ *
+ * This function initalizes a list. The list will be empty after this
+ * function has been called.
+ *
+ * \param list The list to be initialized.
+ */
+void
+list_init(list_t list)
+{
+  *list = NULL;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Get a pointer to the first element of a list.
+ *
+ * This function returns a pointer to the first element of the
+ * list. The element will \b not be removed from the list.
+ *
+ * \param list The list.
+ * \return A pointer to the first element on the list.
+ *
+ * \sa list_tail()
+ */
+void *
+list_head(list_t list)
+{
+  return *list;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Duplicate a list.
+ *
+ * This function duplicates a list by copying the list reference, but
+ * not the elements.
+ *
+ * \note This function does \b not copy the elements of the list, but
+ * merely duplicates the pointer to the first element of the list.
+ *
+ * \param dest The destination list.
+ * \param src The source list.
+ */
+void
+list_copy(list_t dest, list_t src)
+{
+  *dest = *src;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Get the tail of a list.
+ *
+ * This function returns a pointer to the elements following the first
+ * element of a list. No elements are removed by this function.
+ *
+ * \param list The list
+ * \return A pointer to the element after the first element on the list.
+ *
+ * \sa list_head()
+ */
+void *
+list_tail(list_t list)
+{
+  struct list *l;
+  
+  if(*list == NULL) {
+    return NULL;
+  }
+  
+  for(l = *list; l->next != NULL; l = l->next);
+  
+  return l;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Add an item at the end of a list.
+ *
+ * This function adds an item to the end of the list.
+ *
+ * \param list The list.
+ * \param item A pointer to the item to be added.
+ *
+ * \sa list_push()
+ *
+ */
+void
+list_add(list_t list, void *item)
+{
+  struct list *l;
+
+  ((struct list *)item)->next = NULL;
+  
+  l = list_tail(list);
+
+  if(l == NULL) {
+    *list = item;
+  } else {
+    l->next = item;
+  }
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Add an item to the start of the list.
+ */
+void
+list_push(list_t list, void *item)
+{
+  /*  struct list *l;*/
+
+  ((struct list *)item)->next = *list;
+  *list = item;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Remove the last object on the list.
+ *
+ * This function removes the last object on the list and returns it.
+ * 
+ * \param list The list
+ * \return The removed object
+ *
+ */
+void *
+list_chop(list_t list)
+{
+  struct list *l, *r;
+  
+  if(*list == NULL) {
+    return NULL;
+  }
+  if(((struct list *)*list)->next == NULL) {
+    l = *list;
+    *list = NULL;
+    return l;
+  }
+  
+  for(l = *list; l->next->next != NULL; l = l->next);
+
+  r = l->next;
+  l->next = NULL;
+  
+  return r;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Remove the first object on a list.
+ *
+ * This function removes the first object on the list and returns it.
+ *
+ * \param list The list.
+ * \return The new head of the list.
+ */
+/*---------------------------------------------------------------------------*/
+void *
+list_pop(list_t list)
+{
+  struct list *l;
+  
+  if(*list != NULL) {   
+    *list = ((struct list *)*list)->next;
+  }
+
+  return *list;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Remove a specific element from a list.
+ *
+ * This function removes a specified element from the list.
+ *
+ * \param list The list.
+ * \param item The item that is to be removed from the list.
+ *
+ */
+/*---------------------------------------------------------------------------*/
+void
+list_remove(list_t list, void *item)
+{
+  struct list *l, *r;
+  
+  if(*list == NULL) {
+    return;
+  }
+  
+  r = NULL;
+  for(l = *list; l != NULL; l = l->next) {
+    if(l == item) {
+      if(r == NULL) {
+	/* First on list */
+	*list = l->next;
+      } else {
+	/* Not first on list */
+	r->next = l->next;
+      }
+      l->next = NULL;
+      return;
+    }
+    r = l;
+  }
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Get the length of a list.
+ *
+ * This function counts the number of elements on a specified list.
+ *
+ * \param list The list.
+ * \return The length of the list.
+ */
+/*---------------------------------------------------------------------------*/
+int
+list_length(list_t list)
+{
+  struct list *l; 
+  int n = 0;
+
+  for(l = *list; l != NULL; l = l->next) {
+    ++n;
+  }
+
+  return n;
+}
+/*---------------------------------------------------------------------------*/
+
+/** @} */
diff --git a/contiki/lib/list.h b/contiki/lib/list.h
new file mode 100644
index 0000000..abf8c7d
--- /dev/null
+++ b/contiki/lib/list.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: list.h,v 1.3 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+/**
+ * \file
+ * Linked list manipulation routines.
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ *
+\code
+
+struct packet {
+   struct packet *next;
+   char data[1500];
+   int len;
+};
+
+LIST(packets, struct packet *);
+
+static void
+init_function(void) {
+   list_init(&packets);
+}
+
+static void
+another_function(struct packet *p) {
+   list_add(packets, p);
+
+   p = list_head(packets);
+
+   p = list_tail(packets);
+}
+
+\endcode 
+ */
+
+#ifndef __LIST_H__
+#define __LIST_H__
+
+/**
+ */
+#define LIST(name, type) \
+         static type name##_list; \
+         static void **name = (void **)&name##_list; 
+         
+
+void  list_init(void **list);
+void *list_head(void **list);
+void *list_tail(void **list);
+void *list_pop (void **list);
+void  list_push(void **list, void *item);
+
+void *list_chop(void **list);
+
+void  list_add(void **list, void *item);
+
+
+void  list_copy(void **dest, void **src);
+
+#endif /* __LIST_H__ */
+
+
+
+
diff --git a/contiki/lib/memb.c b/contiki/lib/memb.c
new file mode 100644
index 0000000..d4e8d09
--- /dev/null
+++ b/contiki/lib/memb.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: memb.c,v 1.5 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+/**
+ * \defgroup memb Memory block management functions
+ *
+ * The memory block allocation routines provide a simple yet powerful
+ * set of functions for managing a set of memory blocks of fixed
+ * size. A set of memory blocks is statically declared with the
+ * MEMB() macro. Memory blocks are allocated from the declared
+ * memory by the memb_alloc() function, and are deallocated with the
+ * memb_free() function.
+ *
+ * \note Because of namespace clashes only one MEMB() can be
+ * declared per C module, and the name scope of a MEMB() memory
+ * block is local to each C module.
+ *
+ * The following example shows how to declare and use a memory block
+ * called "cmem" which has 8 chunks of memory with each memory chunk
+ * being 20 bytes large.
+ *
+ \code
+ #include "memb.h"
+ 
+ MEMB(cmem, 20, 8);
+
+ int main(int argc, char *argv[]) {
+    char *ptr;
+    
+    memb_init(&cmem);
+
+    ptr = memb_alloc(&cmem);
+
+    if(ptr != NULL) {
+       do_something(ptr);
+    } else {
+       printf("Could not allocate memory.\n");
+    }
+
+    if(memb_free(&cmem, ptr) == 0) {
+       printf("Deallocation succeeded.\n");
+    }
+ }
+ \endcode
+ *
+ * @{
+ */
+
+ /**
+ * \file
+ * Memory block allocation routines.
+ * \author Adam Dunkels <adam@sics.se>
+ */
+#include <string.h>
+
+#include "memb.h"
+
+/*------------------------------------------------------------------------------*/
+/**
+ * Initialize a memory block that was declared with MEMB().
+ *
+ * \param m A memory block previosly declared with MEMB().
+ */
+/*------------------------------------------------------------------------------*/
+void
+memb_init(struct memb_blocks *m)
+{
+  memset(m->mem, 0, (m->size + 1) * m->num);
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Allocate a memory block from a block of memory declared with MEMB().
+ *
+ * \param m A memory block previosly declared with MEMB().
+ */
+/*------------------------------------------------------------------------------*/
+char *
+memb_alloc(struct memb_blocks *m)
+{
+  int i;
+  char *ptr;
+
+  ptr = m->mem;
+  for(i = 0; i < m->num; ++i) {
+    if(*ptr == 0) {
+      /* If this block was unused, we increase the reference count to
+	 indicate that it now is used and return a pointer to the
+	 first byte following the reference counter. */
+      ++*ptr;
+      return ptr + 1;
+    }
+    ptr += m->size + 1;
+  }
+
+  /* No free block was found, so we return NULL to indicate failure to
+     allocate block. */
+  return NULL;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Deallocate a memory block from a memory block previously declared
+ * with MEMB().
+ *
+ * \param m m A memory block previosly declared with MEMB().
+ *
+ * \param ptr A pointer to the memory block that is to be deallocated.
+ *
+ * \return The new reference count for the memory block (should be 0
+ * if successfully deallocated) or -1 if the pointer "ptr" did not
+ * point to a legal memory block.
+ */
+/*------------------------------------------------------------------------------*/
+char
+memb_free(struct memb_blocks *m, void *ptr)
+{
+  int i;
+  char *ptr2;
+
+  /* Walk through the list of blocks and try to find the block to
+     which the pointer "ptr" points to. */
+  ptr2 = m->mem;
+  for(i = 0; i < m->num; ++i) {
+    
+    if(ptr2 == (char *)ptr - 1) {
+      /* We've found to block to which "ptr" points so we decrease the
+	 reference count and return the new value of it. */      
+      return --*ptr2;
+    }
+    ptr2 += m->size + 1;
+  }
+  return -1;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Increase the reference count for a memory chunk.
+ *
+ * \note No sanity checks are currently made.
+ *
+ * \param m m A memory block previosly declared with MEMB().
+ *
+ * \param ptr A pointer to the memory chunk for which the reference
+ * count should be increased.
+ *
+ * \return The new reference count.
+ */
+/*------------------------------------------------------------------------------*/
+char
+memb_ref(struct memb_blocks *m, char *ptr)
+{
+  return ++*(ptr - 1);
+}
+/*------------------------------------------------------------------------------*/
+
+/** @} */
diff --git a/contiki/lib/memb.h b/contiki/lib/memb.h
new file mode 100644
index 0000000..1be35d4
--- /dev/null
+++ b/contiki/lib/memb.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: memb.h,v 1.6 2004/09/12 20:24:55 adamdunkels Exp $
+ */
+/**
+ * \addtogroup memb 
+ * @{
+ */
+
+/**
+ * \file
+ * Memory block allocation routines.
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __MEMB_H__
+#define __MEMB_H__
+
+/**
+ * Declare a memory block.
+ *
+ * This macro is used to staticall declare a block of memory that can
+ * be used by the block allocation functions. The macro statically
+ * declares a C array with a size that matches the specified number of
+ * blocks and their individual sizes.
+ *
+ * Example:
+ \code
+MEMB(connections, sizeof(struct connection), 16);
+ \endcode
+ *
+ * \param name The name of the memory block (later used with
+ * memb_init(), memb_alloc() and memb_free()).
+ *
+ * \param size The size of each memory chunk, in bytes.
+ *
+ * \param num The total number of memory chunks in the block.
+ *
+ */
+#if CC_DOUBLE_HASH
+#define MEMB(name, size, num) \
+        static char name##_memb_mem[(size + 1) * num]; \
+        static struct memb_blocks name = {size, num, name##_memb_mem}
+#else /* CC_DOUBLE_HASH */
+#define MEMB(name, size, num) \
+        static char name_memb_mem[(size + 1) * num]; \
+        static struct memb_blocks name = {size, num, name_memb_mem}
+#endif /* CC_DOUBLE_HASH */
+
+struct memb_blocks {
+  unsigned short size;
+  unsigned short num;
+  char *mem;
+};
+
+void  memb_init(struct memb_blocks *m);
+char *memb_alloc(struct memb_blocks *m);
+char  memb_ref(struct memb_blocks *m, char *ptr);
+char  memb_free(struct memb_blocks *m, void *ptr);
+
+/** @} */
+
+#endif /* __MEMB_H__ */
diff --git a/contiki/lib/petsciiconv.c b/contiki/lib/petsciiconv.c
new file mode 100644
index 0000000..7a46269
--- /dev/null
+++ b/contiki/lib/petsciiconv.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: petsciiconv.c,v 1.3 2003/09/02 21:47:28 adamdunkels Exp $
+ *
+ */
+
+/*
+static unsigned char petscii2ascii[128] = {
+  0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
+  0x14,0x09,0x0d,0x11,0x93,0x0a,0x0e,0x0f,
+  0x10,0x0b,0x12,0x13,0x08,0x15,0x16,0x17,
+  0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+  0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
+  0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+  0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
+  0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+  0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,
+  0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+  0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,
+  0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x7e,0x5f,
+  0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,
+  0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
+  0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
+  0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0x7e,0xdf
+};
+*/
+
+static unsigned char ascii2petscii[128] = {
+  0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
+  0x14,0x09,0x0d,0x11,0x93,0x0a,0x0e,0x0f,
+  0x10,0x0b,0x12,0x13,0x08,0x15,0x16,0x17,
+  0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
+  0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
+  0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
+  0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
+  0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
+  0x40,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,
+  0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
+  0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
+  0xd8,0xd9,0xda,0x5b,0x5c,0x5d,0x5e,0x5f,
+  0xc0,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
+  0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
+  0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,
+  0x58,0x59,0x5a,0xdb,0xdd,0xdd,0x5e,0xdf,
+};
+
+static unsigned int i;
+static unsigned char *ptr;
+
+/*-----------------------------------------------------------------------------------*/
+void
+petsciiconv_toascii(char *buf, unsigned int len)
+{
+  static char c;
+  
+  ptr = buf;
+  for(i = len; i > 0; --i) {
+    c = *ptr;
+    if(c == 0x0a) {
+      c = 0x0d;
+    } else if(c == 0x0d) {
+      c = 0x0a;
+    } 
+    switch (c & 0xe0) {
+    case 0x40:                
+    case 0x60:
+      c ^= 0x20;
+      break;
+    case 0xc0:               
+      c ^= 0x80;
+      break;
+    }
+    *ptr = c & 0x7f;
+    ++ptr;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+petsciiconv_topetscii(char *buf, unsigned int len)
+{
+  ptr = buf;
+  for(i = len; i > 0; --i) {
+    *ptr = ascii2petscii[*ptr & 0x7f];
+    ++ptr;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/petsciiconv.h b/contiki/lib/petsciiconv.h
new file mode 100644
index 0000000..13eb053
--- /dev/null
+++ b/contiki/lib/petsciiconv.h
@@ -0,0 +1,77 @@
+/**
+ * \file
+ * PETSCII/ASCII conversion functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The Commodore based Contiki targets all have a special character
+ * encoding called PETSCII which differs from the ASCII encoding that
+ * normally is used for representing characters.
+ *
+ * \note For targets that do not use PETSCII encoding the C compiler
+ * define WITH_ASCII should be used to avoid the PETSCII converting
+ * functions.
+ *
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: petsciiconv.h,v 1.2 2003/09/02 21:47:28 adamdunkels Exp $
+ *
+ */
+#ifndef __PETSCIICONV_H__
+#define __PETSCIICONV_H__
+
+#ifdef WITH_ASCII
+
+#define petsciiconv_toascii(buf, len)
+#define petsciiconv_topetscii(buf, len)
+
+#else /* WITH_ASCII */
+
+/**
+ * Convert a text buffer from PETSCII to ASCII.
+ *
+ * \param buf A pointer to the buffer which is to be converted.
+ * \param len The length of the buffer to be converted.
+ */
+void petsciiconv_toascii(char *buf, unsigned int len);
+/**
+ * Convert a text buffer from ASCII to PETSCII.
+ *
+ * \param buf A pointer to the buffer which is to be converted.
+ * \param len The length of the buffer to be converted.
+ */
+void petsciiconv_topetscii(char *buf, unsigned int len);
+
+#endif /* WITH_ASCII */
+
+#endif /* __PETSCIICONV_H__ */
diff --git a/contiki/lib/strncasecmp.c b/contiki/lib/strncasecmp.c
new file mode 100644
index 0000000..ee64718
--- /dev/null
+++ b/contiki/lib/strncasecmp.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: strncasecmp.c,v 1.3 2004/06/06 06:09:14 adamdunkels Exp $
+ *
+ */
+
+/* This file contains a naive and non-stanrdards compliant
+   implementation of strncasecmp() for systems that don't implement
+   the function. It works with Contiki, but should most probably not
+   be used anywhere else.
+
+   It copies the n first bytes two strings into two buffers and
+   compares them with strcasecmp.
+*/
+
+#define MAX_STRLEN 40
+
+
+int strncmp(const char *s1, const char *s2, int len);
+
+/*static char buf1[MAX_STRLEN],
+  buf2[MAX_STRLEN];*/
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+strncasecmp(const char *s1, const char *s2, unsigned char n)
+{
+  unsigned char len;
+
+  return strncmp(s1, s2, n);
+  
+  /*  len = MAX_STRLEN;
+  if(n < MAX_STRLEN) {
+    len = n;
+  }
+  strncpy(buf1, s1, len);
+  buf1[MAX_STRLEN - 1] = 0;
+  strncpy(buf2, s2, len);
+  buf2[MAX_STRLEN - 1] = 0;
+  return strcasecmp(buf1, buf2);*/
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/lib/timer.c b/contiki/lib/timer.c
new file mode 100644
index 0000000..dbbe286
--- /dev/null
+++ b/contiki/lib/timer.c
@@ -0,0 +1,160 @@
+/**
+ * \defgroup timer Timer library
+ * @{
+ *
+ * The Contiki kernel does not provide support for timed
+ * events. Rather, an application that wants to use timers needs to
+ * explicitly use the timer library.
+ *
+ * The timer library provides functions for setting, resetting and
+ * restarting timers, and for checking if a timer has expired. An
+ * application must "manually" check if its timers have expired; this
+ * is not done automatically.
+ *
+ * A timer is declared as a \c struct \c timer and all access to the
+ * timer is made by a pointer to the declared timer.
+ *
+ * Example:
+ \code
+
+ static struct timer periodic;
+
+ LOADER_INIT_FUNC(example_init, arg) {
+   timer_set(&periodic, CLOCK_SECOND);
+ }
+ 
+ EK_POLLHANDLER(pollhandler) {
+   if(timer_expired(&periodic)) {
+     timer_restart(&periodic);
+     do_periodic_stuff();
+   }
+ }
+ 
+ \endcode
+ *
+ * \note The timer library uses the \ref clock "Clock library" to
+ * measure time. Intervals should be specified in the format used by
+ * the clock library.
+ *
+ * \sa \ref clock "Clock library"
+ */
+
+/**
+ * \file
+ * Timer library implementation.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: timer.c,v 1.5 2005/02/07 22:45:14 adamdunkels Exp $
+ */
+#include "timer.h"
+
+/*---------------------------------------------------------------------------*/
+/**
+ * Set a timer.
+ *
+ * This function is used to set a timer for a time sometime in the
+ * future. The function timer_expired() will evaluate to true after
+ * the timer has expired.
+ *
+ * \param t A pointer to the timer
+ * \param interval The interval before the timer expires.
+ *
+ */
+void
+timer_set(struct timer *t, clock_time_t interval)
+{
+  t->interval = interval;
+  t->start = clock_time();
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Reset the timer with the same interval.
+ *
+ * This function resets the timer with the same interval that was
+ * given to the timer_set() function. The start point of the interval
+ * is the exact time that the timer last expired. Therefore, this
+ * function will cause the timer to be stable over time, unlike the
+ * timer_rester() function.
+ *
+ * \param t A pointer to the timer.
+ *
+ * \sa timer_restart()
+ */
+void
+timer_reset(struct timer *t)
+{
+  t->start += t->interval;
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Restart the timer from the current point in time
+ *
+ * This function restarts a timer with the same interval that was
+ * given to the timer_set() function. The timer will start at the
+ * current time.
+ *
+ * \note A periodic timer will drift if this function is used to reset
+ * it. For preioric timers, use the timer_reset() function instead.
+ *
+ * \param t A pointer to the timer.
+ *
+ * \sa timer_reset()
+ */
+void
+timer_restart(struct timer *t)
+{
+  t->start = clock_time();
+}
+/*---------------------------------------------------------------------------*/
+/**
+ * Check if a timer has expired.
+ *
+ * This function tests if a timer has expired and returns true or
+ * false depending on its status.
+ *
+ * \param t A pointer to the timer
+ *
+ * \return Non-zero if the timer has expired, zero otherwise.
+ *
+ */
+int
+timer_expired(struct timer *t)
+{
+  return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
+}
+/*---------------------------------------------------------------------------*/
+
diff --git a/contiki/lib/timer.h b/contiki/lib/timer.h
new file mode 100644
index 0000000..a817d53
--- /dev/null
+++ b/contiki/lib/timer.h
@@ -0,0 +1,70 @@
+/**
+ * \addtogroup timer
+ * @{
+ */
+
+/**
+ * \file
+ * Timer library header file.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: timer.h,v 1.4 2005/02/07 22:45:15 adamdunkels Exp $
+ */
+#ifndef __TIMER_H__
+#define __TIMER_H__
+
+#include "clock.h"
+
+/**
+ * A timer.
+ *
+ * This structure is used for declaring a timer. The timer must be set
+ * with timer_set() before it can be used.
+ *
+ * \hideinitializer
+ */
+struct timer {
+  clock_time_t start;
+  clock_time_t interval;
+};
+
+void timer_set(struct timer *t, clock_time_t interval);
+void timer_reset(struct timer *t);
+void timer_restart(struct timer *t);
+int timer_expired(struct timer *t);
+
+#endif /* __TIMER_H__ */
diff --git a/contiki/ppp/ahdlc.c b/contiki/ppp/ahdlc.c
new file mode 100644
index 0000000..a3485cd
--- /dev/null
+++ b/contiki/ppp/ahdlc.c
@@ -0,0 +1,371 @@
+/*																www.mycal.com			
+ *---------------------------------------------------------------------------
+ * ahdlc.c - Ahdlc receive and transmit processor for PPP engine.
+ *
+ *---------------------------------------------------------------------------
+ * Version  
+ *		0.1 Original Version Jan 11, 1998
+ *
+ *--------------------------------------------------------------------------- 
+ *  
+ * Copyright (C) 1998, Mycal Labs www.mycal.com	
+ *  
+ *---------------------------------------------------------------------------
+ */
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ahdlc.c,v 1.3 2005/01/26 23:36:22 oliverschmidt Exp $
+ *
+ */
+
+/*			*/ 
+/* include files 	*/
+/*			*/ 
+ 
+#include "uip.h"
+#include "ppp.h"
+
+#if 0
+#define DEBUG1(x)
+#else
+#include <stdio.h>
+#define DEBUG1(x) debug_printf x
+#endif
+
+#define	PACKET_TX_DEBUG	1
+
+/*---------------------------------------------------------------------------
+ * ahdlc flags bit defins, for ahdlc_flags variable
+ ---------------------------------------------------------------------------*/
+/* Escaped mode bit */
+#define AHDLC_ESCAPED		0x1
+/* Frame is ready bit */
+#define	AHDLC_RX_READY		0x2				
+#define	AHDLC_RX_ASYNC_MAP	0x4
+#define AHDLC_TX_ASYNC_MAP	0x8
+#define AHDLC_PFC		0x10
+#define AHDLC_ACFC		0x20
+
+/*---------------------------------------------------------------------------
+ * Private Local Globals
+ *	10 bytes	- standard
+ *			- with counters
+ ---------------------------------------------------------------------------*/
+/* running tx CRC */
+u16_t ahdlc_tx_crc;
+/* running rx CRC */
+u16_t ahdlc_rx_crc;
+/* number of rx bytes processed, cur frame */
+u16_t ahdlc_rx_count;
+/* ahdlc state flags, see above */
+u8_t ahdlc_flags;
+
+/*
+ * The following can be optimized out
+ */
+u8_t *ahdlc_rx_buffer;			/* What to do here? +++ */
+u16_t ahdlc_max_rx_buffer_size;
+
+/*
+ * Optional statistics counters.
+ */
+#ifdef AHDLC_COUNTERS
+u8_t ahdlc_rx_tobig_error;
+#endif
+
+/*---------------------------------------------------------------------------*/
+/* Simple and fast CRC16 routine for embedded processors.
+ *	Just slightly slower than the table lookup method but consumes
+ *	almost no space.  Much faster and smaller than the loop and
+ *	shift method that is widely used in the embedded space. 
+ *	Can be optimized even more in .ASM
+ *
+ *	data = (crcvalue ^ inputchar) & 0xff;
+ *	data = (data ^ (data << 4)) & 0xff;
+ *	crc = (crc >> 8) ^ ((data << 8) ^ (data <<3) ^ (data >> 4))
+ */
+/*---------------------------------------------------------------------------*/
+static u16_t
+crcadd(u16_t crcvalue, u8_t c)
+{
+  u16_t b;
+
+  b = (crcvalue ^ c) & 0xFF;
+  b = (b ^ (b << 4) & 0xFF);
+  b = (b << 8) ^ (b << 3) ^ (b >> 4);
+  
+  return ((crcvalue >> 8) ^ b);
+}
+/*---------------------------------------------------------------------------*/
+/* ahdlc_init(buffer, buffersize) - this initializes the ahdlc engine to
+ *	allow for rx frames.
+ */
+/*---------------------------------------------------------------------------*/
+void
+ahdlc_init(u8_t *buffer, u16_t maxrxbuffersize)
+{
+  ahdlc_flags = 0;
+  ahdlc_rx_buffer = buffer;
+  ahdlc_max_rx_buffer_size = maxrxbuffersize;
+  /* ahdlc_async_map = 0; */
+#ifdef AHDLC_COUNTERS
+  ahdlc_rx_tobig_error = 0;
+#endif
+}
+/*---------------------------------------------------------------------------*/
+/* ahdlc_rx_ready() - resets the ahdlc engine to the beginning of frame 
+ *	state.
+ */
+/*---------------------------------------------------------------------------*/
+void
+ahdlc_rx_ready(void)
+{
+  ahdlc_rx_count = 0;
+  ahdlc_rx_crc = 0xffff;
+  ahdlc_flags |= AHDLC_RX_READY;
+}
+/*---------------------------------------------------------------------------*/
+/* ahdlc receive function - This routine processes incoming bytes and tries
+ *	to build a PPP frame.
+ *
+ *	Two possible reasons that ahdlc_rx will not process characters:
+ *		o Buffer is locked - in this case ahdlc_rx returns 1, char
+ *			sending routing should retry.
+ */
+/*---------------------------------------------------------------------------*/
+u8_t
+ahdlc_rx(u8_t c)   
+{    
+  static u16_t protocol;
+  
+  /* check to see if PPP packet is useable, we should have hardware
+     flow control set, but if host ignores it and sends us a char when
+     the PPP Receive packet is in use, discard the character. +++ */
+  
+  if(ahdlc_flags & AHDLC_RX_READY) {
+    /* check to see if character is less than 0x20 hex we really
+       should set AHDLC_RX_ASYNC_MAP on by default and only turn it
+       off when it is negotiated off to handle some buggy stacks. */
+    if((c < 0x20) &&
+       ((ahdlc_flags & AHDLC_RX_ASYNC_MAP) == 0)) {
+      /* discard character */
+      DEBUG1(("Discard because char is < 0x20 hex and asysnc map is 0\n"));
+      return 0;
+    }
+    /* are we in escaped mode? */
+    if(ahdlc_flags & AHDLC_ESCAPED) {
+      /* set escaped to FALSE */
+      ahdlc_flags &= ~AHDLC_ESCAPED;	
+      
+      /* if value is 0x7e then silently discard and reset receive packet */
+      if(c == 0x7e) {
+	ahdlc_rx_ready();
+	return 0;
+      }
+      /* incomming char = itself xor 20 */
+      c = c ^ 0x20;	
+    } else if(c == 0x7e) {
+      /* handle frame end */
+      if(ahdlc_rx_crc == CRC_GOOD_VALUE) {
+	DEBUG1(("\nReceiving packet with good crc value, len %d\n",ahdlc_rx_count));
+	/* we hae a good packet, turn off CTS until we are done with
+	   this packet */
+	/*CTS_OFF();*/
+	/* remove CRC bytes from packet */
+	ahdlc_rx_count -= 2;		
+	
+	/* lock PPP buffer */
+	ahdlc_flags &= ~AHDLC_RX_READY;
+	/*
+	 * upcall routine must fully process frame before return
+	 *	as returning signifies that buffer belongs to AHDLC again.
+	 */
+	if((c & 0x1) && (ahdlc_flags & PPP_PFC)) {
+	  /* Send up packet */
+	  ppp_upcall((u16_t)ahdlc_rx_buffer[0],
+		     (u8_t *)&ahdlc_rx_buffer[1],
+		     (u16_t)(ahdlc_rx_count - 1));
+	} else {
+	  /* Send up packet */
+	  ppp_upcall((u16_t)(ahdlc_rx_buffer[0] << 8 | ahdlc_rx_buffer[1]), 
+		     (u8_t *)&ahdlc_rx_buffer[2], (u16_t)(ahdlc_rx_count - 2));
+	}
+	ahdlc_rx_ready();
+	return 0;
+      } else if(ahdlc_rx_count > 3) {	
+	DEBUG1(("\nReceiving packet with bad crc value, was 0x%04x len %d\n",ahdlc_rx_crc, ahdlc_rx_count));
+#ifdef AHDLC_COUNTERS
+	++ahdlc_crc_error;
+#endif
+	/* Shouldn't we dump the packet and not pass it up? */
+	/*ppp_upcall((u16_t)ahdlc_rx_buffer[0],
+	  (u8_t *)&ahdlc_rx_buffer[0], (u16_t)(ahdlc_rx_count+2));
+	  dump_ppp_packet(&ahdlc_rx_buffer[0],ahdlc_rx_count);*/
+	
+      }
+      ahdlc_rx_ready();	
+      return 0;
+    } else if(c == 0x7d) {
+      /* handle escaped chars*/
+      ahdlc_flags |= PPP_ESCAPED;
+      return 0;
+    }
+    
+    /* try to store char if not to big */
+    if(ahdlc_rx_count >= ahdlc_max_rx_buffer_size /*PPP_RX_BUFFER_SIZE*/) { 
+#ifdef AHDLC_COUNTERS			
+      ++ahdlc_rx_tobig_error;
+#endif
+      ahdlc_rx_ready();
+    } else {
+      /* Add CRC in */
+      ahdlc_rx_crc = crcadd(ahdlc_rx_crc, c);
+      /* do auto ACFC, if packet len is zero discard 0xff and 0x03 */
+      if(ahdlc_rx_count == 0) {
+	if((c == 0xff) || (c == 0x03))
+	  return 0;
+      }
+      /* Store char */
+      ppp_rx_buffer[ahdlc_rx_count++] = c;
+    }		
+  } else {
+    /* we are busy and didn't process the character. */
+    DEBUG1(("Busy/not active\n"));
+    return 1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+/* ahdlc_tx_char(char) - write a character to the serial device, 
+ * escape if necessary.
+ *
+ * Relies on local global vars	:	ahdlc_tx_crc, ahdlc_flags.
+ * Modifies local global vars	:	ahdlc_tx_crc.
+ */
+/*---------------------------------------------------------------------------*/
+void
+ahdlc_tx_char(u16_t protocol, u8_t c)
+{
+  /* add in crc */
+  ahdlc_tx_crc = crcadd(ahdlc_tx_crc, c);
+  /*
+   * See if we need to escape char, we always escape 0x7d and 0x7e, in the case
+   * of char < 0x20 we only support async map of default or none, so escape if
+   * ASYNC map is not set.  We may want to modify this to support a bitmap set
+   * ASYNC map.
+   */
+  if((c == 0x7d) || (c == 0x7e) || 
+     ((c < 0x20) && ((protocol == LCP) ||
+		     (ahdlc_flags & PPP_TX_ASYNC_MAP) == 0))) {
+    /* send escape char and xor byte by 0x20 */
+    ppp_arch_putchar(0x7d);
+    c ^= 0x20;
+  }
+  ppp_arch_putchar(c);
+}
+/*---------------------------------------------------------------------------*/
+/* ahdlc_tx(protocol,buffer,len) - Transmit a PPP frame.
+ *	Buffer contains protocol data, ahdlc_tx addes address, control and
+ *	protocol data.
+ *
+ * Relies on local global vars	:	ahdlc_tx_crc, ahdlc_flags.
+ * Modifies local global vars	:	ahdlc_tx_crc.
+ */
+/*---------------------------------------------------------------------------*/
+u8_t
+ahdlc_tx(u16_t protocol, u8_t *header, u8_t *buffer,
+	 u16_t headerlen, u16_t datalen)
+{
+  u16_t i;
+  u8_t c;
+
+  DEBUG1(("\nAHDLC_TX - transmit frame, protocol 0x%04x, length %d\n",protocol,datalen+headerlen));
+  
+#if PACKET_TX_DEBUG
+  DEBUG1(("\n"));
+  for(i = 0; i < headerlen; ++i) {
+    DEBUG1(("0x%02x ", header[i]));
+  }
+  for(i = 0; i < datalen; ++i) {
+    DEBUG1(("0x%02x ", buffer[i]));
+  }
+  DEBUG1(("\n\n"));
+#endif
+
+  /* Check to see that physical layer is up, we can assume is some
+     cases */
+  
+  /* write leading 0x7e */
+  ppp_arch_putchar(0x7e);
+
+  /* set initial CRC value */
+  ahdlc_tx_crc = 0xffff;
+  /* send HDLC control and address if not disabled or of LCP frame type */
+  /*if((0==(ahdlc_flags & PPP_ACFC)) || ((0xc0==buffer[0]) && (0x21==buffer[1]))) */
+  if((0 == (ahdlc_flags & PPP_ACFC)) || (protocol == LCP)) {
+    ahdlc_tx_char(protocol, 0xff);
+    ahdlc_tx_char(protocol, 0x03);
+  }
+  
+  /* Write Protocol */
+  ahdlc_tx_char(protocol,(u8_t)(protocol >> 8));
+  ahdlc_tx_char(protocol,(u8_t)(protocol & 0xff));
+
+  /* write header if it exists */
+  for(i = 0; i < headerlen; ++i) {
+    /* Get next byte from buffer */
+    c = header[i];
+    /* Write it...*/
+    ahdlc_tx_char(protocol, c);
+  }
+
+  /* Write frame bytes */
+  for(i = 0; i < datalen; ++i) {    
+    /* Get next byte from buffer */
+    c = buffer[i];
+    /* Write it...*/
+    ahdlc_tx_char(protocol, c);
+  }
+	
+  /* send crc, lsb then msb */
+  i = ahdlc_tx_crc ^ 0xffff;
+  ahdlc_tx_char(protocol, (u8_t)(i & 0xff));
+  ahdlc_tx_char(protocol, (u8_t)((i >> 8) & 0xff));
+
+  /* write trailing 0x7e, probably not needed but it doesn't hurt*/
+  ppp_arch_putchar(0x7e);
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ppp/ahdlc.h b/contiki/ppp/ahdlc.h
new file mode 100644
index 0000000..16392d5
--- /dev/null
+++ b/contiki/ppp/ahdlc.h
@@ -0,0 +1,57 @@
+#ifndef __AHDLC_H__
+#define __AHDLC_H__
+
+/*---------------------------------------------------------------------------
+ ahdlc.h - ahdlc header file  					  
+---------------------------------------------------------------------------
+ Version    
+		0.1 Original Version Jan 11, 1998				
+ (c)1998 Mycal Labs, All Rights Reserved
+ ---------------------------------------------------------------------------*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ahdlc.h,v 1.2 2004/08/22 12:37:00 oliverschmidt Exp $
+ *
+ */
+
+#include "uip.h"
+
+void ahdlc_init(u8_t *, u16_t);
+void ahdlc_rx_ready(void);
+u8_t ahdlc_rx(u8_t);  
+u8_t ahdlc_tx(u16_t protocol, u8_t *header, u8_t *buffer,
+	      u16_t headerlen, u16_t datalen);
+
+#endif /* __AHDLC_H__ */
diff --git a/contiki/ppp/ipcp.c b/contiki/ppp/ipcp.c
new file mode 100644
index 0000000..2a2f812
--- /dev/null
+++ b/contiki/ppp/ipcp.c
@@ -0,0 +1,448 @@
+/*															
+ *---------------------------------------------------------------------------
+ * ipcp.c - PPP IPCP (intrnet protocol) Processor/Handler
+ *
+ *---------------------------------------------------------------------------
+ *
+ * Version 
+ *		0.1 Original Version Jun 3, 2000
+ *	
+ *---------------------------------------------------------------------------
+ *        
+ * Copyright (C) 2000, Mycal Labs www.mycal.com
+ * 
+ *---------------------------------------------------------------------------
+ */
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ipcp.c,v 1.3 2005/01/26 23:36:22 oliverschmidt Exp $
+ *
+ */
+
+/*			*/ 
+/* include files 	*/
+/*			*/ 
+
+#if 0
+#define DEBUG1(x)
+#else
+#include <stdio.h>
+#define DEBUG1(x) debug_printf x
+#endif
+
+#include "uip.h"
+/*#include "time.h"*/
+#include "ipcp.h"
+#include "ppp.h"
+#include "ahdlc.h"
+
+#define TIMER_expire()
+#define TIMER_set()
+#define TIMER_timeout(x) 1
+
+#ifdef IPCP_GET_PEER_IP
+uip_ipaddr_t	peer_ip_addr;
+#endif
+
+#ifdef IPCP_GET_PRI_DNS
+uip_ipaddr_t	pri_dns_addr;
+#endif
+
+#ifdef IPCP_GET_SEC_DNS
+uip_ipaddr_t	sec_dns_addr;
+#endif
+
+/*
+ * Local IPCP state
+ */
+u8_t ipcp_state;
+
+/*
+ * in the future add copression protocol and name servers (possibly for servers only)
+ */
+u8_t ipcplist[] = {0x3, 0};	
+
+/*---------------------------------------------------------------------------*/
+/*void
+printip(uip_ipaddr_t ip)
+{
+DEBUG1((" %d.%d.%d.%d ",ip.ipb1,ip.ip8[1],ip.ip8[2],ip.ip8[3]));
+    }*/
+#define printip(x)
+/*---------------------------------------------------------------------------*/
+void
+ipcp_init(void)
+{
+  DEBUG1(("ipcp init\n"));
+  ipcp_state = 0;
+  ppp_retry = 0;
+  our_ipaddr.ip16[0] = our_ipaddr.ip16[1] = 0;
+}
+/*---------------------------------------------------------------------------*/
+/*
+ * IPCP RX protocol Handler
+ */
+void
+ipcp_rx(u8_t *buffer, u16_t count)
+{
+  u8_t *bptr = buffer;
+  IPCPPKT *pkt=(IPCPPKT *)buffer;
+  u16_t len;
+
+  DEBUG1(("IPCP len %d\n",count));
+	
+  switch(*bptr++) {
+  case CONF_REQ:
+    /* parce request and see if we can ACK it */
+    ++bptr;
+    len = (*bptr++ << 8);
+    len |= *bptr++;
+    /* len-=2; */
+
+    DEBUG1(("check lcplist\n"));
+    if(scan_packet(IPCP, ipcplist, buffer, bptr, (u16_t)(len - 4))) {
+      DEBUG1(("option was bad\n"));
+    } else {
+      DEBUG1(("IPCP options are good\n"));
+      /*
+       * Parse out the results
+       */
+      /* lets try to implement what peer wants */
+      /* Reject any protocol not */
+      /* Error? if we we need to send a config Reject ++++ this is
+	 good for a subroutine*/
+      /* All we should get is the peer IP address */
+      if(IPCP_IPADDRESS == *bptr++) {
+	/* dump length */
+	++bptr;
+#ifdef IPCP_GET_PEER_IP
+	peer_ip_addr.ip8[0] = *bptr++;
+	peer_ip_addr.ip8[1] = *bptr++;
+	peer_ip_addr.ip8[2] = *bptr++;
+	peer_ip_addr.ip8[3] = *bptr++;
+	DEBUG1(("Peer IP "));
+	/*	printip(peer_ip_addr);*/
+	DEBUG1(("\n"));
+#else
+	bptr += 4;
+#endif
+      } else {
+	DEBUG1(("HMMMM this shouldn't happen IPCP1\n"));
+      }
+      
+#if 0			
+      if(error) {
+	/* write the config NAK packet we've built above, take on the header */
+	bptr = buffer;
+	*bptr++ = CONF_NAK;		/* Write Conf_rej */
+	*bptr++;
+	/*tptr++;*/  /* skip over ID */
+
+	/* Write new length */
+	*bptr++ = 0;
+	*bptr = tptr - buffer;
+	
+	/* write the reject frame */
+	DEBUG1(("Writing NAK frame \n"));
+	ahdlc_tx(IPCP, buffer, (u16_t)(tptr - buffer));
+	DEBUG1(("- End NAK Write frame\n"));
+	
+      } else {
+      }
+#endif
+      /*
+       * If we get here then we are OK, lets send an ACK and tell the rest
+       * of our modules our negotiated config.
+       */
+      ipcp_state |= IPCP_RX_UP;
+      DEBUG1(("Send IPCP ACK!\n"));
+      bptr = buffer;
+      *bptr++ = CONF_ACK;		/* Write Conf_ACK */
+      bptr++;				/* Skip ID (send same one) */
+      /*
+       * Set stuff
+       */
+      /* ppp_flags |= tflag; */
+      DEBUG1(("SET- stuff -- are we up? c=%d dif=%d \n", count, (u16_t)(bptr-buffer)));
+	
+      /* write the ACK frame */
+      DEBUG1(("Writing ACK frame \n"));
+      /* Send packet ahdlc_txz(procol,header,data,headerlen,datalen);	*/
+      ahdlc_tx(IPCP, 0, buffer, 0, count /*bptr-buffer*/);
+      DEBUG1(("- End ACK Write frame\n"));
+	
+      /* expire the timer to make things happen after a state change */
+      /*timer_expire(); */
+	
+      /*			} */
+    }
+    break;
+  case CONF_ACK:			/* config Ack */
+    DEBUG1(("CONF ACK\n"));
+    /*
+     * Parse out the results
+     *
+     * Dump the ID and get the length.
+     */
+    /* dump the ID */
+    bptr++;
+
+    /* get the length */
+    len = (*bptr++ << 8);
+    len |= *bptr++;
+#if 0
+    /* Parse ACK and set data */
+    while(bptr < buffer + len) {
+      switch(*bptr++) {
+      case IPCP_IPADDRESS:
+	/* dump length */
+	bptr++;		
+	ipaddr.ip8[0] = *bptr++;
+	ipaddr.ip8[1] = *bptr++;
+	ipaddr.ip8[2] = *bptr++;
+	ipaddr.ip8[3] = *bptr++;
+	break;
+      case IPCP_PRIMARY_DNS:
+	bptr++;
+	pri_dns_addr.ip8[0] = *bptr++;
+	pri_dns_addr.ip8[1] = *bptr++;
+	pri_dns_addr.ip8[2] = *bptr++;
+	pri_dns_addr.ip8[3] = *bptr++;
+	break;
+      case IPCP_SECONDARY_DNS:
+	bptr++;
+	sec_dns_addr.ip8[0] = *bptr++;
+	sec_dns_addr.ip8[1] = *bptr++;
+	sec_dns_addr.ip8[2] = *bptr++;
+	sec_dns_addr.ip8[3] = *bptr++;
+	break;
+      default:
+	DEBUG1(("IPCP CONFIG_ACK problem1\n"));
+      }
+    }
+#endif
+    ipcp_state |= IPCP_TX_UP;
+    /*ipcp_state &= ~IPCP_RX_UP;*/
+    DEBUG1(("were up! \n"));
+    printip(our_ipaddr);
+#ifdef IPCP_GET_PRI_DNS
+    printip(pri_dns_addr);
+#endif
+#ifdef IPCP_GET_SEC_DNS
+    printip(sec_dns_addr);
+#endif
+    DEBUG1(("\n"));
+		
+    /* expire the timer to make things happen after a state change */
+    TIMER_expire();
+    break;
+  case CONF_NAK:			/* Config Nack */
+    DEBUG1(("CONF NAK\n"));
+    /* dump the ID */
+    bptr++;
+    /* get the length */
+    len = (*bptr++ << 8);
+    len |= *bptr++;
+
+    /* Parse ACK and set data */
+    while(bptr < buffer + len) {
+      switch(*bptr++) {
+      case IPCP_IPADDRESS:
+	/* dump length */
+	bptr++;
+	our_ipaddr.ip8[0] = *bptr++;
+	our_ipaddr.ip8[1] = *bptr++;
+	our_ipaddr.ip8[2] = *bptr++;
+	our_ipaddr.ip8[3] = *bptr++;
+	break;
+#ifdef IPCP_GET_PRI_DNS
+      case IPCP_PRIMARY_DNS:
+	bptr++;
+	pri_dns_addr.ip8[0] = *bptr++;
+	pri_dns_addr.ip8[1] = *bptr++;
+	pri_dns_addr.ip8[2] = *bptr++;
+	pri_dns_addr.ip8[3] = *bptr++;
+	break;
+#endif
+#ifdef IPCP_GET_SEC_DNS
+      case IPCP_SECONDARY_DNS:
+	bptr++;
+	sec_dns_addr.ip8[0] = *bptr++;
+	sec_dns_addr.ip8[1] = *bptr++;
+	sec_dns_addr.ip8[2] = *bptr++;
+	sec_dns_addr.ip8[3] = *bptr++;
+	break;
+#endif
+      default:
+	DEBUG1(("IPCP CONFIG_ACK problem 2\n"));
+      }
+    }
+    ppp_id++;
+    printip(our_ipaddr);
+#ifdef IPCP_GET_PRI_DNS
+    printip(pri_dns_addr);
+#endif
+#ifdef IPCP_GET_PRI_DNS
+    printip(sec_dns_addr);
+#endif
+    DEBUG1(("\n"));
+    /* expire the timer to make things happen after a state change */
+    TIMER_expire();
+    break;
+  case CONF_REJ:			/* Config Reject */
+    DEBUG1(("CONF REJ\n"));
+    /* Remove the offending options*/
+    ppp_id++;
+    /* dump the ID */
+    bptr++;
+    /* get the length */
+    len = (*bptr++ << 8);
+    len |= *bptr++;
+
+    /* Parse ACK and set data */
+    while(bptr < buffer + len) {
+      switch(*bptr++) {
+      case IPCP_IPADDRESS:
+	ipcp_state |= IPCP_IP_BIT;
+	bptr += 5;
+	break;
+#ifdef IPCP_GET_PRI_DNS
+      case IPCP_PRIMARY_DNS:
+	ipcp_state |= IPCP_PRI_DNS_BIT;
+	bptr += 5;
+	break;
+#endif
+#ifdef IPCP_GET_PRI_DNS
+      case IPCP_SECONDARY_DNS:
+	ipcp_state |= IPCP_SEC_DNS_BIT;
+	bptr += 5;
+	break;
+#endif
+      default:
+	DEBUG1(("IPCP this shoudln't happen 3\n"));
+      }
+    }
+    /* expire the timer to make things happen after a state change */
+    /*timer_expire(); */
+    break;
+  default:
+    DEBUG1(("-Unknown 4\n"));
+  }
+}
+  
+/*---------------------------------------------------------------------------*/
+void
+ipcp_task(u8_t *buffer)
+{
+  u8_t *bptr;
+  u16_t	t;
+  IPCPPKT *pkt;
+
+  /* IPCP tx not up and hasn't timed out then lets see if we need to
+     send a request */
+  if(!(ipcp_state & IPCP_TX_UP) && !(ipcp_state & IPCP_TX_TIMEOUT)) {
+    /* Check if we have a request pending */
+    /*t=get_seconds()-ipcp_tx_time;*/
+    if(TIMER_timeout(IPCP_TIMEOUT)) {
+      /*
+       * No pending request, lets build one
+       */
+      pkt=(IPCPPKT *)buffer;		
+      
+      /* Configure-Request only here, write id */
+      pkt->code = CONF_REQ;
+      pkt->id = ppp_id;
+			
+      bptr = pkt->data;       
+
+      /*
+       * Write options, we want IP address, and DNS addresses if set.
+       */
+			
+      /* Write zeros for IP address the first time */
+      *bptr++ = IPCP_IPADDRESS;
+      *bptr++ = 0x6;
+      *bptr++ = our_ipaddr.ip8[0];
+      *bptr++ = our_ipaddr.ip8[1];
+      *bptr++ = our_ipaddr.ip8[2];
+      *bptr++ = our_ipaddr.ip8[3];
+
+#ifdef IPCP_GET_PRI_DNS
+      if(!(ipcp_state & IPCP_PRI_DNS_BIT)) {
+	/* Write zeros for IP address the first time */
+	*bptr++ = IPCP_PRIMARY_DNS;
+	*bptr++ = 0x6;
+	*bptr++ = pri_dns_addr.ip8[0];
+	*bptr++ = pri_dns_addr.ip8[1];
+	*bptr++ = pri_dns_addr.ip8[2];
+	*bptr++ = pri_dns_addr.ip8[3];
+      }
+#endif
+#ifdef IPCP_GET_SEC_DNS
+      if(!(ipcp_state & IPCP_SEC_DNS_BIT)) {
+	/* Write zeros for IP address the first time */
+	*bptr++ = IPCP_SECONDARY_DNS;
+	*bptr++ = 0x6;
+	*bptr++ = sec_dns_addr.ip8[0];
+	*bptr++ = sec_dns_addr.ip8[1];
+	*bptr++ = sec_dns_addr.ip8[2];
+	*bptr++ = sec_dns_addr.ip8[3];
+      }
+#endif
+      /* Write length */
+      t = bptr - buffer;
+      /* length here -  code and ID + */
+      pkt->len = htons(t);	
+      
+      DEBUG1(("\n**Sending IPCP Request packet\n"));
+      
+      /* Send packet ahdlc_txz(procol,header,data,headerlen,datalen); */
+      ahdlc_tx(IPCP, 0, buffer, 0, t);
+
+      /* Set timer */
+      /*ipcp_tx_time=get_seconds();*/
+      TIMER_set();
+      /* Inc retry */
+      /*ipcp_retry++;*/
+      ppp_retry++;
+      /*
+       * Have we timed out? (combide the timers?)
+       */
+      if(ppp_retry > IPCP_RETRY_COUNT)
+	ipcp_state &= IPCP_TX_TIMEOUT;	
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/ 
diff --git a/contiki/ppp/ipcp.h b/contiki/ppp/ipcp.h
new file mode 100644
index 0000000..fef006d
--- /dev/null
+++ b/contiki/ppp/ipcp.h
@@ -0,0 +1,95 @@
+#ifndef __IPCP_H__
+#define __IPCP_H__
+/*  www.mycal.com
+    ---------------------------------------------------------------------------
+    IPCP.h - Internet Protocol Control Protocol header file 
+    ---------------------------------------------------------------------------
+    Version 
+    0.1 Original Version June 3, 2000
+    (c)2000 Mycal Labs, All Rights Reserved
+    ---------------------------------------------------------------------------
+*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ipcp.h,v 1.2 2004/08/22 12:37:00 oliverschmidt Exp $
+ *
+ */
+#include "uip.h"
+#include "ppp-conf.h"
+
+/* Config options (move to pppconfig)
+   #define  IPCP_RETRY_COUNT	5
+   #define  IPCP_TIMEOUT	5
+*/
+
+/* IPCP Option Types */
+#define IPCP_IPADDRESS		0x03
+#define IPCP_PRIMARY_DNS	0x81
+#define IPCP_SECONDARY_DNS	0x83
+
+/* IPCP state machine flags */
+#define	IPCP_TX_UP		0x01
+#define IPCP_RX_UP		0x02
+#define IPCP_IP_BIT		0x04
+#define IPCP_TX_TIMEOUT		0x08
+#define IPCP_PRI_DNS_BIT	0x08
+#define IPCP_SEC_DNS_BIT	0x10
+
+typedef struct  _ipcp
+{
+  u8_t code;
+  u8_t id;
+  u16_t len;
+  u8_t data[0];	
+} IPCPPKT;
+
+/*
+ * Export IP addresses.
+ */
+#if 0	/* moved to mip.c */
+extern	IPAddr our_ipaddr;
+extern	IPAddr peer_ip_addr;
+extern	IPAddr pri_dns_addr;
+extern	IPAddr sec_dns_addr;
+#endif
+
+extern	u8_t ipcp_state;
+
+void ipcp_init(void);
+void ipcp_task(u8_t *buffer);
+void ipcp_rx(u8_t *, u16_t);
+
+#endif /* __IPCP_H__ */
+
diff --git a/contiki/ppp/lcp.c b/contiki/ppp/lcp.c
new file mode 100644
index 0000000..8ae98ab
--- /dev/null
+++ b/contiki/ppp/lcp.c
@@ -0,0 +1,413 @@
+/*  www.mycal.com
+ *---------------------------------------------------------------------------
+ *lcp.c - Link Configuration Protocol Handler.  - -
+ *---------------------------------------------------------------------------
+ *Version - 0.1 Original Version June 3, 2000 -
+ *
+ *---------------------------------------------------------------------------
+ *- Copyright (C) 2000, Mycal Labs www.mycal.com - -
+ *---------------------------------------------------------------------------
+ *
+ *
+*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: lcp.c,v 1.3 2005/01/26 23:36:22 oliverschmidt Exp $
+ *
+ */
+
+/*			*/ 
+/* include files 	*/
+/*			*/ 
+
+#include "ppp-conf.h"
+
+/*#include "time.h"*/
+#include "ppp.h"
+#include "ahdlc.h"
+#include "lcp.h"
+
+#if 0
+#define DEBUG1(x)
+#define DEBUG2(x)
+#else
+#include <stdio.h>
+#define DEBUG1(x) debug_printf x
+#define DEBUG2(x) debug_printf x
+#endif
+
+#define TIMER_expire()
+#define TIMER_set()
+#define TIMER_timeout(x) 1
+
+/*u8_t				tflag;
+u8_t				*lcp_buffer;
+u16_t				lcp_tx_time;
+u8_t				lcp_retry;
+u16_t				lcp_timeout=5;*/
+
+u8_t lcp_state;
+u16_t ppp_tx_mru = 0;
+
+/* We need this when we neg our direction.
+   u8_t				lcp_tx_options; */
+
+/*
+ * Define the supported paramets for this module here.
+ */
+u8_t lcplist[] = {
+  LPC_MAGICNUMBER,
+  LPC_PFC,
+  LPC_ACFC,
+  LPC_AUTH,
+  LPC_ACCM,
+  LPC_MRU,
+  0};	
+
+/*---------------------------------------------------------------------------*/
+/* lcp_init() - Initialize the LCP engine to startup values */
+/*---------------------------------------------------------------------------*/
+void
+lcp_init(void)
+{
+  lcp_state = 0;
+  ppp_retry = 0;
+  TIMER_expire();
+}
+/*---------------------------------------------------------------------------*/
+/* lcp_rx() - Receive an LCP packet and process it.  
+ *	This routine receives a LCP packet in buffer of length count.
+ *	Process it here, support for CONF_REQ, CONF_ACK, CONF_NACK, CONF_REJ or
+ *	TERM_REQ.
+ */
+/*---------------------------------------------------------------------------*/
+void
+lcp_rx(u8_t *buffer, u16_t count)
+{
+  u8_t *bptr = buffer, *tptr;
+  u8_t error = 0;
+  u8_t id;
+  u16_t len, j;
+
+  switch(*bptr++) {
+  case CONF_REQ:			/* config request */
+    /* parce request and see if we can ACK it */
+    id = *bptr++;
+    len = (*bptr++ << 8);
+    len |= *bptr++;
+    /*len -= 2;*/
+    DEBUG1(("received [LCP Config Request id %u\n",id));
+    if(scan_packet((u16_t)LCP, lcplist, buffer, bptr, (u16_t)(len-4))) {
+      /* must do the -4 here, !scan packet */
+      
+      DEBUG1((" options were rejected\n"));
+    } else {
+      /* lets try to implement what peer wants */
+      tptr = bptr = buffer;
+      bptr += 4;			/* skip code, id, len */
+      error = 0;
+      /* first scan for unknown values */
+      while(bptr < buffer+len) {
+	switch(*bptr++) {
+	case LPC_MRU:	/* mru */
+	  j = *bptr++;
+	  j -= 2;
+	  if(j == 2) {
+	    ppp_tx_mru = ((*bptr++<<8) || (*bptr++));
+	    DEBUG1(("<mru %d> ",ppp_tx_mru));
+	  } else {
+	    DEBUG1(("<mru ??> "));
+	  }
+	  break;
+	case LPC_ACCM:	/*		*/
+	  bptr++;		/* skip length */	
+	  j = *bptr++;
+	  j += *bptr++;
+	  j += *bptr++;
+	  j += *bptr++;
+	  if((j==0) || (j==0x3fc)) {
+	    // ok
+	    DEBUG1(("<asyncmap 0x%04x>",j));
+	  } else {
+	    /*
+	     * fail we only support default or all zeros
+	     */
+	    DEBUG1(("We only support default or all zeros for ACCM "));
+	    error = 1;
+	    *tptr++ = LPC_ACCM;
+	    *tptr++ = 0x6;
+	    *tptr++ = 0;
+	    *tptr++ = 0;
+	    *tptr++ = 0;
+	    *tptr++ = 0;
+	  }
+	  break;
+	case LPC_AUTH:
+	  bptr++;
+	  if((*bptr++==0xc0) && (*bptr++==0x23)) {
+	    DEBUG1(("<auth pap> "));
+	    /* negotiate PAP */
+	    lcp_state |= LCP_RX_AUTH;	
+	  } else {
+	    /* we only support PAP */
+	    DEBUG1(("<auth ??>"));
+	    error = 1;
+	    *tptr++ = LPC_AUTH;
+	    *tptr++ = 0x4;
+	    *tptr++ = 0xc0;
+	    *tptr++ = 0x23;
+	  }
+	  break;
+	case LPC_MAGICNUMBER:
+	  DEBUG1(("<magic > "));
+	  /*
+	   * Compair incoming number to our number (not implemented)
+	   */
+	  bptr++;		/* for now just dump */
+	  bptr++;
+	  bptr++;
+	  bptr++;
+	  bptr++;
+	  break;
+	case LPC_PFC:
+	  bptr++;
+	  DEBUG1(("<pcomp> "));
+	  /*tflag|=PPP_PFC;*/
+	  break;
+	case LPC_ACFC:
+	  bptr++;
+	  DEBUG1(("<accomp> "));
+	  /*tflag|=PPP_ACFC;*/
+	  break;
+	  
+	}
+      }
+      /* Error? if we we need to send a config Reject ++++ this is good for a subroutine */
+      if(error) {
+	/* write the config NAK packet we've built above, take on the header */
+	bptr = buffer;
+	*bptr++ = CONF_NAK;		/* Write Conf_rej */
+	*bptr++;/*tptr++;*/		/* skip over ID */
+
+	/* Write new length */
+	*bptr++ = 0;
+	*bptr = tptr - buffer;
+
+	/* write the reject frame */
+	DEBUG1(("\nWriting NAK frame \n"));
+	// Send packet ahdlc_txz(procol,header,data,headerlen,datalen);				
+	ahdlc_tx(LCP, 0, buffer, 0, (u16_t)(tptr-buffer));
+	DEBUG1(("- end NAK Write frame\n"));
+	
+      } else {
+	/*
+	 * If we get here then we are OK, lets send an ACK and tell the rest
+	 * of our modules our negotiated config.
+	 */
+	DEBUG1(("\nSend ACK!\n"));
+	bptr = buffer;
+	*bptr++ = CONF_ACK;		/* Write Conf_ACK */
+	bptr++;				/* Skip ID (send same one) */
+	/*
+	 * Set stuff
+	 */
+	/*ppp_flags|=tflag;*/
+	/* DEBUG2("SET- stuff -- are we up? c=%d dif=%d \n", count, (u16_t)(bptr-buffer)); */
+	
+	/* write the ACK frame */
+	DEBUG2(("Writing ACK frame \n"));
+	/* Send packet ahdlc_txz(procol,header,data,headerlen,datalen);	*/
+	ahdlc_tx(LCP, 0, buffer, 0, count /*bptr-buffer*/);
+       DEBUG2(("- end ACK Write frame\n"));
+	
+	/* expire the timer to make things happen after a state change */
+	/*timer_expire();*/
+	
+      }
+    }
+    break;
+  case CONF_ACK:			/* config Ack   Anytime we do an ack reset the timer to force send. */
+    DEBUG1(("LCP-ACK - "));
+    /* check that ID matches one sent */
+    if(*bptr++ == ppp_id) {	
+      /* Change state to PPP up. */
+      DEBUG1((">>>>>>>> good ACK id up!\n",ppp_id));
+      /* copy negotiated values over */
+      
+      lcp_state |= LCP_TX_UP;		
+      
+      /* expire the timer to make things happen after a state change */
+      TIMER_expire();
+    }
+    else
+      DEBUG1(("*************++++++++++ bad id %d\n",ppp_id));
+    break;
+  case CONF_NAK:			/* Config Nack */
+    DEBUG1(("LCP-CONF NAK\n"));
+    ppp_id++;
+    break;
+  case CONF_REJ:			/* Config Reject */
+    DEBUG1(("LCP-CONF REJ\n"));
+    ppp_id++;
+    break;
+  case TERM_REQ:			/* Terminate Request */
+    DEBUG1(("LCP-TERM-REQ -"));
+    bptr = buffer;
+    *bptr++ = TERM_ACK;			/* Write TERM_ACK */
+    /* write the reject frame */
+    DEBUG1(("Writing TERM_ACK frame \n"));
+    /* Send packet ahdlc_txz(procol,header,data,headerlen,datalen); */
+    ahdlc_tx(LCP, 0, buffer, 0, count);
+    lcp_state &= ~LCP_TX_UP;	
+    lcp_state |= LCP_TERM_PEER;
+    break;
+  case TERM_ACK:
+    DEBUG1(("LCP-TERM ACK\n"));
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+/* lcp_task(buffer) - This routine see if a lcp request needs to be sent
+ *	out.  It uses the passed buffer to form the packet.  This formed LCP
+ *	request is what we negotiate for sending options on the link.
+ *
+ *	Currently we negotiate : Magic Number Only, but this will change.
+ */
+/*---------------------------------------------------------------------------*/
+void
+lcp_task(u8_t *buffer)
+{
+  u8_t *bptr;
+  u16_t t;
+  LCPPKT *pkt;
+
+  /* lcp tx not up and hasn't timed out then lets see if we need to send a request */
+  if(!(lcp_state & LCP_TX_UP) && !(lcp_state & LCP_TX_TIMEOUT)) {
+    /* Check if we have a request pending */
+    /*t=get_seconds()-lcp_tx_time;*/
+    if(1 == TIMER_timeout(LCP_TX_TIMEOUT)) {
+      DEBUG1(("\nSending LCP request packet - "));
+      /*
+       * No pending request, lets build one
+       */
+      pkt = (LCPPKT *)buffer;		
+
+      /* Configure-Request only here, write id */
+      pkt->code = CONF_REQ;
+      pkt->id = ppp_id;
+      
+      bptr = pkt->data;
+      
+      /* Write options */
+      
+      /* Write magic number */
+      DEBUG1(("LPC_MAGICNUMBER -"));
+      *bptr++ = LPC_MAGICNUMBER;
+      *bptr++ = 0x6;
+      *bptr++ = 0;
+      *bptr++ = 0;
+      *bptr++ = 0;
+      *bptr++ = 0;
+      
+      /* ACCM */
+#if 0
+      if((lcp_tx_options & LCP_OPT_ACCM) & 0) {
+	*bptr++ = LPC_ACCM;
+	*bptr++ = 0x6;
+	*bptr++ = 0;
+	*bptr++ = 0;
+	*bptr++ = 0;
+	*bptr++ = 0;
+      }
+      /*
+       * Authentication protocol
+       */
+      if((lcp_tx_options & LCP_OPT_AUTH) && 0) {
+	/*
+	 * If turned on, we only negotiate PAP
+	 */
+	*bptr++ = LPC_AUTH;
+	*bptr++ = 0x4;
+	*bptr++ = 0xc0;
+	*bptr++ = 0x23;
+      }
+      /*
+       * PFC
+       */
+      if((lcp_tx_options & LCP_OPT_PFC) && 0) {
+	/*
+	 * If turned on, we only negotiate PAP
+	 */
+	*bptr++ = LPC_PFC;
+	*bptr++ = 0x2;
+      }
+      /*
+       * ACFC
+       */
+      if((lcp_tx_options & LCP_OPT_ACFC) && 0) {
+	/*
+	 * If turned on, we only negotiate PAP
+	 */
+	*bptr++ = LPC_ACFC;
+	*bptr++ = 0x2;
+      }
+#endif
+      /* Write length */
+      t = bptr - buffer;
+      pkt->len = htons(t);			/* length here -  code and ID + */
+      
+      DEBUG1((" len %d\n",t));
+      
+      /* Send packet */
+      /* Send packet ahdlc_txz(procol,header,data,headerlen,datalen); */
+      ahdlc_tx(LCP, 0, buffer, 0, t);
+      
+      /* Set timer */
+      TIMER_set();
+      /*lcp_tx_time=get_seconds();*/
+      /* Inc retry */
+      ppp_retry++;
+      /*
+       * Have we timed out?
+       */
+      if(ppp_retry > LCP_RETRY_COUNT) {
+	lcp_state &= LCP_TX_TIMEOUT;
+      }
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ppp/lcp.h b/contiki/ppp/lcp.h
new file mode 100644
index 0000000..911f1f3
--- /dev/null
+++ b/contiki/ppp/lcp.h
@@ -0,0 +1,95 @@
+#ifndef __LCP_H__
+#define __LCP_H__
+/* www.mycal.com
+   ---------------------------------------------------------------------------
+   LCP.h - LCP header file
+   ---------------------------------------------------------------------------
+   Version                                                                  -
+   0.1 Original Version June 3, 2000
+   (c)2000 Mycal Labs, All Rights Reserved
+   ---------------------------------------------------------------------------
+*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: lcp.h,v 1.2 2004/08/22 12:37:00 oliverschmidt Exp $
+ *
+ */
+
+#include "uip.h"
+#include "ppp-conf.h"
+
+/* LCP Option Types */
+#define LPC_VENDERX		0x0
+#define	LPC_MRU			0x1
+#define LPC_ACCM		0x2
+#define LPC_AUTH		0x3
+#define LPC_QUALITY		0x4
+#define LPC_MAGICNUMBER		0x5
+#define LPC_PFC			0x7
+#define LPC_ACFC		0x8
+
+/* LCP Negotiated options flag equates */
+#define LCP_OPT_ACCM		0x1
+#define LCP_OPT_AUTH		0x2
+#define LCP_OPT_PFC		0x4
+#define LCP_OPT_ACFC		0x4
+
+/* LCP state machine flags */
+#define	LCP_TX_UP		0x1
+#define LCP_RX_UP		0x2
+
+#define LCP_RX_AUTH		0x10
+/* LCP request for auth */
+#define LCP_TERM_PEER		0x20
+/* LCP Terminated by peer */
+#define LCP_RX_TIMEOUT		0x40
+#define LCP_TX_TIMEOUT		0x80
+
+typedef struct _lcppkt
+{
+  u8_t code;
+  u8_t id;
+  u16_t len;
+  u8_t data[0];	
+} LCPPKT;
+
+/* Exported Vars */
+extern	u8_t lcp_state;
+
+void	lcp_init(void);
+void	lcp_rx(u8_t *, u16_t);
+void	lcp_task(u8_t *buffer);
+
+#endif /* __LCP_H__ */
diff --git a/contiki/ppp/pap.c b/contiki/ppp/pap.c
new file mode 100644
index 0000000..9e55220
--- /dev/null
+++ b/contiki/ppp/pap.c
@@ -0,0 +1,186 @@
+/*www.mycal.net
+ *---------------------------------------------------------------------------
+ *pap.c - PAP processor for the PPP module - -
+ *---------------------------------------------------------------------------
+ *Version - 0.1 Original Version Jun 3, 2000 - -
+ *---------------------------------------------------------------------------
+ *- Copyright (C) 2000, Mycal Labs www.mycal.com - -
+ *---------------------------------------------------------------------------
+*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: pap.c,v 1.4 2005/01/26 23:36:22 oliverschmidt Exp $
+ *
+ */
+
+/*			*/ 
+/* include files 	*/
+/*			*/ 
+
+#include	<string.h>
+#include	"ppp.h"
+#include	"pap.h"
+#include	"lcp.h"
+
+#if 0
+#define DEBUG1(x)
+#else
+#include <stdio.h>
+#define DEBUG1(x) debug_printf x
+#endif
+
+/*#include	"time.h"*/
+/*#include	"utils.h" */
+#define TIMER_expire()
+#define TIMER_set()
+#define TIMER_timeout(x) 1
+
+
+u8_t pap_state;
+
+u8_t pap_username[PAP_USERNAME_SIZE];
+u8_t pap_password[PAP_PASSWORD_SIZE];
+
+/*u16_t			pap_tx_time;
+  u8_t			pap_timeout;*/
+
+/*---------------------------------------------------------------------------*/
+void
+pap_init(void)
+{
+  ppp_retry = 0;			/* We reuse ppp_retry */
+  pap_state = 0;
+}
+/*---------------------------------------------------------------------------*/
+/* pap_rx() - PAP RX protocol Handler */
+/*---------------------------------------------------------------------------*/
+void
+pap_rx(u8_t *buffer, u16_t count)
+{
+  u8_t *bptr=buffer;
+  u8_t len;
+
+  switch(*bptr++) {
+  case CONF_REQ:	
+    DEBUG1(("CONF ACK - only for server, no support\n"));
+    break;
+  case CONF_ACK:			/* config Ack */
+    DEBUG1(("CONF ACK - PAP good - "));
+    /* Display message if debug */
+    len = *bptr++;
+    *(bptr + len) = 0;
+    DEBUG1((" %s \n",bptr));
+    pap_state |= PAP_TX_UP;
+    /* expire the timer to make things happen after a state change */
+    TIMER_expire();
+    break;
+  case CONF_NAK:
+    DEBUG1(("CONF NAK - Failed Auth - "));
+    pap_state |= PAP_TX_AUTH_FAIL;
+    /* display message if debug */
+    len = *bptr++;
+    *(bptr + len)=0;
+    DEBUG1((" %s \n",bptr));
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+/* pap_task() - This task needs to be called every so often during the PAP
+ *	negotiation phase.  This task sends PAP REQ packets.
+ */
+/*---------------------------------------------------------------------------*/
+void
+pap_task(u8_t *buffer)	
+{
+  u8_t *bptr;
+  u16_t t;
+  PAPPKT *pkt;
+
+  /* If LCP is up and PAP negotiated, try to bring up PAP */
+  if(!(pap_state & PAP_TX_UP) && !(pap_state & PAP_TX_TIMEOUT)) {
+    /* Do we need to send a PAP auth packet?
+       Check if we have a request pending*/
+    if(1 == TIMER_timeout(PAP_TIMEOUT)) {
+      /* Check if we have a request pending */
+      /* t=get_seconds()-pap_tx_time;
+	 if(	t > pap_timeout)
+      {
+      */
+      /* We need to send a PAP authentication request */
+      DEBUG1(("\nSending PAP Request packet - "));
+
+      /* Build a PAP request packet */
+      pkt = (PAPPKT *)buffer;		
+      
+      /* Configure-Request only here, write id */
+      pkt->code = CONF_REQ;
+      pkt->id = ppp_id;
+      bptr = pkt->data;
+      
+      /* Write options */
+      t = strlen(pap_username);
+      /* Write peer length */
+      *bptr++ = (u8_t)t;	
+      bptr = memcpy(bptr, pap_username, t);
+
+      t = strlen(pap_password);
+      *bptr++ = (u8_t)t;
+      bptr = memcpy(bptr, pap_password, t);
+			
+      /* Write length */
+      t = bptr - buffer;
+      /* length here -  code and ID +  */
+      pkt->len = htons(t);	
+      
+      DEBUG1((" Len %d\n",t));
+      
+      /* Send packet */
+      ahdlc_tx(PAP, buffer, 0, t, 0);
+
+      /* Set timer */
+      TIMER_set();
+      
+      ppp_retry++;
+
+      /* Have we failed? */
+      if(ppp_retry > 3) {
+	DEBUG1(("PAP - timout\n"));
+	pap_state &= PAP_TX_TIMEOUT;
+	
+      }
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ppp/pap.h b/contiki/ppp/pap.h
new file mode 100644
index 0000000..104a79c
--- /dev/null
+++ b/contiki/ppp/pap.h
@@ -0,0 +1,83 @@
+#ifndef __PAP_H__
+#define __PAP_H__
+/*
+  www.mycal.com
+  ---------------------------------------------------------------------------
+  pap.h - pap header file 
+  ---------------------------------------------------------------------------
+  Version 
+  0.1 Original Version June 3, 2000
+  (c)2000 Mycal Labs, All Rights Reserved
+  ---------------------------------------------------------------------------
+*/
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: pap.h,v 1.3 2004/08/22 21:10:02 oliverschmidt Exp $
+ *
+ */
+
+#include "uip.h"
+
+/* PAP state machine flags */
+/* client only */
+#define PAP_TX_UP		0x01
+/* server only */
+#define PAP_RX_UP		0x02
+
+#define PAP_RX_AUTH_FAIL	0x10
+#define PAP_TX_AUTH_FAIL	0x20
+#define PAP_RX_TIMEOUT		0x80
+#define PAP_TX_TIMEOUT		0x80
+
+typedef struct _pappkt {
+  u8_t code;
+  u8_t id;
+  u16_t len;
+  u8_t data[0];	
+} PAPPKT;
+
+/* Export pap_state */
+extern u8_t pap_state;
+
+extern u8_t pap_username[];
+extern u8_t pap_password[];
+
+/* Function prototypes */
+void	pap_init(void);
+void	pap_rx(u8_t *, u16_t);
+void	pap_task(u8_t *buffer);	
+
+#endif /* __PAP_H__ */
+
diff --git a/contiki/ppp/ppp-service.c b/contiki/ppp/ppp-service.c
new file mode 100644
index 0000000..842f1c4
--- /dev/null
+++ b/contiki/ppp/ppp-service.c
@@ -0,0 +1,57 @@
+
+#include "packet-service.h"
+#include "ppp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME, EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(ppp_service_init, arg)
+{
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  ppp_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+//    ppp_init();
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  ppp_poll();
+  if(uip_len > 0) {
+    tcpip_input();
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ppp/ppp.c b/contiki/ppp/ppp.c
new file mode 100644
index 0000000..ba993a3
--- /dev/null
+++ b/contiki/ppp/ppp.c
@@ -0,0 +1,443 @@
+/*															
+ *---------------------------------------------------------------------------
+ * ppp.c - PPP Processor/Handler											-
+ *																			-
+ *---------------------------------------------------------------------------
+ * 
+ * Version                                                                  -
+ *		0.1 Original Version Jun 3, 2000									-        
+ *																			-
+ *---------------------------------------------------------------------------    
+ */
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ppp.c,v 1.5 2005/02/23 22:38:43 oliverschmidt Exp $
+ *
+ */
+
+/*			*/ 
+/* include files 	*/
+/*			*/ 
+
+
+#include "lcp.h"
+#include "pap.h"
+#include "ipcp.h"
+/*#include "time.h"*/
+/*#include "mip.h"*/
+
+#if 0
+#define DEBUG1(x)
+#else
+#include <stdio.h>
+#define DEBUG1(x) debug_printf x
+#endif
+
+/*
+  Set the debug message level
+*/
+#define	PACKET_RX_DEBUG	1
+
+/*
+  Include stuff
+*/
+/*#include "mTypes.h"*/
+#include "ppp.h"
+#include "ahdlc.h"
+#include "ipcp.h"
+#include "lcp.h"
+
+
+/*
+  Buffers that this layer needs (this can be optimized out)
+*/
+u8_t ppp_rx_buffer[PPP_RX_BUFFER_SIZE];
+/*u8_t ppp_tx_buffer[PPP_TX_BUFFER_SIZE];*/
+
+/*
+ * IP addr set by PPP server
+ */
+uip_ipaddr_t our_ipaddr;
+
+/*
+ * Other state storage (this can be placed in a struct and this could could
+ *	support multiple PPP connections, would have to embedded the other ppp
+ *	module state also)
+ */
+u8_t ppp_flags;
+u8_t ppp_id;
+u8_t ppp_retry;
+
+#if PACKET_RX_DEBUG
+u16_t ppp_rx_frame_count=0;
+u16_t ppp_rx_tobig_error;
+u8_t done;    /* temporary variable */
+#endif
+
+/*---------------------------------------------------------------------------*/
+static u8_t
+check_ppp_errors(void)
+{
+  u8_t ret = 0;
+
+  /* Check Errors */
+  if(lcp_state & LCP_TX_TIMEOUT) {
+    ret = 1;
+  }
+  if(lcp_state & LCP_RX_TIMEOUT) {
+    ret = 2;
+  }
+
+  if(pap_state & PAP_TX_AUTH_FAIL) {
+    ret = 3;
+  }
+  if(pap_state & PAP_RX_AUTH_FAIL) {
+    ret = 4;
+  }
+
+  if(pap_state & PAP_TX_TIMEOUT) {
+    ret = 5;
+  }
+  if(pap_state & PAP_RX_TIMEOUT) {
+    ret = 6;
+  }
+
+  if(ipcp_state & IPCP_TX_TIMEOUT) {
+    ret = 7;
+  }
+
+  return ret;
+}
+/*---------------------------------------------------------------------------*/
+/*
+ * Unknown Protocol Handler, sends reject
+ */
+static void
+ppp_reject_protocol(u16_t protocol, u8_t *buffer, u16_t count)
+{
+  u16_t	i;
+  u8_t *dptr, *sptr;
+  LCPPKT *pkt;
+	
+  /* first copy rejected packet back, start from end and work forward,
+     +++ Pay attention to buffer managment when updated. Assumes fixed
+     PPP blocks. */
+  DEBUG1(("Rejecting Protocol\n"));
+  if((count + 6) > PPP_RX_BUFFER_SIZE) {
+    /* This is a fatal error +++ do somthing about it. */
+    DEBUG1(("Cannot Reject Protocol, PKT to big\n"));
+    return;
+  }
+  dptr = buffer + count + 6;
+  sptr = buffer + count;
+  for(i = 0; i < count; ++i) {
+    *dptr-- = *sptr--;
+  }
+
+  pkt = (LCPPKT *)buffer;
+  pkt->code = PROT_REJ;		/* Write Conf_rej */
+  /*pkt->id = tid++;*/			/* write tid */
+  pkt->len = htons(count + 6);
+  *((u16_t *)(&pkt->data[0])) = htons(protocol);
+
+  ahdlc_tx(LCP, buffer, 0, (u16_t)(count + 6), 0);
+}
+/*---------------------------------------------------------------------------*/
+#if PACKET_RX_DEBUG
+void
+dump_ppp_packet(u8_t *buffer, u16_t len)
+{
+  int i;
+
+  DEBUG1(("\n"));
+  for(i = 0;i < len; ++i) {
+    if((i & 0x1f) == 0x10) {
+      DEBUG1(("\n"));
+    }
+    DEBUG1(("0x%02x ",buffer[i]));
+  }
+  DEBUG1(("\n\n"));
+}
+#endif
+/*---------------------------------------------------------------------------*/
+/* Initialize and start PPP engine.  This just sets things up to
+ * starting values.  This can stay a private method.
+ */
+/*---------------------------------------------------------------------------*/
+void
+ppp_init()
+{
+#if PACKET_RX_DEBUG
+  ppp_rx_frame_count = 0;
+  done = 0;
+#endif
+  ppp_flags = 0;
+  pap_init();
+  ipcp_init();
+  lcp_init();
+  ppp_flags = 0;
+	
+  ahdlc_init(ppp_rx_buffer, PPP_RX_BUFFER_SIZE);
+  ahdlc_rx_ready();
+}
+/*---------------------------------------------------------------------------*/
+/* raise_ppp() - This routine will try to bring up a PPP connection, 
+ *  It is blocking. In the future we probably want to pass a
+ *  structure with all the options on bringing up a PPP link, like
+ *  server/client, DSN server, username password for PAP... +++ for
+ *  now just use config and bit defines
+ */
+/*---------------------------------------------------------------------------*/
+#if 0
+u16_t
+ppp_raise(u8_t config, u8_t *username, u8_t *password)
+{
+  u16_t	status = 0;
+
+  /* Initialize PPP engine */
+  /* init_ppp(); */
+  pap_init();
+  ipcp_init();
+  lcp_init();
+
+  /* Enable PPP */
+  ppp_flags = PPP_RX_READY;
+
+  /* Try to bring up the layers */
+  while(status == 0) {
+#ifdef SYSTEM_POLLER
+    /* If the the serial interrupt is not hooked to ahdlc_rx, or the
+       system needs to handle other stuff while were blocking, call
+       the system poller.*/
+      system_poller();
+#endif		
+
+      /* call the lcp task to bring up the LCP layer */
+      lcp_task(ppp_tx_buffer);
+
+      /* If LCP is up, neg next layer */
+      if(lcp_state & LCP_TX_UP) {
+	/* If LCP wants PAP, try to authenticate, else bring up IPCP */
+	if((lcp_state & LCP_RX_AUTH) && (!(pap_state & PAP_TX_UP))) {
+	  pap_task(ppp_tx_buffer,username,password);  
+	} else {
+	  ipcp_task(ppp_tx_buffer);
+	}
+      }
+
+
+      /* If IPCP came up then our link should be up. */
+      if((ipcp_state & IPCP_TX_UP) && (ipcp_state & IPCP_RX_UP)) {
+	break;
+      }
+      
+      status = check_ppp_errors();
+    }
+  
+  return status;
+}
+#endif
+/*---------------------------------------------------------------------------*/
+void
+ppp_connect(void)
+{
+  /* Initialize PPP engine */
+  /* init_ppp(); */
+  pap_init();
+  ipcp_init();
+  lcp_init();
+  
+  /* Enable PPP */
+  ppp_flags = PPP_RX_READY;
+}
+/*---------------------------------------------------------------------------*/
+void
+ppp_send(void)
+{
+  /* If IPCP came up then our link should be up. */
+  if((ipcp_state & IPCP_TX_UP) && (ipcp_state & IPCP_RX_UP)) {
+    ahdlc_tx(IPV4, uip_buf,        uip_appdata,
+		   UIP_TCPIP_HLEN, uip_len - UIP_TCPIP_HLEN);
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+ppp_poll(void)
+{
+  u8_t c;
+
+  uip_len = 0;
+
+  if(!(ppp_flags & PPP_RX_READY)) {
+    return;
+  }
+
+  while(uip_len == 0 && ppp_arch_getchar(&c)) {
+    ahdlc_rx(c);
+  }
+
+  /* If IPCP came up then our link should be up. */
+  if((ipcp_state & IPCP_TX_UP) && (ipcp_state & IPCP_RX_UP)) {
+    return;
+  }
+
+  /* call the lcp task to bring up the LCP layer */
+  lcp_task(uip_buf);
+
+  /* If LCP is up, neg next layer */
+  if(lcp_state & LCP_TX_UP) {
+    /* If LCP wants PAP, try to authenticate, else bring up IPCP */
+    if((lcp_state & LCP_RX_AUTH) && (!(pap_state & PAP_TX_UP))) {
+      pap_task(uip_buf);  
+    } else {
+      ipcp_task(uip_buf);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+/* ppp_upcall() - this is where valid PPP frames from the ahdlc layer are
+ *	sent to be processed and demuxed.
+ */
+/*---------------------------------------------------------------------------*/
+void
+ppp_upcall(u16_t protocol, u8_t *buffer, u16_t len)
+{
+#if PACKET_RX_DEBUG
+  ++ppp_rx_frame_count;
+  dump_ppp_packet(buffer, len);
+  if(ppp_rx_frame_count > 18) {
+    done = 1;
+  }
+#endif
+
+  /* check to see if we have a packet waiting to be processed */
+  if(ppp_flags & PPP_RX_READY) {	
+    /* demux on protocol field */
+    switch(protocol) {
+    case LCP:	/* We must support some level of LCP */
+      DEBUG1(("LCP Packet - "));
+      lcp_rx(buffer, len);
+      DEBUG1(("\n"));
+      break;
+    case PAP:	/* PAP should be compile in optional */
+      DEBUG1(("PAP Packet - "));
+      pap_rx(buffer, len);
+      DEBUG1(("\n"));
+      break;
+    case IPCP:	/* IPCP should be compile in optional. */
+      DEBUG1(("IPCP Packet - "));
+      ipcp_rx(buffer, len);
+      DEBUG1(("\n"));
+      break;
+    case IPV4:	/* We must support IPV4 */
+      DEBUG1(("IPV4 Packet---\n"));
+      memcpy(uip_buf, buffer, len);
+      uip_len = len;
+      DEBUG1(("\n"));
+      break;
+    default:
+      DEBUG1(("Unknown PPP Packet Type 0x%04x - ",protocol));
+      ppp_reject_protocol(protocol, buffer, len);
+      DEBUG1(("\n"));
+      break;
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+/* scan_packet(list,buffer,len)
+ *
+ * list = list of supported ID's
+ * *buffer pointer to the first code in the packet
+ * length of the codespace
+ */
+u16_t
+scan_packet(u16_t protocol, u8_t *list, u8_t *buffer, u8_t *options, u16_t len)
+{
+  u8_t *tlist, *bptr;
+  u8_t *tptr;
+  u8_t bad = 0;
+  u8_t i, j, good;
+
+  bptr = tptr = options;
+  /* scan through the packet and see if it has any unsupported codes */
+  while(bptr < options + len) {
+    /* get code and see if it matches somwhere in the list, if not
+       we don't support it */
+    i = *bptr++;
+    
+    /*    DEBUG2("%x - ",i);*/
+    tlist = list;
+      good = 0;
+      while(*tlist) {
+	/*	DEBUG2("%x ",*tlist);*/
+	if(i == *tlist++) {
+	  good = 1;
+	  break;
+	}
+      }
+      if(!good) {
+	/* we don't understand it, write it back */
+	DEBUG1(("We don't understand option 0x%02x\n",i));
+	bad = 1;
+	*tptr++ = i;
+	j = *tptr++ = *bptr++;
+	for(i = 0; i < j - 2; ++i) {
+	  *tptr++ = *bptr++;
+	}
+      } else {
+	/* advance over to next option */
+	bptr += *bptr - 1;
+      }
+  }
+  
+  /* Bad? if we we need to send a config Reject */
+  if(bad) {
+    /* write the config Rej packet we've built above, take on the header */
+    bptr = buffer;
+    *bptr++ = CONF_REJ;		/* Write Conf_rej */
+    bptr++;			/* skip over ID */
+    *bptr++ = 0;
+    *bptr = tptr - buffer;
+    /* length right here? */
+		
+    /* write the reject frame */
+    DEBUG1(("Writing Reject frame --\n"));
+    ahdlc_tx(protocol, buffer, 0, (u16_t)(tptr - buffer), 0);
+    DEBUG1(("\nEnd writing reject \n"));
+    
+  }		
+  return bad;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/ppp/ppp.h b/contiki/ppp/ppp.h
new file mode 100644
index 0000000..c9991fe
--- /dev/null
+++ b/contiki/ppp/ppp.h
@@ -0,0 +1,135 @@
+#ifndef __PPP_H__
+#define __PPP_H__
+/*																www.mycal.net
+---------------------------------------------------------------------------
+ ppp.h - ppp header file      									 
+---------------------------------------------------------------------------
+ Version                                                                 
+ 0.1 Original Version June 3, 2000					      
+ (c)2000 Mycal Labs, All Rights Reserved	     
+ --------------------------------------------------------------------------- */
+/*
+ * Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Mike Johnson/Mycal Labs
+ *		www.mycal.net.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Mycal Modified uIP TCP/IP stack.
+ *
+ * $Id: ppp.h,v 1.4 2005/01/26 23:36:22 oliverschmidt Exp $
+ *
+ */
+#include "uip.h"
+#include "ppp-conf.h"
+#include "ahdlc.h"
+#include "lcp.h"
+#include "ipcp.h"
+#include "pap.h"
+#include "ppp_arch.h"
+/*#include "mip.h"*/
+
+/* moved to pppconfig.h
+#define PPP_RX_BUFFER_SIZE	1024 
+#define PPP_TX_BUFFER_SIZE	64*/
+
+#define CRC_GOOD_VALUE		0xf0b8
+
+/* ppp_rx_status values */
+#define	PPP_RX_IDLE		0
+#define PPP_READY		1
+
+/* ppp flags */
+#define PPP_ESCAPED		0x1
+#define	PPP_RX_READY		0x2
+#define	PPP_RX_ASYNC_MAP	0x8
+#define PPP_TX_ASYNC_MAP	0x8
+#define PPP_PFC			0x10
+#define PPP_ACFC		0x20
+
+/* Supported PPP Protocols */
+#define LCP			0xc021
+#define PAP			0xc023
+#define IPCP			0x8021
+#define	IPV4			0x0021
+
+/* LCP codes packet types */
+#define CONF_REQ		0x1			
+#define CONF_ACK		0x2
+#define CONF_NAK		0x3
+#define CONF_REJ		0x4
+#define TERM_REQ		0x5
+#define TERM_ACK		0x6
+#define PROT_REJ		0x8
+
+/* Raise PPP config bits */
+#define USE_PAP			0x1
+#define USE_NOACCMBUG		0x2
+#define USE_GETDNS		0x4
+
+#define ppp_setusername(un)	strncpy(pap_username, (un), PAP_USERNAME_SIZE)
+#define ppp_setpassword(pw)	strncpy(pap_password, (pw), PAP_PASSWORD_SIZE)
+
+/*
+ * Export Variables
+ */
+/*extern u8_t ppp_tx_buffer[PPP_TX_BUFFER_SIZE];*/
+extern u8_t ppp_rx_buffer[];
+extern u8_t ppp_rx_count;
+
+typedef union {
+  u8_t ip8[4];
+  u16_t ip16[2];
+} uip_ipaddr_t;
+
+extern uip_ipaddr_t our_ipaddr;
+
+/*extern u16_t ppp_crc_error;*/
+
+extern u8_t ppp_flags;
+extern u8_t ppp_status;
+/*extern u16_t ppp_rx_crc; */
+extern u16_t ppp_rx_tobig_error;
+extern u8_t ppp_lcp_state;
+
+extern u8_t ppp_id;
+extern u8_t ppp_retry;
+
+/*
+ * Function Prototypes
+ */
+void ppp_init(void);
+void ppp_connect(void);
+
+void ppp_send(void);
+void ppp_poll(void);
+
+void ppp_upcall(u16_t, u8_t *, u16_t);
+u16_t scan_packet(u16_t, u8_t *list, u8_t *buffer, u8_t *options, u16_t len);
+
+#endif /* __PPP_H__ */
diff --git a/contiki/uip/FILES b/contiki/uip/FILES
new file mode 100644
index 0000000..fea1922
--- /dev/null
+++ b/contiki/uip/FILES
@@ -0,0 +1,65 @@
+The contiki/uip/ directory contains the source code for the uIP TCP/IP
+stack and associated utility libraries.
+
+dhcpc.[ch]
+
+  A rudimentary DHCP client.
+
+packet-service.h
+
+  The Contiki/uIP packet driver interface, used by network device
+  drivers.
+  
+packet-service.c.example
+
+  An example implementation of the packet driver interface.
+
+resolv.[ch]
+
+  DNS hostname resolver library.
+
+slipdev.[ch]
+
+  A generic SLIP implementation.
+
+socket.[ch]
+
+  A BSD socket-like API built on top of the uIP API using
+  protothreads.
+
+tcpip.[ch]
+
+  The glue module between Contiki and uIP.
+
+uip-fw*.[ch]
+
+  uIP packet routing/forwarding.
+
+uip-split.[ch]
+
+  uIP TCP throughput booster hack.
+
+uip.[ch]
+
+  The uIP TCP/IP stack.
+
+uip_arch.h
+
+  The uIP architecture dependant functions interface.
+
+uip_arp.[ch]
+
+  ARP protocol implementation.
+
+uipbuf.[ch]
+
+  uIP input buffering utility functions.
+
+uiplib.[ch]
+
+  uIP conversion utility functions.
+
+uipopt.h
+
+  uIP options file with Contiki-specific settings.    
+            
\ No newline at end of file
diff --git a/contiki/uip/dhcpc.c b/contiki/uip/dhcpc.c
new file mode 100644
index 0000000..932f1f7
--- /dev/null
+++ b/contiki/uip/dhcpc.c
@@ -0,0 +1,312 @@
+
+#include "contiki.h"
+#include "dhcpc.h"
+#include "uip_arp.h"
+#include "pt.h"
+
+#include <string.h>
+
+#define STATE_INITIAL         0
+#define STATE_SENDING         1
+#define STATE_OFFER_RECEIVED  2
+#define STATE_CONFIG_RECEIVED 3
+
+static struct {
+  struct pt pt;
+  char state;
+  struct uip_udp_conn *conn;
+  struct timer timer;
+  u16_t secs;
+  
+  u8_t serverid[4];
+  
+  u16_t ipaddr[2];
+  u16_t netmask[2];
+  u16_t dnsaddr[2];
+  u16_t default_router[2];
+} s;
+
+struct dhcp_msg {
+  u8_t op, htype, hlen, hops;
+  u8_t xid[4];
+  u16_t secs, flags;
+  u8_t ciaddr[4];
+  u8_t yiaddr[4];
+  u8_t siaddr[4];
+  u8_t giaddr[4];
+  u8_t chaddr[16];
+  u8_t sname[64];
+  u8_t file[128];
+  u8_t options[312];
+};
+#define DHCP_REQUEST        1
+#define DHCP_REPLY          2
+#define DHCP_HTYPE_ETHERNET 1
+#define DHCP_HLEN_ETHERNET  6
+#define DHCP_MSG_LEN      236
+
+#define DHCPC_SERVER_PORT  67
+#define DHCPC_CLIENT_PORT  68
+
+#define DHCPDISCOVER  1
+#define DHCPOFFER     2
+#define DHCPREQUEST   3
+#define DHCPDECLINE   4
+#define DHCPACK       5
+#define DHCPNAK       6
+#define DHCPRELEASE   7 
+
+#define DHCP_OPTION_SUBNET_MASK   1
+#define DHCP_OPTION_ROUTER        3
+#define DHCP_OPTION_DNS_SERVER    6
+#define DHCP_OPTION_REQ_IPADDR   50
+#define DHCP_OPTION_MSG_TYPE     53
+#define DHCP_OPTION_SERVER_ID    54
+#define DHCP_OPTION_REQ_LIST     55
+#define DHCP_OPTION_END         255
+
+static const u8_t xid[4] = {0xad, 0xde, 0x12, 0x23};
+static const u8_t magic_cookie[4] = {99, 130, 83, 99};
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_msg_type(u8_t *optptr, u8_t type)
+{
+  *optptr++ = DHCP_OPTION_MSG_TYPE;
+  *optptr++ = 1;
+  *optptr++ = type;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_server_id(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_SERVER_ID;
+  *optptr++ = 4;
+  memcpy(optptr, s.serverid, 4);  
+  return optptr + 4;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_req_ipaddr(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_REQ_IPADDR;
+  *optptr++ = 4;
+  memcpy(optptr, s.ipaddr, 4);  
+  return optptr + 4;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_req_options(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_REQ_LIST;
+  *optptr++ = 3;
+  *optptr++ = DHCP_OPTION_SUBNET_MASK;
+  *optptr++ = DHCP_OPTION_ROUTER;
+  *optptr++ = DHCP_OPTION_DNS_SERVER;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static u8_t *
+add_end(u8_t *optptr)
+{
+  *optptr++ = DHCP_OPTION_END;
+  return optptr;
+}
+/*---------------------------------------------------------------------------*/
+static void
+create_msg(register struct dhcp_msg *m)
+{
+  m->op = DHCP_REQUEST;
+  m->htype = DHCP_HTYPE_ETHERNET;
+  m->hlen = DHCP_HLEN_ETHERNET;
+  m->hops = 0;
+  memcpy(m->xid, xid, sizeof(m->xid));
+  m->secs = 0;
+  m->flags = 0;
+  /*  uip_ipaddr_copy(m->ciaddr, uip_hostaddr);*/
+  memcpy(m->ciaddr, uip_hostaddr, sizeof(m->ciaddr));
+  memset(m->yiaddr, 0, sizeof(m->yiaddr));
+  memset(m->siaddr, 0, sizeof(m->siaddr));
+  memset(m->giaddr, 0, sizeof(m->giaddr));
+  memcpy(m->chaddr, &uip_ethaddr, 6);
+  memset(&m->chaddr[6], 0, 10);
+  memset(m->sname, 0, sizeof(m->sname));
+  memset(m->file, 0, sizeof(m->file));
+
+  memcpy(m->options, magic_cookie, sizeof(magic_cookie));
+}
+/*---------------------------------------------------------------------------*/
+static void
+send_discover(void)
+{
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+
+  create_msg(m);
+
+  add_end(add_req_options(add_msg_type(&m->options[4], DHCPDISCOVER)));
+
+
+  uip_udp_send(300);
+}
+/*---------------------------------------------------------------------------*/
+static void
+send_request(void)
+{
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+
+  create_msg(m);
+  
+  add_end(add_req_ipaddr(add_server_id(add_msg_type(&m->options[4],
+						    DHCPREQUEST))));
+  
+  uip_udp_send(300);
+}
+/*---------------------------------------------------------------------------*/
+static u8_t
+parse_options(u8_t *optptr, int len)
+{
+  u8_t *optptr2;
+  u8_t type;
+
+  type = 0;
+  optptr2 = NULL;
+  
+  while(*optptr != DHCP_OPTION_END) {
+    switch(*optptr) {
+    case DHCP_OPTION_SUBNET_MASK:
+      memcpy(s.netmask, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_ROUTER:
+      memcpy(s.default_router, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_DNS_SERVER:
+      memcpy(s.dnsaddr, optptr + 2, 4);
+      break;
+    case DHCP_OPTION_MSG_TYPE:
+      type = *(optptr + 2);
+      break;
+    case DHCP_OPTION_SERVER_ID:
+      memcpy(s.serverid, optptr + 2, 4);
+      break;
+    }
+
+    /*    printf("option type %d len %d\n", *optptr, *(optptr + 1));*/
+    len -= *(optptr + 1) + 2;
+    optptr += *(optptr + 1) + 2;
+    if(len <= 0) {
+      return 0;
+    }
+
+    if(optptr == optptr2) {
+      /* Abort if we don't make progress. */
+      return 0;
+    }
+  }
+  return type;
+}
+/*---------------------------------------------------------------------------*/
+static void
+parse_msg(void)
+{
+  struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
+  
+  if(m->op == DHCP_REPLY &&
+     memcmp(m->xid, xid, sizeof(xid)) == 0/* &&
+					     memcmp(m->chaddr, &uip_ethaddr, sizeof(uip_ethaddr))*/) {
+    memcpy(s.ipaddr, m->yiaddr, 4);
+    parse_options(&m->options[4], uip_datalen());
+  }
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_dhcp(void))
+{
+  PT_BEGIN(&s.pt);
+  
+  PT_WAIT_UNTIL(&s.pt, s.state == STATE_SENDING);
+
+  s.secs = 0;
+  timer_set(&s.timer, CLOCK_SECOND * 2);
+
+  while(s.state != STATE_OFFER_RECEIVED) {
+    send_discover();
+    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
+
+    timer_reset(&s.timer);
+    
+    if(uip_newdata()) {
+      parse_msg();
+      s.state = STATE_OFFER_RECEIVED;
+    }
+    ++s.secs;
+  }
+  
+  while(s.state != STATE_CONFIG_RECEIVED) {
+    
+    send_request();
+    
+    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
+
+    timer_reset(&s.timer);
+    
+    if(uip_newdata()) {
+      s.state = STATE_CONFIG_RECEIVED;
+    }
+    ++s.secs;
+  }
+  
+  /*  printf("Got IP address %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),
+	 uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));
+  printf("Got netmask %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),
+	 uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));
+  printf("Got DNS server %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),
+	 uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));
+  printf("Got default router %d.%d.%d.%d\n",
+	 uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),
+	 uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));*/
+
+  uip_sethostaddr(s.ipaddr);
+  uip_setnetmask(s.netmask);
+  uip_setdraddr(s.default_router);
+  resolv_conf(s.dnsaddr);
+  dhcpc_configured();
+  
+  PT_END(&s.pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_init(void)
+{
+  u16_t addr[2];
+  
+  s.state = STATE_INITIAL;
+  uip_ipaddr(addr, 255,255,255,255);
+  s.conn = udp_new(addr, HTONS(DHCPC_SERVER_PORT), NULL);
+  if(s.conn != NULL) {
+    udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
+  }
+  PT_INIT(&s.pt);
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_appcall(void *state)
+{
+  handle_dhcp();
+}
+/*---------------------------------------------------------------------------*/
+void
+dhcpc_request(void)
+{
+  u16_t ipaddr[2];
+  
+  if(s.state == STATE_INITIAL) {
+    uip_ipaddr(ipaddr, 0,0,0,0);
+    uip_sethostaddr(ipaddr);
+    s.state = STATE_SENDING;
+    tcpip_poll_udp(s.conn);
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/dhcpc.h b/contiki/uip/dhcpc.h
new file mode 100644
index 0000000..d0cdf11
--- /dev/null
+++ b/contiki/uip/dhcpc.h
@@ -0,0 +1,11 @@
+#ifndef __DHCPC_H__
+#define __DHCPC_H__
+
+void dhcpc_init(void);
+void dhcpc_request(void);
+
+void dhcpc_appcall(void *state);
+
+void dhcpc_configured(void);
+
+#endif /* __DHCPC_H__ */
diff --git a/contiki/uip/packet-service.c.example b/contiki/uip/packet-service.c.example
new file mode 100644
index 0000000..b3824a8
--- /dev/null
+++ b/contiki/uip/packet-service.c.example
@@ -0,0 +1,54 @@
+
+#include "packet-service.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct tcpip_packetservice_state state =
+  {
+    TCPIP_PACKETSERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, TCPIP_PACKETSERVICE_NAME, EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(packet_service_init, arg)
+{
+  ek_service_start(tcpip_packetservice_name, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  printf("packet-service: output (%p, %d) (%p, %d)\n",
+	 hdr, hdrlen, data, datalen);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  printf("packet-service: event %d\n", ev);
+  switch(ev) {
+  case EK_EVENT_STARTED:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, state);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/packet-service.h b/contiki/uip/packet-service.h
new file mode 100644
index 0000000..05220b7
--- /dev/null
+++ b/contiki/uip/packet-service.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: packet-service.h,v 1.3 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+#ifndef __PACKET_SERVICE_H__
+#define __PACKET_SERVICE_H__
+
+#include "ek-service.h"
+
+#include "uip.h"
+
+/* Packet service interface. */
+
+#define PACKET_SERVICE_NAME "Packet driver"
+#define PACKET_SERVICE_VERSION 0x01
+struct packet_service_state {
+  u8_t version;
+  void (* output)(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+};
+
+EK_PROCESS_INIT(packet_service_init, arg);
+
+#endif /* __PACKET_SERVICE_H__ */
diff --git a/contiki/uip/psock.c b/contiki/uip/psock.c
new file mode 100644
index 0000000..4e5daaf
--- /dev/null
+++ b/contiki/uip/psock.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: psock.c,v 1.1 2005/02/22 22:23:07 adamdunkels Exp $
+ */
+
+#include "psock.h"
+
+#define PSOCK_STATE_NONE 0
+#define PSOCK_STATE_ACKED 1
+#define PSOCK_STATE_READ 2
+#define PSOCK_STATE_BLOCKED_NEWDATA 3
+#define PSOCK_STATE_BLOCKED_CLOSE 4
+#define PSOCK_STATE_BLOCKED_SEND 5
+#define PSOCK_STATE_DATA_SENT 6
+
+/*---------------------------------------------------------------------------*/
+static char
+send_data(register struct psock *s)
+{
+  if(s->state != PSOCK_STATE_DATA_SENT || uip_rexmit()) {
+    if(s->sendlen > uip_mss()) {
+      uip_send(s->sendptr, uip_mss());
+    } else {
+      uip_send(s->sendptr, s->sendlen);
+    }
+    s->state = PSOCK_STATE_DATA_SENT;
+    return 1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+static char
+data_sent(register struct psock *s)
+{
+  if(s->state == PSOCK_STATE_DATA_SENT && uip_acked()) {
+    if(s->sendlen > uip_mss()) {
+      s->sendlen -= uip_mss();
+      s->sendptr += uip_mss();
+    } else {
+      s->sendptr += s->sendlen;
+      s->sendlen = 0;
+    }
+    s->state = PSOCK_STATE_ACKED;
+    return 1;
+  }
+  return 0;
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_send(register struct psock *s, const char *buf, unsigned int len))
+{
+  PT_BEGIN(&s->psockpt);
+
+  if(len == 0) {
+    PT_EXIT(&s->psockpt);
+  }
+  
+  s->sendptr = buf;
+  s->sendlen = len;
+
+  s->state = PSOCK_STATE_NONE;
+  
+  while(s->sendlen > 0) {
+    PT_WAIT_UNTIL(&s->psockpt, data_sent(s) & send_data(s));
+  }
+
+  s->state = PSOCK_STATE_NONE;
+  
+  PT_END(&s->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_generator_send(register struct psock *s,
+			       unsigned short (*generate)(void *), void *arg))
+{
+  PT_BEGIN(&s->psockpt);
+
+  if(generate == NULL) {
+    PT_EXIT(&s->psockpt);
+  }
+  
+  s->state = PSOCK_STATE_NONE;
+  s->sendlen = generate(arg);
+  s->sendptr = uip_appdata;
+  do {
+
+    if(uip_rexmit()) {
+      generate(arg);
+    }
+    PT_WAIT_UNTIL(&s->psockpt, data_sent(s) & send_data(s));
+  } while(s->sendlen > 0);    
+  
+  s->state = PSOCK_STATE_NONE;
+  
+  PT_END(&s->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+char
+psock_newdata(struct psock *s)
+{
+  if(s->readlen > 0) {
+    /* Data in uip_appdata buffer that has not yet been read. */
+    return 1;
+  } else if(s->state == PSOCK_STATE_READ) {
+    /* Data in uip_appdata buffer already consumed. */
+    s->state = PSOCK_STATE_BLOCKED_NEWDATA;
+    return 0;
+  } else if(uip_newdata()) {
+    /* There is new data that has not been consumed. */
+    return 1;
+  } else {
+    /* There is no new data. */
+    return 0;
+  }
+}
+/*---------------------------------------------------------------------------*/
+PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
+{
+  PT_BEGIN(&psock->psockpt);
+
+  uipbuf_setup(&psock->buf, psock->bufptr, psock->bufsize);
+  
+  /* XXX: Should add uipbuf_checkmarker() before do{} loop, if
+     incoming data has been handled while waiting for a write. */
+
+  do {
+    if(psock->readlen == 0) {
+      PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
+      psock->state = PSOCK_STATE_READ;
+      psock->readptr = (u8_t *)uip_appdata;
+      psock->readlen = uip_datalen();
+    }
+  } while((uipbuf_bufto(&psock->buf, c,
+			&psock->readptr,
+			&psock->readlen) & UIPBUF_FOUND) == 0);
+
+  if(uipbuf_len(&psock->buf) == 0) {
+    psock->state = PSOCK_STATE_NONE;
+    PT_RESTART(&psock->psockpt);
+  }  
+  PT_END(&psock->psockpt);
+}
+/*---------------------------------------------------------------------------*/
+void
+psock_init(register struct psock *psock, char *buffer, unsigned int buffersize)
+{
+  psock->state = PSOCK_STATE_NONE;
+  psock->readlen = 0;
+  psock->bufptr = buffer;
+  psock->bufsize = buffersize;
+  uipbuf_setup(&psock->buf, buffer, buffersize);
+  PT_INIT(&psock->pt);
+  PT_INIT(&psock->psockpt);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/psock.h b/contiki/uip/psock.h
new file mode 100644
index 0000000..287bf44
--- /dev/null
+++ b/contiki/uip/psock.h
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: psock.h,v 1.1 2005/02/22 22:23:07 adamdunkels Exp $
+ */
+
+/**
+ * \defgroup psock Protosockets library
+ * @{
+ *
+ * The protosocket library provides an interface to the uIP stack that is
+ * similar to the traditional BSD socket interface. Unlike programs
+ * written for the ordinary uIP event-driven interface, programs
+ * written with the protosocket library are executed in a sequential
+ * fashion and does not have to be implemented as explicit state
+ * machines.
+ *
+ * Protosockets only work with TCP connections. 
+ *
+ * The protosocket library uses \ref pt protothreads to provide
+ * sequential control flow. This makes the protosockets lightweight in
+ * terms of memory, but also means that protosockets inherits the
+ * functional limitations of protothreads. Each protosocket lives only
+ * within a single function block. Automatic variables (stack
+ * variables) are not necessarily retained across a protosocket
+ * library function call.
+ *
+ * \note Because the protosocket library uses protothreads, local variables
+ * will not always be saved across a call to a protosocket library
+ * function. It is therefore advised that local variables are used
+ * with extreme care.
+ *
+ * The protosocket library provides functions for sending data without
+ * having to deal with retransmissions and acknowledgements, as well
+ * as functions for reading data without having to deal with data
+ * being split across more than one TCP segment.
+ *
+ * Because each protosocket runs as a protothread, the protosocket has to be
+ * started with a call to PSOCK_BEGIN() at the start of the function
+ * in which the protosocket is used. Similarly, the protosocket protothread can
+ * be terminated by a call to PSOCK_EXIT().
+ *
+ * The example code below illustrates how to use the protosocket
+ * library. The program implements a simple SMTP client that sends a
+ * short email. The program is divided into two functions, one uIP
+ * event handler (smtp_uipcall()) and one function that runs the
+ * protosocket protothread and performs the SMTP communication
+ * (smtp_socketthread()).
+ *
+ * An SMTP connection is represented by a smtp_state structure
+ * containing a struct psock and a small input buffer. The input
+ * buffer only needs to be 3 bytes long to accomodate the 3 byte
+ * status codes used by SMTP. Connection structures can be allocated
+ * from the memory buffer called connections, which is declared with
+ * the MEMB() macro.
+ *
+ * The convenience macro SEND_STRING() is defined in order to simplify
+ * the code, as it mostly involves sending strings.
+ *  
+ * The function smtp_socketthread() is declared as a protothread using
+ * the PT_THREAD() macro. The PSOCK_BEGIN() call at the first line of
+ * the smtp_socketthread() function starts the protothread. SMTP
+ * specifies that the server will start with sending a welcome message
+ * that should include the status code 220 if the server is ready to
+ * accept messages. Therefore, the smtp_socketthread() first calls
+ * PSOCK_READTO() to read all incoming data up to the first
+ * newline. If the status code was anything else but 220, the protosocket
+ * is closed and the protosocket's protothread is terminated with the call
+ * to PSOCK_CLOSE_EXIT().
+ *
+ * If the connection is accepted by the server, smtp_socketthread()
+ * continues with sending the HELO message. If this gets a positive
+ * reply (a status code beginning with a 2), the protothread moves on
+ * with the rest of the SMTP procedure. Finally, after all headers and
+ * data is sent, the program sends a QUIT before it finally closes the
+ * protosocket and exits the protosocket's protothread.
+ * 
+ *
+ \code
+#include <string.h>
+
+#include "psock.h"
+#include "memb.h"
+
+struct smtp_state {  
+  struct psock psock;
+  char inputbuffer[3];
+};
+
+MEMB(connections, sizeof(struct smtp_state), 2);
+
+#define SEND_STRING(s, str) PSOCK_SEND(s, str, strlen(str))
+
+static
+PT_THREAD(smtp_socketthread(struct smtp_state *s))
+{
+  PSOCK_BEGIN(&s->psock);
+
+  PSOCK_READTO(&s->psock, '\n');
+   
+  if(strncmp(s->inputbuffer, "220", 3) != 0) {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+
+  SEND_STRING(&s->psock, "HELO contiki.example.com\r\n");
+
+  PSOCK_READTO(&s->psock, '\n');  
+  if(s->inputbuffer[0] != '2') {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+
+  SEND_STRING(&s->psock, "MAIL FROM: contiki@example.com\r\n");
+
+  PSOCK_READTO(&s->psock, '\n');  
+  if(s->inputbuffer[0] != '2') {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+
+  SEND_STRING(&s->psock, "RCPT TO: contiki@example.com\r\n");
+
+  PSOCK_READTO(&s->psock, '\n');  
+  if(s->inputbuffer[0] != '2') {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+  
+  SEND_STRING(&s->psock, "DATA\r\n");
+  
+  PSOCK_READTO(&s->psock, '\n');
+  if(s->inputbuffer[0] != '3') {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+
+  SEND_STRING(&s->psock, "To: contiki@example.com\r\n");
+  SEND_STRING(&s->psock, "From: contiki@example.com\r\n");
+  SEND_STRING(&s->psock, "Subject: Example\r\n");
+
+  SEND_STRING(&s->psock, "A test message from Contiki.\r\n");
+  
+  SEND_STRING(&s->psock, "\r\n.\r\n");
+
+  PSOCK_READTO(&s->psock, '\n');  
+  if(s->inputbuffer[0] != '2') {
+    PSOCK_CLOSE_EXIT(&s->psock);
+  }
+
+  SEND_STRING(&s->psock, "QUIT\r\n");
+  
+  PSOCK_END(&s->psock);
+}
+
+void
+smtp_uipcall(void *state)
+{
+  struct smtp_state *s = (struct smtp_state *)state;
+  
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    memb_free(&connections, s);
+  } else if(uip_connected()) {
+    PSOCK_INIT(s, s->inputbuffer, sizeof(s->inputbuffer));
+  } else {
+    smtp_socketthread(s);
+  }
+}
+ \endcode
+ *
+ */
+
+/**
+ * \file
+ * Protosocket library header file
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __PSOCK_H__
+#define __PSOCK_H__
+
+#include "pt.h"
+#include "uipbuf.h"
+#include "memb.h"
+
+/**
+ * The representation of a protosocket.
+ *
+ * The protosocket structrure is an opaque structure with no user-visible
+ * elements.
+ */
+struct psock {
+  struct pt pt, psockpt;
+  unsigned char state;
+  const u8_t *sendptr;
+  u16_t sendlen;
+  u8_t *readptr;
+  u16_t readlen;
+
+  struct uipbuf_buffer buf;
+  char *bufptr;
+  unsigned int bufsize;
+};
+
+void psock_init(struct psock *psock, char *buffer, unsigned int buffersize);
+/**
+ * Initialize a protosocket.
+ *
+ * This macro initializes a protosocket and must be called before the
+ * protosocket is used. The initialization also specifies the input buffer
+ * for the protosocket.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket to be
+ * initialized
+ *
+ * \param buffer (char *) A pointer to the input buffer for the
+ * protosocket.
+ *
+ * \param buffersize (unsigned int) The size of the input buffer.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_INIT(psock, buffer, buffersize) \
+  psock_init(psock, buffer, buffersize)
+
+/**
+ * Start the protosocket protothread in a function.
+ *
+ * This macro starts the protothread associated with the protosocket and
+ * must come before other protosocket calls in the function it is used.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket to be
+ * started.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt))
+
+PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len));
+/**
+ * Send data.
+ *
+ * This macro sends data over a protosocket. The protosocket protothread blocks
+ * until all data has been sent and is known to have been received by
+ * the remote end of the TCP connection.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket over which
+ * data is to be sent.
+ *
+ * \param data (char *) A pointer to the data that is to be sent.
+ *
+ * \param datalen (unsigned int) The length of the data that is to be
+ * sent.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_SEND(psock, data, datalen)		\
+    PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, data, datalen))
+
+PT_THREAD(psock_generator_send(struct psock *psock,
+				unsigned short (*f)(void *), void *arg));
+
+#define PSOCK_GENERATOR_SEND(psock, generator, arg)     \
+    PT_WAIT_THREAD(&((psock)->pt),					\
+		   psock_generator_send(psock, generator, arg))
+
+
+/*PT_THREAD(psock_closew(struct psock *psock));
+#define PSOCK_CLOSEW(psock)				\
+  PT_WAIT_THREAD(&(psock)->pt, psock_closew(psock))
+*/
+
+/**
+ * Close a protosocket.
+ *
+ * This macro closes a protosocket and can only be called from within the
+ * protothread in which the protosocket lives.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket that is to
+ * be closed.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_CLOSE(psock) uip_close()
+
+PT_THREAD(psock_readto(struct psock *psock, unsigned char c));
+
+/**
+ * Read data up to a specified character.
+ *
+ * This macro will block waiting for data and read the data into the
+ * input buffer specified with the call to PSOCK_INIT(). Data is only
+ * read until the specifieed character appears in the data stream.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket from which
+ * data should be read.
+ *
+ * \param c (char) The character at which to stop reading.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_READTO(psock, c)				\
+  PT_WAIT_THREAD(&((psock)->pt), psock_readto(psock, c))
+
+/**
+ * The length of the data that was previously read.
+ *
+ * This macro returns the length of the data that was previously read
+ * using PSOCK_READTO() or PSOCK_READ().
+ *
+ * \param psock (struct psock *) A pointer to the protosocket holding the data.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_DATALEN(psock) uipbuf_len(&(psock)->buf)
+
+/**
+ * Exit the protosocket's protothread.
+ *
+ * This macro terminates the protothread of the protosocket and should
+ * almost always be used in conjunction with PSOCK_CLOSE().
+ *
+ * \sa PSOCK_CLOSE_EXIT()
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_EXIT(psock) PT_EXIT(&((psock)->pt))
+
+/**
+ * Close a protosocket and exit the protosocket's protothread.
+ *
+ * This macro closes a protosocket and exits the protosocket's protothread.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_CLOSE_EXIT(psock)		\
+  do {						\
+    PSOCK_CLOSE(psock);			\
+    PSOCK_EXIT(psock);			\
+  } while(0)
+
+#define PSOCK_END(psock) PT_END(&((psock)->pt))
+
+char psock_newdata(struct psock *s);
+
+/**
+ * Check if new data has arrived on a protosocket.
+ *
+ * This macro is used in conjunction with the PSOCK_WAIT_UNTIL()
+ * macro to check if data has arrived on a protosocket.
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_NEWDATA(psock) psock_newdata(psock)
+
+/**
+ * Wait until a condition is true.
+ *
+ * This macro blocks the protothread until the specified condition is
+ * true. The macro PSOCK_NEWDATA() can be used to check if new data
+ * arrives when the protosocket is waiting.
+ *
+ * Typically, this macro is used as follows:
+ *
+ \code
+ PT_THREAD(thread(struct psock *s, struct timer *t))
+ {
+   PSOCK_BEGIN(s);
+
+   PSOCK_WAIT_UNTIL(s, PSOCK_NEWADATA(s) || timer_expired(t));
+   
+   if(PSOCK_NEWDATA(s)) {
+     PSOCK_READTO(s, '\n');
+   } else {
+     handle_timed_out(s);
+   }
+   
+   PSOCK_END(s);
+ }
+ \endcode 
+ *
+ * \param psock (struct psock *) A pointer to the protosocket.
+ * \param condition The condition to wait for.
+ *
+ * \hideinitializer
+ */
+#define PSOCK_WAIT_UNTIL(psock, condition)    \
+  PT_WAIT_UNTIL(&((psock)->pt), (condition));
+
+#define PSOCK_WAIT_THREAD(psock, condition)   \
+  PT_WAIT_THREAD(&((psock)->pt), (condition))
+
+#endif /* __PSOCK_H__ */
diff --git a/contiki/uip/resolv.c b/contiki/uip/resolv.c
new file mode 100644
index 0000000..2af92f0
--- /dev/null
+++ b/contiki/uip/resolv.c
@@ -0,0 +1,510 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uipdns uIP hostname resolver functions
+ * @{
+ *
+ * The uIP DNS resolver functions are used to lookup a hostname and
+ * map it to a numerical IP address. It maintains a list of resolved
+ * hostnames that can be queried with the resolv_lookup()
+ * function. New hostnames can be resolved using the resolv_query()
+ * function.
+ *
+ * The event resolv_event_found is posted when a hostname has been
+ * resolved. It is up to the receiving process to determine if the
+ * correct hostname has been found by calling the resolv_lookup()
+ * function with the hostname.
+ */
+
+/**
+ * \file
+ * DNS host name to IP address resolver.
+ * \author Adam Dunkels <adam@dunkels.com>
+ * 
+ * This file implements a DNS host name to IP address resolver.
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: resolv.c,v 1.15 2005/02/07 07:08:03 adamdunkels Exp $
+ *
+ */
+
+#include "ek.h"
+#include "tcpip.h"
+#include "resolv.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+/** \internal The maximum number of retries when asking for a name. */
+#define MAX_RETRIES 8
+
+/** \internal The DNS message header. */
+struct dns_hdr {
+  u16_t id;
+  u8_t flags1, flags2;
+#define DNS_FLAG1_RESPONSE        0x80
+#define DNS_FLAG1_OPCODE_STATUS   0x10
+#define DNS_FLAG1_OPCODE_INVERSE  0x08
+#define DNS_FLAG1_OPCODE_STANDARD 0x00
+#define DNS_FLAG1_AUTHORATIVE     0x04
+#define DNS_FLAG1_TRUNC           0x02
+#define DNS_FLAG1_RD              0x01
+#define DNS_FLAG2_RA              0x80
+#define DNS_FLAG2_ERR_MASK        0x0f
+#define DNS_FLAG2_ERR_NONE        0x00
+#define DNS_FLAG2_ERR_NAME        0x03
+  u16_t numquestions;
+  u16_t numanswers;
+  u16_t numauthrr;
+  u16_t numextrarr;
+};
+
+/** \internal The DNS answer message structure. */
+struct dns_answer {
+  /* DNS answer record starts with either a domain name or a pointer
+     to a name already present somewhere in the packet. */
+  u16_t type;
+  u16_t class;
+  u16_t ttl[2];
+  u16_t len;
+  u16_t ipaddr[2];
+};
+
+struct namemap {
+#define STATE_UNUSED 0
+#define STATE_NEW    1
+#define STATE_ASKING 2
+#define STATE_DONE   3
+#define STATE_ERROR  4
+  u8_t state;
+  u8_t tmr;
+  u8_t retries;
+  u8_t seqno;
+  u8_t err;
+  char name[32];
+  u16_t ipaddr[2];
+};
+
+#ifndef UIP_CONF_RESOLV_ENTRIES
+#define RESOLV_ENTRIES 4
+#else /* UIP_CONF_RESOLV_ENTRIES */
+#define RESOLV_ENTRIES UIP_CONF_RESOLV_ENTRIES
+#endif /* UIP_CONF_RESOLV_ENTRIES */
+
+
+static struct namemap names[RESOLV_ENTRIES];
+
+static u8_t seqno;
+
+static struct uip_udp_conn *resolv_conn = NULL;
+
+ek_event_t resolv_event_found;
+
+/*static DISPATCHER_UIPCALL(udp_appcall, arg);
+static struct dispatcher_proc p =
+{DISPATCHER_PROC("DNS resolver", NULL, NULL, udp_appcall)};*/
+EK_EVENTHANDLER(resolv_eventhandler, ev, data);
+EK_PROCESS(p, "DNS resolver", EK_PRIO_NORMAL, resolv_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+enum {
+  EVENT_NEW_SERVER=0
+};
+
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Walk through a compact encoded DNS name and return the end of it.
+ *
+ * \return The end of the name.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *
+parse_name(unsigned char *query)
+{
+  unsigned char n;
+
+  do {
+    n = *query++;
+    
+    while(n > 0) {
+      /*      printf("%c", *query);*/
+      ++query;
+      --n;
+    };
+    /*    printf(".");*/
+  } while(*query != 0);
+  /*  printf("\n");*/
+  return query + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Runs through the list of names to see if there are any that have
+ * not yet been queried and, if so, sends out a query.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+check_entries(void)
+{
+  register struct dns_hdr *hdr;
+  char *query, *nptr, *nameptr;
+  static u8_t i;
+  static u8_t n;
+  register struct namemap *namemapptr;
+  
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {    
+    namemapptr = &names[i];
+    if(namemapptr->state == STATE_NEW ||
+       namemapptr->state == STATE_ASKING) {
+      if(namemapptr->state == STATE_ASKING) {
+	if(--namemapptr->tmr == 0) {
+	  if(++namemapptr->retries == MAX_RETRIES) {
+	    namemapptr->state = STATE_ERROR;
+	    resolv_found(namemapptr->name, NULL);
+	    continue;
+	  }
+	  namemapptr->tmr = namemapptr->retries;	  
+	} else {
+	  /*	  printf("Timer %d\n", namemapptr->tmr);*/
+	  /* Its timer has not run out, so we move on to next
+	     entry. */
+	  continue;
+	}
+      } else {
+	namemapptr->state = STATE_ASKING;
+	namemapptr->tmr = 1;
+	namemapptr->retries = 0;
+      }
+      hdr = (struct dns_hdr *)uip_appdata;
+      memset(hdr, 0, sizeof(struct dns_hdr));
+      hdr->id = htons(i);
+      hdr->flags1 = DNS_FLAG1_RD;
+      hdr->numquestions = HTONS(1);
+      query = (char *)uip_appdata + 12;
+      nameptr = namemapptr->name;
+      --nameptr;
+      /* Convert hostname into suitable query format. */
+      do {
+	++nameptr;
+	nptr = query;
+	++query;
+	for(n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr) {
+	  *query = *nameptr;
+	  ++query;
+	  ++n;
+	}
+	*nptr = n;
+      } while(*nameptr != 0);
+      {
+	static unsigned char endquery[] =
+	  {0,0,1,0,1};
+	memcpy(query, endquery, 5);
+      }
+      uip_udp_send((unsigned char)(query + 5 - (char *)uip_appdata));
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Called when new UDP data arrives.
+ */
+/*-----------------------------------------------------------------------------------*/
+static void
+newdata(void)
+{
+  char *nameptr;
+  struct dns_answer *ans;
+  struct dns_hdr *hdr;
+  static u8_t nquestions, nanswers;
+  static u8_t i;
+  register struct namemap *namemapptr;
+  
+  hdr = (struct dns_hdr *)uip_appdata;
+  /*  printf("ID %d\n", htons(hdr->id));
+  printf("Query %d\n", hdr->flags1 & DNS_FLAG1_RESPONSE);
+  printf("Error %d\n", hdr->flags2 & DNS_FLAG2_ERR_MASK);
+  printf("Num questions %d, answers %d, authrr %d, extrarr %d\n",
+	 htons(hdr->numquestions),
+	 htons(hdr->numanswers),
+	 htons(hdr->numauthrr),
+	 htons(hdr->numextrarr));
+  */
+
+  /* The ID in the DNS header should be our entry into the name
+     table. */
+  i = htons(hdr->id);
+  namemapptr = &names[i];
+  if(i < RESOLV_ENTRIES &&
+     namemapptr->state == STATE_ASKING) {
+
+    /* This entry is now finished. */
+    namemapptr->state = STATE_DONE;
+    namemapptr->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
+
+    /* Check for error. If so, call callback to inform. */
+    if(namemapptr->err != 0) {
+      namemapptr->state = STATE_ERROR;
+      resolv_found(namemapptr->name, NULL);
+      return;
+    }
+
+    /* We only care about the question(s) and the answers. The authrr
+       and the extrarr are simply discarded. */
+    nquestions = htons(hdr->numquestions);
+    nanswers = htons(hdr->numanswers);
+
+    /* Skip the name in the question. XXX: This should really be
+       checked agains the name in the question, to be sure that they
+       match. */
+    nameptr = parse_name((char *)uip_appdata + 12) + 4;
+
+    while(nanswers > 0) {
+      /* The first byte in the answer resource record determines if it
+	 is a compressed record or a normal one. */
+      if(*nameptr & 0xc0) {       
+	/* Compressed name. */
+	nameptr +=2;
+	/*	printf("Compressed anwser\n");*/
+      } else {
+	/* Not compressed name. */
+	nameptr = parse_name((char *)nameptr);
+      }
+
+      ans = (struct dns_answer *)nameptr;
+      /*      printf("Answer: type %x, class %x, ttl %x, length %x\n",
+	     htons(ans->type), htons(ans->class), (htons(ans->ttl[0])
+	     << 16) | htons(ans->ttl[1]), htons(ans->len));*/
+
+      /* Check for IP address type and Internet class. Others are
+	 discarded. */
+      if(ans->type == HTONS(1) &&
+	 ans->class == HTONS(1) &&
+	 ans->len == HTONS(4)) {
+	/*	printf("IP address %d.%d.%d.%d\n",
+	       htons(ans->ipaddr[0]) >> 8,
+	       htons(ans->ipaddr[0]) & 0xff,
+	       htons(ans->ipaddr[1]) >> 8,
+	       htons(ans->ipaddr[1]) & 0xff);*/
+	/* XXX: we should really check that this IP address is the one
+	   we want. */
+	namemapptr->ipaddr[0] = ans->ipaddr[0];
+	namemapptr->ipaddr[1] = ans->ipaddr[1];
+	
+	resolv_found(namemapptr->name, namemapptr->ipaddr);
+	return;
+      } else {
+	nameptr = nameptr + 10 + htons(ans->len);
+      }
+      --nanswers;
+    }
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * The main UDP function.
+ */
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(resolv_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  if(ev == EVENT_NEW_SERVER) {
+    if(resolv_conn != NULL) {
+      uip_udp_remove(resolv_conn);
+    }
+    
+    resolv_conn = udp_new((u16_t *)data, HTONS(53), NULL);
+
+  } else if(ev == tcpip_event) {
+    if(uip_udp_conn->rport == HTONS(53)) {
+      if(uip_poll()) {
+	check_entries();
+      }
+      if(uip_newdata()) {
+	newdata();
+      }       
+    }
+  } 
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Queues a name so that a question for the name will be sent out.
+ *
+ * \param name The hostname that is to be queried.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+resolv_query(char *name)
+{
+  static u8_t i;
+  static u8_t lseq, lseqi;
+  register struct namemap *nameptr;
+      
+  lseq = lseqi = 0;
+  
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    nameptr = &names[i];
+    if(nameptr->state == STATE_UNUSED) {
+      break;
+    }
+    if(seqno - nameptr->seqno > lseq) {
+      lseq = seqno - nameptr->seqno;
+      lseqi = i;
+    }
+  }
+
+  if(i == RESOLV_ENTRIES) {
+    i = lseqi;
+    nameptr = &names[i];
+  }
+
+  strncpy(nameptr->name, name, sizeof(nameptr->name));
+  nameptr->state = STATE_NEW;
+  nameptr->seqno = seqno;
+  ++seqno;
+
+  if(resolv_conn != NULL) {
+    tcpip_poll_udp(resolv_conn);
+    /*ek_post(EK_BROADCAST, uip_event_poll_udp, resolv_conn);*/
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Look up a hostname in the array of known hostnames.
+ *
+ * \note This function only looks in the internal array of known
+ * hostnames, it does not send out a query for the hostname if none
+ * was found. The function resolv_query() can be used to send a query
+ * for a hostname.
+ *
+ * \return A pointer to a 4-byte representation of the hostname's IP
+ * address, or NULL if the hostname was not found in the array of
+ * hostnames.
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t *
+resolv_lookup(char *name)
+{
+  static u8_t i;
+  struct namemap *nameptr;
+  
+  /* Walk through the list to see if the name is in there. If it is
+     not, we return NULL. */
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    nameptr = &names[i];
+    if(nameptr->state == STATE_DONE &&
+       strcmp(name, nameptr->name) == 0) {            
+      return nameptr->ipaddr;
+    }
+  }
+  return NULL;
+}  
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Obtain the currently configured DNS server.
+ *
+ * \return A pointer to a 4-byte representation of the IP address of
+ * the currently configured DNS server or NULL if no DNS server has
+ * been configured.
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t *
+resolv_getserver(void)
+{
+  if(resolv_conn == NULL) {
+    return NULL;
+  }
+  return resolv_conn->ripaddr;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Configure a DNS server.
+ *
+ * \param dnsserver A pointer to a 4-byte representation of the IP
+ * address of the DNS server to be configured.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+resolv_conf(u16_t *dnsserver)
+{
+  static u16_t server[2];
+  uip_ipaddr_copy(server, dnsserver);
+  ek_post(id, EVENT_NEW_SERVER, server);
+  
+  /*  if(resolv_conn != NULL) {
+    uip_udp_remove(resolv_conn);
+  }
+  
+  resolv_conn = udp_new(dnsserver, 53, NULL);*/
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initalize the resolver.
+ */
+/*-----------------------------------------------------------------------------------*/
+/*LOADER_INIT_FUNC(resolv_init, arg)*/
+void
+resolv_init(char *arg)
+{
+  static u8_t i;
+  arg_free(arg);
+  
+  id = ek_start(&p);
+  
+  for(i = 0; i < RESOLV_ENTRIES; ++i) {
+    names[i].state = STATE_UNUSED;
+  }
+  resolv_conn = NULL;
+  resolv_event_found = ek_alloc_event();    
+}
+/*-----------------------------------------------------------------------------------*/
+/** \internal
+ * Callback function which is called when a hostname is found.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+resolv_found(char *name, u16_t *ipaddr)
+{
+  ek_post(EK_BROADCAST, resolv_event_found, name);
+}
+/*-----------------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
diff --git a/contiki/uip/resolv.h b/contiki/uip/resolv.h
new file mode 100644
index 0000000..c1067fc
--- /dev/null
+++ b/contiki/uip/resolv.h
@@ -0,0 +1,61 @@
+/**
+ * \file
+ * uIP DNS resolver code header file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: resolv.h,v 1.7 2005/02/07 07:08:03 adamdunkels Exp $
+ *
+ */
+#ifndef __RESOLV_H__
+#define __RESOLV_H__
+
+#include "uip.h"
+
+/**
+ * Event that is broadcasted when a DNS name has been resolved.
+ */
+extern ek_event_t resolv_event_found;
+
+/* Callbacks. */
+void resolv_found(char *name, u16_t *ipaddr);
+
+/* Functions. */
+void resolv_conf(u16_t *dnsserver);
+u16_t *resolv_getserver(void);
+/*LOADER_INIT_FUNC(resolv_init, arg);*/
+void resolv_init(char *arg);
+u16_t *resolv_lookup(char *name);
+void resolv_query(char *name);
+
+#endif /* __RESOLV_H__ */
diff --git a/contiki/uip/slipdev.c b/contiki/uip/slipdev.c
new file mode 100644
index 0000000..f66405f
--- /dev/null
+++ b/contiki/uip/slipdev.c
@@ -0,0 +1,208 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup slip Serial Line IP (SLIP) protocol
+ * @{
+ *
+ * The SLIP protocol is a very simple way to transmit IP packets over
+ * a serial line. It does not provide any framing or error control,
+ * and is therefore not very widely used today.
+ *
+ * This SLIP implementation requires two functions for accessing the
+ * serial device: slipdev_char_poll() and slipdev_char_put(). These
+ * must be implemented specifically for the system on which the SLIP
+ * protocol is to be run.
+ */
+
+/**
+ * \file
+ * SLIP protocol implementation
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: slipdev.c,v 1.2 2003/11/27 15:54:20 adamdunkels Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. 
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include "uip.h"
+#include "uip-fw.h"
+#include "slipdev.h"
+#include <string.h>  /* For memcpy() */
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+static u8_t slip_buf[UIP_BUFSIZE];
+
+static u16_t len, tmplen;
+static u8_t lastc;
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Send the packet in the uip_buf and uip_appdata buffers using the
+ * SLIP protocol.
+ *
+ * The first 40 bytes of the packet (the IP and TCP headers) are read
+ * from the uip_buf buffer, and the following bytes (the application
+ * data) are read from the uip_appdata buffer.
+ *
+ * \return This function will always return UIP_FW_OK.
+ */
+/*-----------------------------------------------------------------------------------*/
+u8_t
+slipdev_send(void)
+{
+  u16_t i;
+  u8_t *ptr;
+  u8_t c;
+
+  slipdev_char_put(SLIP_END);
+
+  ptr = &uip_buf[UIP_LLH_LEN];
+  for(i = 0; i < uip_len; ++i) {
+    if(i == UIP_TCPIP_HLEN) {
+      ptr = (char *)uip_appdata;
+    }
+    c = *ptr++;
+    switch(c) {
+    case SLIP_END:
+      slipdev_char_put(SLIP_ESC);
+      slipdev_char_put(SLIP_ESC_END);
+      break;
+    case SLIP_ESC:
+      slipdev_char_put(SLIP_ESC);
+      slipdev_char_put(SLIP_ESC_ESC);
+      break;
+    default:
+      slipdev_char_put(c);
+      break;
+    }
+  }
+  slipdev_char_put(SLIP_END);
+
+  return UIP_FW_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/** 
+ * Poll the SLIP device for an available packet.
+ *
+ * This function will poll the SLIP device to see if a packet is
+ * available. It uses a buffer in which all avaliable bytes from the
+ * RS232 interface are read into. When a full packet has been read
+ * into the buffer, the packet is copied into the uip_buf buffer and
+ * the length of the packet is returned.
+ *
+ * \return The length of the packet placed in the uip_buf buffer, or
+ * zero if no packet is available.
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+slipdev_poll(void)
+{
+  u8_t c;
+  
+  while(slipdev_char_poll(&c)) {
+    switch(c) {
+    case SLIP_ESC:
+      lastc = c;
+      break;
+      
+    case SLIP_END:
+      lastc = c;
+      /* End marker found, we copy our input buffer to the uip_buf
+	 buffer and return the size of the packet we copied. */
+      memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+      tmplen = len;
+      len = 0;
+      return tmplen;
+      
+    default:     
+      if(lastc == SLIP_ESC) {
+	lastc = c;
+	/* Previous read byte was an escape byte, so this byte will be
+	   interpreted differently from others. */
+	switch(c) {
+	case SLIP_ESC_END:
+	  c = SLIP_END;
+	  break;
+	case SLIP_ESC_ESC:
+	  c = SLIP_ESC;
+	  break;
+	}
+      } else {
+	lastc = c;
+      }
+      
+      slip_buf[len] = c;
+      ++len;
+      
+      if(len > UIP_BUFSIZE) {
+	len = 0;
+      }
+    
+      break;
+    }
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the SLIP module.
+ *
+ * This function does not initialize the underlying RS232 device, but
+ * only the SLIP part.
+ */ 
+/*-----------------------------------------------------------------------------------*/
+void
+slipdev_init(void)
+{
+  lastc = len = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
diff --git a/contiki/uip/slipdev.h b/contiki/uip/slipdev.h
new file mode 100644
index 0000000..f0114f6
--- /dev/null
+++ b/contiki/uip/slipdev.h
@@ -0,0 +1,88 @@
+/**
+ * \addtogroup slip
+ * @{
+ */
+
+/**
+ * \file
+ * SLIP header file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: slipdev.h,v 1.2 2003/11/27 15:54:20 adamdunkels Exp $
+ *
+ */
+
+#ifndef __SLIPDEV_H__
+#define __SLIPDEV_H__
+
+#include "uip.h"
+
+/**
+ * Put a character on the serial device.
+ *
+ * This function is used by the SLIP implementation to put a character
+ * on the serial device. It must be implemented specifically for the
+ * system on which the SLIP implementation is to be run.
+ *
+ * \param c The character to be put on the serial device.
+ */
+void slipdev_char_put(u8_t c);
+
+/**
+ * Poll the serial device for a character.
+ *
+ * This function is used by the SLIP implementation to poll the serial
+ * device for a character. It must be implemented specifically for the
+ * system on which the SLIP implementation is to be run.
+ *
+ * The function should return immediately regardless if a character is
+ * available or not. If a character is available it should be placed
+ * at the memory location pointed to by the pointer supplied by the
+ * arguement c.
+ *
+ * \param c A pointer to a byte that is filled in by the function with
+ * the received character, if available.
+ *
+ * \retval 0 If no character is available.
+ * \retval Non-zero If a character is available.
+ */
+u8_t slipdev_char_poll(u8_t *c);
+
+void slipdev_init(void);
+u8_t slipdev_send(void);
+u16_t slipdev_poll(void);
+
+#endif /* __SLIPDEV_H__ */
+
+/** @} */
diff --git a/contiki/uip/tcpdump.c b/contiki/uip/tcpdump.c
new file mode 100644
index 0000000..226dda8
--- /dev/null
+++ b/contiki/uip/tcpdump.c
@@ -0,0 +1,254 @@
+
+#include "cc.h"
+#include "uip.h"
+
+#include <string.h>
+#include <stdio.h>
+
+ struct ip_hdr {
+  /* IP header. */
+   u8_t vhl,
+    tos,          
+     len[2],       
+     ipid[2],        
+     ipoffset[2],  
+     ttl,          
+     proto;     
+   u16_t ipchksum;
+   u8_t srcipaddr[4], 
+     destipaddr[4];
+ };
+
+#define TCP_FIN 0x01
+#define TCP_SYN 0x02
+#define TCP_RST 0x04
+#define TCP_PSH 0x08
+#define TCP_ACK 0x10
+#define TCP_URG 0x20
+#define TCP_CTL 0x3f
+
+struct tcpip_hdr {
+  /* IP header. */
+   u8_t vhl,
+    tos,          
+     len[2],       
+     ipid[2],        
+     ipoffset[2],  
+     ttl,          
+     proto;     
+   u16_t ipchksum;
+   u8_t srcipaddr[4], 
+     destipaddr[4];
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],  
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];     
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+};
+
+#define ICMP_ECHO_REPLY 0
+#define ICMP_ECHO       8     
+
+struct icmpip_hdr {
+  /* IP header. */
+   u8_t vhl,
+    tos,          
+     len[2],       
+     ipid[2],        
+     ipoffset[2],  
+     ttl,          
+     proto;     
+  u16_t ipchksum;
+  u8_t srcipaddr[4], 
+    destipaddr[4];
+  /* The ICMP and IP headers. */
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+  u16_t id, seqno;  
+};
+
+
+/* The UDP and IP headers. */
+struct udpip_hdr {
+  /* IP header. */
+   u8_t vhl,
+    tos,          
+     len[2],       
+     ipid[2],        
+     ipoffset[2],  
+     ttl,          
+     proto;     
+   u16_t ipchksum;
+  u8_t srcipaddr[4], 
+    destipaddr[4];
+  
+  /* UDP header. */
+  u16_t srcport,
+    destport;
+  u16_t udplen;
+  u16_t udpchksum;
+};
+
+#define ETHBUF    ((struct eth_hdr *)&uip_buf[0])
+#define IPBUF     ((struct ip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define UDPBUF  ((struct udpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define ICMPBUF ((struct icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define TCPBUF  ((struct tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+
+/*---------------------------------------------------------------------------*/
+static void
+tcpflags(unsigned char flags, char *flagsstr)
+{
+  if(flags & TCP_FIN) {
+    *flagsstr++ = 'F';
+  }
+  if(flags & TCP_SYN) {
+    *flagsstr++ = 'S';
+  }
+  if(flags & TCP_RST) {
+    *flagsstr++ = 'R';
+  }
+  if(flags & TCP_ACK) {
+    *flagsstr++ = 'A';
+  }
+  if(flags & TCP_URG) {
+    *flagsstr++ = 'U';
+  }
+
+  *flagsstr = 0;
+}
+/*---------------------------------------------------------------------------*/
+static char * CC_FASTCALL 
+n(u16_t num, char *ptr)
+{
+  u16_t d;
+  u8_t a, f;
+
+  if(num == 0) {
+    *ptr = '0';
+    return ptr + 1;    
+  } else {
+    f = 0;
+    for(d = 10000; d >= 1; d /= 10) {
+      a = (num / d) % 10;
+      if(f == 1 || a > 0) {
+	*ptr = a + '0';
+	++ptr;
+	f = 1;
+      }
+    }
+  }
+  return ptr;
+}
+/*---------------------------------------------------------------------------*/
+static char * CC_FASTCALL 
+d(char *ptr)
+{
+  *ptr = '.';
+  return ptr + 1;
+}
+/*---------------------------------------------------------------------------*/
+static char * CC_FASTCALL
+s(char *str, char *ptr)
+{
+  strcpy(ptr, str);
+  return ptr + strlen(str);
+}
+/*---------------------------------------------------------------------------*/
+int
+tcpdump_print(char *buf, u16_t buflen)
+{
+  char flags[8];
+  if(IPBUF->proto == UIP_PROTO_ICMP) {
+    if(ICMPBUF->type == ICMP_ECHO) {
+      return s(" ping",
+	     n(IPBUF->destipaddr[3], d(
+	     n(IPBUF->destipaddr[2], d(	       
+	     n(IPBUF->destipaddr[1], d(	       
+	     n(IPBUF->destipaddr[0],
+             s(" ",
+	     n(IPBUF->srcipaddr[3], d(	       
+	     n(IPBUF->srcipaddr[2], d(	       
+	     n(IPBUF->srcipaddr[1], d(	       
+             n(IPBUF->srcipaddr[0],
+	     buf)))))))))))))))) - buf;
+	     
+      /*      return sprintf(buf, "%d.%d.%d.%d %d.%d.%d.%d ping",
+		     IPBUF->srcipaddr[0], IPBUF->srcipaddr[1],
+		     IPBUF->srcipaddr[2], IPBUF->srcipaddr[3],
+		     IPBUF->destipaddr[0], IPBUF->destipaddr[1],
+		     IPBUF->destipaddr[2], IPBUF->destipaddr[3]);*/
+    } else if(ICMPBUF->type == ICMP_ECHO_REPLY) {
+      return s(" pong",
+	     n(IPBUF->destipaddr[3], d(
+	     n(IPBUF->destipaddr[2], d(	       
+	     n(IPBUF->destipaddr[1], d(	       
+	     n(IPBUF->destipaddr[0],
+             s(" ",
+	     n(IPBUF->srcipaddr[3], d(	       
+	     n(IPBUF->srcipaddr[2], d(	       
+	     n(IPBUF->srcipaddr[1], d(	       
+             n(IPBUF->srcipaddr[0],
+	     buf)))))))))))))))) - buf;
+      /*      return sprintf(buf, "%d.%d.%d.%d %d.%d.%d.%d pong",
+		     IPBUF->srcipaddr[0], IPBUF->srcipaddr[1],
+		     IPBUF->srcipaddr[2], IPBUF->srcipaddr[3],
+		     IPBUF->destipaddr[0], IPBUF->destipaddr[1],
+		     IPBUF->destipaddr[2], IPBUF->destipaddr[3]);*/
+    }
+  } else if(IPBUF->proto == UIP_PROTO_UDP) {
+      return s(" UDP",
+	     n(htons(UDPBUF->destport), d(	       
+	     n(IPBUF->destipaddr[3], d(
+	     n(IPBUF->destipaddr[2], d(	       
+	     n(IPBUF->destipaddr[1], d(	       
+	     n(IPBUF->destipaddr[0],
+             s(" ",
+	     n(htons(UDPBUF->srcport), d(
+	     n(IPBUF->srcipaddr[3], d(	       
+	     n(IPBUF->srcipaddr[2], d(	       
+	     n(IPBUF->srcipaddr[1], d(	       
+             n(IPBUF->srcipaddr[0],
+	     buf)))))))))))))))))))) - buf;
+      /*    return sprintf(buf, "%d.%d.%d.%d.%d %d.%d.%d.%d.%d UDP",
+		   IPBUF->srcipaddr[0], IPBUF->srcipaddr[1],
+		   IPBUF->srcipaddr[2], IPBUF->srcipaddr[3],
+		   htons(UDPBUF->srcport),
+		   IPBUF->destipaddr[0], IPBUF->destipaddr[1],
+		   IPBUF->destipaddr[2], IPBUF->destipaddr[3],
+		   htons(UDPBUF->destport));*/
+  } else if(IPBUF->proto == UIP_PROTO_TCP) {
+    tcpflags(TCPBUF->flags, flags);
+      return s(flags,
+             s(" ",
+	     n(htons(TCPBUF->destport), d(	       
+	     n(IPBUF->destipaddr[3], d(
+	     n(IPBUF->destipaddr[2], d(	       
+	     n(IPBUF->destipaddr[1], d(	       
+	     n(IPBUF->destipaddr[0],
+             s(" ",
+	     n(htons(TCPBUF->srcport), d(
+	     n(IPBUF->srcipaddr[3], d(	       
+	     n(IPBUF->srcipaddr[2], d(	       
+	     n(IPBUF->srcipaddr[1], d(	       
+             n(IPBUF->srcipaddr[0],
+	     buf))))))))))))))))))))) - buf;
+    /*    return sprintf(buf, "%d.%d.%d.%d.%d %d.%d.%d.%d.%d %s",
+		   IPBUF->srcipaddr[0], IPBUF->srcipaddr[1],
+		   IPBUF->srcipaddr[2], IPBUF->srcipaddr[3],
+		   htons(TCPBUF->srcport),
+		   IPBUF->destipaddr[0], IPBUF->destipaddr[1],
+		   IPBUF->destipaddr[2], IPBUF->destipaddr[3],
+		   htons(TCPBUF->destport),
+		   flags);  */
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/tcpdump.h b/contiki/uip/tcpdump.h
new file mode 100644
index 0000000..3d6eccb
--- /dev/null
+++ b/contiki/uip/tcpdump.h
@@ -0,0 +1,8 @@
+#ifndef __TCPDUMP_H__
+#define __TCPDUMP_H__
+
+#include "uip.h"
+
+int tcpdump_print(char *buf, u16_t buflen);
+
+#endif /* __TCPDUMP_H__ */
diff --git a/contiki/uip/tcpip.c b/contiki/uip/tcpip.c
new file mode 100644
index 0000000..4aef8c9
--- /dev/null
+++ b/contiki/uip/tcpip.c
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: tcpip.c,v 1.6 2005/02/27 09:44:33 adamdunkels Exp $
+ */
+#include "tcpip.h"
+
+#include "ek-service.h"
+
+#include "tcpip.h"
+
+#include "uip.h"
+#include "uip-fw.h"
+
+#include "timer.h"
+
+#include "packet-service.h"
+
+#include "uip-split.h"
+
+#include <string.h>
+
+ek_event_t tcpip_event;
+
+EK_SERVICE(packetservice, PACKET_SERVICE_NAME);
+
+/**
+ * \internal Structure for holding a TCP port and a process ID.
+ */
+struct listenport {
+  u16_t port;
+  ek_id_t id;
+};
+
+/*static struct tcpip_event_args ev_args;*/
+
+static struct timer periodic;
+
+static struct internal_state {
+  struct listenport listenports[UIP_LISTENPORTS];
+  ek_event_t event;
+  ek_id_t id;
+} s;
+
+enum {
+  TCP_POLL,
+  UDP_POLL
+};
+
+static unsigned char forwarding = 0;
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, "TCP/IP stack", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, NULL);
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(tcpip_init, arg)
+{
+  uip_init();
+  ek_start(&proc);
+  forwarding = 0;
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_set_forwarding(unsigned char f)
+{
+  forwarding = f;
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_input(void)
+{
+  if(uip_len > 0) {
+    if(forwarding) {
+      if(uip_fw_forward() == 0) {
+	uip_input();
+	if(uip_len > 0) {
+#if UIP_CONF_TCP_SPLIT
+	  uip_split_output();
+#else
+	  tcpip_output();
+#endif
+	}
+      }
+    } else {
+      uip_input();
+      if(uip_len > 0) {
+#if UIP_CONF_TCP_SPLIT
+	uip_split_output();
+#else
+	tcpip_output();
+#endif
+      }
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_output(void)
+{
+  struct packet_service_state *state;
+  u16_t hdrlen, datalen;  
+  
+  state = (struct packet_service_state *)ek_service_state(&packetservice);
+
+  if(state != NULL &&
+     state->version == PACKET_SERVICE_VERSION) {
+
+    hdrlen = UIP_TCPIP_HLEN;
+    if(uip_len < UIP_TCPIP_HLEN) {
+      hdrlen = uip_len;
+      datalen = 0;
+    } else {
+      datalen = uip_len - UIP_TCPIP_HLEN;
+    }
+    
+    state->output(&uip_buf[UIP_LLH_LEN], hdrlen, uip_appdata, datalen);
+  }
+}
+/*---------------------------------------------------------------------------*/
+struct uip_conn *
+tcp_connect(u16_t *ripaddr, u16_t port, void *appstate)
+{
+  struct uip_conn *c;
+  
+  c = uip_connect(ripaddr, port);
+  if(c == NULL) {
+    return NULL;
+  }
+
+  ((struct tcpip_uipstate *)(c->appstate))->id = EK_PROC_ID(EK_CURRENT());
+  ((struct tcpip_uipstate *)(c->appstate))->state = appstate;
+
+  ek_post(s.id, TCP_POLL, c);
+  
+  return c;
+}
+/*---------------------------------------------------------------------------*/
+void
+tcp_unlisten(u16_t port)
+{
+  static unsigned char i;
+  struct listenport *l;
+
+  l = s.listenports;
+  for(i = 0; i < UIP_LISTENPORTS; ++i) {
+    if(l->port == port &&
+       l->id == EK_PROC_ID(EK_CURRENT())) {
+      l->port = 0;      
+      uip_unlisten(port);
+      break;
+    }
+    ++l;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+tcp_listen(u16_t port)
+{
+  static unsigned char i;
+  struct listenport *l;
+
+  l = s.listenports;
+  for(i = 0; i < UIP_LISTENPORTS; ++i) {
+    if(l->port == 0) {
+      l->port = port;
+      l->id = EK_PROC_ID(EK_CURRENT());
+      uip_listen(port);
+      break;
+    }
+    ++l;
+  }
+}
+/*---------------------------------------------------------------------------*/
+void
+tcp_markconn(struct uip_conn *conn,
+             void *appstate)
+{
+  register struct tcpip_uipstate *s;
+
+  s = (struct tcpip_uipstate *)conn->appstate;
+  s->id = ek_current->id;
+  s->state = appstate;
+}
+/*---------------------------------------------------------------------------*/
+struct uip_udp_conn *
+udp_new(u16_t *ripaddr, u16_t port, void *appstate)
+{
+  struct uip_udp_conn *c;
+  struct tcpip_uipstate *s;
+  
+  c = uip_udp_new(ripaddr, port);
+  if(c == NULL) {
+    return NULL;
+  }
+
+  s = (struct tcpip_uipstate *)c->appstate;
+  s->id = EK_PROC_ID(EK_CURRENT());
+  s->state = appstate;
+
+  return c;
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  static unsigned char i;
+  register struct listenport *l;
+  ek_id_t id;
+  struct internal_state *state;
+  
+  switch(ev) {
+  case EK_EVENT_INIT:       
+    for(i = 0; i < UIP_LISTENPORTS; ++i) {
+      s.listenports[i].port = 0;
+    }
+    s.id = EK_PROC_ID(EK_CURRENT());
+    tcpip_event = s.event = ek_alloc_event();
+    timer_set(&periodic, CLOCK_SECOND/2);  
+    break;
+  case EK_EVENT_REPLACE:
+    memcpy(&s, data, sizeof(s));
+    arg_free(data);
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    state = (struct internal_state *)arg_alloc(sizeof(s));
+    /* Copy state */
+    memcpy(state, &s, sizeof(s)); 
+    ek_replace((struct ek_proc *)data, state);
+    break;
+    
+  case EK_EVENT_EXITED:
+    id = (ek_id_t)data;
+    l = s.listenports;
+    for(i = 0; i < UIP_LISTENPORTS; ++i) {
+      if(l->id == id) {
+	uip_unlisten(l->port);
+	l->port = 0;
+	l->id = EK_ID_NONE;
+      }
+      ++l;
+    }
+    /*    for(i = 0; i < UIP_CONNS; ++i) {
+      if(((struct tcpip_uipstate *)uip_conns[i].appstate)->id == id) {
+      ((struct tcpip_uipstate *)uip_conns[i].appstate)->id = EK_ID_NONE;
+	uip_conns[i].tcpstateflags = CLOSED;
+      }
+      }*/
+    {
+      register struct uip_conn *cptr;
+     
+      for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) {
+	if(((struct tcpip_uipstate *)cptr->appstate)->id == id) {
+	  ((struct tcpip_uipstate *)cptr->appstate)->id = EK_ID_NONE;
+	  cptr->tcpstateflags = CLOSED;
+	}
+      
+      }
+      
+    }
+#if UIP_UDP
+    {
+      register struct uip_udp_conn *cptr;
+      for(cptr = &uip_udp_conns[0];
+	  cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) {
+	if(((struct tcpip_uipstate *)cptr->appstate)->id == id) {
+	  cptr->lport = 0;
+	}
+      }
+      
+    }
+    /*    for(i = 0; i < UIP_UDP_CONNS; ++i) {
+      if(((struct tcpip_uipstate *)uip_udp_conns[i].appstate)->id == id) {
+	uip_udp_conns[i].lport = 0;
+      }
+      }*/
+#endif /* UIP_UDP */
+    break;
+  case TCP_POLL:
+    if(data != NULL) {
+      uip_poll_conn(data);
+      if(uip_len > 0) {
+	tcpip_output();
+      }
+    }
+    break;
+  case UDP_POLL:
+    if(data != NULL) {
+      uip_udp_periodic_conn(data);
+      if(uip_len > 0) {
+	tcpip_output();
+      }
+    }
+    break;
+  };
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_poll_udp(struct uip_udp_conn *conn)
+{
+  ek_post(s.id, UDP_POLL, conn);
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_poll_tcp(struct uip_conn *conn)
+{
+  ek_post(s.id, TCP_POLL, conn);
+}
+/*---------------------------------------------------------------------------*/
+void
+tcpip_uipcall(void)     
+{
+  register struct tcpip_uipstate *ts;
+  static unsigned char i;
+  register struct listenport *l;
+
+  if(uip_conn != NULL) {
+    ts = (struct tcpip_uipstate *)uip_conn->appstate;
+  } else {
+    ts = (struct tcpip_uipstate *)uip_udp_conn->appstate;
+  }
+
+  /* If this is a connection request for a listening port, we must
+     mark the connection with the right process ID. */
+  if(uip_connected()) {
+    l = &s.listenports[0];
+    for(i = 0; i < UIP_LISTENPORTS; ++i) {
+      if(l->port == uip_conn->lport &&
+	 l->id != EK_ID_NONE) {
+	ts->id = l->id;
+	ts->state = NULL;
+	break;
+      }
+      ++l;
+    }
+  }
+
+  ek_post_synch(ts->id, s.event, ts->state);
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  static unsigned char i;
+  
+  /* Check the clock so see if we should call the periodic uIP
+     processing. */
+  if(timer_expired(&periodic)) {
+    timer_restart(&periodic);
+    for(i = 0; i < UIP_CONNS; ++i) {
+      uip_periodic(i);
+      if(uip_len > 0) {
+	tcpip_output();
+	/*	uip_fw_output();*/
+      }
+    }
+    
+    for(i = 0; i < UIP_UDP_CONNS; i++) {
+      uip_udp_periodic(i);
+      if(uip_len > 0) {
+	tcpip_output();
+	/*	uip_fw_output();*/
+      }
+    }
+    uip_fw_periodic();
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/tcpip.h b/contiki/uip/tcpip.h
new file mode 100644
index 0000000..dd57cbc
--- /dev/null
+++ b/contiki/uip/tcpip.h
@@ -0,0 +1,282 @@
+/**
+ * \defgroup tcpip The Contiki/uIP interface
+ * @{
+ *
+ * TCP/IP support in Contiki is implemented using the uIP TCP/IP
+ * stack. For sending and receiving data, Contiki uses the functions
+ * provided by the uIP module, but Contiki adds a set of functions for
+ * connection management. The connection management functions make
+ * sure that the uIP TCP/IP connections are connected to the correct
+ * process.
+ *
+ * Contiki also includes an optional protosocket library that provides
+ * an API similar to the BSD socket API.
+ *
+ * \sa \ref uip "The uIP TCP/IP stack"
+ * \sa \ref psock "Protosockets library"
+ *
+ */
+
+/**
+ * \file
+ * Header for the Contiki/uIP interface.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ */
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: tcpip.h,v 1.6 2005/02/22 22:34:46 adamdunkels Exp $
+ */
+#ifndef __TCPIP_H__
+#define __TCPIP_H__
+
+#include "ek.h"
+
+
+
+
+struct uip_conn;
+
+struct tcpip_uipstate {
+  ek_id_t id;  
+  void *state;
+};
+
+#define UIP_APPCALL tcpip_uipcall
+#define UIP_UDP_APPCALL tcpip_uipcall
+#define UIP_APPSTATE_SIZE sizeof(struct tcpip_uipstate)
+
+#include "uip.h"
+
+EK_PROCESS_INIT(tcpip_init, arg);
+     
+void tcpip_uipcall(void);
+
+/**
+ * Mark a TCP connection with the current process.
+ *
+ * This function ties a TCP connection with the current process. Each
+ * TCP connection must be tied to a process in order for the process
+ * to be able to receive and send data. Additionally, this function
+ * can add a pointer with connection state to the connection.
+ *
+ * \param conn A pointer to the TCP connection.
+ *
+ * \param appstate An opaque pointer that will be passed to the
+ * process whenever an event occurs on the connection.
+ *
+ */
+void tcp_markconn(struct uip_conn *conn,
+		  void *appstate);
+
+/**
+ * Open a TCP port.
+ *
+ * This function opens a TCP port for listening. When a TCP connection
+ * request occurs for the port, the process will be sent a tcpip_event
+ * with the new connection request.
+ *
+ * \note Port numbers must always be given in network byte order. The
+ * functions HTONS() and htons() can be used to convert port numbers
+ * from host byte order to network byte order.
+ *
+ * Example
+ \code
+ static void init_ports(void) {
+   tcp_listen(HTONS(80));
+   tcp_listen(HTONS(81));
+ }
+ \endcode
+ *
+ * \param port The port number in network byte order. 
+ *
+ */
+void tcp_listen(u16_t port);
+
+/**
+ * Close a listening TCP port.
+ *
+ * This function closes a listening TCP port.
+ *
+ * \note Port numbers must always be given in network byte order. The
+ * functions HTONS() and htons() can be used to convert port numbers
+ * from host byte order to network byte order.
+ *
+ * Example
+ \code
+ static void close_ports(void) {
+   tcp_unlisten(HTONS(80));
+   tcp_unlisten(HTONS(81));
+ }
+ \endcode
+ *
+ * \param port The port number in network byte order. 
+ *
+ */
+void tcp_unlisten(u16_t port);
+
+/**
+ * Open a TCP connection to the specified IP address and port.
+ *
+ * This function opens a TCP connection to the specified port at the
+ * host specified with an IP address. Additionally, an opaque pointer
+ * can be attached to the connection. This pointer will be sent
+ * together with uIP events to the process.
+ *
+ * \note The port number must be provided in network byte order so a
+ * conversion with HTONS() usually is necessary.
+ *
+ * \note This function will only create the connection. The connection
+ * is not opened directly. uIP will try to open the connection the
+ * next time the uIP stack is scheduled by Contiki.
+ *
+ * Example:
+ \code
+ static struct uip_conn *conn;
+ 
+ EK_EVENTHANDLER(eventhandler, ev, data)
+ {
+   u16_t addr[2];
+   
+   if(ev == EK_EVENT_INIT) {
+     uip_ipaddr(addr, 192,168,1,1);
+     conn = tcp_connect(addr, HTONS(80), NULL);
+   }
+ }
+ \endcode
+ *
+ * \param ripaddr Pointer to the IP address of the remote host.
+ * \param port Port number in network byte order.
+ * \param appstate Pointer to application defined data.
+ *
+ * \return A pointer to the newly created connection, or NULL if
+ * memory could not be allocated for the connection.
+ *
+ */
+struct uip_conn *tcp_connect(u16_t *ripaddr, u16_t port,
+			     void *appstate);
+
+/**
+ * Create a new UDP connection.
+ *
+ * This function creates a new UDP connection with the specified
+ * remote endpoint.
+ *
+ * \note The port number must be provided in network byte order so a
+ * conversion with HTONS() usually is necessary.
+ *
+ * \sa udp_bind()
+ *
+ * \param ripaddr Pointer to the IP address of the remote host.
+ * \param port Port number in network byte order.
+ * \param appstate Pointer to application defined data.
+ *
+ * \return A pointer to the newly created connection, or NULL if
+ * memory could not be allocated for the connection.
+ */
+struct uip_udp_conn *udp_new(u16_t *ripaddr, u16_t port,
+			     void *appstate);
+
+/**
+ * Bind a UDP connection to a local port.
+ *
+ * This function binds a UDP conncetion to a specified local port.
+ *
+ * When a connction is created with udp_new(), it gets a local port number assigned automatically. If the application needs to bind the connection to a specified local port, this function should be used.
+ *
+ * \note The port number must be provided in network byte order so a
+ * conversion with HTONS() usually is necessary.
+ *
+ * Example
+ \code
+  EK_EVENTHANDLER(eventhandler, ev, data)
+  {
+    u16_t addr[2];
+  
+    if(ev == EK_EVENT_INIT) {
+      uip_ipaddr(addr, 255,255,255,255);
+      conn = udp_new(addr, HTONS(PORT), NULL);
+      if(conn != NULL) {
+        udp_bind(conn, HTONS(PORT));
+      }
+    }
+  }
+ \endcode
+ *
+ * \param conn A pointer to the UDP connection that is to be bound.
+ * \param port The port number in network byte order to which to bind
+ * the connection.
+ */
+#define udp_bind(conn, port) uip_udp_bind(conn, port)
+
+/**
+ * The uIP event.
+ *
+ * This event is posted to a process whenever a uIP event has occured.
+ */
+extern ek_event_t tcpip_event;
+
+
+
+void tcpip_set_forwarding(unsigned char f);
+void tcpip_input(void);
+void tcpip_output(void);
+
+
+/**
+ * Cause a specified TCP connection to be polled.
+ *
+ * This function causes uIP to poll the specified TCP connection. The
+ * function is used when the application has data that is to be sent
+ * immediately and do not wish to wait for the periodic uIP polling
+ * mechanism.
+ *
+ * \param conn A pointer to the TCP connection that should be polled.
+ *
+ */
+void tcpip_poll_tcp(struct uip_conn *conn);
+
+/**
+ * Cause a specified UDP connection to be polled.
+ *
+ * This function causes uIP to poll the specified UDP connection. The
+ * function is used when the application has data that is to be sent
+ * immediately and do not wish to wait for the periodic uIP polling
+ * mechanism.
+ *
+ * \param conn A pointer to the UDP connection that should be polled.
+ *
+ */
+void tcpip_poll_udp(struct uip_udp_conn *conn);
+
+#endif /* __TCPIP_H__ */
diff --git a/contiki/uip/uip-fw-service.c b/contiki/uip/uip-fw-service.c
new file mode 100644
index 0000000..4898b42
--- /dev/null
+++ b/contiki/uip/uip-fw-service.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw-service.c,v 1.4 2005/02/07 07:06:59 adamdunkels Exp $
+ */
+
+#include "packet-service.h"
+
+#include "uip-fw.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+  {
+    PACKET_SERVICE_VERSION,
+    output
+  };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": IP forwarding", EK_PRIO_NORMAL,
+	   eventhandler, NULL, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(uip_fw_service_init, arg)
+{  
+  ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+  uip_fw_output();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  switch(ev) {
+  case EK_EVENT_INIT:
+  case EK_EVENT_REPLACE:
+    break;
+  case EK_EVENT_REQUEST_REPLACE:
+    ek_replace((struct ek_proc *)data, NULL);
+    LOADER_UNLOAD();
+    break;
+  case EK_EVENT_REQUEST_EXIT:
+    ek_exit();
+    LOADER_UNLOAD();
+    break;
+  default:
+    break;
+  }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki/uip/uip-fw-service.h b/contiki/uip/uip-fw-service.h
new file mode 100644
index 0000000..92699fb
--- /dev/null
+++ b/contiki/uip/uip-fw-service.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw-service.h,v 1.2 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+#ifndef __UIP_FW_SERVICE_H__
+#define __UIP_FW_SERVICE_H__
+
+#include "contiki.h"
+
+EK_PROCESS_INIT(uip_fw_service_init, arg);
+
+#endif /* __UIP_FW_SERVICE_H__ */
diff --git a/contiki/uip/uip-fw.c b/contiki/uip/uip-fw.c
new file mode 100644
index 0000000..3ba8baa
--- /dev/null
+++ b/contiki/uip/uip-fw.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw.c,v 1.9 2005/02/23 22:40:40 oliverschmidt Exp $
+ */
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uipfw uIP packet forwarding
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * uIP packet forwarding.
+ * \author Adam Dunkels <adam@sics.se>
+ *
+ * This file implements a number of simple functions which do packet
+ * forwarding over multiple network interfaces with uIP.
+ *
+ */
+
+#include "uip.h"
+#include "uip_arch.h"
+#include "uip-fw.h"
+#include "uip-conf.h"
+
+#include <string.h> /* for memcpy() */
+
+/**
+ * \internal
+ * The list of registered network interfaces.
+ */
+static struct uip_fw_netif *netifs = NULL;
+
+/**
+ * \internal
+ * A pointer to the default network interface.
+ */
+static struct uip_fw_netif *defaultnetif = NULL;
+
+struct tcpip_hdr {
+  /* IP header. */
+  u8_t vhl,
+    tos;     
+  u16_t len,
+    ipid,        
+    ipoffset;
+  u8_t ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+  
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],  
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];     
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+};
+
+struct icmpip_hdr {
+  /* IP header. */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+  u16_t id, seqno;
+  u8_t payload[1];
+};
+
+/**
+ * \internal
+ * ICMP ECHO type definition.
+ */
+#define ICMP_ECHO 8 
+
+/**
+ * \internal
+ * ICMP TIME-EXCEEDED type definition.
+ */
+#define ICMP_TE 11 
+
+/**
+ * \internal
+ * Pointer to the TCP/IP headers of the packet in the uip_buf buffer.
+ */
+#define BUF ((struct tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/**
+ * \internal
+ * Pointer to the ICMP/IP headers of the packet in the uip_buf buffer.
+ */
+#define ICMPBUF ((struct icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/**
+ * \internal
+ * Certain fields of an IP packet that are used for identifying
+ * duplicate packets.
+ */
+struct fwcache_entry {
+  u16_t timer;
+  
+  u16_t len, offset, ipid;
+  u16_t srcipaddr[2];
+  u16_t destipaddr[2];
+  u16_t payload[2];
+  u8_t proto;
+};
+
+/**
+ * \internal
+ * The number of packets to remember when looking for duplicates.
+ */
+#ifdef UIP_CONF_FWCACHE_SIZE
+#define FWCACHE_SIZE UIP_CONF_FWCACHE_SIZE
+#else
+#define FWCACHE_SIZE 2
+#endif
+
+
+/**
+ * \internal
+ * A cache of packet header fields which are used for
+ * identifying duplicate packets.
+ */
+static struct fwcache_entry fwcache[FWCACHE_SIZE];
+
+/**
+ * \internal
+ * The time that a packet cache is active.
+ */
+#define FW_TIME 20
+
+/*------------------------------------------------------------------------------*/
+/**
+ * Initialize the uIP packet forwarding module.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_init(void)
+{
+  defaultnetif = netifs = NULL;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Check if an IP address is within the network defined by an IP
+ * address and a netmask.
+ *
+ * \param ipaddr The IP address to be checked.
+ * \param netipaddr The IP address of the network.
+ * \param netmask The netmask of the network.
+ *
+ * \return Non-zero if IP address is in network, zero otherwise.
+ */
+/*------------------------------------------------------------------------------*/
+static unsigned char
+ipaddr_maskcmp(u16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)
+{
+  return (ipaddr[0] & netmask [0]) == (netipaddr[0] & netmask[0]) &&
+    (ipaddr[1] & netmask[1]) == (netipaddr[1] & netmask[1]);
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Send out an ICMP TIME-EXCEEDED message.
+ *
+ * This function replaces the packet in the uip_buf buffer with the
+ * ICMP packet.
+ */
+/*------------------------------------------------------------------------------*/
+static void
+time_exceeded(void)
+{
+  u16_t tmp16;
+
+  /* We don't send out ICMP errors for ICMP messages. */
+  if(ICMPBUF->proto == UIP_PROTO_ICMP) {
+    uip_len = 0;
+    return;
+  }
+  /* Copy fields from packet header into payload of this ICMP packet. */
+  memcpy(&(ICMPBUF->payload[0]), ICMPBUF, 28);
+
+  /* Set the ICMP type and code. */
+  ICMPBUF->type = ICMP_TE;
+  ICMPBUF->icode = 0;
+
+  /* Calculate the ICMP checksum. */
+  ICMPBUF->icmpchksum = 0;
+  ICMPBUF->icmpchksum = ~uip_chksum((u16_t *)&(ICMPBUF->type), 36);
+
+  /* Set the IP destination address to be the source address of the
+     original packet. */
+  tmp16= BUF->destipaddr[0];
+  BUF->destipaddr[0] = BUF->srcipaddr[0];
+  BUF->srcipaddr[0] = tmp16;
+  tmp16 = BUF->destipaddr[1];
+  BUF->destipaddr[1] = BUF->srcipaddr[1];
+  BUF->srcipaddr[1] = tmp16;
+
+  /* Set our IP address as the source address. */
+  BUF->srcipaddr[0] = uip_hostaddr[0];
+  BUF->srcipaddr[1] = uip_hostaddr[1];
+
+  /* The size of the ICMP time exceeded packet is 36 + the size of the
+     IP header (20) = 56. */
+  uip_len = 56;
+  ICMPBUF->len[0] = 0;
+  ICMPBUF->len[1] = uip_len;
+
+  /* Fill in the other fields in the IP header. */
+  ICMPBUF->vhl = 0x45;
+  ICMPBUF->tos = 0;
+  ICMPBUF->ipoffset[0] = ICMPBUF->ipoffset[1] = 0;
+  ICMPBUF->ttl  = UIP_TTL;
+  ICMPBUF->proto = UIP_PROTO_ICMP;
+  
+  /* Calculate IP checksum. */
+  ICMPBUF->ipchksum = 0;
+  ICMPBUF->ipchksum = ~(uip_ipchksum());
+
+
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Register a packet in the forwarding cache so that it won't be
+ * forwarded again.
+ */
+/*------------------------------------------------------------------------------*/
+static void
+fwcache_register(void)
+{
+  struct fwcache_entry *fw;
+  int i, oldest;
+
+  oldest = FW_TIME;
+  fw = NULL;
+  
+  /* Find the oldest entry in the cache. */
+  for(i = 0; i < FWCACHE_SIZE; ++i) {
+    if(fwcache[i].timer == 0) {
+      fw = &fwcache[i];
+      break;
+    } else if(fwcache[i].timer <= oldest) {
+      fw = &fwcache[i];
+      oldest = fwcache[i].timer;
+    }
+  }
+
+  fw->timer = FW_TIME;
+  fw->len = BUF->len;
+  fw->offset = BUF->ipoffset;
+  fw->ipid = BUF->ipid;
+  fw->srcipaddr[0] = BUF->srcipaddr[0];
+  fw->srcipaddr[1] = BUF->srcipaddr[1];
+  fw->destipaddr[0] = BUF->destipaddr[0];
+  fw->destipaddr[1] = BUF->destipaddr[1];
+  fw->payload[0] = BUF->srcport;
+  fw->payload[1] = BUF->destport;
+  fw->proto = BUF->proto;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Find a network interface for the IP packet in uip_buf.
+ */
+/*------------------------------------------------------------------------------*/
+static struct uip_fw_netif *
+find_netif(void)
+{
+  struct uip_fw_netif *netif;
+  
+  /* Walk through every network interface to check for a match. */
+  for(netif = netifs; netif != NULL; netif = netif->next) {
+    if(ipaddr_maskcmp(BUF->destipaddr, netif->ipaddr,
+		      netif->netmask)) {
+      /* If there was a match, we break the loop. */
+      return netif;
+    }
+  }
+  
+  /* If no matching netif was found, we use default netif. */
+  return defaultnetif;  
+}    
+/*------------------------------------------------------------------------------*/
+/**
+ * Output an IP packet on the correct network interface.
+ *
+ * The IP packet should be present in the uip_buf buffer and its
+ * length in the global uip_len variable.
+ *
+ * \retval UIP_FW_ZEROLEN Indicates that a zero-length packet
+ * transmission was attempted and that no packet was sent.
+ *
+ * \retval UIP_FW_NOROUTE No suitable network interface could be found
+ * for the outbound packet, and the packet was not sent.
+ *
+ * \return The return value from the actual network interface output
+ * function is passed unmodified as a return value.
+ */
+/*------------------------------------------------------------------------------*/
+u8_t
+uip_fw_output(void)
+{
+  struct uip_fw_netif *netif;
+
+  if(uip_len == 0) {
+    return UIP_FW_ZEROLEN;
+  }
+
+#if UIP_BROADCAST
+  /* Link local broadcasts go out on all interfaces. */
+  if(BUF->proto == UIP_PROTO_UDP &&
+     BUF->destipaddr[0] == 0xffff &&
+     BUF->destipaddr[1] == 0xffff) {
+    for(netif = netifs; netif != NULL; netif = netif->next) {
+      netif->output();
+    }
+    return UIP_FW_OK;
+  }
+#endif /* UIP_BROADCAST */  
+
+  
+  netif = find_netif();
+  /*  printf("uip_fw_output: netif %p ->output %p len %d\n", netif,
+	 netif->output,
+	 uip_len);*/
+
+  if(netif == NULL) {
+    return UIP_FW_NOROUTE;
+  }
+  /* If we now have found a suitable network interface, we call its
+     output function to send out the packet. */
+  fwcache_register();
+  return netif->output();
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Forward an IP packet in the uip_buf buffer.
+ *
+ * 
+ *
+ * \return UIP_FW_FORWARDED if the packet was forwarded, UIP_FW_LOCAL if
+ * the packet should be processed locally.
+ */
+/*------------------------------------------------------------------------------*/
+u8_t
+uip_fw_forward(void)
+{
+  struct uip_fw_netif *netif;
+  struct fwcache_entry *fw;
+
+  /* First check if the packet is destined for ourselves and return 0
+     to indicate that the packet should be processed locally. */
+  if(BUF->destipaddr[0] == uip_hostaddr[0] &&
+     BUF->destipaddr[1] == uip_hostaddr[1]) {
+    return UIP_FW_LOCAL;
+  }
+
+#if UIP_BROADCAST
+  if(BUF->proto == UIP_PROTO_UDP &&
+     BUF->destipaddr[0] == 0xffff &&
+     BUF->destipaddr[1] == 0xffff) {
+    return UIP_FW_LOCAL;
+  }
+#endif /* UIP_BROADCAST */  
+
+  /* If we use ping IP address configuration, and our IP address is
+     not yet configured, we should intercept all ICMP echo packets. */
+#if UIP_PINGADDRCONF
+  if((uip_hostaddr[0] | uip_hostaddr[1]) == 0 &&
+     BUF->proto == UIP_PROTO_ICMP &&
+     ICMPBUF->type == ICMP_ECHO) {
+    return UIP_FW_LOCAL;
+  }
+#endif /* UIP_PINGADDRCONF */
+
+  /* Check if the packet is in the forwarding cache already, and if so
+     we drop it. */
+
+  for(fw = fwcache; fw <= &fwcache[FWCACHE_SIZE]; ++fw) {
+    if(fw->timer != 0 &&
+       fw->len == BUF->len &&
+       fw->offset == BUF->ipoffset &&
+       fw->ipid == BUF->ipid &&      
+       fw->srcipaddr[0] == BUF->srcipaddr[0] &&
+       fw->srcipaddr[1] == BUF->srcipaddr[1] &&
+       fw->destipaddr[0] == BUF->destipaddr[0] &&
+       fw->destipaddr[1] == BUF->destipaddr[1] &&
+       fw->proto == BUF->proto &&
+       fw->payload[0] == BUF->srcport &&
+       fw->payload[1] == BUF->destport) {
+      /* Drop packet. */
+      return UIP_FW_FORWARDED;
+    }       
+  }
+
+  netif = find_netif();
+
+  /* Decrement the TTL (time-to-live) value in the IP header */
+  BUF->ttl = BUF->ttl - 1;
+  
+  /* Update the IP checksum. */
+  if(BUF->ipchksum >= HTONS(0xffff - 0x0100)) {
+    BUF->ipchksum = BUF->ipchksum + HTONS(0x0100) + 1;
+  } else {
+    BUF->ipchksum = BUF->ipchksum + HTONS(0x0100);
+  }
+  
+  /* If the TTL reaches zero we procude an ICMP time exceeded message
+     in the uip_buf buffer and forward that packet back to the sender
+     of the packet. */
+  if(BUF->ttl == 0) {    
+    time_exceeded();
+    netif = find_netif();
+  }
+  
+  /* If we now have found a suitable network interface, we call its
+     output function to send out the packet. */
+  if(netif != NULL && uip_len > 0) {
+    uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN];
+    fwcache_register();
+    netif->output();
+  }
+
+  /* Return non-zero to indicate that the packet was forwarded and that no
+     other processing should be made. */
+  return UIP_FW_FORWARDED;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Register a network interface with the forwarding module.
+ *
+ * \param netif A pointer to the network interface that is to be
+ * registered.  
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_register(struct uip_fw_netif *netif)
+{
+  netif->next = netifs;
+  netifs = netif;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Register a default network interface.
+ *
+ * All packets that don't go out on any of the other interfaces will
+ * be routed to the default interface.
+ *
+ * \param netif A pointer to the network interface that is to be
+ * registered.  
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_default(struct uip_fw_netif *netif)
+{
+  defaultnetif = netif;
+}
+/*------------------------------------------------------------------------------*/
+/**
+ * Perform periodic processing.
+ */
+/*------------------------------------------------------------------------------*/
+void
+uip_fw_periodic(void)
+{
+  struct fwcache_entry *fw;
+  for(fw = fwcache; fw <= &fwcache[FWCACHE_SIZE]; ++fw) {
+    if(fw->timer > 0) {
+      --fw->timer;
+    }    
+  }
+}
+/*------------------------------------------------------------------------------*/
diff --git a/contiki/uip/uip-fw.h b/contiki/uip/uip-fw.h
new file mode 100644
index 0000000..d7c0a98
--- /dev/null
+++ b/contiki/uip/uip-fw.h
@@ -0,0 +1,176 @@
+/**
+ * \addtogroup uipfw
+ * @{
+ */
+
+/**
+ * \file
+ * uIP packet forwarding header file.
+ * \author Adam Dunkels <adam@sics.se>
+ */
+
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-fw.h,v 1.7 2005/02/07 07:06:31 adamdunkels Exp $
+ */
+#ifndef __UIP_FW_H__
+#define __UIP_FW_H__
+
+#include "uip.h"
+
+/**
+ * Representation of a uIP network interface.
+ */
+struct uip_fw_netif {
+  struct uip_fw_netif *next;  /**< Pointer to the next interface when
+				 linked in a list. */
+  u16_t ipaddr[2];            /**< The IP address of this interface. */
+  u16_t netmask[2];           /**< The netmask of the interface. */
+  u8_t (* output)(void);
+                              /**< A pointer to the function that
+				 sends a packet. */
+};
+
+/**
+ * Intantiating macro for a uIP network interface.
+ *
+ * Example:
+ \code
+ struct uip_fw_netif slipnetif =
+   {UIP_FW_NETIF(192,168,76,1, 255,255,255,0, slip_output)};
+ \endcode
+ * \param ip1,ip2,ip3,ip4 The IP address of the network interface.
+ *
+ * \param nm1,nm2,nm3,nm4 The netmask of the network interface.
+ *
+ * \param outputfunc A pointer to the output function of the network interface.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \
+        NULL, \
+	{HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \
+	{HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \
+        outputfunc
+
+/**
+ * Set the IP address of a network interface.
+ *
+ * \param netif A pointer to the uip_fw_netif structure for the network interface.
+ *
+ * \param addr A pointer to an IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_fw_setipaddr(netif, addr) \
+        do { (netif)->ipaddr[0] = ((u16_t *)(addr))[0]; \
+             (netif)->ipaddr[1] = ((u16_t *)(addr))[1]; } while(0)
+/**
+ * Set the netmask of a network interface.
+ *
+ * \param netif A pointer to the uip_fw_netif structure for the network interface.
+ *
+ * \param addr A pointer to an IP address representing the netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_fw_setnetmask(netif, addr) \
+        do { (netif)->netmask[0] = ((u16_t *)(addr))[0]; \
+             (netif)->netmask[1] = ((u16_t *)(addr))[1]; } while(0)
+
+void uip_fw_init(void);
+u8_t uip_fw_forward(void);
+u8_t uip_fw_output(void);
+void uip_fw_register(struct uip_fw_netif *netif);
+void uip_fw_default(struct uip_fw_netif *netif);
+void uip_fw_periodic(void);
+
+
+/**
+ * A non-error message that indicates that a packet should be
+ * processed locally.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_LOCAL     0
+
+/**
+ * A non-error message that indicates that something went OK.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_OK        0
+
+/**
+ * A non-error message that indicates that a packet was forwarded.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_FORWARDED 1
+
+/**
+ * A non-error message that indicates that a zero-length packet
+ * transmission was attempted, and that no packet was sent.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_ZEROLEN   2
+
+/**
+ * An error message that indicates that a packet that was too large
+ * for the outbound network interface was detected.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_TOOLARGE  3
+
+/**
+ * An error message that indicates that no suitable interface could be
+ * found for an outbound packet.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_NOROUTE   4
+
+/**
+ * An error message that indicates that a packet that should be
+ * forwarded or output was dropped.
+ *
+ * \hideinitializer
+ */
+#define UIP_FW_DROPPED   5
+
+
+#endif /* __UIP_FW_H__ */
+
+/** @} */
diff --git a/contiki/uip/uip-split.c b/contiki/uip/uip-split.c
new file mode 100644
index 0000000..927bf57
--- /dev/null
+++ b/contiki/uip/uip-split.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-split.c,v 1.3 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+
+#include "uip-split.h"
+#include "uip.h"
+#include "uip-fw.h"
+#include "uip_arch.h"
+
+#include "tcpip.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+/*-----------------------------------------------------------------------------*/
+void
+uip_split_output(void)
+{
+  u16_t tcplen, len1, len2;
+
+  /* We only try to split maximum sized TCP segments. */
+  if(BUF->proto == UIP_PROTO_TCP &&
+     uip_len == UIP_BUFSIZE - UIP_LLH_LEN) {
+
+    tcplen = uip_len - UIP_TCPIP_HLEN;
+    /* Split the segment in two. If the original packet length was
+       odd, we make the second packet one byte larger. */
+    len1 = len2 = tcplen / 2;
+    if(len1 + len2 < tcplen) {
+      ++len2;
+    }
+
+    /* Create the first packet. This is done by altering the length
+       field of the IP header and updating the checksums. */
+    uip_len = len1 + UIP_TCPIP_HLEN;
+    BUF->len[0] = (uip_len >> 8);
+    BUF->len[1] = (uip_len & 0xff);
+    
+    /* Recalculate the TCP checksum. */
+    BUF->tcpchksum = 0;
+    BUF->tcpchksum = ~(uip_tcpchksum());
+    
+    /* Recalculate the IP checksum. */
+    BUF->ipchksum = 0;
+    BUF->ipchksum = ~(uip_ipchksum());
+
+    /* Transmit the first packet. */
+    /*    uip_fw_output();*/
+    tcpip_output();
+
+    /* Now, create the second packet. To do this, it is not enough to
+       just alter the length field, but we must also update the TCP
+       sequence number and point the uip_appdata to a new place in
+       memory. This place is detemined by the length of the first
+       packet (len1). */
+    uip_len = len2 + UIP_TCPIP_HLEN;
+    BUF->len[0] = (uip_len >> 8);
+    BUF->len[1] = (uip_len & 0xff);
+
+    uip_appdata += len1;
+
+    uip_add32(BUF->seqno, len1);
+    BUF->seqno[0] = uip_acc32[0];
+    BUF->seqno[1] = uip_acc32[1];
+    BUF->seqno[2] = uip_acc32[2];
+    BUF->seqno[3] = uip_acc32[3];
+    
+    /* Recalculate the TCP checksum. */
+    BUF->tcpchksum = 0;
+    BUF->tcpchksum = ~(uip_tcpchksum());
+    
+    /* Recalculate the IP checksum. */
+    BUF->ipchksum = 0;
+    BUF->ipchksum = ~(uip_ipchksum());
+
+    /* Transmit the second packet. */
+    /*    uip_fw_output();*/
+    tcpip_output();
+  } else {
+    /*    uip_fw_output();*/
+    tcpip_output();
+  }
+     
+}
+/*-----------------------------------------------------------------------------*/
diff --git a/contiki/uip/uip-split.h b/contiki/uip/uip-split.h
new file mode 100644
index 0000000..9131a80
--- /dev/null
+++ b/contiki/uip/uip-split.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uip-split.h,v 1.2 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uipsplit uIP TCP throughput booster hack
+ * @{
+ *
+ * The basic uIP TCP implementation only allows each TCP connection to
+ * have a single TCP segment in flight at any given time. Because of
+ * the delayed ACK algorithm employed by most TCP receivers, uIP's
+ * limit on the amount of in-flight TCP segments seriously reduces the
+ * maximum achievable throughput for sending data from uIP.
+ *
+ * The uip-split module is a hack which tries to remedy this
+ * situation. By splitting maximum sized outgoing TCP segments into
+ * two, the delayed ACK algorithm is not invoked at TCP
+ * receivers. This improves the throughput when sending data from uIP
+ * by orders of magnitude.
+ *
+ * The uip-split module uses the uip-fw module (uIP IP packet
+ * forwarding) for sending packets. Therefore, the uip-fw module must
+ * be set up with the appropriate network interfaces for this module
+ * to work.
+ */
+
+
+/**
+ * \file
+ * Module for splitting outbound TCP segments in two to avoid the
+ * delayed ACK throughput degradation. 
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __UIP_SPLIT_H__
+#define __UIP_SPLIT_H__
+
+/**
+ * Handle outgoing packets.
+ *
+ * This function inspects an outgoing packet in the uip_buf buffer and
+ * sends it out using the uip_fw_output() function. If the packet is a
+ * full-sized TCP segment it will be split into two segments and
+ * transmitted separately. This function should be called instead of
+ * the actual device driver output function, or the uip_fw_output()
+ * function.
+ *
+ * The headers of the outgoing packet is assumed to be in the uip_buf
+ * buffer and the payload is assumed to be wherever uip_appdata
+ * points. The length of the outgoing packet is assumed to be in the
+ * uip_len variable.
+ *
+ */
+void uip_split_output(void);
+
+#endif /* __UIP_SPLIT_H__ */
+
+/** @} */
+/** @} */
diff --git a/contiki/uip/uip.c b/contiki/uip/uip.c
new file mode 100644
index 0000000..661e2b7
--- /dev/null
+++ b/contiki/uip/uip.c
@@ -0,0 +1,1589 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \file
+ * The uIP TCP/IP stack code.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip.c,v 1.24 2005/03/14 07:18:15 adamdunkels Exp $
+ *
+ */
+
+/*
+This is a small implementation of the IP, UDP and TCP protocols (as
+well as some basic ICMP stuff). The implementation couples the IP,
+UDP, TCP and the application layers very tightly. To keep the size of
+the compiled code down, this code frequently uses the goto
+statement. While it would be possible to break the uip_process()
+function into many smaller functions, this would increase the code
+size because of the overhead of parameter passing and the fact that
+the optimier would not be as efficient.
+
+The principle is that we have a small buffer, called the uip_buf, in
+which the device driver puts an incoming packet. The TCP/IP stack
+parses the headers in the packet, and calls the application. If the
+remote host has sent data to the application, this data is present in
+the uip_buf and the application read the data from there. It is up to
+the application to put this data into a byte stream if needed. The
+application will not be fed with data that is out of sequence.
+
+If the application whishes to send data to the peer, it should put its
+data into the uip_buf. The uip_appdata pointer points to the first
+available byte. The TCP/IP stack will calculate the checksums, and
+fill in the necessary header fields and finally send the packet back
+to the peer.
+*/
+
+#include "uip.h"
+#include "uipopt.h"
+#include "uip_arch.h"
+
+/*-----------------------------------------------------------------------------------*/
+/* Variable definitions. */
+
+
+/* The IP address of this host. If it is defined to be fixed (by setting UIP_FIXEDADDR to 1 in uipopt.h), the address is set here. Otherwise, the address */
+#if UIP_FIXEDADDR > 0
+const u16_t uip_hostaddr[2] =
+  {HTONS((UIP_IPADDR0 << 8) | UIP_IPADDR1),
+   HTONS((UIP_IPADDR2 << 8) | UIP_IPADDR3)};
+const u16_t uip_draddr[2] =
+  {HTONS((UIP_DRIPADDR0 << 8) | UIP_DRIPADDR1),
+   HTONS((UIP_DRIPADDR2 << 8) | UIP_DRIPADDR3)};
+const u16_t uip_netmask[2] =
+  {HTONS((UIP_NETMASK0 << 8) | UIP_NETMASK1),
+   HTONS((UIP_NETMASK2 << 8) | UIP_NETMASK3)};
+#else
+u16_t uip_hostaddr[2];       
+u16_t uip_draddr[2], uip_netmask[2];
+#endif /* UIP_FIXEDADDR */
+
+#if UIP_FIXEDETHADDR
+const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
+					  UIP_ETHADDR1,
+					  UIP_ETHADDR2,
+					  UIP_ETHADDR3,
+					  UIP_ETHADDR4,
+					  UIP_ETHADDR5}};
+#else
+struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}};
+#endif
+
+#ifndef UIP_CONF_EXTERNAL_BUFFER
+u8_t uip_buf[UIP_BUFSIZE + 2];   /* The packet buffer that contains
+				    incoming packets. */
+#endif /* UIP_CONF_EXTERNAL_BUFFER */
+
+u8_t *uip_appdata;               /* The uip_appdata pointer points to
+				    application data. */
+u8_t *uip_sappdata;              /* The uip_appdata pointer points to
+				    the application data which is to
+				    be sent. */
+#if UIP_URGDATA > 0
+u8_t *uip_urgdata;               /* The uip_urgdata pointer points to
+   				    urgent data (out-of-band data), if
+   				    present. */
+u16_t uip_urglen, uip_surglen;
+#endif /* UIP_URGDATA > 0 */
+
+u16_t uip_len, uip_slen;
+                             /* The uip_len is either 8 or 16 bits,
+				depending on the maximum packet
+				size. */
+
+u8_t uip_flags;     /* The uip_flags variable is used for
+				communication between the TCP/IP stack
+				and the application program. */
+struct uip_conn *uip_conn;   /* uip_conn always points to the current
+				connection. */
+
+struct uip_conn uip_conns[UIP_CONNS];
+                             /* The uip_conns array holds all TCP
+				connections. */
+u16_t uip_listenports[UIP_LISTENPORTS];
+                             /* The uip_listenports list all currently
+				listning ports. */
+#if UIP_UDP
+struct uip_udp_conn *uip_udp_conn;
+struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
+#endif /* UIP_UDP */
+
+static u16_t ipid;           /* Ths ipid variable is an increasing
+				number that is used for the IP ID
+				field. */
+
+static u8_t iss[4];          /* The iss variable is used for the TCP
+				initial sequence number. */
+
+#if UIP_ACTIVE_OPEN
+static u16_t lastport;       /* Keeps track of the last port used for
+				a new connection. */
+#endif /* UIP_ACTIVE_OPEN */
+
+/* Temporary variables. */
+u8_t uip_acc32[4];
+static u8_t c, opt;
+static u16_t tmp16;
+
+/* Structures and definitions. */
+#define TCP_FIN 0x01
+#define TCP_SYN 0x02
+#define TCP_RST 0x04
+#define TCP_PSH 0x08
+#define TCP_ACK 0x10
+#define TCP_URG 0x20
+#define TCP_CTL 0x3f
+
+#define TCP_OPT_END     0   /* End of TCP options list */
+#define TCP_OPT_NOOP    1   /* "No-operation" TCP option */
+#define TCP_OPT_MSS     2   /* Maximum segment size TCP option */
+
+#define TCP_OPT_MSS_LEN 4   /* Length of TCP MSS option. */
+
+#define ICMP_ECHO_REPLY 0
+#define ICMP_ECHO       8     
+
+
+/* Macros. */
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define FBUF ((uip_tcpip_hdr *)&uip_reassbuf[0])
+#define ICMPBUF ((uip_icmpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define UDPBUF ((uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])
+
+
+#if UIP_STATISTICS == 1
+struct uip_stats uip_stat;
+#define UIP_STAT(s) s
+#else
+#define UIP_STAT(s)
+#endif /* UIP_STATISTICS == 1 */
+
+#if UIP_LOGGING == 1
+#include <stdio.h>
+void uip_log(char *msg);
+#define UIP_LOG(m) uip_log(m)
+#else
+#define UIP_LOG(m)
+#endif /* UIP_LOGGING == 1 */
+
+/*-----------------------------------------------------------------------------------*/
+void
+uip_init(void)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    uip_listenports[c] = 0;
+  }
+  for(c = 0; c < UIP_CONNS; ++c) {
+    uip_conns[c].tcpstateflags = CLOSED;
+  }
+#if UIP_ACTIVE_OPEN
+  lastport = 1024;
+#endif /* UIP_ACTIVE_OPEN */
+
+#if UIP_UDP
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    uip_udp_conns[c].lport = 0;
+  }
+#endif /* UIP_UDP */
+  
+
+  /* IPv4 initialization. */
+#if UIP_FIXEDADDR == 0
+  /*  uip_hostaddr[0] = uip_hostaddr[1] = 0;*/
+#endif /* UIP_FIXEDADDR */
+
+}
+/*-----------------------------------------------------------------------------------*/
+#if UIP_ACTIVE_OPEN
+struct uip_conn *
+uip_connect(u16_t *ripaddr, u16_t rport)
+{
+  register struct uip_conn *conn, *cconn;
+  
+  /* Find an unused local port. */
+ again:
+  ++lastport;
+
+  if(lastport >= 32000) {
+    lastport = 4096;
+  }
+
+  /* Check if this port is already in use, and if so try to find
+     another one. */
+  for(c = 0; c < UIP_CONNS; ++c) {
+    conn = &uip_conns[c];
+    if(conn->tcpstateflags != CLOSED &&
+       conn->lport == htons(lastport)) {
+      goto again;
+    }
+  }
+
+  conn = 0;
+  for(c = 0; c < UIP_CONNS; ++c) {
+    cconn = &uip_conns[c]; 
+    if(cconn->tcpstateflags == CLOSED) {
+      conn = cconn;
+      break;
+    }
+    if(cconn->tcpstateflags == TIME_WAIT) {
+      if(conn == 0 ||
+	 cconn->timer > conn->timer) {
+	conn = cconn;
+      }
+    }
+  }
+
+  if(conn == 0) {
+    return 0;
+  }
+  
+  conn->tcpstateflags = SYN_SENT;
+
+  conn->snd_nxt[0] = iss[0];
+  conn->snd_nxt[1] = iss[1];
+  conn->snd_nxt[2] = iss[2];
+  conn->snd_nxt[3] = iss[3];
+
+  conn->initialmss = conn->mss = UIP_TCP_MSS;
+  
+  conn->len = 1;   /* TCP length of the SYN is one. */
+  conn->nrtx = 0;
+  conn->timer = 1; /* Send the SYN next time around. */
+  conn->rto = UIP_RTO;
+  conn->sa = 0;
+  conn->sv = 16;   /* Initial value of the RTT variance. */
+  conn->lport = htons(lastport);
+  conn->rport = rport;
+  conn->ripaddr[0] = ripaddr[0];
+  conn->ripaddr[1] = ripaddr[1];
+  
+  return conn;
+}
+#endif /* UIP_ACTIVE_OPEN */
+/*-----------------------------------------------------------------------------------*/
+#if UIP_UDP
+struct uip_udp_conn *
+uip_udp_new(u16_t *ripaddr, u16_t rport)
+{
+  register struct uip_udp_conn *conn;
+  
+  /* Find an unused local port. */
+ again:
+  ++lastport;
+
+  if(lastport >= 32000) {
+    lastport = 4096;
+  }
+  
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    if(uip_udp_conns[c].lport == htons(lastport)) {
+      goto again;
+    }
+  }
+
+
+  conn = 0;
+  for(c = 0; c < UIP_UDP_CONNS; ++c) {
+    if(uip_udp_conns[c].lport == 0) {
+      conn = &uip_udp_conns[c]; 
+      break;
+    }
+  }
+
+  if(conn == 0) {
+    return 0;
+  }
+  
+  conn->lport = HTONS(lastport);
+  conn->rport = rport;
+  conn->ripaddr[0] = ripaddr[0];
+  conn->ripaddr[1] = ripaddr[1];
+  
+  return conn;
+}
+#endif /* UIP_UDP */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_unlisten(u16_t port)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(uip_listenports[c] == port) {
+      uip_listenports[c] = 0;
+      return;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_listen(u16_t port)
+{
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(uip_listenports[c] == 0) {
+      uip_listenports[c] = port;
+      return;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* XXX: IP fragment reassembly: not well-tested. */
+
+#if UIP_REASSEMBLY
+#define UIP_REASS_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+static u8_t uip_reassbuf[UIP_REASS_BUFSIZE];
+static u8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
+static const u8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f,
+				    0x0f, 0x07, 0x03, 0x01};
+static u16_t uip_reasslen;
+static u8_t uip_reassflags;
+#define UIP_REASS_FLAG_LASTFRAG 0x01
+static u8_t uip_reasstmr;
+
+#define IP_MF   0x20
+
+static u8_t
+uip_reass(void)
+{
+  u16_t offset, len;
+  u16_t i;
+
+  /* If ip_reasstmr is zero, no packet is present in the buffer, so we
+     write the IP header of the fragment into the reassembly
+     buffer. The timer is updated with the maximum age. */
+  if(uip_reasstmr == 0) {
+    memcpy(uip_reassbuf, &BUF->vhl, UIP_IPH_LEN);
+    uip_reasstmr = UIP_REASS_MAXAGE;
+    uip_reassflags = 0;
+    /* Clear the bitmap. */
+    memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap));
+  }
+
+  /* Check if the incoming fragment matches the one currently present
+     in the reasembly buffer. If so, we proceed with copying the
+     fragment into the buffer. */
+  if(BUF->srcipaddr[0] == FBUF->srcipaddr[0] &&
+     BUF->srcipaddr[1] == FBUF->srcipaddr[1] &&
+     BUF->destipaddr[0] == FBUF->destipaddr[0] &&
+     BUF->destipaddr[1] == FBUF->destipaddr[1] &&
+     BUF->ipid[0] == FBUF->ipid[0] &&
+     BUF->ipid[1] == FBUF->ipid[1]) {
+
+    len = (BUF->len[0] << 8) + BUF->len[1] - (BUF->vhl & 0x0f) * 4;
+    offset = (((BUF->ipoffset[0] & 0x3f) << 8) + BUF->ipoffset[1]) * 8;
+
+    /* If the offset or the offset + fragment length overflows the
+       reassembly buffer, we discard the entire packet. */
+    if(offset > UIP_REASS_BUFSIZE ||
+       offset + len > UIP_REASS_BUFSIZE) {
+      uip_reasstmr = 0;
+      goto nullreturn;
+    }
+
+    /* Copy the fragment into the reassembly buffer, at the right
+       offset. */
+    memcpy(&uip_reassbuf[UIP_IPH_LEN + offset],
+	   (char *)BUF + (int)((BUF->vhl & 0x0f) * 4),
+	   len);
+      
+    /* Update the bitmap. */
+    if(offset / (8 * 8) == (offset + len) / (8 * 8)) {
+      /* If the two endpoints are in the same byte, we only update
+	 that byte. */
+	     
+      uip_reassbitmap[offset / (8 * 8)] |=
+	     bitmap_bits[(offset / 8 ) & 7] &
+	     ~bitmap_bits[((offset + len) / 8 ) & 7];
+    } else {
+      /* If the two endpoints are in different bytes, we update the
+	 bytes in the endpoints and fill the stuff inbetween with
+	 0xff. */
+      uip_reassbitmap[offset / (8 * 8)] |=
+	bitmap_bits[(offset / 8 ) & 7];
+      for(i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) {
+	uip_reassbitmap[i] = 0xff;
+      }      
+      uip_reassbitmap[(offset + len) / (8 * 8)] |=
+	~bitmap_bits[((offset + len) / 8 ) & 7];
+    }
+    
+    /* If this fragment has the More Fragments flag set to zero, we
+       know that this is the last fragment, so we can calculate the
+       size of the entire packet. We also set the
+       IP_REASS_FLAG_LASTFRAG flag to indicate that we have received
+       the final fragment. */
+
+    if((BUF->ipoffset[0] & IP_MF) == 0) {
+      uip_reassflags |= UIP_REASS_FLAG_LASTFRAG;
+      uip_reasslen = offset + len;
+    }
+    
+    /* Finally, we check if we have a full packet in the buffer. We do
+       this by checking if we have the last fragment and if all bits
+       in the bitmap are set. */
+    if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) {
+      /* Check all bytes up to and including all but the last byte in
+	 the bitmap. */
+      for(i = 0; i < uip_reasslen / (8 * 8) - 1; ++i) {
+	if(uip_reassbitmap[i] != 0xff) {
+	  goto nullreturn;
+	}
+      }
+      /* Check the last byte in the bitmap. It should contain just the
+	 right amount of bits. */
+      if(uip_reassbitmap[uip_reasslen / (8 * 8)] !=
+	 (u8_t)~bitmap_bits[uip_reasslen / 8 & 7]) {
+	goto nullreturn;
+      }
+
+      /* If we have come this far, we have a full packet in the
+	 buffer, so we allocate a pbuf and copy the packet into it. We
+	 also reset the timer. */
+      uip_reasstmr = 0;
+      memcpy(BUF, FBUF, uip_reasslen);
+
+      /* Pretend to be a "normal" (i.e., not fragmented) IP packet
+	 from now on. */
+      BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
+      BUF->len[0] = uip_reasslen >> 8;
+      BUF->len[1] = uip_reasslen & 0xff;
+      BUF->ipchksum = 0;
+      BUF->ipchksum = ~(uip_ipchksum());
+
+      return uip_reasslen;
+    }
+  }
+
+ nullreturn:
+  return 0;
+}
+#endif /* UIP_REASSEMBLY */
+/*-----------------------------------------------------------------------------------*/
+static void
+uip_add_rcv_nxt(u16_t n)
+{
+  uip_add32(uip_conn->rcv_nxt, n);
+  uip_conn->rcv_nxt[0] = uip_acc32[0];
+  uip_conn->rcv_nxt[1] = uip_acc32[1];
+  uip_conn->rcv_nxt[2] = uip_acc32[2];
+  uip_conn->rcv_nxt[3] = uip_acc32[3];
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_process(u8_t flag)
+{
+  register struct uip_conn *uip_connr = uip_conn;
+  
+  uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
+
+  /* Check if we were invoked because of a poll request for a
+     particular connection. */
+  if(flag == UIP_POLL_REQUEST) {
+    if((uip_connr->tcpstateflags & TS_MASK) == ESTABLISHED &&
+       !uip_outstanding(uip_connr)) {
+	uip_flags = UIP_POLL;
+	UIP_APPCALL();
+	goto appsend;      
+    }
+    goto drop;
+    
+    /* Check if we were invoked because of the perodic timer fireing. */
+  } else if(flag == UIP_TIMER) {
+#if UIP_REASSEMBLY
+    if(uip_reasstmr != 0) {
+      --uip_reasstmr;
+    }
+#endif /* UIP_REASSEMBLY */
+    /* Increase the initial sequence number. */
+    if(++iss[3] == 0) {
+      if(++iss[2] == 0) {
+	if(++iss[1] == 0) {
+	  ++iss[0];
+	}
+      }
+    }    
+    uip_len = 0;
+    uip_slen = 0;
+    if(uip_connr->tcpstateflags == TIME_WAIT ||
+       uip_connr->tcpstateflags == FIN_WAIT_2) {
+      ++(uip_connr->timer);
+      if(uip_connr->timer == UIP_TIME_WAIT_TIMEOUT) {
+	uip_connr->tcpstateflags = CLOSED;
+      }
+    } else if(uip_connr->tcpstateflags != CLOSED) {
+      /* If the connection has outstanding data, we increase the
+	 connection's timer and see if it has reached the RTO value
+	 in which case we retransmit. */
+      if(uip_outstanding(uip_connr)) {
+	if(uip_connr->timer-- == 0) {
+	  if(uip_connr->nrtx == UIP_MAXRTX ||
+	     ((uip_connr->tcpstateflags == SYN_SENT ||
+	       uip_connr->tcpstateflags == SYN_RCVD) &&
+	      uip_connr->nrtx == UIP_MAXSYNRTX)) {
+	    uip_connr->tcpstateflags = CLOSED;
+
+	    /* We call UIP_APPCALL() with uip_flags set to
+	       UIP_TIMEDOUT to inform the application that the
+	       connection has timed out. */
+	    uip_flags = UIP_TIMEDOUT;
+	    UIP_APPCALL();
+
+	    /* We also send a reset packet to the remote host. */
+	    BUF->flags = TCP_RST | TCP_ACK;
+	    goto tcp_send_nodata;
+	  }
+
+	  /* Exponential backoff. */
+	  uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4?
+					 4:
+					 uip_connr->nrtx);
+	  ++(uip_connr->nrtx);
+	  
+	  /* Ok, so we need to retransmit. We do this differently
+	     depending on which state we are in. In ESTABLISHED, we
+	     call upon the application so that it may prepare the
+	     data for the retransmit. In SYN_RCVD, we resend the
+	     SYNACK that we sent earlier and in LAST_ACK we have to
+	     retransmit our FINACK. */
+	  UIP_STAT(++uip_stat.tcp.rexmit);
+	  switch(uip_connr->tcpstateflags & TS_MASK) {
+	  case SYN_RCVD:
+	    /* In the SYN_RCVD state, we should retransmit our
+               SYNACK. */
+	    goto tcp_send_synack;
+	    
+#if UIP_ACTIVE_OPEN
+	  case SYN_SENT:
+	    /* In the SYN_SENT state, we retransmit out SYN. */
+	    BUF->flags = 0;
+	    goto tcp_send_syn;
+#endif /* UIP_ACTIVE_OPEN */
+	    
+	  case ESTABLISHED:
+	    /* In the ESTABLISHED state, we call upon the application
+               to do the actual retransmit after which we jump into
+               the code for sending out the packet (the apprexmit
+               label). */
+	    uip_flags = UIP_REXMIT;
+	    UIP_APPCALL();
+	    goto apprexmit;
+	    
+	  case FIN_WAIT_1:
+	  case CLOSING:
+	  case LAST_ACK:
+	    /* In all these states we should retransmit a FINACK. */
+	    goto tcp_send_finack;
+	    
+	  }
+	}
+      } else if((uip_connr->tcpstateflags & TS_MASK) == ESTABLISHED) {
+	/* If there was no need for a retransmission, we poll the
+           application for new data. */
+	uip_flags = UIP_POLL;
+	UIP_APPCALL();
+	goto appsend;
+      }
+    }
+    goto drop;
+  }
+#if UIP_UDP 
+  if(flag == UIP_UDP_TIMER) {
+    if(uip_udp_conn->lport != 0) {
+      uip_conn = NULL;
+      uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];
+      uip_len = uip_slen = 0;
+      uip_flags = UIP_POLL;
+      UIP_UDP_APPCALL();
+      goto udp_send;
+    } else {
+      goto drop;
+    }
+  }
+#endif
+
+  /* This is where the input processing starts. */
+  UIP_STAT(++uip_stat.ip.recv);
+
+
+  /* Start of IPv4 input header processing code. */
+  
+  /* Check validity of the IP header. */  
+  if(BUF->vhl != 0x45)  { /* IP version and header length. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.vhlerr);
+    UIP_LOG("ip: invalid version or header length.");
+    goto drop;
+  }
+  
+  /* Check the size of the packet. If the size reported to us in
+     uip_len is smaller the size reported in the IP header, we assume
+     that the packet has been corrupted in transit. If the size of
+     uip_len is larger than the size reported in the IP packet header,
+     the packet has been padded and we set uip_len to the correct
+     value.. */
+
+  if((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
+    uip_len = (BUF->len[0] << 8) + BUF->len[1];
+  } else {
+    UIP_LOG("ip: packet shorter than reported in IP header.");
+    goto drop;
+  }
+
+  /* Check the fragment flag. */
+  if((BUF->ipoffset[0] & 0x3f) != 0 ||
+     BUF->ipoffset[1] != 0) { 
+#if UIP_REASSEMBLY
+    uip_len = uip_reass();
+    if(uip_len == 0) {
+      goto drop;
+    }
+#else
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.fragerr);
+    UIP_LOG("ip: fragment dropped.");    
+    goto drop;
+#endif /* UIP_REASSEMBLY */
+  }
+
+  if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
+    /* If we are configured to use ping IP address configuration and
+       hasn't been assigned an IP address yet, we accept all ICMP
+       packets. */
+#if UIP_PINGADDRCONF
+    if(BUF->proto == UIP_PROTO_ICMP) {
+      UIP_LOG("ip: possible ping config packet received.");
+      goto icmp_input;
+    } else {
+      UIP_LOG("ip: packet dropped since no address assigned.");
+      goto drop;
+    }  
+#endif /* UIP_PINGADDRCONF */
+
+  } else {
+    /* If IP broadcast support is configured, we check for a broadcast
+       UDP packet, which may be destined to us. */
+#if UIP_BROADCAST
+    if(BUF->proto == UIP_PROTO_UDP &&
+       BUF->destipaddr[0] == 0xffff &&
+     BUF->destipaddr[1] == 0xffff &&
+       uip_ipchksum() == 0xffff) {
+      goto udp_input;
+    }
+#endif /* UIP_BROADCAST */
+    
+    /* Check if the packet is destined for our IP address. */  
+    if(BUF->destipaddr[0] != uip_hostaddr[0]) {
+      UIP_STAT(++uip_stat.ip.drop);
+      goto drop;
+    }
+    if(BUF->destipaddr[1] != uip_hostaddr[1]) {
+      UIP_STAT(++uip_stat.ip.drop);
+      goto drop;
+    }
+  }
+  
+  if(uip_ipchksum() != 0xffff) { /* Compute and check the IP header
+				    checksum. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.chkerr);
+    UIP_LOG("ip: bad checksum.");
+    goto drop;
+  }
+
+  if(BUF->proto == UIP_PROTO_TCP) { /* Check for TCP packet. If so,
+				       proceed with TCP input
+				       processing. */
+    goto tcp_input;
+  }
+
+#if UIP_UDP
+  if(BUF->proto == UIP_PROTO_UDP) {
+    goto udp_input;
+  }
+#endif /* UIP_UDP */
+
+  if(BUF->proto != UIP_PROTO_ICMP) { /* We only allow ICMP packets from
+					here. */
+    UIP_STAT(++uip_stat.ip.drop);
+    UIP_STAT(++uip_stat.ip.protoerr);
+    UIP_LOG("ip: neither tcp nor icmp.");        
+    goto drop;
+  }
+
+#if UIP_PINGADDRCONF  
+ icmp_input:
+#endif /* UIP_PINGADDRCONF */
+  UIP_STAT(++uip_stat.icmp.recv);
+  
+  /* ICMP echo (i.e., ping) processing. This is simple, we only change
+     the ICMP type from ECHO to ECHO_REPLY and adjust the ICMP
+     checksum before we return the packet. */
+  if(ICMPBUF->type != ICMP_ECHO) {
+    UIP_STAT(++uip_stat.icmp.drop);
+    UIP_STAT(++uip_stat.icmp.typeerr);
+    UIP_LOG("icmp: not icmp echo.");
+    goto drop;
+  }
+
+  /* If we are configured to use ping IP address assignment, we use
+     the destination IP address of this ping packet and assign it to
+     ourself. */
+#if UIP_PINGADDRCONF
+  if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
+    uip_hostaddr[0] = BUF->destipaddr[0];
+    uip_hostaddr[1] = BUF->destipaddr[1];
+  }
+#endif /* UIP_PINGADDRCONF */  
+  
+  ICMPBUF->type = ICMP_ECHO_REPLY;
+  
+  if(ICMPBUF->icmpchksum >= HTONS(0xffff - (ICMP_ECHO << 8))) {
+    ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8) + 1;
+  } else {
+    ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8);
+  }
+  
+  /* Swap IP addresses. */
+  tmp16 = BUF->destipaddr[0];
+  BUF->destipaddr[0] = BUF->srcipaddr[0];
+  BUF->srcipaddr[0] = tmp16;
+  tmp16 = BUF->destipaddr[1];
+  BUF->destipaddr[1] = BUF->srcipaddr[1];
+  BUF->srcipaddr[1] = tmp16;
+
+  UIP_STAT(++uip_stat.icmp.sent);
+  goto send;
+
+  /* End of IPv4 input header processing code. */
+  
+
+#if UIP_UDP
+  /* UDP input processing. */
+ udp_input:
+  /* UDP processing is really just a hack. We don't do anything to the
+     UDP/IP headers, but let the UDP application do all the hard
+     work. If the application sets uip_slen, it has a packet to
+     send. */
+#if UIP_UDP_CHECKSUMS
+  uip_len = uip_len - UIP_IPTCPH_LEN;
+  uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
+  if(uip_udpchksum() != 0xffff) {
+    printf("checksum 0x%04x\n", uip_udpchksum());
+    UIP_STAT(++uip_stat.udp.drop);
+    UIP_STAT(++uip_stat.udp.chkerr);
+    UIP_LOG("udp: bad checksum.");    
+    goto drop;
+  }
+  uip_len = uip_len + (UIP_IPTCPH_LEN - UIP_IPUDPH_LEN);
+#else /* UIP_UDP_CHECKSUMS */
+  uip_len = uip_len - UIP_IPUDPH_LEN;
+#endif /* UIP_UDP_CHECKSUMS */
+
+  /* Demultiplex this UDP packet between the UDP "connections". */
+  for(uip_udp_conn = &uip_udp_conns[0];
+      uip_udp_conn < &uip_udp_conns[UIP_UDP_CONNS];
+      ++uip_udp_conn) {
+    /* If the local UDP port is non-zero, the connection is considered
+       to be used. If so, the local port number is checked against the
+       destination port number in the received packet. If the two port
+       numbers match, the remote port number is checked if the
+       connection is bound to a remote port. Finally, if the
+       connection is bound to a remote IP address, the source IP
+       address of the packet is checked. */
+    if(uip_udp_conn->lport != 0 && 
+       UDPBUF->destport == uip_udp_conn->lport &&
+       (uip_udp_conn->rport == 0 ||
+        UDPBUF->srcport == uip_udp_conn->rport) &&
+       ((uip_udp_conn->ripaddr[0] | uip_udp_conn->ripaddr[1]) == 0 ||
+	(uip_udp_conn->ripaddr[0] == 0xffff &&
+	 uip_udp_conn->ripaddr[1] == 0xffff) ||	
+	uip_ipaddr_cmp(BUF->srcipaddr, uip_udp_conn->ripaddr))) {
+      goto udp_found; 
+    }
+  }
+  UIP_LOG("udp: no matching connection found");    
+  goto drop;
+  
+ udp_found:
+  uip_conn = NULL;
+  uip_flags = UIP_NEWDATA;
+  uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];
+  uip_slen = 0;
+  UIP_UDP_APPCALL();
+ udp_send:
+  if(uip_slen == 0) {
+    goto drop;      
+  }
+  uip_len = uip_slen + UIP_IPUDPH_LEN;
+
+  BUF->len[0] = (uip_len >> 8);
+  BUF->len[1] = (uip_len & 0xff);
+  
+  BUF->proto = UIP_PROTO_UDP;
+
+  UDPBUF->udplen = HTONS(uip_slen + UIP_UDPH_LEN);
+  UDPBUF->udpchksum = 0;
+
+  BUF->srcport  = uip_udp_conn->lport;
+  BUF->destport = uip_udp_conn->rport;
+
+  BUF->srcipaddr[0] = uip_hostaddr[0];
+  BUF->srcipaddr[1] = uip_hostaddr[1];
+  BUF->destipaddr[0] = uip_udp_conn->ripaddr[0];
+  BUF->destipaddr[1] = uip_udp_conn->ripaddr[1];
+ 
+  uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
+
+#if UIP_UDP_CHECKSUMS 
+  /* Calculate UDP checksum. */
+  UDPBUF->udpchksum = ~(uip_udpchksum());
+  if(UDPBUF->udpchksum == 0) {
+    UDPBUF->udpchksum = 0xffff;
+  }
+#endif /* UIP_UDP_CHECKSUMS */
+  
+  goto ip_send_nolen;
+#endif /* UIP_UDP */
+  
+  /* TCP input processing. */  
+ tcp_input:
+  UIP_STAT(++uip_stat.tcp.recv);
+
+  /* Start of TCP input header processing code. */
+  
+  if(uip_tcpchksum() != 0xffff) {   /* Compute and check the TCP
+				       checksum. */
+    UIP_STAT(++uip_stat.tcp.drop);
+    UIP_STAT(++uip_stat.tcp.chkerr);
+    UIP_LOG("tcp: bad checksum.");
+    goto drop;
+  }
+  
+  
+  /* Demultiplex this segment. */
+  /* First check any active connections. */
+  for(uip_connr = &uip_conns[0]; uip_connr <= &uip_conns[UIP_CONNS - 1];
+      ++uip_connr) {
+    if(uip_connr->tcpstateflags != CLOSED &&
+       BUF->destport == uip_connr->lport &&
+       BUF->srcport == uip_connr->rport &&
+       BUF->srcipaddr[0] == uip_connr->ripaddr[0] &&
+       BUF->srcipaddr[1] == uip_connr->ripaddr[1]) {
+      goto found;    
+    }
+  }
+
+  /* If we didn't find and active connection that expected the packet,
+     either this packet is an old duplicate, or this is a SYN packet
+     destined for a connection in LISTEN. If the SYN flag isn't set,
+     it is an old packet and we send a RST. */
+  if((BUF->flags & TCP_CTL) != TCP_SYN) {
+    goto reset;
+  }
+  
+  tmp16 = BUF->destport;
+  /* Next, check listening connections. */  
+  for(c = 0; c < UIP_LISTENPORTS; ++c) {
+    if(tmp16 == uip_listenports[c])
+      goto found_listen;
+  }
+  
+  /* No matching connection found, so we send a RST packet. */
+  UIP_STAT(++uip_stat.tcp.synrst);
+ reset:
+
+  /* We do not send resets in response to resets. */
+  if(BUF->flags & TCP_RST) {
+    goto drop;
+  }
+
+  UIP_STAT(++uip_stat.tcp.rst);
+  
+  BUF->flags = TCP_RST | TCP_ACK;
+  uip_len = UIP_IPTCPH_LEN;
+  BUF->tcpoffset = 5 << 4;
+
+  /* Flip the seqno and ackno fields in the TCP header. */
+  c = BUF->seqno[3];
+  BUF->seqno[3] = BUF->ackno[3];  
+  BUF->ackno[3] = c;
+  
+  c = BUF->seqno[2];
+  BUF->seqno[2] = BUF->ackno[2];  
+  BUF->ackno[2] = c;
+  
+  c = BUF->seqno[1];
+  BUF->seqno[1] = BUF->ackno[1];
+  BUF->ackno[1] = c;
+  
+  c = BUF->seqno[0];
+  BUF->seqno[0] = BUF->ackno[0];  
+  BUF->ackno[0] = c;
+
+  /* We also have to increase the sequence number we are
+     acknowledging. If the least significant byte overflowed, we need
+     to propagate the carry to the other bytes as well. */
+  if(++BUF->ackno[3] == 0) {
+    if(++BUF->ackno[2] == 0) {
+      if(++BUF->ackno[1] == 0) {
+	++BUF->ackno[0];
+      }
+    }
+  }
+ 
+  /* Swap port numbers. */
+  tmp16 = BUF->srcport;
+  BUF->srcport = BUF->destport;
+  BUF->destport = tmp16;
+  
+  /* Swap IP addresses. */
+  tmp16 = BUF->destipaddr[0];
+  BUF->destipaddr[0] = BUF->srcipaddr[0];
+  BUF->srcipaddr[0] = tmp16;
+  tmp16 = BUF->destipaddr[1];
+  BUF->destipaddr[1] = BUF->srcipaddr[1];
+  BUF->srcipaddr[1] = tmp16;
+
+  
+  /* And send out the RST packet! */
+  goto tcp_send_noconn;
+
+  /* This label will be jumped to if we matched the incoming packet
+     with a connection in LISTEN. In that case, we should create a new
+     connection and send a SYNACK in return. */
+ found_listen:
+  /* First we check if there are any connections avaliable. Unused
+     connections are kept in the same table as used connections, but
+     unused ones have the tcpstate set to CLOSED. Also, connections in
+     TIME_WAIT are kept track of and we'll use the oldest one if no
+     CLOSED connections are found. Thanks to Eddie C. Dost for a very
+     nice algorithm for the TIME_WAIT search. */
+  uip_connr = 0;
+  for(c = 0; c < UIP_CONNS; ++c) {
+    if(uip_conns[c].tcpstateflags == CLOSED) {
+      uip_connr = &uip_conns[c];
+      break;
+    }
+    if(uip_conns[c].tcpstateflags == TIME_WAIT) {
+      if(uip_connr == 0 ||
+	 uip_conns[c].timer > uip_connr->timer) {
+	uip_connr = &uip_conns[c];
+      }
+    }
+  }
+
+  if(uip_connr == 0) {
+    /* All connections are used already, we drop packet and hope that
+       the remote end will retransmit the packet at a time when we
+       have more spare connections. */
+    UIP_STAT(++uip_stat.tcp.syndrop);
+    UIP_LOG("tcp: found no unused connections.");
+    goto drop;
+  }
+  uip_conn = uip_connr;
+  
+  /* Fill in the necessary fields for the new connection. */
+  uip_connr->rto = uip_connr->timer = UIP_RTO;
+  uip_connr->sa = 0;
+  uip_connr->sv = 4;  
+  uip_connr->nrtx = 0;
+  uip_connr->lport = BUF->destport;
+  uip_connr->rport = BUF->srcport;
+  uip_connr->ripaddr[0] = BUF->srcipaddr[0];
+  uip_connr->ripaddr[1] = BUF->srcipaddr[1];
+  uip_connr->tcpstateflags = SYN_RCVD;
+
+  uip_connr->snd_nxt[0] = iss[0];
+  uip_connr->snd_nxt[1] = iss[1];
+  uip_connr->snd_nxt[2] = iss[2];
+  uip_connr->snd_nxt[3] = iss[3];
+  uip_connr->len = 1;
+
+  /* rcv_nxt should be the seqno from the incoming packet + 1. */
+  uip_connr->rcv_nxt[3] = BUF->seqno[3];
+  uip_connr->rcv_nxt[2] = BUF->seqno[2];
+  uip_connr->rcv_nxt[1] = BUF->seqno[1];
+  uip_connr->rcv_nxt[0] = BUF->seqno[0];
+  uip_add_rcv_nxt(1);
+
+  /* Parse the TCP MSS option, if present. */
+  if((BUF->tcpoffset & 0xf0) > 0x50) {
+    for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) {
+      opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + c];
+      if(opt == TCP_OPT_END) {
+	/* End of options. */	
+	break;
+      } else if(opt == TCP_OPT_NOOP) {
+	++c;
+	/* NOP option. */
+      } else if(opt == TCP_OPT_MSS &&
+		uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) {
+	/* An MSS option with the right option length. */	
+	tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
+	  (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
+	uip_connr->initialmss = uip_connr->mss =
+	  tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
+	
+	/* And we are done processing options. */
+	break;
+      } else {
+	/* All other options have a length field, so that we easily
+	   can skip past them. */
+	if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) {
+	  /* If the length field is zero, the options are malformed
+	     and we don't process them further. */
+	  break;
+	}
+	c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c];
+      }      
+    }
+  }
+  
+  /* Our response will be a SYNACK. */
+#if UIP_ACTIVE_OPEN
+ tcp_send_synack:
+  BUF->flags = TCP_ACK;    
+  
+ tcp_send_syn:
+  BUF->flags |= TCP_SYN;    
+#else /* UIP_ACTIVE_OPEN */
+ tcp_send_synack:
+  BUF->flags = TCP_SYN | TCP_ACK;    
+#endif /* UIP_ACTIVE_OPEN */
+  
+  /* We send out the TCP Maximum Segment Size option with our
+     SYNACK. */
+  BUF->optdata[0] = TCP_OPT_MSS;
+  BUF->optdata[1] = TCP_OPT_MSS_LEN;
+  BUF->optdata[2] = (UIP_TCP_MSS) / 256;
+  BUF->optdata[3] = (UIP_TCP_MSS) & 255;
+  uip_len = UIP_IPTCPH_LEN + TCP_OPT_MSS_LEN;
+  BUF->tcpoffset = ((UIP_TCPH_LEN + TCP_OPT_MSS_LEN) / 4) << 4;
+  goto tcp_send;
+
+  /* This label will be jumped to if we found an active connection. */
+ found:
+  uip_conn = uip_connr;
+  uip_flags = 0;
+  /* We do a very naive form of TCP reset processing; we just accept
+     any RST and kill our connection. We should in fact check if the
+     sequence number of this reset is wihtin our advertised window
+     before we accept the reset. */
+  if(BUF->flags & TCP_RST) {
+    uip_connr->tcpstateflags = CLOSED;
+    UIP_LOG("tcp: got reset, aborting connection.");
+    uip_flags = UIP_ABORT;
+    UIP_APPCALL();
+    goto drop;
+  }      
+  /* Calculated the length of the data, if the application has sent
+     any data to us. */
+  c = (BUF->tcpoffset >> 4) << 2;
+  /* uip_len will contain the length of the actual TCP data. This is
+     calculated by subtracing the length of the TCP header (in
+     c) and the length of the IP header (20 bytes). */
+  uip_len = uip_len - c - UIP_IPH_LEN;
+
+  /* First, check if the sequence number of the incoming packet is
+     what we're expecting next. If not, we send out an ACK with the
+     correct numbers in. */
+  if(!(((uip_connr->tcpstateflags & TS_MASK) == SYN_SENT) &&
+       ((BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)))) {
+    if((uip_len > 0 || ((BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) &&
+       (BUF->seqno[0] != uip_connr->rcv_nxt[0] ||
+	BUF->seqno[1] != uip_connr->rcv_nxt[1] ||
+	BUF->seqno[2] != uip_connr->rcv_nxt[2] ||
+	BUF->seqno[3] != uip_connr->rcv_nxt[3])) {
+      goto tcp_send_ack;
+    }
+  }
+
+  /* Next, check if the incoming segment acknowledges any outstanding
+     data. If so, we update the sequence number, reset the length of
+     the outstanding data, calculate RTT estimations, and reset the
+     retransmission timer. */
+  if((BUF->flags & TCP_ACK) && uip_outstanding(uip_connr)) {
+    uip_add32(uip_connr->snd_nxt, uip_connr->len);
+
+    if(BUF->ackno[0] == uip_acc32[0] &&
+       BUF->ackno[1] == uip_acc32[1] &&
+       BUF->ackno[2] == uip_acc32[2] &&
+       BUF->ackno[3] == uip_acc32[3]) {
+      /* Update sequence number. */
+      uip_connr->snd_nxt[0] = uip_acc32[0];
+      uip_connr->snd_nxt[1] = uip_acc32[1];
+      uip_connr->snd_nxt[2] = uip_acc32[2];
+      uip_connr->snd_nxt[3] = uip_acc32[3];
+	
+
+      /* Do RTT estimation, unless we have done retransmissions. */
+      if(uip_connr->nrtx == 0) {
+	signed char m;
+	m = uip_connr->rto - uip_connr->timer;
+	/* This is taken directly from VJs original code in his paper */
+	m = m - (uip_connr->sa >> 3);
+	uip_connr->sa += m;
+	if(m < 0) {
+	  m = -m;
+	}
+	m = m - (uip_connr->sv >> 2);
+	uip_connr->sv += m;
+	uip_connr->rto = (uip_connr->sa >> 3) + uip_connr->sv;
+
+      }
+      /* Set the acknowledged flag. */
+      uip_flags = UIP_ACKDATA;
+      /* Reset the retransmission timer. */
+      uip_connr->timer = uip_connr->rto;
+
+      /* Reset length of outstanding data. */
+      uip_connr->len = 0;
+    }
+    
+  }
+
+  /* Do different things depending on in what state the connection is. */
+  switch(uip_connr->tcpstateflags & TS_MASK) {
+    /* CLOSED and LISTEN are not handled here. CLOSE_WAIT is not
+	implemented, since we force the application to close when the
+	peer sends a FIN (hence the application goes directly from
+	ESTABLISHED to LAST_ACK). */
+  case SYN_RCVD:
+    /* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and
+       we are waiting for an ACK that acknowledges the data we sent
+       out the last time. Therefore, we want to have the UIP_ACKDATA
+       flag set. If so, we enter the ESTABLISHED state. */
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = ESTABLISHED;
+      uip_flags = UIP_CONNECTED;
+      uip_connr->len = 0;
+      if(uip_len > 0) {
+        uip_flags |= UIP_NEWDATA;
+        uip_add_rcv_nxt(uip_len);
+      }
+      uip_slen = 0;
+      UIP_APPCALL();
+      goto appsend;
+    }
+    goto drop;
+#if UIP_ACTIVE_OPEN
+  case SYN_SENT:
+    /* In SYN_SENT, we wait for a SYNACK that is sent in response to
+       our SYN. The rcv_nxt is set to sequence number in the SYNACK
+       plus one, and we send an ACK. We move into the ESTABLISHED
+       state. */
+    if((uip_flags & UIP_ACKDATA) &&
+       (BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)) {
+
+      /* Parse the TCP MSS option, if present. */
+      if((BUF->tcpoffset & 0xf0) > 0x50) {
+	for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) {
+	  opt = uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + c];
+	  if(opt == TCP_OPT_END) {
+	    /* End of options. */	
+	    break;
+	  } else if(opt == TCP_OPT_NOOP) {
+	    ++c;
+	    /* NOP option. */
+	  } else if(opt == TCP_OPT_MSS &&
+		    uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) {
+	    /* An MSS option with the right option length. */
+	    tmp16 = (uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) |
+	      uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 3 + c];
+	    uip_connr->initialmss =
+	      uip_connr->mss = tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
+
+	    /* And we are done processing options. */
+	    break;
+	  } else {
+	    /* All other options have a length field, so that we easily
+	       can skip past them. */
+	    if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) {
+	      /* If the length field is zero, the options are malformed
+		 and we don't process them further. */
+	      break;
+	    }
+	    c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c];
+	  }      
+	}
+      }
+      uip_connr->tcpstateflags = ESTABLISHED;      
+      uip_connr->rcv_nxt[0] = BUF->seqno[0];
+      uip_connr->rcv_nxt[1] = BUF->seqno[1];
+      uip_connr->rcv_nxt[2] = BUF->seqno[2];
+      uip_connr->rcv_nxt[3] = BUF->seqno[3];
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CONNECTED | UIP_NEWDATA;
+      uip_connr->len = 0;
+      uip_len = 0;
+      uip_slen = 0;
+      UIP_APPCALL();
+      goto appsend;
+    }
+    /* Inform the application that the connection failed */
+    uip_flags = UIP_ABORT;
+    UIP_APPCALL();
+    /* The connection is closed after we send the RST */
+    uip_conn->tcpstateflags = CLOSED;
+    goto reset;
+#endif /* UIP_ACTIVE_OPEN */
+    
+  case ESTABLISHED:
+    /* In the ESTABLISHED state, we call upon the application to feed
+    data into the uip_buf. If the UIP_ACKDATA flag is set, the
+    application should put new data into the buffer, otherwise we are
+    retransmitting an old segment, and the application should put that
+    data into the buffer.
+
+    If the incoming packet is a FIN, we should close the connection on
+    this side as well, and we send out a FIN and enter the LAST_ACK
+    state. We require that there is no outstanding data; otherwise the
+    sequence numbers will be screwed up. */
+
+    if(BUF->flags & TCP_FIN && !(uip_connr->tcpstateflags & UIP_STOPPED)) {
+      if(uip_outstanding(uip_connr)) {
+	goto drop;
+      }
+      uip_add_rcv_nxt(1 + uip_len);      
+      uip_flags = UIP_CLOSE;
+      if(uip_len > 0) {
+	uip_flags |= UIP_NEWDATA;
+      }
+      UIP_APPCALL();
+      uip_connr->len = 1;
+      uip_connr->tcpstateflags = LAST_ACK;
+      uip_connr->nrtx = 0;
+    tcp_send_finack:
+      BUF->flags = TCP_FIN | TCP_ACK;      
+      goto tcp_send_nodata;
+    }
+
+    /* Check the URG flag. If this is set, the segment carries urgent
+       data that we must pass to the application. */
+    if((BUF->flags & TCP_URG) != 0) {
+#if UIP_URGDATA > 0
+      uip_urglen = (BUF->urgp[0] << 8) | BUF->urgp[1];
+      if(uip_urglen > uip_len) {
+	/* There is more urgent data in the next segment to come. */
+	uip_urglen = uip_len;
+      }
+      uip_add_rcv_nxt(uip_urglen);
+      uip_len -= uip_urglen;
+      uip_urgdata = uip_appdata;
+      uip_appdata += uip_urglen;
+    } else {
+      uip_urglen = 0;
+#else /* UIP_URGDATA > 0 */      
+      uip_appdata += (BUF->urgp[0] << 8) | BUF->urgp[1];
+      uip_len -= (BUF->urgp[0] << 8) | BUF->urgp[1];
+#endif /* UIP_URGDATA > 0 */      
+    }
+
+    /* If uip_len > 0 we have TCP data in the packet, and we flag this
+       by setting the UIP_NEWDATA flag and update the sequence number
+       we acknowledge. If the application has stopped the dataflow
+       using uip_stop(), we must not accept any data packets from the
+       remote host. */
+    if(uip_len > 0 && !(uip_connr->tcpstateflags & UIP_STOPPED)) {
+      uip_flags |= UIP_NEWDATA;
+      uip_add_rcv_nxt(uip_len);
+    }
+
+    /* Check if the available buffer space advertised by the other end
+       is smaller than the initial MSS for this connection. If so, we
+       set the current MSS to the window size to ensure that the
+       application does not send more data than the other end can
+       handle.
+
+       If the remote host advertises a zero window, we set the MSS to
+       the initial MSS so that the application will send an entire MSS
+       of data. This data will not be acknowledged by the receiver,
+       and the application will retransmit it. This is called the
+       "persistent timer" and uses the retransmission mechanim.
+    */
+    tmp16 = ((u16_t)BUF->wnd[0] << 8) + (u16_t)BUF->wnd[1];
+    if(tmp16 > uip_connr->initialmss ||
+       tmp16 == 0) {
+      tmp16 = uip_connr->initialmss;
+    }
+    uip_connr->mss = tmp16;
+
+    /* If this packet constitutes an ACK for outstanding data (flagged
+       by the UIP_ACKDATA flag, we should call the application since it
+       might want to send more data. If the incoming packet had data
+       from the peer (as flagged by the UIP_NEWDATA flag), the
+       application must also be notified.
+
+       When the application is called, the global variable uip_len
+       contains the length of the incoming data. The application can
+       access the incoming data through the global pointer
+       uip_appdata, which usually points UIP_IPTCPH_LEN + UIP_LLH_LEN
+       bytes into the uip_buf array.
+
+       If the application wishes to send any data, this data should be
+       put into the uip_appdata and the length of the data should be
+       put into uip_len. If the application don't have any data to
+       send, uip_len must be set to 0. */
+    if(uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) {
+      uip_slen = 0;
+      UIP_APPCALL();
+
+    appsend:
+      
+      if(uip_flags & UIP_ABORT) {
+	uip_slen = 0;
+	uip_connr->tcpstateflags = CLOSED;
+	BUF->flags = TCP_RST | TCP_ACK;
+	goto tcp_send_nodata;
+      }
+
+      if(uip_flags & UIP_CLOSE) {
+	uip_slen = 0;
+	uip_connr->len = 1;
+	uip_connr->tcpstateflags = FIN_WAIT_1;
+	uip_connr->nrtx = 0;
+	BUF->flags = TCP_FIN | TCP_ACK;
+	goto tcp_send_nodata;	
+      }
+
+      /* If uip_slen > 0, the application has data to be sent. */
+      if(uip_slen > 0) {
+
+	/* If the connection has acknowledged data, the contents of
+	   the ->len variable should be discarded. */ 
+	if((uip_flags & UIP_ACKDATA) != 0) {
+	  uip_connr->len = 0;
+	}
+
+	/* If the ->len variable is non-zero the connection has
+	   already data in transit and cannot send anymore right
+	   now. */
+	if(uip_connr->len == 0) {
+
+	  /* The application cannot send more than what is allowed by
+	     the mss (the minumum of the MSS and the available
+	     window). */
+	  if(uip_slen > uip_connr->mss) {
+	    uip_slen = uip_connr->mss;
+	  }
+
+	  /* Remember how much data we send out now so that we know
+	     when everything has been acknowledged. */
+	  uip_connr->len = uip_slen;
+	} else {
+
+	  /* If the application already had unacknowledged data, we
+	     make sure that the application does not send (i.e.,
+	     retransmit) out more than it previously sent out. */
+	  uip_slen = uip_connr->len;
+	}
+      }
+      uip_connr->nrtx = 0;
+    apprexmit:
+      uip_appdata = uip_sappdata;
+      
+      /* If the application has data to be sent, or if the incoming
+         packet had new data in it, we must send out a packet. */
+      if(uip_slen > 0 && uip_connr->len > 0) {
+	/* Add the length of the IP and TCP headers. */
+	uip_len = uip_connr->len + UIP_TCPIP_HLEN;
+	/* We always set the ACK flag in response packets. */
+	BUF->flags = TCP_ACK | TCP_PSH;
+	/* Send the packet. */
+	goto tcp_send_noopts;
+      }
+      /* If there is no data to send, just send out a pure ACK if
+	 there is newdata. */
+      if(uip_flags & UIP_NEWDATA) {
+	uip_len = UIP_TCPIP_HLEN;
+	BUF->flags = TCP_ACK;
+	goto tcp_send_noopts;
+      }
+    }
+    goto drop;
+  case LAST_ACK:
+    /* We can close this connection if the peer has acknowledged our
+       FIN. This is indicated by the UIP_ACKDATA flag. */     
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = CLOSED;
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+    }
+    break;
+    
+  case FIN_WAIT_1:
+    /* The application has closed the connection, but the remote host
+       hasn't closed its end yet. Thus we do nothing but wait for a
+       FIN from the other side. */
+    if(uip_len > 0) {
+      uip_add_rcv_nxt(uip_len);
+    }
+    if(BUF->flags & TCP_FIN) {
+      if(uip_flags & UIP_ACKDATA) {
+	uip_connr->tcpstateflags = TIME_WAIT;
+	uip_connr->timer = 0;
+	uip_connr->len = 0;
+      } else {
+	uip_connr->tcpstateflags = CLOSING;
+      }
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+      goto tcp_send_ack;
+    } else if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = FIN_WAIT_2;
+      uip_connr->len = 0;
+      goto drop;
+    }
+    if(uip_len > 0) {
+      goto tcp_send_ack;
+    }
+    goto drop;
+      
+  case FIN_WAIT_2:
+    if(uip_len > 0) {
+      uip_add_rcv_nxt(uip_len);
+    }
+    if(BUF->flags & TCP_FIN) {
+      uip_connr->tcpstateflags = TIME_WAIT;
+      uip_connr->timer = 0;
+      uip_add_rcv_nxt(1);
+      uip_flags = UIP_CLOSE;
+      UIP_APPCALL();
+      goto tcp_send_ack;
+    }
+    if(uip_len > 0) {
+      goto tcp_send_ack;
+    }
+    goto drop;
+
+  case TIME_WAIT:
+    goto tcp_send_ack;
+    
+  case CLOSING:
+    if(uip_flags & UIP_ACKDATA) {
+      uip_connr->tcpstateflags = TIME_WAIT;
+      uip_connr->timer = 0;
+    }
+  }  
+  goto drop;
+  
+
+  /* We jump here when we are ready to send the packet, and just want
+     to set the appropriate TCP sequence numbers in the TCP header. */
+ tcp_send_ack:
+  BUF->flags = TCP_ACK;
+ tcp_send_nodata:
+  uip_len = UIP_IPTCPH_LEN;
+ tcp_send_noopts:
+  BUF->tcpoffset = (UIP_TCPH_LEN / 4) << 4;
+ tcp_send:
+  /* We're done with the input processing. We are now ready to send a
+     reply. Our job is to fill in all the fields of the TCP and IP
+     headers before calculating the checksum and finally send the
+     packet. */
+  BUF->ackno[0] = uip_connr->rcv_nxt[0];
+  BUF->ackno[1] = uip_connr->rcv_nxt[1];
+  BUF->ackno[2] = uip_connr->rcv_nxt[2];
+  BUF->ackno[3] = uip_connr->rcv_nxt[3];
+  
+  BUF->seqno[0] = uip_connr->snd_nxt[0];
+  BUF->seqno[1] = uip_connr->snd_nxt[1];
+  BUF->seqno[2] = uip_connr->snd_nxt[2];
+  BUF->seqno[3] = uip_connr->snd_nxt[3];
+
+  BUF->proto = UIP_PROTO_TCP;
+  
+  BUF->srcport  = uip_connr->lport;
+  BUF->destport = uip_connr->rport;
+
+  BUF->srcipaddr[0] = uip_hostaddr[0];
+  BUF->srcipaddr[1] = uip_hostaddr[1];
+  BUF->destipaddr[0] = uip_connr->ripaddr[0];
+  BUF->destipaddr[1] = uip_connr->ripaddr[1];
+ 
+
+  if(uip_connr->tcpstateflags & UIP_STOPPED) {
+    /* If the connection has issued uip_stop(), we advertise a zero
+       window so that the remote host will stop sending data. */
+    BUF->wnd[0] = BUF->wnd[1] = 0;
+  } else {
+    BUF->wnd[0] = ((UIP_RECEIVE_WINDOW) >> 8);
+    BUF->wnd[1] = ((UIP_RECEIVE_WINDOW) & 0xff); 
+  }
+
+ tcp_send_noconn:
+
+  BUF->len[0] = (uip_len >> 8);
+  BUF->len[1] = (uip_len & 0xff);
+
+  BUF->urgp[0] = BUF->urgp[1] = 0;
+  
+  /* Calculate TCP checksum. */
+  BUF->tcpchksum = 0;
+  BUF->tcpchksum = ~(uip_tcpchksum());
+  
+ ip_send_nolen:
+
+  BUF->vhl = 0x45;
+  BUF->tos = 0;
+  BUF->ipoffset[0] = BUF->ipoffset[1] = 0;
+  BUF->ttl  = UIP_TTL;
+  ++ipid;
+  BUF->ipid[0] = ipid >> 8;
+  BUF->ipid[1] = ipid & 0xff;
+  
+  /* Calculate IP checksum. */
+  BUF->ipchksum = 0;
+  BUF->ipchksum = ~(uip_ipchksum());
+
+  UIP_STAT(++uip_stat.tcp.sent);
+ send:
+  
+  UIP_STAT(++uip_stat.ip.sent);
+  /* Return and let the caller do the actual transmission. */
+  return;
+ drop:
+  uip_len = 0;
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+htons(u16_t val)
+{
+  return HTONS(val);
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki/uip/uip.h b/contiki/uip/uip.h
new file mode 100644
index 0000000..3a3d62e
--- /dev/null
+++ b/contiki/uip/uip.h
@@ -0,0 +1,1370 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the uIP TCP/IP stack.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The uIP TCP/IP stack header file contains definitions for a number
+ * of C macros that are used by uIP programs as well as internal uIP
+ * structures, TCP/IP header structures and function declarations.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip.h,v 1.20 2006/05/17 15:25:15 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIP_H__
+#define __UIP_H__
+
+#include "uipopt.h"
+
+/*-----------------------------------------------------------------------------------*/
+/* First, the functions that should be called from the
+ * system. Initialization, the periodic timer and incoming packets are
+ * handled by the following three functions.
+ */
+
+/**
+ * \defgroup uipconffunc uIP configuration functions
+ * @{
+ *
+ * The uIP configuration functions are used for setting run-time
+ * parameters in uIP such as IP addresses. 
+ */
+
+/**
+ * Set the IP address of this host.
+ *
+ * The IP address is represented as a 4-byte array where the first
+ * octet of the IP address is put in the first member of the 4-byte
+ * array.
+ *
+ * \param addr A pointer to a 4-byte representation of the IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_sethostaddr(addr) do { uip_hostaddr[0] = ((u16_t *)(addr))[0]; \
+                              uip_hostaddr[1] = ((u16_t *)(addr))[1]; } while(0)
+
+/**
+ * Get the IP address of this host.
+ *
+ * The IP address is represented as a 4-byte array where the first
+ * octet of the IP address is put in the first member of the 4-byte
+ * array.
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the currently configured IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_gethostaddr(addr) do { ((u16_t *)(addr))[0] = uip_hostaddr[0]; \
+                              ((u16_t *)(addr))[1] = uip_hostaddr[1]; } while(0)
+
+/**
+ * Set the default router's IP address.
+ *
+ * \param addr A pointer to a 4-byte array containing the IP address
+ * of the default router.
+ *
+ * \hideinitializer
+ */
+#define uip_setdraddr(addr) do { uip_draddr[0] = ((u16_t *)(addr))[0]; \
+                                 uip_draddr[1] = ((u16_t *)(addr))[1]; } while(0)
+
+/**
+ * Set the netmask.
+ *
+ * \param addr A pointer to a 4-byte array containing the IP address
+ * of the netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_setnetmask(addr) do { uip_netmask[0] = ((u16_t *)(addr))[0]; \
+                                  uip_netmask[1] = ((u16_t *)(addr))[1]; } while(0)
+
+
+/**
+ * Get the default router's IP address.
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the IP address of the default router.
+ *
+ * \hideinitializer
+ */
+#define uip_getdraddr(addr) do { ((u16_t *)(addr))[0] = uip_draddr[0]; \
+                                 ((u16_t *)(addr))[1] = uip_draddr[1]; } while(0)
+
+/**
+ * Get the netmask.
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the value of the netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_getnetmask(addr) do { ((u16_t *)(addr))[0] = uip_netmask[0]; \
+                                  ((u16_t *)(addr))[1] = uip_netmask[1]; } while(0)
+
+/** @} */
+
+/**
+ * \defgroup uipinit uIP initialization functions
+ * @{
+ *
+ * The uIP initialization functions are used for booting uIP.
+ */
+
+/**
+ * uIP initialization function.
+ *
+ * This function should be called at boot up to initilize the uIP
+ * TCP/IP stack.
+ */
+void uip_init(void);
+
+/** @} */
+
+/**
+ * \defgroup uipdevfunc uIP device driver functions
+ * @{
+ *
+ * These functions are used by a network device driver for interacting
+ * with uIP.
+ */
+
+/**
+ * Process an incoming packet.
+ *
+ * This function should be called when the device driver has received
+ * a packet from the network. The packet from the device driver must
+ * be present in the uip_buf buffer, and the length of the packet
+ * should be placed in the uip_len variable.
+ *
+ * When the function returns, there may be an outbound packet placed
+ * in the uip_buf packet buffer. If so, the uip_len variable is set to
+ * the length of the packet. If no packet is to be sent out, the
+ * uip_len variable is set to 0.
+ *
+ * The usual way of calling the function is presented by the source
+ * code below.
+ \code
+  uip_len = devicedriver_poll();
+  if(uip_len > 0) {
+    uip_input();
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \note If you are writing a uIP device driver that needs ARP
+ * (Address Resolution Protocol), e.g., when running uIP over
+ * Ethernet, you will need to call the uIP ARP code before calling
+ * this function:
+ \code
+  #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+  uip_len = ethernet_devicedrver_poll();
+  if(uip_len > 0) {
+    if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+      uip_arp_ipin();
+      uip_input();
+      if(uip_len > 0) {
+        uip_arp_out();
+	ethernet_devicedriver_send();
+      }
+    } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+      uip_arp_arpin();
+      if(uip_len > 0) {
+	ethernet_devicedriver_send();
+      }
+    }
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define uip_input()        uip_process(UIP_DATA)
+
+/**
+ * Periodic processing for a connection identified by its number.
+ * 
+ * This function does the necessary periodic processing (timers,
+ * polling) for a uIP TCP conneciton, and should be called when the
+ * periodic uIP timer goes off. It should be called for every
+ * connection, regardless of whether they are open of closed.
+ *
+ * When the function returns, it may have an outbound packet waiting
+ * for service in the uIP packet buffer, and if so the uip_len
+ * variable is set to a value larger than zero. The device driver
+ * should be called to send out the packet.
+ *
+ * The ususal way of calling the function is through a for() loop like
+ * this:
+ \code
+  for(i = 0; i < UIP_CONNS; ++i) {
+    uip_periodic(i);
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }
+ \endcode
+ *
+ * \note If you are writing a uIP device driver that needs ARP
+ * (Address Resolution Protocol), e.g., when running uIP over
+ * Ethernet, you will need to call the uip_arp_out() function before
+ * calling the device driver:
+ \code
+  for(i = 0; i < UIP_CONNS; ++i) {
+    uip_periodic(i);
+    if(uip_len > 0) {
+      uip_arp_out();
+      ethernet_devicedriver_send();
+    }
+  }
+ \endcode 
+ *
+ * \param conn The number of the connection which is to be periodically polled.
+ *
+ * \hideinitializer
+ */
+#define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
+                                uip_process(UIP_TIMER); } while (0)
+
+/**
+ * Perform periodic processing for a connection identified by a pointer
+ * to its structure.
+ *
+ * Same as uip_periodic() but takes a pointer to the actual uip_conn
+ * struct instead of an integer as its argument. This function can be
+ * used to force periodic processing of a specific connection.
+ *
+ * \param conn A pointer to the uip_conn struct for the connection to
+ * be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_periodic_conn(conn) do { uip_conn = conn; \
+                                     uip_process(UIP_TIMER); } while (0)
+
+/**
+ * Reuqest that a particular connection should be polled.
+ *
+ * Similar to uip_periodic_conn() but does not perform any timer
+ * processing. The application is polled for new data.
+ *
+ * \param conn A pointer to the uip_conn struct for the connection to
+ * be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_poll_conn(conn) do { uip_conn = conn; \
+                                 uip_process(UIP_POLL_REQUEST); } while (0)
+
+
+#if UIP_UDP
+/**
+ * Periodic processing for a UDP connection identified by its number.
+ *
+ * This function is essentially the same as uip_periodic(), but for
+ * UDP connections. It is called in a similar fashion as the
+ * uip_periodic() function:
+ \code
+  for(i = 0; i < UIP_UDP_CONNS; i++) {
+    uip_udp_periodic(i);
+    if(uip_len > 0) {
+      devicedriver_send();
+    }
+  }   
+ \endcode
+ *
+ * \note As for the uip_periodic() function, special care has to be
+ * taken when using uIP together with ARP and Ethernet:
+ \code
+  for(i = 0; i < UIP_UDP_CONNS; i++) {
+    uip_udp_periodic(i);
+    if(uip_len > 0) {
+      uip_arp_out();
+      ethernet_devicedriver_send();
+    }
+  }   
+ \endcode
+ *
+ * \param conn The number of the UDP connection to be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
+                                uip_process(UIP_UDP_TIMER); } while (0)
+
+/**
+ * Periodic processing for a UDP connection identified by a pointer to
+ * its structure.
+ *
+ * Same as uip_udp_periodic() but takes a pointer to the actual
+ * uip_conn struct instead of an integer as its argument. This
+ * function can be used to force periodic processing of a specific
+ * connection.
+ *
+ * \param conn A pointer to the uip_udp_conn struct for the connection
+ * to be processed.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \
+                                         uip_process(UIP_UDP_TIMER); } while (0)
+
+
+#endif /* UIP_UDP */
+
+/**
+ * The uIP packet buffer.
+ *
+ * The uip_buf array is used to hold incoming and outgoing
+ * packets. The device driver should place incoming data into this
+ * buffer. When sending data, the device driver should read the link
+ * level headers and the TCP/IP headers from this buffer. The size of
+ * the link level headers is configured by the UIP_LLH_LEN define.
+ *
+ * \note The application data need not be placed in this buffer, so
+ * the device driver must read it from the place pointed to by the
+ * uip_appdata pointer as illustrated by the following example:
+ \code
+ void
+ devicedriver_send(void)
+ {
+    hwsend(&uip_buf[0], UIP_LLH_LEN); 
+    if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+      hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN);    
+    } else {
+      hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN);
+      hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN);
+    }
+ }
+ \endcode
+ */
+extern u8_t uip_buf[UIP_BUFSIZE+2];
+
+/** @} */
+
+/*-----------------------------------------------------------------------------------*/
+/* Functions that are used by the uIP application program. Opening and
+ * closing connections, sending and receiving data, etc. is all
+ * handled by the functions below.
+*/
+/**
+ * \defgroup uipappfunc uIP application functions
+ * @{
+ *
+ * Functions used by an application running of top of uIP.
+ */
+
+/**
+ * Start listening to the specified port.
+ *
+ * \note Since this function expects the port number in network byte
+ * order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ uip_listen(HTONS(80)); 
+ \endcode
+ *
+ * \param port A 16-bit port number in network byte order.
+ */
+void uip_listen(u16_t port);
+
+/**
+ * Stop listening to the specified port.
+ *
+ * \note Since this function expects the port number in network byte
+ * order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ uip_unlisten(HTONS(80)); 
+ \endcode
+ *
+ * \param port A 16-bit port number in network byte order.
+ */
+void uip_unlisten(u16_t port);
+
+/**
+ * Connect to a remote host using TCP.
+ *
+ * This function is used to start a new connection to the specified
+ * port on the specied host. It allocates a new connection identifier,
+ * sets the connection to the SYN_SENT state and sets the
+ * retransmission timer to 0. This will cause a TCP SYN segment to be
+ * sent out the next time this connection is periodically processed,
+ * which usually is done within 0.5 seconds after the call to
+ * uip_connect().
+ *
+ * \note This function is avaliable only if support for active open
+ * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h.
+ *
+ * \note Since this function requires the port number to be in network
+ * byte order, a conversion using HTONS() or htons() is necessary.
+ *
+ \code
+ u16_t ipaddr[2];
+
+ uip_ipaddr(ipaddr, 192,168,1,2);
+ uip_connect(ipaddr, HTONS(80)); 
+ \endcode
+ * 
+ * \param ripaddr A pointer to a 4-byte array representing the IP
+ * address of the remote hot.
+ *
+ * \param port A 16-bit port number in network byte order.
+ *
+ * \return A pointer to the uIP connection identifier for the new connection,
+ * or NULL if no connection could be allocated.   
+ *
+ */
+struct uip_conn *uip_connect(u16_t *ripaddr, u16_t port);
+
+
+
+/**
+ * \internal
+ *
+ * Check if a connection has outstanding (i.e., unacknowledged) data.
+ *
+ * \param conn A pointer to the uip_conn structure for the connection.
+ *
+ * \hideinitializer
+ */
+#define uip_outstanding(conn) ((conn)->len)
+
+/**
+ * Send data on the current connection.
+ *
+ * This function is used to send out a single segment of TCP
+ * data. Only applications that have been invoked by uIP for event
+ * processing can send data. 
+ *
+ * The amount of data that actually is sent out after a call to this
+ * funcion is determined by the maximum amount of data TCP allows. uIP
+ * will automatically crop the data so that only the appropriate
+ * amount of data is sent. The function uip_mss() can be used to query
+ * uIP for the amount of data that actually will be sent.
+ * 
+ * \note This function does not guarantee that the sent data will
+ * arrive at the destination. If the data is lost in the network, the
+ * application will be invoked with the uip_rexmit() event being
+ * set. The application will then have to resend the data using this
+ * function.
+ * 
+ * \param data A pointer to the data which is to be sent.
+ *
+ * \param len The maximum amount of data bytes to be sent.
+ *
+ * \hideinitializer
+ */
+#define uip_send(data, len) do { uip_sappdata = (void *)(data); uip_slen = (len);} while(0)   
+
+/**
+ * The length of any incoming data that is currently avaliable (if avaliable)
+ * in the uip_appdata buffer.
+ *
+ * The test function uip_data() must first be used to check if there
+ * is any data available at all.
+ *
+ * \hideinitializer
+ */
+#define uip_datalen()       uip_len
+
+/**
+ * The length of any out-of-band data (urgent data) that has arrived
+ * on the connection.
+ *
+ * \note The configuration parameter UIP_URGDATA must be set for this
+ * function to be enabled.
+ *
+ * \hideinitializer
+ */
+#define uip_urgdatalen()    uip_urglen
+
+/**
+ * Close the current connection.
+ *
+ * This function will close the current connection in a nice way.
+ *
+ * \hideinitializer
+ */
+#define uip_close()         (uip_flags = UIP_CLOSE)
+
+/**
+ * Abort the current connection.
+ *
+ * This function will abort (reset) the current connection, and is
+ * usually used when an error has occured that prevents using the
+ * uip_close() function.
+ *
+ * \hideinitializer
+ */
+#define uip_abort()         (uip_flags = UIP_ABORT)
+
+/**
+ * Tell the sending host to stop sending data.
+ *
+ * This function will close our receiver's window so that we stop
+ * receiving data for the current connection.
+ *
+ * \hideinitializer
+ */
+#define uip_stop()          (uip_conn->tcpstateflags |= UIP_STOPPED)
+
+/**
+ * Find out if the current connection has been previously stopped with
+ * uip_stop().
+ *
+ * \hideinitializer
+ */
+#define uip_stopped(conn)   ((conn)->tcpstateflags & UIP_STOPPED)
+
+/**
+ * Restart the current connection, if is has previously been stopped
+ * with uip_stop().
+ *
+ * This function will open the receiver's window again so that we
+ * start receiving data for the current connection.
+ *
+ * \hideinitializer
+ */
+#define uip_restart()         do { uip_flags |= UIP_NEWDATA; \
+                                   uip_conn->tcpstateflags &= ~UIP_STOPPED; \
+                              } while(0)
+
+
+/* uIP tests that can be made to determine in what state the current
+   connection is, and what the application function should do. */
+
+/**
+ * Is the current connection a UDP connection?
+ *
+ * This function checks whether the current connection is a UDP connection.
+ *
+ * \hideinitializer
+ *
+ */
+#define uip_udpconnection() (uip_conn == NULL)
+
+/**
+ * Is new incoming data available?
+ *
+ * Will reduce to non-zero if there is new data for the application
+ * present at the uip_appdata pointer. The size of the data is
+ * avaliable through the uip_len variable.
+ *
+ * \hideinitializer
+ */
+#define uip_newdata()   (uip_flags & UIP_NEWDATA)
+
+/**
+ * Has previously sent data been acknowledged?
+ *
+ * Will reduce to non-zero if the previously sent data has been
+ * acknowledged by the remote host. This means that the application
+ * can send new data. 
+ *
+ * \hideinitializer
+ */
+#define uip_acked()   (uip_flags & UIP_ACKDATA)
+
+/**
+ * Has the connection just been connected?  
+ *
+ * Reduces to non-zero if the current connection has been connected to
+ * a remote host. This will happen both if the connection has been
+ * actively opened (with uip_connect()) or passively opened (with
+ * uip_listen()).
+ *
+ * \hideinitializer
+ */
+#define uip_connected() (uip_flags & UIP_CONNECTED)
+
+/**
+ * Has the connection been closed by the other end?
+ *
+ * Is non-zero if the connection has been closed by the remote
+ * host. The application may then do the necessary clean-ups.
+ *
+ * \hideinitializer
+ */
+#define uip_closed()    (uip_flags & UIP_CLOSE)
+
+/**
+ * Has the connection been aborted by the other end?
+ *
+ * Non-zero if the current connection has been aborted (reset) by the
+ * remote host.
+ *
+ * \hideinitializer
+ */
+#define uip_aborted()    (uip_flags & UIP_ABORT)
+
+/**
+ * Has the connection timed out?
+ *
+ * Non-zero if the current connection has been aborted due to too many
+ * retransmissions.
+ *
+ * \hideinitializer
+ */
+#define uip_timedout()    (uip_flags & UIP_TIMEDOUT) 
+
+/**
+ * Do we need to retransmit previously data?
+ *
+ * Reduces to non-zero if the previously sent data has been lost in
+ * the network, and the application should retransmit it. The
+ * application should send the exact same data as it did the last
+ * time, using the uip_send() function.
+ *
+ * \hideinitializer
+ */
+#define uip_rexmit()     (uip_flags & UIP_REXMIT)
+
+/**
+ * Is the connection being polled by uIP?
+ *
+ * Is non-zero if the reason the application is invoked is that the
+ * current connection has been idle for a while and should be
+ * polled.
+ *
+ * The polling event can be used for sending data without having to
+ * wait for the remote host to send data.
+ *
+ * \hideinitializer
+ */ 
+#define uip_poll()       (uip_flags & UIP_POLL)
+
+/**
+ * Get the initial maxium segment size (MSS) of the current
+ * connection.
+ *
+ * \hideinitializer
+ */
+#define uip_initialmss()             (uip_conn->initialmss)
+
+/**
+ * Get the current maxium segment size that can be sent on the current
+ * connection.
+ *
+ * The current maxiumum segment size that can be sent on the
+ * connection is computed from the receiver's window and the MSS of
+ * the connection (which also is available by calling
+ * uip_initialmss()).
+ *
+ * \hideinitializer
+ */
+#define uip_mss()             (uip_conn->mss)
+
+/**
+ * Set up a new UDP connection.
+ *
+ * \param ripaddr A pointer to a 4-byte structure representing the IP
+ * address of the remote host.
+ *
+ * \param rport The remote port number in network byte order.
+ *
+ * \return The uip_udp_conn structure for the new connection or NULL
+ * if no connection could be allocated.
+ */
+struct uip_udp_conn *uip_udp_new(u16_t *ripaddr, u16_t rport);
+
+/**
+ * Removed a UDP connection.
+ *
+ * \param conn A pointer to the uip_udp_conn structure for the connection.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_remove(conn) (conn)->lport = 0
+
+/**
+ * Bind a UDP connection to a local port.
+ *
+ * \param conn A pointer to the uip_udp_conn structure for the
+ * connection.
+ *
+ * \param port The local port number, in network byte order.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_bind(conn, port) (conn)->lport = port
+
+/**
+ * Send a UDP datagram of length len on the current connection.
+ *
+ * This function can only be called in response to a UDP event (poll
+ * or newdata). The data must be present in the uip_buf buffer, at the
+ * place pointed to by the uip_appdata pointer.
+ *
+ * \param len The length of the data in the uip_buf buffer.
+ *
+ * \hideinitializer
+ */
+#define uip_udp_send(len) uip_slen = (len)
+
+/** @} */
+
+/* uIP convenience and converting functions. */
+
+/**
+ * \defgroup uipconvfunc uIP conversion functions
+ * @{
+ *
+ * These functions can be used for converting between different data
+ * formats used by uIP.
+ */
+ 
+/**
+ * Pack an IP address into a 4-byte array which is used by uIP to
+ * represent IP addresses.
+ *
+ * Example:
+ \code
+ u16_t ipaddr[2];
+
+ uip_ipaddr(&ipaddr, 192,168,1,2); 
+ \endcode
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the IP addres.
+ * \param addr0 The first octet of the IP address.
+ * \param addr1 The second octet of the IP address.
+ * \param addr2 The third octet of the IP address.
+ * \param addr3 The forth octet of the IP address. 
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
+                     ((u16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \
+                     ((u16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \
+                  } while(0)
+
+/**
+ * Copy an IP address to another IP address.
+ *
+ * Copies an IP address from one place to another.
+ *
+ * Example:
+ \code
+ u16_t ipaddr1[2], ipaddr2[2];
+
+ uip_ipaddr(ipaddr1, 192,16,1,2);
+ uip_ipaddr_copy(ipaddr2, ipaddr1);
+ \endcode
+ *
+ * \param dest The destination for the copy.
+ * \param src The source from where to copy.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr_copy(dest, src) do { \
+                     ((u16_t *)dest)[0] = ((u16_t *)src)[0]; \
+                     ((u16_t *)dest)[1] = ((u16_t *)src)[1]; \
+                  } while(0)
+/**
+ * Compare two IP addresses
+ *
+ * Compares two IP addresses.
+ *
+ * Example:
+ \code
+ u16_t ipaddr1[2], ipaddr2[2];
+
+ uip_ipaddr(ipaddr1, 192,16,1,2);
+ if(uip_ipaddr_cmp(ipaddr2, ipaddr1)) {
+    printf("They are the same");
+ }
+ \endcode
+ *
+ * \param addr1 The first IP address.
+ * \param addr2 The second IP address.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr_cmp(addr1, addr2) (((u16_t *)addr1)[0] == ((u16_t *)addr2)[0] && \
+				      ((u16_t *)addr1)[1] == ((u16_t *)addr2)[1])
+
+/**
+ * Compare two IP addresses with netmasks
+ *
+ * Compares two IP addresses with netmasks. The masks are used to mask
+ * out the bits that are to be compared.
+ *
+ * Example:
+ \code
+ u16_t ipaddr1[2], ipaddr2[2], mask[2];
+
+ uip_ipaddr(mask, 255,255,255,0);
+ uip_ipaddr(ipaddr1, 192,16,1,2);
+ uip_ipaddr(ipaddr2, 192,16,1,3); 
+ if(uip_ipaddr_maskcmp(ipaddr1, ipaddr2, mask)) {
+    printf("They are the same");
+ }
+ \endcode
+ * 
+ * \param addr1 The first IP address.
+ * \param addr2 The second IP address.
+ * \param mask The netmask.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr_maskcmp(addr1, addr2, mask) \
+                          (((((u16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \
+                            (((u16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \
+                           ((((u16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \
+                            (((u16_t *)addr2)[1] & ((u16_t *)mask)[1])))
+
+
+/**
+ * Mask out the network part of an IP address.
+ *
+ * Masks out the network part of an IP address, given the address and
+ * the netmask.
+ *
+ * Example:
+ \code
+ u16_t ipaddr1[2], ipaddr2[2], netmask[2];
+
+ uip_ipaddr(ipaddr1, 192,16,1,2);
+ uip_ipaddr(netmask, 255,255,255,0);
+ uip_ipaddr_mask(ipaddr2, ipaddr1, netmask);
+ \endcode
+ *
+ * In the example above, the variable "ipaddr2" will contain the IP
+ * address 192.168.1.0.
+ *
+ * \param dest Where the result is to be placed.
+ * \param src The IP address.
+ * \param mask The netmask.
+ *
+ * \hideinitializer
+ */  
+#define uip_ipaddr_mask(dest, src, mask) do { \
+                     ((u16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \
+                     ((u16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \
+                  } while(0)
+
+/**
+ * Pick the first octet of an IP address.
+ *
+ * Picks out the first octet of an IP address.
+ *
+ * Example:
+ \code
+ u16_t ipaddr[2];
+ u8_t octet;
+
+ uip_ipaddr(ipaddr, 1,2,3,4);
+ octet = uip_ipaddr1(ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 1.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr1(addr) (htons(((u16_t *)(addr))[0]) >> 8)
+
+/**
+ * Pick the second octet of an IP address.
+ *
+ * Picks out the second octet of an IP address.
+ *
+ * Example:
+ \code
+ u16_t ipaddr[2];
+ u8_t octet;
+
+ uip_ipaddr(ipaddr, 1,2,3,4);
+ octet = uip_ipaddr2(ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 2.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr2(addr) (htons(((u16_t *)(addr))[0]) & 0xff)
+
+/**
+ * Pick the third octet of an IP address.
+ *
+ * Picks out the third octet of an IP address.
+ *
+ * Example:
+ \code
+ u16_t ipaddr[2];
+ u8_t octet;
+
+ uip_ipaddr(ipaddr, 1,2,3,4);
+ octet = uip_ipaddr3(ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 3.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr3(addr) (htons(((u16_t *)(addr))[1]) >> 8)
+
+/**
+ * Pick the fourth octet of an IP address.
+ *
+ * Picks out the fourth octet of an IP address.
+ *
+ * Example:
+ \code
+ u16_t ipaddr[2];
+ u8_t octet;
+
+ uip_ipaddr(ipaddr, 1,2,3,4);
+ octet = uip_ipaddr4(ipaddr);
+ \endcode
+ *
+ * In the example above, the variable "octet" will contain the value 4.
+ *
+ * \hideinitializer
+ */
+#define uip_ipaddr4(addr) (htons(((u16_t *)(addr))[1]) & 0xff)
+
+/**
+ * Convert 16-bit quantity from host byte order to network byte order.
+ *
+ * This macro is primarily used for converting constants from host
+ * byte order to network byte order. For converting variables to
+ * network byte order, use the htons() function instead.
+ *
+ * \hideinitializer
+ */
+#ifndef HTONS
+#   if BYTE_ORDER == BIG_ENDIAN
+#      define HTONS(n) (n)
+#   else /* BYTE_ORDER == BIG_ENDIAN */
+#      define HTONS(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
+#   endif /* BYTE_ORDER == BIG_ENDIAN */
+#endif /* HTONS */
+
+/**
+ * Convert 16-bit quantity from host byte order to network byte order.
+ *
+ * This function is primarily used for converting variables from host
+ * byte order to network byte order. For converting constants to
+ * network byte order, use the HTONS() macro instead.
+ */
+u16_t htons(u16_t val);
+
+/** @} */
+
+/**
+ * Pointer to the application data in the packet buffer.
+ *
+ * This pointer points to the application data when the application is
+ * called. If the application wishes to send data, the application may
+ * use this space to write the data into before calling uip_send().
+ */
+extern u8_t *uip_appdata;
+extern u8_t *uip_sappdata; 
+
+#if UIP_URGDATA > 0 
+/* u8_t *uip_urgdata:
+ *
+ * This pointer points to any urgent data that has been received. Only
+ * present if compiled with support for urgent data (UIP_URGDATA).
+ */
+extern u8_t *uip_urgdata; 
+#endif /* UIP_URGDATA > 0 */
+
+
+/* u[8|16]_t uip_len:
+ *
+ * When the application is called, uip_len contains the length of any
+ * new data that has been received from the remote host. The
+ * application should set this variable to the size of any data that
+ * the application wishes to send. When the network device driver
+ * output function is called, uip_len should contain the length of the
+ * outgoing packet.
+ */
+extern u16_t uip_len, uip_slen;
+
+#if UIP_URGDATA > 0 
+extern u8_t uip_urglen, uip_surglen;
+#endif /* UIP_URGDATA > 0 */
+
+
+/**
+ * Representation of a uIP TCP connection.
+ *
+ * The uip_conn structure is used for identifying a connection. All
+ * but one field in the structure are to be considered read-only by an
+ * application. The only exception is the appstate field whos purpose
+ * is to let the application store application-specific state (e.g.,
+ * file pointers) for the connection. The size of this field is
+ * configured in the "uipopt.h" header file.
+ */
+struct uip_conn {
+  u16_t ripaddr[2];   /**< The IP address of the remote host. */
+  
+  u16_t lport;        /**< The local TCP port, in network byte order. */
+  u16_t rport;        /**< The local remote TCP port, in network byte
+			 order. */  
+  
+  u8_t rcv_nxt[4];    /**< The sequence number that we expect to
+			 receive next. */
+  u8_t snd_nxt[4];    /**< The sequence number that was last sent by
+                         us. */
+  u16_t len;          /**< Length of the data that was previously sent. */
+  u16_t mss;          /**< Current maximum segment size for the
+			 connection. */
+  u16_t initialmss;   /**< Initial maximum segment size for the
+			 connection. */  
+  u8_t sa;            /**< Retransmission time-out calculation state
+			 variable. */
+  u8_t sv;            /**< Retransmission time-out calculation state
+			 variable. */
+  u8_t rto;           /**< Retransmission time-out. */
+  u8_t tcpstateflags; /**< TCP state and flags. */
+  u8_t timer;         /**< The retransmission timer. */
+  u8_t nrtx;          /**< The number of retransmissions for the last
+			 segment sent. */
+
+  /** The application state. */
+  u8_t appstate[UIP_APPSTATE_SIZE];  
+};
+
+
+/* Pointer to the current connection. */
+extern struct uip_conn *uip_conn;
+/* The array containing all uIP connections. */
+extern struct uip_conn uip_conns[UIP_CONNS];
+/**
+ * \addtogroup uiparch
+ * @{
+ */
+
+/**
+ * 4-byte array used for the 32-bit sequence number calculations.
+ */
+extern u8_t uip_acc32[4];
+
+/** @} */
+
+
+#if UIP_UDP
+/**
+ * Representation of a uIP UDP connection.
+ */
+struct uip_udp_conn {
+  u16_t ripaddr[2];   /**< The IP address of the remote peer. */
+  u16_t lport;        /**< The local port number in network byte order. */
+  u16_t rport;        /**< The remote port number in network byte order. */
+  
+  /** The application state. */
+  u8_t appstate[UIP_APPSTATE_SIZE];    
+};
+
+extern struct uip_udp_conn *uip_udp_conn;
+extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
+#endif /* UIP_UDP */
+
+/**
+ * The structure holding the TCP/IP statistics that are gathered if
+ * UIP_STATISTICS is set to 1.
+ *
+ */
+struct uip_stats {
+  struct {
+    uip_stats_t drop;     /**< Number of dropped packets at the IP
+			     layer. */
+    uip_stats_t recv;     /**< Number of received packets at the IP
+			     layer. */
+    uip_stats_t sent;     /**< Number of sent packets at the IP
+			     layer. */
+    uip_stats_t vhlerr;   /**< Number of packets dropped due to wrong
+			     IP version or header length. */
+    uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
+			     IP length, high byte. */
+    uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
+			     IP length, low byte. */
+    uip_stats_t fragerr;  /**< Number of packets dropped since they
+			     were IP fragments. */
+    uip_stats_t chkerr;   /**< Number of packets dropped due to IP
+			     checksum errors. */
+    uip_stats_t protoerr; /**< Number of packets dropped since they
+			     were neither ICMP, UDP nor TCP. */
+  } ip;                   /**< IP statistics. */
+  struct {
+    uip_stats_t drop;     /**< Number of dropped ICMP packets. */
+    uip_stats_t recv;     /**< Number of received ICMP packets. */
+    uip_stats_t sent;     /**< Number of sent ICMP packets. */
+    uip_stats_t typeerr;  /**< Number of ICMP packets with a wrong
+			     type. */
+  } icmp;                 /**< ICMP statistics. */
+  struct {
+    uip_stats_t drop;     /**< Number of dropped TCP segments. */
+    uip_stats_t recv;     /**< Number of recived TCP segments. */
+    uip_stats_t sent;     /**< Number of sent TCP segments. */
+    uip_stats_t chkerr;   /**< Number of TCP segments with a bad
+			     checksum. */
+    uip_stats_t ackerr;   /**< Number of TCP segments with a bad ACK
+			     number. */
+    uip_stats_t rst;      /**< Number of recevied TCP RST (reset) segments. */
+    uip_stats_t rexmit;   /**< Number of retransmitted TCP segments. */
+    uip_stats_t syndrop;  /**< Number of dropped SYNs due to too few
+			     connections was avaliable. */
+    uip_stats_t synrst;   /**< Number of SYNs for closed ports,
+			     triggering a RST. */
+  } tcp;                  /**< TCP statistics. */
+};
+
+/**
+ * The uIP TCP/IP statistics.
+ *
+ * This is the variable in which the uIP TCP/IP statistics are gathered.
+ */
+extern struct uip_stats uip_stat;
+
+
+/*-----------------------------------------------------------------------------------*/
+/* All the stuff below this point is internal to uIP and should not be
+ * used directly by an application or by a device driver.
+ */
+/*-----------------------------------------------------------------------------------*/
+/* u8_t uip_flags:
+ *
+ * When the application is called, uip_flags will contain the flags
+ * that are defined in this file. Please read below for more
+ * infomation.
+ */
+extern u8_t uip_flags;
+
+/* The following flags may be set in the global variable uip_flags
+   before calling the application callback. The UIP_ACKDATA and
+   UIP_NEWDATA flags may both be set at the same time, whereas the
+   others are mutualy exclusive. Note that these flags should *NOT* be
+   accessed directly, but through the uIP functions/macros. */
+
+#define UIP_ACKDATA   1     /* Signifies that the outstanding data was
+			       acked and the application should send
+			       out new data instead of retransmitting
+			       the last data. */
+#define UIP_NEWDATA   2     /* Flags the fact that the peer has sent
+			       us new data. */
+#define UIP_REXMIT    4     /* Tells the application to retransmit the
+			       data that was last sent. */
+#define UIP_POLL      8     /* Used for polling the application, to
+			       check if the application has data that
+			       it wants to send. */
+#define UIP_CLOSE     16    /* The remote host has closed the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to close the
+			       connection. */
+#define UIP_ABORT     32    /* The remote host has aborted the
+			       connection, thus the connection has
+			       gone away. Or the application signals
+			       that it wants to abort the
+			       connection. */
+#define UIP_CONNECTED 64    /* We have got a connection from a remote
+                               host and have set up a new connection
+                               for it, or an active connection has
+                               been successfully established. */
+
+#define UIP_TIMEDOUT  128   /* The connection has been aborted due to
+			       too many retransmissions. */
+
+
+/* uip_process(flag):
+ *
+ * The actual uIP function which does all the work.
+ */
+void uip_process(u8_t flag);
+
+/* The following flags are passed as an argument to the uip_process()
+   function. They are used to distinguish between the two cases where
+   uip_process() is called. It can be called either because we have
+   incoming data that should be processed, or because the periodic
+   timer has fired. These values are never used directly, but only in
+   the macrose defined in this file. */
+ 
+#define UIP_DATA          1     /* Tells uIP that there is incoming
+				   data in the uip_buf buffer. The
+				   length of the data is stored in the
+				   global variable uip_len. */
+#define UIP_TIMER         2     /* Tells uIP that the periodic timer
+				   has fired. */
+#define UIP_POLL_REQUEST  3     /* Tells uIP that a connection should
+				   be polled. */
+#if UIP_UDP
+#define UIP_UDP_TIMER     4
+#endif /* UIP_UDP */
+
+/* The TCP states used in the uip_conn->tcpstateflags. */
+#define CLOSED      0
+#define SYN_RCVD    1
+#define SYN_SENT    2
+#define ESTABLISHED 3
+#define FIN_WAIT_1  4
+#define FIN_WAIT_2  5
+#define CLOSING     6
+#define TIME_WAIT   7
+#define LAST_ACK    8
+#define TS_MASK     15
+  
+#define UIP_STOPPED      16
+
+#define UIP_TCPIP_HLEN 40
+
+/**
+ * The buffer size available for user data in the \ref uip_buf buffer.
+ *
+ * This macro holds the available size for user data in the \ref
+ * uip_buf buffer. The macro is intended to be used for checking
+ * bounds of available user data.
+ *
+ * Example:
+ \code
+ snprintf(uip_appdata, UIP_APPDATA_SIZE, "%u\n", i);
+ \endcode
+ *
+ * \hideinitializer
+ */
+#define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
+
+/* The TCP and IP headers. */
+typedef struct {
+  /* IP header. */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+  
+  /* TCP header. */
+  u16_t srcport,
+    destport;
+  u8_t seqno[4],  
+    ackno[4],
+    tcpoffset,
+    flags,
+    wnd[2];     
+  u16_t tcpchksum;
+  u8_t urgp[2];
+  u8_t optdata[4];
+} uip_tcpip_hdr;
+
+/* The ICMP and IP headers. */
+typedef struct {
+  /* IP header. */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+  /* ICMP (echo) header. */
+  u8_t type, icode;
+  u16_t icmpchksum;
+  u16_t id, seqno;  
+} uip_icmpip_hdr;
+
+
+/* The UDP and IP headers. */
+typedef struct {
+  /* IP header. */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+  
+  /* UDP header. */
+  u16_t srcport,
+    destport;
+  u16_t udplen;
+  u16_t udpchksum;
+} uip_udpip_hdr;
+
+#define UIP_PROTO_ICMP  1
+#define UIP_PROTO_TCP   6
+#define UIP_PROTO_UDP   17
+
+/* Header sizes. */
+#define UIP_IPH_LEN    20    /* Size of IP header */
+#define UIP_UDPH_LEN    8    /* Size of UDP header */
+#define UIP_TCPH_LEN   20    /* Size of TCP header */
+#define UIP_IPUDPH_LEN 28    /* Size of IP + UDP header */
+#define UIP_IPTCPH_LEN 40    /* Size of IP + TCP header */
+
+
+
+#if UIP_FIXEDADDR
+extern const u16_t uip_hostaddr[2], uip_netmask[2], uip_draddr[2];
+#else /* UIP_FIXEDADDR */
+extern u16_t uip_hostaddr[2], uip_netmask[2], uip_draddr[2];
+#endif /* UIP_FIXEDADDR */
+
+
+
+/**
+ * Representation of a 48-bit Ethernet address.
+ */
+struct uip_eth_addr {
+  u8_t addr[6];
+};
+
+#endif /* __UIP_H__ */
+
+
+/** @} */
+
diff --git a/contiki/uip/uip_arch.h b/contiki/uip/uip_arch.h
new file mode 100644
index 0000000..4c13f6e
--- /dev/null
+++ b/contiki/uip/uip_arch.h
@@ -0,0 +1,138 @@
+/**
+ * \addtogroup uip
+ * {@
+ */
+
+/**
+ * \defgroup uiparch Architecture specific uIP functions
+ * @{
+ *
+ * The functions in the architecture specific module implement the IP
+ * check sum and 32-bit additions.
+ *
+ * The IP checksum calculation is the most computationally expensive
+ * operation in the TCP/IP stack and it therefore pays off to
+ * implement this in efficient assembler. The purpose of the uip-arch
+ * module is to let the checksum functions to be implemented in
+ * architecture specific assembler.
+ *
+ */
+
+/**
+ * \file
+ * Declarations of architecture specific functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.3 2004/09/18 20:17:33 adamdunkels Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+/**
+ * Carry out a 32-bit addition.
+ *
+ * Because not all architectures for which uIP is intended has native
+ * 32-bit arithmetic, uIP uses an external C function for doing the
+ * required 32-bit additions in the TCP protocol processing. This
+ * function should add the two arguments and place the result in the
+ * global variable uip_acc32.
+ *
+ * \note The 32-bit integer pointed to by the op32 parameter and the
+ * result in the uip_acc32 variable are in network byte order (big
+ * endian).
+ *
+ * \param op32 A pointer to a 4-byte array representing a 32-bit
+ * integer in network byte order (big endian).
+ *
+ * \param op16 A 16-bit integer in host byte order.
+ */
+void uip_add32(u8_t *op32, u16_t op16);
+
+/**
+ * Calculate the Internet checksum over a buffer.
+ *
+ * The Internet checksum is the one's complement of the one's
+ * complement sum of all 16-bit words in the buffer.
+ *
+ * See RFC1071.
+ *
+ * \note This function is not called in the current version of uIP,
+ * but future versions might make use of it.
+ *
+ * \param buf A pointer to the buffer over which the checksum is to be
+ * computed.
+ *
+ * \param len The length of the buffer over which the checksum is to
+ * be computed.
+ *
+ * \return The Internet checksum of the buffer.
+ */
+u16_t uip_chksum(u16_t *buf, u16_t len);
+
+/**
+ * Calculate the IP header checksum of the packet header in uip_buf.
+ *
+ * The IP header checksum is the Internet checksum of the 20 bytes of
+ * the IP header.
+ *
+ * \return The IP header checksum of the IP header in the uip_buf
+ * buffer.
+ */
+u16_t uip_ipchksum(void);
+
+/**
+ * Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
+ *
+ * The TCP checksum is the Internet checksum of data contents of the
+ * TCP segment, and a pseudo-header as defined in RFC793.
+ *
+ * \note The uip_appdata pointer that points to the packet data may
+ * point anywhere in memory, so it is not possible to simply calculate
+ * the Internet checksum of the contents of the uip_buf buffer.
+ *
+ * \return The TCP checksum of the TCP segment in uip_buf and pointed
+ * to by uip_appdata.
+ */
+u16_t uip_tcpchksum(void);
+
+u16_t uip_udpchksum(void);
+
+/** @} */
+/** @} */
+
+#endif /* __UIP_ARCH_H__ */
diff --git a/contiki/uip/uip_arp.c b/contiki/uip/uip_arp.c
new file mode 100644
index 0000000..40f6e23
--- /dev/null
+++ b/contiki/uip/uip_arp.c
@@ -0,0 +1,427 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \defgroup uiparp uIP Address Resolution Protocol
+ * @{
+ * 
+ * The Address Resolution Protocol ARP is used for mapping between IP
+ * addresses and link level addresses such as the Ethernet MAC
+ * addresses. ARP uses broadcast queries to ask for the link level
+ * address of a known IP address and the host which is configured with
+ * the IP address for which the query was meant, will respond with its
+ * link level address.
+ *
+ * \note This ARP implementation only supports Ethernet.
+ */
+ 
+/**
+ * \file
+ * Implementation of the ARP Address Resolution Protocol.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arp.c,v 1.15 2005/02/23 22:40:40 oliverschmidt Exp $
+ *
+ */
+
+
+#include "uip_arp.h"
+
+#include <string.h>
+
+struct arp_hdr {
+  struct uip_eth_hdr ethhdr;
+  u16_t hwtype;
+  u16_t protocol;
+  u8_t hwlen;
+  u8_t protolen;
+  u16_t opcode;
+  struct uip_eth_addr shwaddr;
+  u16_t sipaddr[2];
+  struct uip_eth_addr dhwaddr;
+  u16_t dipaddr[2]; 
+};
+
+struct ethip_hdr {
+  struct uip_eth_hdr ethhdr;
+  /* IP header. */
+  u8_t vhl,
+    tos,          
+    len[2],       
+    ipid[2],        
+    ipoffset[2],  
+    ttl,          
+    proto;     
+  u16_t ipchksum;
+  u16_t srcipaddr[2], 
+    destipaddr[2];
+};
+
+#define ARP_REQUEST 1
+#define ARP_REPLY   2
+
+#define ARP_HWTYPE_ETH 1
+
+struct arp_entry {
+  u16_t ipaddr[2];
+  struct uip_eth_addr ethaddr;
+  u8_t time;
+};
+
+static const struct uip_eth_addr broadcast_ethaddr =
+  {{0xff,0xff,0xff,0xff,0xff,0xff}};
+static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
+
+static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
+static u16_t ipaddr[2];
+static u8_t i, c;
+
+static u8_t arptime;
+static u8_t tmpage;
+
+#define BUF   ((struct arp_hdr *)&uip_buf[0])
+#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the ARP module.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_init(void)
+{
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    memset(arp_table[i].ipaddr, 0, 4);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Periodic ARP processing function.
+ *
+ * This function performs periodic timer processing in the ARP module
+ * and should be called at regular intervals. The recommended interval
+ * is 10 seconds between the calls.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_timer(void)
+{
+  struct arp_entry *tabptr;
+  
+  ++arptime;
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    tabptr = &arp_table[i];
+    if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
+       arptime - tabptr->time >= UIP_ARP_MAXAGE) {
+      memset(tabptr->ipaddr, 0, 4);
+    }
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
+{
+  register struct arp_entry *tabptr;
+  /* Walk through the ARP mapping table and try to find an entry to
+     update. If none is found, the IP -> MAC address mapping is
+     inserted in the ARP table. */
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+
+    tabptr = &arp_table[i];
+    /* Only check those entries that are actually in use. */
+    if(tabptr->ipaddr[0] != 0 &&
+       tabptr->ipaddr[1] != 0) {
+
+      /* Check if the source IP address of the incoming packet matches
+         the IP address in this ARP table entry. */
+      if(ipaddr[0] == tabptr->ipaddr[0] &&
+	 ipaddr[1] == tabptr->ipaddr[1]) {
+	 
+	/* An old entry found, update this and return. */
+	memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
+	tabptr->time = arptime;
+
+	return;
+      }
+    }
+  }
+
+  /* If we get here, no existing ARP table entry was found, so we
+     create one. */
+
+  /* First, we try to find an unused entry in the ARP table. */
+  for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+    tabptr = &arp_table[i];
+    if(tabptr->ipaddr[0] == 0 &&
+       tabptr->ipaddr[1] == 0) {
+      break;
+    }
+  }
+
+  /* If no unused entry is found, we try to find the oldest entry and
+     throw it away. */
+  if(i == UIP_ARPTAB_SIZE) {
+    tmpage = 0;
+    c = 0;
+    for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+      tabptr = &arp_table[i];
+      if(arptime - tabptr->time > tmpage) {
+	tmpage = arptime - tabptr->time;
+	c = i;
+      }
+    }
+    i = c;
+    tabptr = &arp_table[i];
+  }
+
+  /* Now, i is the ARP table entry which we will fill with the new
+     information. */
+  memcpy(tabptr->ipaddr, ipaddr, 4);
+  memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
+  tabptr->time = arptime;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * ARP processing for incoming IP packets
+ *
+ * This function should be called by the device driver when an IP
+ * packet has been received. The function will check if the address is
+ * in the ARP cache, and if so the ARP cache entry will be
+ * refreshed. If no ARP cache entry was found, a new one is created.
+ *
+ * This function expects an IP packet with a prepended Ethernet header
+ * in the uip_buf[] buffer, and the length of the packet in the global
+ * variable uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if 0
+void
+uip_arp_ipin(void)
+{
+  uip_len -= sizeof(struct uip_eth_hdr);
+	
+  /* Only insert/update an entry if the source IP address of the
+     incoming IP packet comes from a host on the local network. */
+  if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
+     (uip_hostaddr[0] & uip_netmask[0])) {
+    return;
+  }
+  if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
+     (uip_hostaddr[1] & uip_netmask[1])) {
+    return;
+  }
+  uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
+  
+  return;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * ARP processing for incoming ARP packets.
+ *
+ * This function should be called by the device driver when an ARP
+ * packet has been received. The function will act differently
+ * depending on the ARP packet type: if it is a reply for a request
+ * that we previously sent out, the ARP cache will be filled in with
+ * the values from the ARP reply. If the incoming ARP packet is an ARP
+ * request for our IP address, an ARP reply packet is created and put
+ * into the uip_buf[] buffer.
+ *
+ * When the function returns, the value of the global variable uip_len
+ * indicates whether the device driver should send out a packet or
+ * not. If uip_len is zero, no packet should be sent. If uip_len is
+ * non-zero, it contains the length of the outbound packet that is
+ * present in the uip_buf[] buffer.
+ *
+ * This function expects an ARP packet with a prepended Ethernet
+ * header in the uip_buf[] buffer, and the length of the packet in the
+ * global variable uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_arpin(void)
+{
+  
+  if(uip_len < sizeof(struct arp_hdr)) {
+    uip_len = 0;
+    return;
+  }
+  uip_len = 0;
+  
+  switch(BUF->opcode) {
+  case HTONS(ARP_REQUEST):
+    /* ARP request. If it asked for our address, we send out a
+       reply. */    
+    /*    if(BUF->dipaddr[0] == uip_hostaddr[0] &&
+	  BUF->dipaddr[1] == uip_hostaddr[1]) {*/
+    if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
+      /* First, we register the one who made the request in our ARP
+	 table, since it is likely that we will do more communication
+	 with this host in the future. */
+      uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
+      
+      /* The reply opcode is 2. */
+      BUF->opcode = HTONS(2);
+
+      memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
+      memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
+      
+      BUF->dipaddr[0] = BUF->sipaddr[0];
+      BUF->dipaddr[1] = BUF->sipaddr[1];
+      BUF->sipaddr[0] = uip_hostaddr[0];
+      BUF->sipaddr[1] = uip_hostaddr[1];
+
+      BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);      
+      uip_len = sizeof(struct arp_hdr);
+    }      
+    break;
+  case HTONS(ARP_REPLY):
+    /* ARP reply. We insert or update the ARP table if it was meant
+       for us. */
+    /*    if(BUF->dipaddr[0] == uip_hostaddr[0] &&
+	  BUF->dipaddr[1] == uip_hostaddr[1]) {*/
+    if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
+      uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
+    }
+    break;
+  }
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Prepend Ethernet header to an outbound IP packet and see if we need
+ * to send out an ARP request.
+ *
+ * This function should be called before sending out an IP packet. The
+ * function checks the destination IP address of the IP packet to see
+ * what Ethernet MAC address that should be used as a destination MAC
+ * address on the Ethernet.
+ *
+ * If the destination IP address is in the local network (determined
+ * by logical ANDing of netmask and our IP address), the function
+ * checks the ARP cache to see if an entry for the destination IP
+ * address is found. If so, an Ethernet header is prepended and the
+ * function returns. If no ARP cache entry is found for the
+ * destination IP address, the packet in the uip_buf[] is replaced by
+ * an ARP request packet for the IP address. The IP packet is dropped
+ * and it is assumed that they higher level protocols (e.g., TCP)
+ * eventually will retransmit the dropped packet.
+ *
+ * If the destination IP address is not on the local network, the IP
+ * address of the default router is used instead.
+ *
+ * When the function returns, a packet is present in the uip_buf[]
+ * buffer, and the length of the packet is in the global variable
+ * uip_len.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_arp_out(void)
+{
+  struct arp_entry *tabptr;
+  
+  /* Find the destination IP address in the ARP table and construct
+     the Ethernet header. If the destination IP addres isn't on the
+     local network, we use the default router's IP address instead.
+
+     If not ARP table entry is found, we overwrite the original IP
+     packet with an ARP request for the IP address. */
+
+  /* First check if destination is a local broadcast. */
+  if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) {
+    memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
+  } else {
+    /* Check if the destination address is on the local network. */
+    if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
+      /* Destination address was not on the local network, so we need to
+	 use the default router's IP address instead of the destination
+	 address when determining the MAC address. */
+      uip_ipaddr_copy(ipaddr, uip_draddr); 
+    } else {
+      /* Else, we use the destination IP address. */
+      uip_ipaddr_copy(ipaddr, IPBUF->destipaddr); 
+    }
+      
+    for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
+      tabptr = &arp_table[i];
+      if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) {
+	break;
+      }
+    }
+
+    if(i == UIP_ARPTAB_SIZE) {
+      /* The destination address was not in our ARP table, so we
+	 overwrite the IP packet with an ARP request. */
+
+      memset(BUF->ethhdr.dest.addr, 0xff, 6);
+      memset(BUF->dhwaddr.addr, 0x00, 6);
+      memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+      memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
+    
+      uip_ipaddr_copy(BUF->dipaddr, ipaddr);
+      uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr);
+      BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
+      BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
+      BUF->protocol = HTONS(UIP_ETHTYPE_IP);
+      BUF->hwlen = 6;
+      BUF->protolen = 4;
+      BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
+
+      uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
+    
+      uip_len = sizeof(struct arp_hdr);
+      return;
+    }
+
+    /* Build an ethernet header. */
+    memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
+  }
+  memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
+  
+  IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
+
+  uip_len += sizeof(struct uip_eth_hdr);
+}
+/*-----------------------------------------------------------------------------------*/
+
+/** @} */
+/** @} */
diff --git a/contiki/uip/uip_arp.h b/contiki/uip/uip_arp.h
new file mode 100644
index 0000000..3c2e8c7
--- /dev/null
+++ b/contiki/uip/uip_arp.h
@@ -0,0 +1,146 @@
+/**
+ * \addtogroup uip
+ * @{
+ */
+
+/**
+ * \addtogroup uiparp 
+ * @{
+ */
+ 
+/**
+ * \file
+ * Macros and definitions for the ARP module.
+ * \author Adam Dunkels <adam@dunkels.com>
+ */
+  
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arp.h,v 1.10 2004/09/17 20:59:23 adamdunkels Exp $
+ *
+ */
+
+#ifndef __UIP_ARP_H__
+#define __UIP_ARP_H__
+
+#include "uip.h"
+
+
+extern struct uip_eth_addr uip_ethaddr;
+
+/**
+ * The Ethernet header. 
+ */
+struct uip_eth_hdr {
+  struct uip_eth_addr dest;
+  struct uip_eth_addr src;
+  u16_t type;
+};
+
+#define UIP_ETHTYPE_ARP 0x0806
+#define UIP_ETHTYPE_IP  0x0800
+#define UIP_ETHTYPE_IP6 0x86dd 
+
+
+/* The uip_arp_init() function must be called before any of the other
+   ARP functions. */
+void uip_arp_init(void);
+
+/* The uip_arp_ipin() function should be called whenever an IP packet
+   arrives from the Ethernet. This function refreshes the ARP table or
+   inserts a new mapping if none exists. The function assumes that an
+   IP packet with an Ethernet header is present in the uip_buf buffer
+   and that the length of the packet is in the uip_len variable. */
+/*void uip_arp_ipin(void);*/
+#define uip_arp_ipin()
+
+/* The uip_arp_arpin() should be called when an ARP packet is received
+   by the Ethernet driver. This function also assumes that the
+   Ethernet frame is present in the uip_buf buffer. When the
+   uip_arp_arpin() function returns, the contents of the uip_buf
+   buffer should be sent out on the Ethernet if the uip_len variable
+   is > 0. */
+void uip_arp_arpin(void);
+
+/* The uip_arp_out() function should be called when an IP packet
+   should be sent out on the Ethernet. This function creates an
+   Ethernet header before the IP header in the uip_buf buffer. The
+   Ethernet header will have the correct Ethernet MAC destination
+   address filled in if an ARP table entry for the destination IP
+   address (or the IP address of the default router) is present. If no
+   such table entry is found, the IP packet is overwritten with an ARP
+   request and we rely on TCP to retransmit the packet that was
+   overwritten. In any case, the uip_len variable holds the length of
+   the Ethernet frame that should be transmitted. */
+void uip_arp_out(void);
+
+/* The uip_arp_timer() function should be called every ten seconds. It
+   is responsible for flushing old entries in the ARP table. */
+void uip_arp_timer(void);
+
+/** @} */
+
+/**
+ * \addtogroup uipconffunc
+ * @{
+ */
+
+
+/**
+ * Specifiy the Ethernet MAC address.
+ *
+ * The ARP code needs to know the MAC address of the Ethernet card in
+ * order to be able to respond to ARP queries and to generate working
+ * Ethernet headers.
+ *
+ * \note This macro only specifies the Ethernet MAC address to the ARP
+ * code. It cannot be used to change the MAC address of the Ethernet
+ * card.
+ *
+ * \param eaddr A pointer to a struct uip_eth_addr containing the
+ * Ethernet MAC address of the Ethernet card.
+ *
+ * \hideinitializer
+ */
+#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
+                              uip_ethaddr.addr[1] = eaddr.addr[1];\
+                              uip_ethaddr.addr[2] = eaddr.addr[2];\
+                              uip_ethaddr.addr[3] = eaddr.addr[3];\
+                              uip_ethaddr.addr[4] = eaddr.addr[4];\
+                              uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
+
+/** @} */
+
+
+#endif /* __UIP_ARP_H__ */
+
+
diff --git a/contiki/uip/uipbuf.c b/contiki/uip/uipbuf.c
new file mode 100644
index 0000000..f574b6e
--- /dev/null
+++ b/contiki/uip/uipbuf.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uipbuf.c,v 1.6 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+
+#include "uipbuf.h"
+
+#include <string.h>
+
+/*---------------------------------------------------------------------------*/
+void
+uipbuf_setup(struct uipbuf_buffer *buf,
+	     u8_t *bufptr, u16_t bufsize)
+{
+  buf->buffer = buf->ptr = bufptr;
+  buf->bufsize = buf->left = bufsize;
+}
+/*---------------------------------------------------------------------------*/
+u8_t
+uipbuf_bufdata(struct uipbuf_buffer *buf, u16_t len,
+	       u8_t **dataptr, u16_t *datalen)
+{
+  if(*datalen < buf->left) {
+    memcpy(buf->ptr, *dataptr, *datalen);
+    buf->ptr += *datalen;
+    buf->left -= *datalen;
+    *dataptr += *datalen;
+    *datalen = 0;
+    return UIPBUF_NOT_FULL;
+  } else if(*datalen == buf->left) {
+    memcpy(buf->ptr, *dataptr, *datalen);
+    buf->ptr += *datalen;
+    buf->left = 0;
+    *dataptr += *datalen;
+    *datalen = 0;
+    return UIPBUF_FULL;
+  } else {
+    memcpy(buf->ptr, *dataptr, buf->left);
+    buf->ptr += buf->left;
+    *datalen -= buf->left;
+    *dataptr += buf->left;
+    buf->left = 0;
+    return UIPBUF_FULL;
+  }
+
+}
+/*---------------------------------------------------------------------------*/
+u8_t
+uipbuf_bufto(register struct uipbuf_buffer *buf, u8_t endmarker,
+	     register u8_t **dataptr, register u16_t *datalen)
+{
+  u8_t c;
+  /*
+  int len;
+
+  ptr = memchr(*dataptr, endmarker, *datalen);
+  if(ptr != NULL) {
+    len = ptr - *dataptr;
+  } else {
+    len = *datalen;
+  }
+  memcpy(buf->ptr, *dataptr, len);
+  *dataptr += len;
+  *datalen -= len;
+  buf->ptr += len;
+  */
+  while(buf->left > 0 && *datalen > 0) {
+    c = *buf->ptr = **dataptr;
+    ++*dataptr;
+    ++buf->ptr;
+    --*datalen;
+    --buf->left;
+    
+    if(c == endmarker) {
+      return UIPBUF_FOUND;
+    }
+  }
+
+  if(*datalen == 0) {
+    return UIPBUF_NOT_FOUND;
+  }
+
+  while(*datalen > 0) {
+    c = **dataptr;
+    --*datalen;
+    ++*dataptr;
+    
+    if(c == endmarker) {
+      return UIPBUF_FOUND | UIPBUF_FULL;
+    }
+  }
+  
+  return UIPBUF_FULL;
+}
+/*----------------------------------------------------------------------------*/
+u16_t
+uipbuf_len(struct uipbuf_buffer *buf)
+{
+  return buf->bufsize - buf->left;
+}
+/*----------------------------------------------------------------------------*/
diff --git a/contiki/uip/uipbuf.h b/contiki/uip/uipbuf.h
new file mode 100644
index 0000000..ff14a01
--- /dev/null
+++ b/contiki/uip/uipbuf.h
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: uipbuf.h,v 1.3 2004/09/12 20:24:56 adamdunkels Exp $
+ */
+/**
+ * \file
+ * uIP data buffering helper functions.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+#ifndef __UIPBUF_H__
+#define __UIPBUF_H__
+
+#include "uip.h"
+
+/**
+ * \defgroup uipbuf uIP data buffering helper library.
+ *
+ * The event driven API that uIP uses can be tricky to use when
+ * dealing with incoming TCP data. The data can be split over any
+ * number of incoming segments and uIP does not provide any stream
+ * abstraction by itself. To remedy this, the uIP data buffering
+ * helper library provides a set of functions that make buffering data
+ * easier.
+ *
+ * The data buffering library provides a structure that holds a
+ * pointer to a buffer and the state of the buffer, as well as a set
+ * of functions for manipulating the buffer state. The functions are
+ * intended to facilitate buffering of both data that is of a known
+ * size and data that is terminated by a specified byte.
+ *
+ * @{
+ */
+
+/**
+ * Return value of the buffering functions that indicates that a
+ * buffer was not filled by incoming data.
+ *
+ * \hideinitializer
+ */
+#define UIPBUF_NOT_FULL 0
+#define UIPBUF_NOT_FOUND 0
+
+/**
+ * Return value of the buffering functions that indicates that a
+ * buffer was completely filled by incoming data.
+ *
+ * \hideinitializer
+ */
+#define UIPBUF_FULL 1
+
+/**
+ * Return value of the buffering functions that indicates that an
+ * end-marker byte was found.
+ *
+ * \hideinitializer
+ */
+#define UIPBUF_FOUND 2
+
+/**
+ * The structure that holds the state of a uIP buffer.
+ *
+ * This structure holds the state of a uIP buffer. The structure has
+ * no user-visible elements, but is used through the functions
+ * provided by the library.
+ *
+ * \hideinitializer
+ */
+struct uipbuf_buffer {
+  u8_t *ptr, *buffer;
+  unsigned short left, bufsize;
+};
+
+/**
+ * Set up a new uIP buffer structure.
+ *
+ * This function is used for setting up a uIP buffer structure with a
+ * specified size. The function should be called the first time a uIP
+ * buffer is used. The caller must provide the memory for holding the
+ * buffered bytes and the size of the buffer memory.
+ *
+ * \param buf A pointer to a uipbuf_buffer structure that is to be
+ * initialized.
+ *
+ * \param bufptr A pointer to the memory for holding the buffered
+ * data.
+ * 
+ * \param size The size of the buffer memory.
+ *
+ */
+void uipbuf_setup(struct uipbuf_buffer *buf,
+		  u8_t *bufptr, u16_t size);
+
+/**
+ * Buffer data until the buffer is full.
+ *
+ * This function puts data into the buffer, but no more than the
+ * buffer can hold.
+ *
+ * \param buf A pointer to the ::uipbuf_buffer structure that holds
+ * the state of the buffer.
+ *
+ * \param dataptr A pointer to the data that is to be buffered.
+ *
+ * \param datalen The length of the data that is to be buffered.
+ *
+ * \return If the buffer was not filled, the value UIPBUF_NOT_FULL
+ * is returned. If the buffer was filled, the number of bytes that
+ * could not be buffered is returned. If the buffer was exactly filled
+ * with the data, the value of 0 is returned.
+ *
+ */
+u8_t uipbuf_bufdata(struct uipbuf_buffer *buf, u16_t len,
+		    u8_t **dataptr, u16_t *datalen);
+
+/**
+ * Buffer data until a specific character is found or the buffer is full.
+ *
+ * This function puts data into the buffer until a specific marker
+ * byte is found. The marker byte is put into the buffer at the end of
+ * the data.
+ *
+ * \param buf A pointer to the ::uipbuf_buffer structure that holds
+ * the state of the buffer.
+ *
+ * \param dataptr A pointer to the data that is to be buffered.
+ *
+ * \param datalen The length of the data that is to be buffered.
+ *
+ * \param byte The end-marker byte that indicates the end of the data
+ * that is to be buffered.
+ * 
+ * \return This function returns the number of protruding bytes after
+ * the end-marker byte, if the marker was found. If the marker was not
+ * found and all of the data was buffered, the value of
+ * UIPBUF_NOT_FOUND is returned. If the marker was not found, but the
+ * data made the buffer fill up, the value of UIPBUF_FULL is returned.
+ *
+ */
+u8_t uipbuf_bufto(struct uipbuf_buffer *buf, u8_t endmarker,
+		  u8_t **dataptr, u16_t *datalen);
+
+u16_t uipbuf_len(struct uipbuf_buffer *buf);
+
+/** @} */
+
+#endif /* __UIPBUF_H__ */
diff --git a/contiki/uip/uiplib.c b/contiki/uip/uiplib.c
new file mode 100644
index 0000000..c239d23
--- /dev/null
+++ b/contiki/uip/uiplib.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and the Swedish Institute of
+ * Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack and the Contiki operating system.
+ *
+ * $Id: uiplib.c,v 1.3 2004/09/12 20:24:56 adamdunkels Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "uiplib.h"
+
+#include "ek.h"
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
+{
+  unsigned char tmp;
+  char c;
+  unsigned char i, j;
+
+  tmp = 0;
+  
+  for(i = 0; i < 4; ++i) {
+    j = 0;
+    do {
+      c = *addrstr;
+      ++j;
+      if(j > 4) {
+	return 0;
+      }
+      if(c == '.' || c == 0) {
+	*ipaddr = tmp;
+	++ipaddr;
+	tmp = 0;
+      } else if(c >= '0' && c <= '9') {
+	tmp = (tmp * 10) + (c - '0');
+      } else {
+	return 0;
+      }
+      ++addrstr;
+    } while(c != '.' && c != 0);
+  }
+  return 1;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki/uip/uiplib.h b/contiki/uip/uiplib.h
new file mode 100644
index 0000000..09af1fb
--- /dev/null
+++ b/contiki/uip/uiplib.h
@@ -0,0 +1,71 @@
+/**
+ * \file
+ * Various uIP library functions.
+ * \author
+ * Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment for the C64.
+ *
+ * $Id: uiplib.h,v 1.2 2004/03/18 21:07:00 adamdunkels Exp $
+ *
+ */
+#ifndef __UIPLIB_H__
+#define __UIPLIB_H__
+
+/**
+ * \addtogroup uipconvfunc
+ * @{
+ */
+
+/**
+ * Convert a textual representation of an IP address to a numerical representation.
+ *
+ * This function takes a textual representation of an IP address in
+ * the form a.b.c.d and converts it into a 4-byte array that can be
+ * used by other uIP functions.
+ *
+ * \param addrstr A pointer to a string containing the IP address in
+ * textual form.
+ *
+ * \param addr A pointer to a 4-byte array that will be filled in with
+ * the numerical representation of the address.
+ *
+ * \retval 0 If the IP address could not be parsed.
+ * \retval Non-zero If the IP address was parsed. 
+ */
+unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
+
+/** @} */
+
+#endif /* __UIPLIB_H__ */
diff --git a/contiki/uip/uipopt.h b/contiki/uip/uipopt.h
new file mode 100644
index 0000000..9f88594
--- /dev/null
+++ b/contiki/uip/uipopt.h
@@ -0,0 +1,570 @@
+/**
+ * \defgroup uipopt Configuration options for uIP
+ * @{
+ *
+ * uIP is configured using the per-project configuration file
+ * "uipopt.h". This file contains all compile-time options for uIP and
+ * should be tweaked to match each specific project. The uIP
+ * distribution contains a documented example "uipopt.h" that can be
+ * copied and modified for each project.
+ *
+ * \note Contiki does not use the uipopt.h file to configure uIP, but
+ * uses a per-port uip-conf.h file that should be edited instead.
+ */
+
+/**
+ * \file
+ * Configuration options for uIP.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file is used for tweaking various configuration options for
+ * uIP. You should make a copy of this file into one of your project's
+ * directories instead of editing this example "uipopt.h" file that
+ * comes with the uIP distribution.
+ */
+
+/*
+ * Copyright (c) 2001-2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uipopt.h,v 1.16 2005/02/24 22:25:12 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __UIPOPT_H__
+#define __UIPOPT_H__
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN  3412
+#endif /* LITTLE_ENDIAN */
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN     1234
+#endif /* BIGE_ENDIAN */
+
+#include "uip-conf.h"
+
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipopttypedef uIP type definitions
+ * @{
+ */
+
+/**
+ * The 8-bit unsigned data type.
+ *
+ * This may have to be tweaked for your particular compiler. "unsigned
+ * char" works for most compilers.
+ */
+typedef unsigned char u8_t;
+
+/**
+ * The 16-bit unsigned data type.
+ *
+ * This may have to be tweaked for your particular compiler. "unsigned
+ * short" works for most compilers.
+ */
+typedef unsigned short u16_t;
+
+/**
+ * The statistics data type.
+ *
+ * This datatype determines how high the statistics counters are able
+ * to count.
+ */
+typedef unsigned short uip_stats_t;
+
+/** @} */
+
+#include "tcpip.h"
+
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \defgroup uipoptstaticconf Static configuration options
+ * @{
+ *
+ * These configuration options can be used for setting the IP address
+ * settings statically, but only if UIP_FIXEDADDR is set to 1. The
+ * configuration options for a specific node includes IP address,
+ * netmask and default router as well as the Ethernet address. The
+ * netmask, default router and Ethernet address are appliciable only
+ * if uIP should be run over Ethernet.
+ *
+ * All of these should be changed to suit your project.
+*/
+
+/**
+ * Determines if uIP should use a fixed IP address or not.
+ *
+ * If uIP should use a fixed IP address, the settings are set in the
+ * uipopt.h file. If not, the macros uip_sethostaddr(),
+ * uip_setdraddr() and uip_setnetmask() should be used instead.
+ *
+ * \hideinitializer
+ */
+#define UIP_FIXEDADDR    0
+
+/**
+ * Ping IP address asignment.
+ *
+ * uIP uses a "ping" packets for setting its own IP address if this
+ * option is set. If so, uIP will start with an empty IP address and
+ * the destination IP address of the first incoming "ping" (ICMP echo)
+ * packet will be used for setting the hosts IP address.
+ *
+ * \note This works only if UIP_FIXEDADDR is 0.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_PINGADDRCONF
+#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
+#else /* UIP_CONF_PINGADDRCONF */
+#define UIP_PINGADDRCONF 0
+#endif /* UIP_CONF_PINGADDRCONF */
+
+
+/**
+ * Specifies if the uIP ARP module should be compiled with a fixed
+ * Ethernet MAC address or not.
+ *
+ * If this configuration option is 0, the macro uip_setethaddr() can
+ * be used to specify the Ethernet address at run-time.
+ *
+ * \hideinitializer
+ */
+#define UIP_FIXEDETHADDR 0
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipoptip IP configuration options
+ * @{
+ *
+ */
+/**
+ * The IP TTL (time to live) of IP packets sent by uIP.
+ *
+ * This should normally not be changed.
+ */
+#define UIP_TTL         255
+
+/**
+ * Turn on support for IP packet reassembly.
+ *
+ * uIP supports reassembly of fragmented IP packets. This features
+ * requires an additonal amount of RAM to hold the reassembly buffer
+ * and the reassembly code size is approximately 700 bytes.  The
+ * reassembly buffer is of the same size as the uip_buf buffer
+ * (configured by UIP_BUFSIZE).
+ *
+ * \note IP packet reassembly is not heavily tested.
+ *
+ * \hideinitializer
+ */
+#define UIP_REASSEMBLY 0
+
+/**
+ * The maximum time an IP fragment should wait in the reassembly
+ * buffer before it is dropped.
+ *
+ */
+#define UIP_REASS_MAXAGE 40
+
+/** @} */
+
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipoptudp UDP configuration options
+ * @{
+ *
+ * \note The UDP support in uIP is still not entirely complete; there
+ * is no support for sending or receiving broadcast or multicast
+ * packets, but it works well enough to support a number of vital
+ * applications such as DNS queries, though
+ */
+
+/**
+ * Toggles wether UDP support should be compiled in or not.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP
+#define UIP_UDP UIP_CONF_UDP
+#else /* UIP_CONF_UDP */
+#define UIP_UDP           1
+#endif /* UIP_CONF_UDP */
+
+/**
+ * Toggles if UDP checksums should be used or not.
+ *
+ * \note Support for UDP checksums is currently not included in uIP,
+ * so this option has no function.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP_CHECKSUMS
+#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
+#else
+#define UIP_UDP_CHECKSUMS 0
+#endif
+
+/**
+ * The maximum amount of concurrent UDP connections.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_UDP_CONNS
+#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
+#else /* UIP_CONF_UDP_CONNS */
+#define UIP_UDP_CONNS    10
+#endif /* UIP_CONF_UDP_CONNS */
+
+/**
+ * The name of the function that should be called when UDP datagrams arrive.
+ *
+ * \hideinitializer
+ */
+
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipopttcp TCP configuration options
+ * @{
+ */
+
+/**
+ * Determines if support for opening connections from uIP should be
+ * compiled in.
+ *
+ * If the applications that are running on top of uIP for this project
+ * do not need to open outgoing TCP connections, this configration
+ * option can be turned off to reduce the code size of uIP.
+ *
+ * \hideinitializer
+ */
+#define UIP_ACTIVE_OPEN 1
+
+/**
+ * The maximum number of simultaneously open TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_MAX_CONNECTIONS
+#define UIP_CONNS       10
+#else /* UIP_CONF_MAX_CONNECTIONS */
+#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
+#endif /* UIP_CONF_MAX_CONNECTIONS */
+
+
+/**
+ * The maximum number of simultaneously listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_MAX_LISTENPORTS
+#define UIP_LISTENPORTS 20
+#else /* UIP_CONF_MAX_LISTENPORTS */
+#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS       
+#endif /* UIP_CONF_MAX_LISTENPORTS */
+
+/**
+ * The size of the advertised receiver's window.
+ *
+ * Should be set low (i.e., to the size of the uip_buf buffer) is the
+ * application is slow to process incoming data, or high (32768 bytes)
+ * if the application processes data quickly.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_RECEIVE_WINDOW
+#define UIP_RECEIVE_WINDOW   32768U
+#else
+#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
+#endif
+
+/**
+ * Determines if support for TCP urgent data notification should be
+ * compiled in.
+ *
+ * Urgent data (out-of-band data) is a rarely used TCP feature that
+ * very seldom would be required.
+ *
+ * \hideinitializer
+ */
+#define UIP_URGDATA      0
+
+/**
+ * The initial retransmission timeout counted in timer pulses.
+ *
+ * This should not be changed.
+ */
+#define UIP_RTO         3
+
+/**
+ * The maximum number of times a segment should be retransmitted
+ * before the connection should be aborted.
+ *
+ * This should not be changed.
+ */
+#define UIP_MAXRTX      8
+
+/**
+ * The maximum number of times a SYN segment should be retransmitted
+ * before a connection request should be deemed to have been
+ * unsuccessful.
+ *
+ * This should not need to be changed.
+ */
+#define UIP_MAXSYNRTX      5
+
+/**
+ * The TCP maximum segment size.
+ *
+ * This is should not be to set to more than
+ * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
+ */
+#define UIP_TCP_MSS     (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
+
+/**
+ * How long a connection should stay in the TIME_WAIT state.
+ *
+ * This configiration option has no real implication, and it should be
+ * left untouched.
+ */ 
+#define UIP_TIME_WAIT_TIMEOUT 120
+
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipoptarp ARP configuration options
+ * @{
+ */
+
+/**
+ * The size of the ARP table.
+ *
+ * This option should be set to a larger value if this uIP node will
+ * have many connections from the local network.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_ARPTAB_SIZE
+#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
+#else
+#define UIP_ARPTAB_SIZE 8
+#endif
+
+/**
+ * The maxium age of ARP table entries measured in 10ths of seconds.
+ *
+ * An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
+ * default).
+ */
+#define UIP_ARP_MAXAGE 120
+
+/** @} */
+
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \defgroup uipoptgeneral General configuration options
+ * @{
+ */
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_BUFFER_SIZE
+#define UIP_BUFSIZE     400
+#else /* UIP_CONF_BUFFER_SIZE */
+#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
+#endif /* UIP_CONF_BUFFER_SIZE */
+
+
+/**
+ * Determines if statistics support should be compiled in.
+ *
+ * The statistics is useful for debugging and to show the user.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_STATISTICS
+#define UIP_STATISTICS  0
+#else /* UIP_CONF_STATISTICS */
+#define UIP_STATISTICS UIP_CONF_STATISTICS
+#endif /* UIP_CONF_STATISTICS */
+
+/**
+ * Determines if logging of certain events should be compiled in.
+ *
+ * This is useful mostly for debugging. The function uip_log()
+ * must be implemented to suit the architecture of the project, if
+ * logging is turned on.
+ *
+ * \hideinitializer
+ */
+#ifndef UIP_CONF_LOGGING
+#define UIP_LOGGING     0
+#else /* UIP_CONF_LOGGING */
+#define UIP_LOGGING     UIP_CONF_LOGGING
+#endif /* UIP_CONF_LOGGING */
+
+/**
+ * Broadcast support.
+ *
+ * This flag configures IP broadcast support. This is useful only
+ * together with UDP.
+ *
+ * \hideinitializer
+ *
+ */
+#ifndef UIP_CONF_BROADCAST
+#define UIP_BROADCAST 0
+#else /* UIP_CONF_BROADCAST */
+#define UIP_BROADCAST UIP_CONF_BROADCAST
+#endif /* UIP_CONF_BROADCAST */
+
+/**
+ * Print out a uIP log message.
+ *
+ * This function must be implemented by the module that uses uIP, and
+ * is called by uIP whenever a log message is generated.
+ */
+void uip_log(char *msg);
+
+/**
+ * The link level header length.
+ *
+ * This is the offset into the uip_buf where the IP header can be
+ * found. For Ethernet, this should be set to 14. For SLIP, this
+ * should be set to 0.
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_LLH_LEN
+#define UIP_LLH_LEN UIP_CONF_LLH_LEN
+#else /* UIP_CONF_LLH_LEN */
+#define UIP_LLH_LEN     14
+#endif /* UIP_CONF_LLH_LEN */
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+/**
+ * \defgroup uipoptcpu CPU architecture configuration
+ * @{
+ *
+ * The CPU architecture configuration is where the endianess of the
+ * CPU on which uIP is to be run is specified. Most CPUs today are
+ * little endian, and the most notable exception are the Motorolas
+ * which are big endian. The BYTE_ORDER macro should be changed to
+ * reflect the CPU architecture on which uIP is to be run.
+ */
+
+/**
+ * The byte order of the CPU architecture on which uIP is to be run.
+ *
+ * This option can be either BIG_ENDIAN (Motorola byte order) or
+ * LITTLE_ENDIAN (Intel byte order).
+ *
+ * \hideinitializer
+ */
+#ifdef UIP_CONF_BYTE_ORDER
+#define BYTE_ORDER     UIP_CONF_BYTE_ORDER
+#else /* UIP_CONF_BYTE_ORDER */
+#define BYTE_ORDER     LITTLE_ENDIAN
+#endif /* UIP_CONF_BYTE_ORDER */
+
+
+/** @} */
+/*------------------------------------------------------------------------------*/
+
+/**
+ * \defgroup uipoptapp Appication specific configurations
+ * @{
+ *
+ * An uIP application is implemented using a single application
+ * function that is called by uIP whenever a TCP/IP event occurs. The
+ * name of this function must be registered with uIP at compile time
+ * using the UIP_APPCALL definition.
+ *
+ * uIP applications can store the application state within the
+ * uip_conn structure by specifying the size of the application
+ * structure with the UIP_APPSTATE_SIZE macro.
+ *
+ * The file containing the definitions must be included in the
+ * uipopt.h file.
+ *
+ * The following example illustrates how this can look.
+ \code
+
+void httpd_appcall(void);
+#define UIP_APPCALL     httpd_appcall
+
+struct httpd_state {
+  u8_t state; 
+  u16_t count;
+  char *dataptr;
+  char *script;
+};
+#define UIP_APPSTATE_SIZE (sizeof(struct httpd_state))
+ \endcode
+ */
+
+/**
+ * \var #define UIP_APPCALL
+ *
+ * The name of the application function that uIP should call in
+ * response to TCP/IP events.
+ *
+ */
+
+/**
+ * \var #define UIP_APPSTATE_SIZE
+ *
+ * The size of the application state that is to be stored in the
+ * uip_conn structure.
+ */
+/** @} */
+
+
+#endif /* __UIPOPT_H__ */