Initial port to the bitbox.

Uses the conio driver with a few tweaks to look a little less ugly.
Still not as good as the VNC one, but we don't have a 4 color textmode
(yet?). Some more custom chars and palette efforts like in the VNC
driver could make it look better, still.

TODO
- Embed more apps (but most of them are network related)
- Mouse support (USB)
- Network support (ENC28J60 or other)
- Filesystem on SD card + add the "directory" app
- Dynamic loader is not really needed, we can easily fit all apps in
  flash (more easily than in RAM, actually).
diff --git a/contiki-bitbox/Makefile b/contiki-bitbox/Makefile
new file mode 100644
index 0000000..0d8cb45
--- /dev/null
+++ b/contiki-bitbox/Makefile
@@ -0,0 +1,35 @@
+CONTIKI=../contiki
+
+# -----------------------------------------------------------------------------
+
+NAME = contiki
+DEFINES += FONT_W=6 FONT_H=8
+
+
+GAME_C_FILES = contiki-main.c ctk/ctk-arch.c ctk/conio.c \
+	$(CONTIKI)/apps/about-dsc.c $(CONTIKI)/apps/about.c \
+	$(CONTIKI)/apps/calc-dsc.c $(CONTIKI)/apps/calc.c \
+	$(CONTIKI)/apps/editor-dsc.c $(CONTIKI)/apps/editor.c \
+	$(CONTIKI)/apps/processes-dsc.c $(CONTIKI)/apps/processes.c \
+	$(CONTIKI)/apps/program-handler.c $(CONTIKI)/ctk/ctk.c \
+	$(CONTIKI)/ctk/ctk-conio.c \
+	$(CONTIKI)/ek/arg.c $(CONTIKI)/ek/ek.c $(CONTIKI)/ek/ek-service.c \
+	$(CONTIKI)/lib/cfs.c $(CONTIKI)/lib/ctk-filedialog.c \
+	$(CONTIKI)/lib/memb.c \
+	$(CONTIKI)/lib/petsciiconv.c $(CONTIKI)/lib/timer.c \
+	lib/textmode/textmode.c \
+	lib/events/events.c \
+
+GAME_C_OPTS = -I ctk -I conf -I $(CONTIKI)/apps -I $(CONTIKI)/ctk \
+    -I $(CONTIKI)/ek -I $(CONTIKI)/lib -I $(CONTIKI)/uip \
+#	-D__GP32__ -DCTK_CONIO -DWITH_UIP \
+	-DWITH_WWW -D WITH_TELNET_WWW \
+	-DWITH_TELNET -D WITH_TELNET_ICON \
+	-DWITH_EMAIL -D WITH_EMAIL_ICON \
+	-DWITH_CALC -D WITH_CALC_ICON
+
+BITBOX ?= ../../../../bitbox-dist/sdk
+
+include $(BITBOX)/kernel/bitbox.mk
+
+# -----------------------------------------------------------------------------
diff --git a/contiki-bitbox/conf/cc-conf.h b/contiki-bitbox/conf/cc-conf.h
new file mode 100644
index 0000000..ff365d1
--- /dev/null
+++ b/contiki-bitbox/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/05/19 09:30:10 gpz 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
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-bitbox/conf/clock-conf.h b/contiki-bitbox/conf/clock-conf.h
new file mode 100644
index 0000000..814861a
--- /dev/null
+++ b/contiki-bitbox/conf/clock-conf.h
@@ -0,0 +1,7 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned long clock_time_t;
+#define CLOCK_CONF_SECOND 60
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-bitbox/conf/ctk-conf.h b/contiki-bitbox/conf/ctk-conf.h
new file mode 100644
index 0000000..3f0fa39
--- /dev/null
+++ b/contiki-bitbox/conf/ctk-conf.h
@@ -0,0 +1,80 @@
+/*
+ * 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:48:37 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             (signed char)KEY_HOME
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     (signed char)KEY_END
+
+#define CTK_CONF_WIDGETDOWN_KEY       '\t'
+#define CTK_CONF_WIDGETUP_KEY         (signed char)KEY_PAGEUP
+
+/* 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-bitbox/conf/ctk-conio-conf.h b/contiki-bitbox/conf/ctk-conio-conf.h
new file mode 100644
index 0000000..f0fa209
--- /dev/null
+++ b/contiki-bitbox/conf/ctk-conio-conf.h
@@ -0,0 +1,62 @@
+/*
+ * 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:56:23 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+/* Blue color scheme: */
+#define BORDERCOLOR         0
+#define SCREENCOLOR         1
+#define BACKGROUNDCOLOR     1
+
+#define WINDOWCOLOR_FOCUS   5
+#define WINDOWCOLOR         8
+
+#define DIALOGCOLOR         5
+
+#define WIDGETCOLOR_HLINK   6
+#define WIDGETCOLOR_FWIN    5
+#define WIDGETCOLOR         8
+#define WIDGETCOLOR_DIALOG  5
+#define WIDGETCOLOR_FOCUS   7
+
+#define MENUCOLOR           2
+#define OPENMENUCOLOR       3
+#define ACTIVEMENUITEMCOLOR 4
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-bitbox/conf/ek-conf.h b/contiki-bitbox/conf/ek-conf.h
new file mode 100644
index 0000000..7155251
--- /dev/null
+++ b/contiki-bitbox/conf/ek-conf.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. 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/05/19 09:30:09 gpz 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_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; 
+
+#define EK_CONF_NUMLISTENERS  32    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_MAXPROCS 32
+
+#define EK_CONF_NUMEVENTS 32
+typedef unsigned char ek_num_events_t;
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-bitbox/conf/email-conf.h b/contiki-bitbox/conf/email-conf.h
new file mode 100644
index 0000000..1515662
--- /dev/null
+++ b/contiki-bitbox/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:41:49 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-bitbox/conf/libconio-conf.h b/contiki-bitbox/conf/libconio-conf.h
new file mode 100644
index 0000000..7a53680
--- /dev/null
+++ b/contiki-bitbox/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.3 2004/07/04 21:15:53 adamdunkels Exp $
+ *
+ */
+#ifndef __LIBCONIO_CONF_H__
+#define __LIBCONIO_CONF_H__
+
+#define LIBCONIO_CONF_SCREEN_WIDTH  106
+#define LIBCONIO_CONF_SCREEN_HEIGHT 60
+
+#endif /* __LIBCONIO_CONF_H__ */
+
diff --git a/contiki-bitbox/conf/log-conf.h b/contiki-bitbox/conf/log-conf.h
new file mode 100644
index 0000000..642ac2b
--- /dev/null
+++ b/contiki-bitbox/conf/log-conf.h
@@ -0,0 +1,6 @@
+#ifndef __LOG_CONF_H__
+#define __LOG_CONF_H__
+
+#define LOG_CONF_ENABLED 1
+
+#endif /* __LOG_CONF__H__ */
diff --git a/contiki-bitbox/conf/program-handler-conf.h b/contiki-bitbox/conf/program-handler-conf.h
new file mode 100644
index 0000000..9e95053
--- /dev/null
+++ b/contiki-bitbox/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:59:07 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-bitbox/conf/uip-conf.h b/contiki-bitbox/conf/uip-conf.h
new file mode 100644
index 0000000..8f2bd98
--- /dev/null
+++ b/contiki-bitbox/conf/uip-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. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY 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 2007/09/05 16:11:06 oliverschmidt Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 40
+#define UIP_CONF_MAX_LISTENPORTS 40
+#define UIP_CONF_BUFFER_SIZE     800
+
+#define UIP_CONF_BYTE_ORDER      LITTLE_ENDIAN
+
+#define UIP_CONF_LOGGING         1
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-bitbox/conf/www-conf.h b/contiki-bitbox/conf/www-conf.h
new file mode 100644
index 0000000..12df913
--- /dev/null
+++ b/contiki-bitbox/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/05/19 09:30:09 gpz 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 80
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+   a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 10
+
+/* 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-bitbox/contiki-main.c b/contiki-bitbox/contiki-main.c
new file mode 100644
index 0000000..4a4b464
--- /dev/null
+++ b/contiki-bitbox/contiki-main.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
+ * Distributed under terms of the MIT license.
+ */
+
+// Contiki includes
+#include "ctk.h"
+#include "program-handler.h"
+
+#include "clock-conf.h"
+
+// Applications
+#include "netconf-dsc.h"
+#include "dhcp-dsc.h"
+#include "www-dsc.h"
+#include "webserver-dsc.h"
+#include "ftp-dsc.h"
+#include "telnet-dsc.h"
+#include "email-dsc.h"
+#include "irc-dsc.h"
+#include "editor-dsc.h"
+#include "calc-dsc.h"
+#include "processes-dsc.h"
+#include "shell-dsc.h"
+#include "about-dsc.h"
+
+// Bitbox includes
+#include "lib/textmode/textmode.h"
+
+void conio_init(void)
+{
+	// Clear display and set a visible palette (default is black on black)
+	clear();
+
+	for (int i = 0; i < 256; i++)
+		set_palette(i, 0, 0);
+
+	set_palette(0, RGB(0, 0, 0), RGB(0, 0, 0));       // border (ok)
+	set_palette(1, RGB(0, 0, 0), RGB(146, 146, 255)); // screen (ok)
+	set_palette(3, RGB(0, 0, 0), RGB(128, 128, 128)); // open menu (ok)
+	set_palette(4, RGB(0, 0, 0), RGB(255, 128, 128)); // active menu item (ok)
+	set_palette(5, RGB(0, 0, 0), RGB(240,240,240));     // dialogs (ok)
+	set_palette(6, RGB(100,100,255), RGB(255,128,128));   // highlighted hyperlinks (ok)
+	set_palette(8, RGB(64,64,64), RGB(192,192,192)); // inactive window/widgets
+
+	set_palette(2+16, RGB(0, 0, 0), RGB(255, 255, 255)); // menu (ok)
+	set_palette(6+16, RGB(0, 0, 255), RGB(240,240,240));    // hyperlinks (ok)
+	set_palette(7+16, RGB(0,0,0), RGB(255,128,128));  // focus widget
+
+	set_palette(7, RGB(0,0,64), RGB(192,192,255)); // moving window
+
+
+}
+
+clock_time_t clock_time(void)
+{
+	return vga_frame;
+}
+
+void
+log_message(const char *part1, const char *part2)
+{
+	  printf("%s%s\n", part1, part2);
+}
+
+void bitbox_main(void)
+{
+	ek_init();
+	conio_init();
+	ctk_init();
+	program_handler_init();
+
+#if 0
+  program_handler_add(&netconf_dsc,   "Network setup", 1);
+  program_handler_add(&dhcp_dsc,      "DHCP client",   1);
+  program_handler_add(&www_dsc,       "Web browser",   1);
+  program_handler_add(&webserver_dsc, "Web server",    1);
+  program_handler_add(&ftp_dsc,       "FTP client",    1);
+  program_handler_add(&telnet_dsc,    "Telnet",        1);
+  program_handler_add(&email_dsc,     "E-mail",        1);
+  program_handler_add(&irc_dsc,       "IRC client",    1);
+#endif
+	program_handler_add(&editor_dsc,    "Editor",        1);
+	program_handler_add(&calc_dsc,      "Calculator",    1);
+	program_handler_add(&processes_dsc, "Processes",     1);
+	//program_handler_add(&shell_dsc,     "Command shell", 1);
+	program_handler_add(&about_dsc,     "About Contiki", 0);
+
+	// Call ek_run until everything is initialized. Then, load welcome.prg.
+	while(1) {
+		if(ek_run() == 0) {
+			//program_handler_load("welcome.prg", NULL);
+			//TODO we don't have a loader; so call the init func directly
+			break;
+		}
+	}
+	// Run the main loop.
+	while(1) {
+		if (ek_run() == 0) {
+			// We are out of events to run, sleep a little.
+			wait_vsync(1);
+		}
+	}
+}
diff --git a/contiki-bitbox/ctk/conio.c b/contiki-bitbox/ctk/conio.c
new file mode 100644
index 0000000..0b1d6a2
--- /dev/null
+++ b/contiki-bitbox/ctk/conio.c
@@ -0,0 +1,177 @@
+/*
+ * 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"
+
+#include "lib/textmode/textmode.h"
+
+static unsigned char cursx, cursy;
+static unsigned char color;
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+  return cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+  return cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+clrscr(void)
+{
+  memset(vram, 0, LIBCONIO_SCREEN_WIDTH * LIBCONIO_SCREEN_HEIGHT);
+  memset(vram_attr, 0, LIBCONIO_SCREEN_WIDTH * LIBCONIO_SCREEN_HEIGHT);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+revers(unsigned char c)
+{
+	if (c != 0) color |= 16;
+	else color &= ~16;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputc(char c)
+{
+  ctk_arch_draw_char(c, cursx, cursy, 0, color);
+  ++cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cputs(char *str)
+{
+  cursx += print_at(cursx, cursy, color, str);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cclear(unsigned char length)
+{
+	memset((uint8_t*)vram + cursy * LIBCONIO_SCREEN_WIDTH + cursx, 0, length);
+	memset((uint8_t*)vram_attr + cursy * LIBCONIO_SCREEN_WIDTH + cursx, color, length);
+	cursx += length;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+chline(unsigned char length)
+{
+	memset((uint8_t*)vram + cursy * LIBCONIO_SCREEN_WIDTH + cursx, 196, length);
+	memset((uint8_t*)vram_attr + cursy * LIBCONIO_SCREEN_WIDTH + cursx, color, length);
+	cursx += length;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cvline(unsigned char length)
+{
+  int i;
+  for(i = 0; i < length; ++i) {
+    vram_attr[cursy][cursx] = color;
+    vram[cursy++][cursx] = 179;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+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 &= 16;
+  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-bitbox/ctk/conio.h b/contiki-bitbox/ctk/conio.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contiki-bitbox/ctk/conio.h
diff --git a/contiki-bitbox/ctk/ctk-arch.c b/contiki-bitbox/ctk/ctk-arch.c
new file mode 100644
index 0000000..dae9818
--- /dev/null
+++ b/contiki-bitbox/ctk/ctk-arch.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
+ * Distributed under terms of the MIT license.
+ */
+
+
+#include "ctk-arch.h"
+
+#include "lib/textmode/textmode.h"
+
+struct event e = {0};
+
+ctk_arch_key_t
+ctk_arch_getkey(void)
+{
+	while (e.type != evt_keyboard_press || e.kbd.sym < 8)
+	{
+		events_poll();
+		e = event_get();
+	}
+
+	return e.kbd.sym;
+}
+
+unsigned char kbhit(void)
+{
+	events_poll();
+	e = event_get();
+	return e.type == evt_keyboard_press && e.kbd.sym >= 8;
+}
+
+void
+ctk_arch_draw_char(char c,
+		   unsigned char x, unsigned char y,
+		   unsigned char reversed,
+		   unsigned char color)
+{
+	vram[y][x] = c;
+	vram_attr[y][x] = color;
+}
diff --git a/contiki-bitbox/ctk/ctk-arch.h b/contiki-bitbox/ctk/ctk-arch.h
new file mode 100644
index 0000000..f3b9cdf
--- /dev/null
+++ b/contiki-bitbox/ctk/ctk-arch.h
@@ -0,0 +1,62 @@
+/*
+ * 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/05/19 09:30:03 gpz Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include "kernel/bitbox.h"
+#include "lib/events/events.h"
+
+#include "libconio.h"
+
+#define CH_DEL			'\b'
+#define CH_CURS_UP		(signed char)KEY_UP
+#define CH_CURS_LEFT	(signed char)KEY_LEFT
+#define CH_CURS_RIGHT	(signed char)KEY_RIGHT
+#define CH_CURS_DOWN	(signed char)KEY_DOWN
+
+// FIXME use the semigraphics
+#define CH_ULCORNER	'\xDA'
+#define CH_URCORNER	'\xBF'
+#define CH_LLCORNER	'\xC0'
+#define CH_LRCORNER	'\xD9'
+
+#include "ctk-conio.h"
+
+#undef ctk_arch_getkey
+
+#endif /* __CTK_ARCH_H__ */