Initial revision
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/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..3776e42
--- /dev/null
+++ b/contiki-cpc/ctk/unused/ctk-80col.c
@@ -0,0 +1,1197 @@
+/*
+ * 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.1 2006/04/17 15:02:29 kthacker 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, '>');
+	  for(i = 0; i < w->w; ++i) {
+	    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/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__ */