Initial import
diff --git a/contiki-c64/Makefile b/contiki-c64/Makefile
new file mode 100644
index 0000000..9f338f0
--- /dev/null
+++ b/contiki-c64/Makefile
@@ -0,0 +1,68 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+#
+
+CONTIKI=../contiki
+
+usage:
+	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+	@echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+	@echo 'is one of the following:'
+	@echo c64-tfe
+	@echo c64-rs232-eyecandy
+	@echo c64-rs232-blueround
+	@echo c64-rs232-conio
+	@echo '(Also check the Makefile for more targets to try...)'
+
+c64-tfe:
+	$(MAKE) CONTIKI=$(CONTIKI) -fMakefile.c64-tfe
+c64-rs232-eyecandy:
+	$(MAKE) CONTIKI=$(CONTIKI) -fMakefile.c64-rs232-eyecandy
+c64-rs232-conio:
+	$(MAKE) CONTIKI=$(CONTIKI) -fMakefile.c64-rs232-conio
+c64-rs232-blueround:
+	$(MAKE) CONTIKI=$(CONTIKI) -fMakefile.c64-rs232-blueround
+
+depend:
+	gcc -MM -D_CBM__ -D__C64__ -v \
+        -Ictk -Iuip -Iconf \
+	-I$(CONTIKI)/lib -I$(CONTIKI)/ek \
+        -I$(CONTIKI)/ctk -I$(CONTIKI)/apps -I$(CONTIKI)/uip \
+        *.c */*.c $(CONTIKI)/*/*.c > Makefile.depend
+size:
+	od65 --dump-segsize *.o
+codesize:
+	od65 --dump-segsize *.o | egrep '\.o|CODE'
+clean:
+	rm -f *.o *~ *core contiki *.s
diff --git a/contiki-c64/Makefile.c64-rs232-blueround b/contiki-c64/Makefile.c64-rs232-blueround
new file mode 100644
index 0000000..53c62fc
--- /dev/null
+++ b/contiki-c64/Makefile.c64-rs232-blueround
@@ -0,0 +1,53 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64-rs232-blueround,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGS) \
+        -DCTK_BLUEROUND \
+        -DWITH_UIP -DWITH_RS232 \
+        -DWITH_TELNET -DWITH_WWW 
+
+contiki:  contiki-main.o petsciiconv.o \
+ctk.o ek.o dispatcher.o \
+ contiki.o programs.o \
+ fire.o \
+ $(CTK_BLUEROUND) \
+ $(UIP) rs232dev.o \
+ $(TELNET) $(WWW) 
+	cl65 -Ln labels -o contiki -t $(SYS) $^
+
diff --git a/contiki-c64/Makefile.c64-rs232-conio b/contiki-c64/Makefile.c64-rs232-conio
new file mode 100644
index 0000000..8fb5485
--- /dev/null
+++ b/contiki-c64/Makefile.c64-rs232-conio
@@ -0,0 +1,53 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64-rs232-conio,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGS) \
+        -DCTK_CONIO \
+        -DWITH_UIP -DWITH_RS232 \
+        -DWITH_TELNET -DWITH_WWW 
+
+contiki:  contiki-main.o petsciiconv.o \
+ctk.o ek.o dispatcher.o \
+ contiki.o programs.o \
+ fire.o \
+ $(CTK_CONIO) \
+ $(UIP) rs232dev.o \
+ $(TELNET) $(WWW) 
+	cl65 -Ln labels -o contiki -t $(SYS) $^
+
diff --git a/contiki-c64/Makefile.c64-rs232-eyecandy b/contiki-c64/Makefile.c64-rs232-eyecandy
new file mode 100644
index 0000000..2f93510
--- /dev/null
+++ b/contiki-c64/Makefile.c64-rs232-eyecandy
@@ -0,0 +1,53 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64-rs232-eyecandy,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGS) \
+        -DCTK_EYECANDY \
+        -DWITH_UIP -DWITH_RS232 \
+        -DWITH_TELNET -DWITH_WWW 
+
+contiki:  contiki-main.o petsciiconv.o \
+ctk.o ek.o dispatcher.o \
+ contiki.o programs.o \
+ fire.o \
+ $(CTK_EYECANDY) \
+ $(UIP) rs232dev.o \
+ $(TELNET) $(WWW) 
+	cl65 -Ln labels -o contiki -t $(SYS) $^
+
diff --git a/contiki-c64/Makefile.c64-tfe b/contiki-c64/Makefile.c64-tfe
new file mode 100644
index 0000000..3ee3d83
--- /dev/null
+++ b/contiki-c64/Makefile.c64-tfe
@@ -0,0 +1,53 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved. 
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met: 
+# 1. Redistributions of source code must retain the above copyright 
+#    notice, this list of conditions and the following disclaimer. 
+# 2. Redistributions in binary form must reproduce the above copyright 
+#    notice, this list of conditions and the following disclaimer in the 
+#    documentation and/or other materials provided with the distribution. 
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#      This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.  
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.c64-tfe,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGS) \
+        -DCTK_EYECANDY \
+        -DWITH_UIP -DWITH_TFE -DWITH_ETHERNET\
+        -DWITH_WEBSERVER -DWITH_WWW 
+
+contiki:  contiki-main.o petsciiconv.o \
+ ctk.o ek.o dispatcher.o \
+ contiki.o programs.o \
+ fire.o \
+ $(CTK_EYECANDY) \
+ $(UIP) uip_arp.o cs8900a.o \
+ $(WEBSERVER) $(WWW) 
+	cl65 -Ln labels -o contiki -t $(SYS) $^
+
diff --git a/contiki-c64/Makefile.common b/contiki-c64/Makefile.common
new file mode 100644
index 0000000..596a5e9
--- /dev/null
+++ b/contiki-c64/Makefile.common
@@ -0,0 +1,62 @@
+SYS=c64
+
+CC=cc65
+AS=ca65
+CFLAGS=-I ctk -I uip -I conf \
+       -I $(CONTIKI)/apps -I $(CONTIKI)/ctk -I $(CONTIKI)/ek \
+       -I $(CONTIKI)/lib -I $(CONTIKI)/uip \
+       -t $(SYS) --add-source 
+OPT=-Or
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: ctk/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: uip/%.c
+	$(CC) $(CFLAGS)  -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/apps/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ctk/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/ek/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/lib/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+%.o: $(CONTIKI)/uip/%.c
+	$(CC) $(CFLAGS) $(OPT) -o $(patsubst %c, %s, $(notdir $<)) $<
+	$(AS) -o $@ $(AFLAGS) $(*).s
+
+
+%.o: ctk/%.S
+	$(AS) -o $@ $(AFLAGS) $<
+
+include Makefile.depend
+
+UIP=uip.o uip_arch.o uip_main.o resolv.o
+
+
+CTK_CONIO=ctk-conio.o
+CTK_EYECANDY=ctk-eyecandy.o ctk-eyecandy-asm.o
+CTK_BLUEROUND=ctk-blueround.o ctk-blueround-asm.o
+
+
+WWW=www.o webclient.o http-strings.o htmlparser.o html-strings.o 
+EMAIL=email.o smtp.o smtp-strings.o
+WEBSERVER=webserver.o http-strings.o 
+TELNET=simpletelnet.o telnet.o
+
+
diff --git a/contiki-c64/Makefile.depend b/contiki-c64/Makefile.depend
new file mode 100644
index 0000000..0bd8bf9
--- /dev/null
+++ b/contiki-c64/Makefile.depend
@@ -0,0 +1,112 @@
+contiki-main.o: contiki-main.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ctk/ctk-draw.h ctk/ctk-arch.h ctk/fire.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/apps/simpletelnet.h \
+ ../contiki/apps/programs.h ../contiki/apps/email.h \
+ ../contiki/apps/www.h ../contiki/apps/contiki.h \
+ ../contiki/uip/uip_main.h ../contiki/uip/uip_arp.h \
+ ../contiki/uip/resolv.h
+ctk-blueround.o: ctk/ctk-blueround.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ctk/ctk-draw.h ctk/ctk-arch.h ctk/fire.h \
+ ctk/ctk-blueround.h ctk/ctk-blueround-asm.h ctk/ctk-blueround-conf.h
+ctk-conio.o: ctk/ctk-conio.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ctk/ctk-draw.h ctk/ctk-arch.h ctk/fire.h \
+ ctk/ctk-conio-conf.h
+ctk-eyecandy.o: ctk/ctk-eyecandy.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ctk/ctk-draw.h ctk/ctk-arch.h ctk/fire.h \
+ ctk/ctk-eyecandy.h ctk/ctk-eyecandy-asm.h ctk/ctk-eyecandy-conf.h
+fire.o: ctk/fire.c
+cs8900a.o: uip/cs8900a.c uip/cs8900a.h uip/uip_arch.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ ../contiki/ek/dispatcher.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/uip/uip_arp.h
+rs232dev.o: uip/rs232dev.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h
+uip_arch.o: uip/uip_arch.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h uip/uip_arch.h
+contiki.o: ../contiki/apps/contiki.c ../contiki/uip/uip_main.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ ../contiki/ek/dispatcher.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/uip/uip_arp.h ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/uip/resolv.h \
+ ../contiki/apps/email.h
+email.o: ../contiki/apps/email.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/apps/smtp.h \
+ ../contiki/uip/uip_main.h ../contiki/lib/petsciiconv.h
+html-strings.o: ../contiki/apps/html-strings.c
+htmlparser.o: ../contiki/apps/htmlparser.c \
+ ../contiki/apps/htmlparser.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/apps/html-strings.h \
+ ../contiki/apps/www-conf.h
+http-strings.o: ../contiki/apps/http-strings.c
+programs.o: ../contiki/apps/programs.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/apps/webserver.h \
+ ../contiki/apps/www.h ../contiki/apps/email.h \
+ ../contiki/apps/simpletelnet.h
+simpletelnet.o: ../contiki/apps/simpletelnet.c \
+ ../contiki/lib/petsciiconv.h ../contiki/uip/uip_main.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ ../contiki/ek/dispatcher.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ctk/ctk.h ../contiki/ctk/ctk-conf.h \
+ ../contiki/uip/resolv.h ../contiki/apps/telnet.h \
+ ../contiki/apps/simpletelnet.h
+smtp-strings.o: ../contiki/apps/smtp-strings.c
+smtp.o: ../contiki/apps/smtp.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/apps/smtp.h \
+ ../contiki/apps/smtp-strings.h
+telnet.o: ../contiki/apps/telnet.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/apps/telnet.h
+webclient.o: ../contiki/apps/webclient.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/apps/webclient.h \
+ ../contiki/apps/http-strings.h ../contiki/uip/resolv.h \
+ ../contiki/uip/uip_main.h
+webserver.o: ../contiki/apps/webserver.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/apps/http-strings.h \
+ ../contiki/uip/uip_main.h ../contiki/lib/petsciiconv.h
+www.o: ../contiki/apps/www.c ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/apps/webclient.h \
+ ../contiki/apps/http-strings.h ../contiki/apps/htmlparser.h \
+ ../contiki/uip/resolv.h ../contiki/lib/petsciiconv.h \
+ ../contiki/apps/www-conf.h
+ctk.o: ../contiki/ctk/ctk.c ../contiki/ek/ek.h ../contiki/ek/ek-conf.h \
+ ../contiki/ek/dispatcher.h ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ctk/ctk.h \
+ ../contiki/ctk/ctk-conf.h ../contiki/ctk/ctk-draw.h ctk/ctk-arch.h \
+ ctk/fire.h
+dispatcher.o: ../contiki/ek/dispatcher.c ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/ek/dispatcher.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h
+ek.o: ../contiki/ek/ek.c ../contiki/ek/ek.h ../contiki/ek/ek-conf.h
+libconio.o: ../contiki/lib/libconio.c ../contiki/lib/libconio.h
+petsciiconv.o: ../contiki/lib/petsciiconv.c
+strncasecmp.o: ../contiki/lib/strncasecmp.c
+resolv.o: ../contiki/uip/resolv.c ../contiki/uip/resolv.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ ../contiki/ek/dispatcher.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h
+uip.o: ../contiki/uip/uip.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h uip/uip_arch.h
+uip_arp.o: ../contiki/uip/uip_arp.c ../contiki/uip/uip_arp.h \
+ ../contiki/uip/uip.h ../contiki/uip/uipopt.h \
+ ../contiki/ek/dispatcher.h ../contiki/ek/ek.h ../contiki/ek/ek-conf.h
+uip_main.o: ../contiki/uip/uip_main.c ../contiki/uip/uip.h \
+ ../contiki/uip/uipopt.h ../contiki/ek/dispatcher.h ../contiki/ek/ek.h \
+ ../contiki/ek/ek-conf.h ../contiki/uip/uip_arp.h
diff --git a/contiki-c64/conf/ctk-conf.h b/contiki-c64/conf/ctk-conf.h
new file mode 100644
index 0000000..bd68873
--- /dev/null
+++ b/contiki-c64/conf/ctk-conf.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY             CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+   window.  */
+#define CTK_CONF_WINDOWSWITCH_KEY     CH_F3
+
+/* 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  1 /* 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
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-c64/conf/ek-conf.h b/contiki-c64/conf/ek-conf.h
new file mode 100644
index 0000000..6458660
--- /dev/null
+++ b/contiki-c64/conf/ek-conf.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+   highest timeout value used by the system. For example, if all
+   timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+   "unsigned char", but if the maximum timeout is over 256, "unsigned
+   short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+   used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t; 
+
+#define EK_CONF_NUMSIGNALS   32    /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS    4    /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS  32    /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#define EK_CONF_UNLISTEN 0
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-c64/conf/www-conf.h b/contiki-c64/conf/www-conf.h
new file mode 100644
index 0000000..c58a1d9
--- /dev/null
+++ b/contiki-c64/conf/www-conf.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_MAX_URLLEN 100
+
+#define WWW_CONF_RENDERSTATE 1
+#define WWW_CONF_FORMS       1
+
+
+#define WWW_CONF_MAX_FORMACTIONLEN  40
+#define WWW_CONF_MAX_FORMNAMELEN    20
+#define WWW_CONF_MAX_INPUTNAMELEN   20
+#define WWW_CONF_MAX_INPUTVALUELEN  34
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-c64/contiki-main.c b/contiki-c64/contiki-main.c
new file mode 100644
index 0000000..41b55b0
--- /dev/null
+++ b/contiki-c64/contiki-main.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment 
+ *
+ * $Id: contiki-main.c,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+
+#include "simpletelnet.h"
+#include "programs.h"
+#include "email.h"
+#include "www.h"
+#include "contiki.h"
+
+#include "uip_main.h"
+#include "uip.h"
+#include "uip_arp.h"
+#if WITH_TFE
+#include "cs8900a.h"
+#endif /* WITH_TFE */
+#include "resolv.h"
+
+#include <time.h>
+#include <stdio.h>
+#include <6502.h>
+#include <conio.h>
+#include <rs232.h>
+#include <time.h>
+#include <string.h>
+
+
+/*-----------------------------------------------------------------------------------*/
+int
+main(int argc, char **argv)
+{
+  /*  irqload_init();*/
+
+#ifdef WITH_UIP
+  uip_init();
+  uip_main_init();
+  resolv_init();
+
+#ifdef WITH_TFE
+  cs8900a_init();
+#endif /* WITH_TFE */
+
+  
+#ifdef WITH_RS232
+  rs232dev_init();
+#endif /* WITH_RS232 */
+  
+#ifdef WITH_TAPDEV
+  tapdev_init();
+#endif /* WITH_TAPDEV */
+
+
+#endif /* WITH_UIP */
+	    
+  ek_init();
+  dispatcher_init();
+  ctk_init();
+  
+  contiki_init();
+  
+  programs_init();
+  
+  ctk_redraw();
+  ek_run();
+
+  clrscr();
+  
+  return 0;
+
+  argv = argv;
+  argc = argc;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-arch.h b/contiki-c64/ctk/ctk-arch.h
new file mode 100644
index 0000000..9a4db14
--- /dev/null
+++ b/contiki-c64/ctk/ctk-arch.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2003/03/19 16:26:18 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#if CTK_EYECANDY
+#include "ctk-eyecandy.h"
+#endif 
+
+#if CTK_BLUEROUND
+#include "ctk-blueround.h"
+#endif 
+
+#if CTK_REDFIRE
+#include "ctk-redfire.h"
+#endif 
+
+#if CTK_CONIO
+#include "ctk-conio.h"
+#endif 
+
+#include "fire.h"
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-c64/ctk/ctk-blueround-asm.S b/contiki-c64/ctk/ctk-blueround-asm.S
new file mode 100644
index 0000000..e868266
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround-asm.S
@@ -0,0 +1,872 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		incsp2
+
+	
+	.import		_ctk_blueround_cursx
+	.import		_ctk_blueround_cursy
+	.import		_ctk_blueround_color
+	.import		_ctk_blueround_underline
+	.import		_ctk_blueround_reversed
+
+	.import		_ctk_blueround_yscreenaddr
+	.import		_ctk_blueround_yhiresaddr
+
+	.import		_ctk_blueround_windowparams
+	
+	.export		_ctk_blueround_cclear
+	.export		_ctk_blueround_chline
+	.export		_ctk_blueround_cputc
+	.export		_ctk_blueround_cputsn
+
+	.export		_ctk_blueround_draw_buttonleft
+	.export		_ctk_blueround_draw_buttonright
+	
+	.export		_ctk_blueround_draw_windowborders
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+		
+.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
+	.include "ctk/ctk-blueround-conf.inc"
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_blueround_cursy
+	asl
+	tax
+	lda _ctk_blueround_yhiresaddr,x
+	sta ptr2
+	lda _ctk_blueround_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_blueround_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_blueround_cursy
+	asl
+	tax	
+	lda _ctk_blueround_yscreenaddr,x
+	clc
+	adc _ctk_blueround_cursx
+	sta ptr1
+	lda _ctk_blueround_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_blueround_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_blueround_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_blueround_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_blueround_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_blueround_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_blueround_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_blueround_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_blueround_cputc:
+	sta tmpc
+
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_blueround_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_blueround_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_blueround_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_blueround_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_blueround_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+	
+	jsr setupptrs
+
+	ldy tmpl
+	dey
+	lda _ctk_blueround_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_blueround_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_blueround_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_blueround_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_blueround_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_blueround_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	ldy _ctk_blueround_windowparams + wpw
+	iny
+	lda _ctk_blueround_windowparams + wpcolor1
+	sta (ptr1),y	
+	dey
+	dey
+	dey
+	sty tmpw	
+
+	ldy _ctk_blueround_windowparams + wptitlelen
+	iny
+	iny
+	iny
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	inc tmpw
+
+	;; Set color for upper left corner
+	ldy #0
+	lda _ctk_blueround_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 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_blueround_windowparams + wptitle
+	sta ptr4
+	lda _ctk_blueround_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_blueround_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 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 urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_blueround_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_blueround_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_blueround_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_blueround_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	ldy tmpw
+	lda _ctk_blueround_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_blueround_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx _ctk_blueround_windowparams + wpclipy2
+	beq @bordercloopend
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_blueround_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_blueround_windowparams + wpw
+	lda _ctk_blueround_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx _ctk_blueround_windowparams + wpclipy2
+	beq @rborderloopend
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_blueround_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 lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_blueround_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_blueround_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #7
+:
+	lda lborderpattern,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 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_blueround_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda 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_blueround_draw_buttonleft:
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_blueround_color
+	sta (ptr1),y
+
+:		
+	lda buttonleftpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_blueround_draw_buttonright:
+	jsr setupptrs
+	ldy #0
+	lda _ctk_blueround_color
+	sta (ptr1),y
+
+:		
+	lda buttonrightpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+	
\ No newline at end of file
diff --git a/contiki-c64/ctk/ctk-blueround-asm.h b/contiki-c64/ctk/ctk-blueround-asm.h
new file mode 100644
index 0000000..27bdab5
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround-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. 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-blueround-asm.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_BLUEROUND_ASM_H__
+#define __CTK_BLUEROUND_ASM_H__
+
+void __fastcall__ ctk_blueround_cclear(unsigned char len);
+void __fastcall__ ctk_blueround_chline(unsigned char len);
+void __fastcall__ ctk_blueround_cputc(unsigned char c);
+void __fastcall__ ctk_blueround_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_blueround_draw_buttonleft(void);
+void ctk_blueround_draw_buttonright(void);
+
+struct ctk_blueround_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_blueround_windowparams ctk_blueround_windowparams;
+void ctk_blueround_draw_windowborder(void);
+
+extern unsigned char ctk_blueround_cursx,
+  ctk_blueround_cursy,
+  ctk_blueround_color,
+  ctk_blueround_reversed,
+  ctk_blueround_underline;
+
+#endif /* __CTK_BLUEROUND_ASM_H__ */
diff --git a/contiki-c64/ctk/ctk-blueround-conf.h b/contiki-c64/ctk/ctk-blueround-conf.h
new file mode 100644
index 0000000..e99d7ab
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround-conf.h
@@ -0,0 +1,197 @@
+/*
+ * 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-blueround-conf.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_BLUEROUND_CONF_H__
+#define __CTK_BLUEROUND_CONF_H__
+
+/* Order is: bgwin/non-focus, bgwin/focus, fgwin/non-focus, fgwin/focus,
+   dialog/non-focus, dialog/focus, menucolor, openmenu, activemenu*/
+
+/* COLOR(bg, fg) */
+
+static unsigned char colors[] = {
+  /* Window background colors. */
+  /*  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),*/
+  
+  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),
+
+  
+  /* Separator colors. */
+  /*  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), */
+
+  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),
+  
+  /* Label colors. */
+  /*  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),*/
+
+  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),
+
+  
+  /* Button colors.*/
+  /*  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),*/
+  
+  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),
+
+  /* Hyperlink colors. */
+  /*  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),*/
+  
+  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),
+
+
+
+  /* Text entry colors. */
+  /*  COLOR(COLOR_GRAY2, COLOR_GRAY1),
+  COLOR(COLOR_GRAY2, COLOR_BLACK),
+  COLOR(COLOR_WHITE, COLOR_GRAY1),
+  COLOR(COLOR_WHITE, COLOR_BLACK),
+  COLOR(COLOR_WHITE, COLOR_GRAY1),
+  COLOR(COLOR_WHITE, COLOR_BLACK),*/
+  
+  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),
+
+
+  /* Icon colors. */
+  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),
+
+
+  /* Button left corner colors.*/
+  /*  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),*/
+
+  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),
+  
+  /* Button right corner colors.*/
+  /*  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),*/
+
+  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 */
+  COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+  COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+  COLOR(COLOR_CYAN, COLOR_BLUE),
+};
+
+#define BGCOLOR1 0x00
+#define BGCOLOR2 0x06
+#define BGCOLOR3 0x00
+#define BGCOLOR4 0x06
+
+
+
+#endif /* __CTK_BLUEROUND_CONF_H__ */
diff --git a/contiki-c64/ctk/ctk-blueround-conf.inc b/contiki-c64/ctk/ctk-blueround-conf.inc
new file mode 100644
index 0000000..3e96a05
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround-conf.inc
@@ -0,0 +1,12 @@
+ulcornerpattern:	.byte $fe,$f8,$e0,$c0,$c0,$80,$80,$00
+titlebarpattern:	.byte $00,$55,$aa,$00,$aa,$00,$00,$00
+urcornerpattern:	.byte $7f,$1f,$07,$03,$03,$01,$01,$00
+
+lborderpattern:		.byte $00,$00,$00,$00,$00,$00,$00,$00
+rborderpattern:		.byte $00,$00,$00,$00,$00,$00,$00,$00  
+	
+lrcornerpattern:	.byte $00,$01,$01,$03,$03,$07,$1f,$7f
+llcornerpattern:	.byte $00,$80,$80,$c0,$c0,$e0,$f8,$fe
+
+buttonleftpattern:	.byte $03,$0f,$1f,$1f,$1f,$1f,$0f,$03
+buttonrightpattern:	.byte $c0,$f0,$f8,$f8,$f8,$f8,$f0,$c0
diff --git a/contiki-c64/ctk/ctk-blueround.c b/contiki-c64/ctk/ctk-blueround.c
new file mode 100644
index 0000000..0ca40f4
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround.c
@@ -0,0 +1,966 @@
+/*
+ * 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-blueround.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-blueround.h"
+#include "ctk-blueround-asm.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_blueround_cursx, ctk_blueround_cursy;
+unsigned char ctk_blueround_reversed;
+unsigned char ctk_blueround_color;
+unsigned char ctk_blueround_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_blueround_windowparams ctk_blueround_windowparams;
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+/* Order is: bgwin/non-focus, bgwin/focus, fgwin/non-focus, fgwin/focus,
+   dialog/non-focus, dialog/focus, menucolor, openmenu, activemenu*/
+
+#define MENUCOLOR       54
+#define OPENMENUCOLOR   55
+#define ACTIVEMENUCOLOR 56
+
+#include "ctk-blueround-conf.h"
+
+
+unsigned short ctk_blueround_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_blueround_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};
+
+static unsigned char linecolors[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)};
+
+static unsigned char dither48[4*8] =
+  {0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00};
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_blueround_cursx
+#define hires_revers(c)   ctk_blueround_reversed = c
+#define hires_color(c)   ctk_blueround_color = c
+#define hires_underline(c)   ctk_blueround_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cvline(unsigned char length)
+{
+  unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_blueround_cputc('|');
+    --ctk_blueround_cursx;
+    ++ctk_blueround_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_blueround_cursx = x;
+  ctk_blueround_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_blueround_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_blueround_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_blueround_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda _lineptr");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_blueround_yhiresaddr,x");
+  asm("sta ptr2");
+  asm("lda _ctk_blueround_yhiresaddr+1,x");
+  asm("sta ptr2+1");
+  asm("lda _ctk_blueround_yscreenaddr,x");
+  asm("sta ptr1");
+  asm("lda _ctk_blueround_yscreenaddr+1,x");
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx _lineptr");
+  asm("lda _linecolors,x");
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda _lineptr");
+  asm("and #7");
+  asm("asl");
+  /*  asm("asl");*/
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda _dither48+0,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+1,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+2,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+3,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  /*  asm("lda _dither48+4,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+5,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+6,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+7,x");
+      asm("sta (ptr2),y");
+      asm("iny");*/
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda _dither48+0,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+1,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+2,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+3,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  /*  asm("lda _dither48+4,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+5,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+6,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+7,x");
+      asm("sta (ptr2),y");
+      asm("iny");*/
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+/*-----------------------------------------------------------------------------------*/
+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();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  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 */
+  VIC.bordercolor = 0x06; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  /* 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");
+  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);
+  
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_bitmap_icon(unsigned char *bitmap)
+{
+  tmpptr = bitmap;
+
+  /* Find screen address. */
+  asm("lda _ctk_blueround_cursy");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_blueround_yscreenaddr,x");
+  asm("sta ptr1");
+  asm("lda _ctk_blueround_yscreenaddr+1,x");
+  asm("sta ptr1+1");
+
+  /* Turn off interrupts, prepare $01 to store color data in RAM under
+     I/O area. */
+  asm("sei");
+  asm("lda $01");
+  asm("sta _tmp01");
+  asm("and #$f8");
+  asm("sta $01");
+
+  /* Actually store color value in color RAM. */
+  asm("ldy _ctk_blueround_cursx");
+  asm("lda _ctk_blueround_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("tya");
+  asm("clc");
+  asm("adc #$26");
+  asm("tay");
+  asm("lda _ctk_blueround_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("tya");
+  asm("clc");
+  asm("adc #$26");
+  asm("tay");
+  asm("lda _ctk_blueround_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+
+
+
+  /* Find hires address. */
+  asm("lda _ctk_blueround_cursy");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_blueround_yhiresaddr,x");
+  asm("sta ptr2");
+  asm("lda _ctk_blueround_yhiresaddr+1,x");
+  asm("sta ptr2+1");
+
+  /* Add X coordinate to the hires address. */
+  asm("lda #0");
+  asm("sta ptr1+1");
+  asm("lda _ctk_blueround_cursx");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("clc");
+  asm("adc ptr2");
+  asm("sta ptr2");
+  asm("lda ptr2+1");
+  asm("adc ptr1+1");
+  asm("sta ptr2+1");
+
+  asm("lda _tmpptr");
+  asm("sta ptr1");
+  asm("lda _tmpptr+1");
+  asm("sta ptr1+1");
+
+  asm("ldx #3");
+  asm("iconloop1:");
+  asm("ldy #0");
+  asm("iconloop2:");
+  asm("lda (ptr1),y");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$18");
+  asm("bne iconloop2");
+  asm("lda ptr1");
+  asm("clc");
+  asm("adc #$18");
+  asm("sta ptr1");
+  asm("lda ptr1+1");
+  asm("adc #0");
+  asm("sta ptr1+1");
+  asm("lda ptr2");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta ptr2");
+  asm("lda ptr2+1");
+  asm("adc #1");
+  asm("sta ptr2+1");
+  asm("dex");
+  asm("bne iconloop1");
+
+  
+  
+  asm("lda _tmp01");
+  asm("sta $01");  
+  asm("cli"); 
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len;
+
+  xpos = x + w->x;
+  ypos = y + w->y;
+
+  hires_color(colors[w->type * 6 + focus]);
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->widget.label.h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_blueround_cputsn(text, w->w);
+	if(w->w - (hires_wherex() - xpos) > 0) {
+	  ctk_blueround_cclear(w->w - (hires_wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_color(colors[7 * 6 + focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_blueround_draw_buttonleft();
+      hires_color(colors[w->type * 6 + focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_blueround_cputsn(w->widget.button.text, w->w);
+      hires_color(colors[8 * 6 + focus]);      
+      ctk_blueround_draw_buttonright();
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_blueround_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    if(focus & CTK_FOCUS_WIDGET &&
+       w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+      hires_revers(1);
+    } else {
+      hires_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->widget.textentry.h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  hires_revers(0);
+	  hires_cputcxy(xpos, ypos, '>');
+	  for(i = 0; i < w->w; ++i) {
+	    c = text[i + xscroll];
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      hires_revers(1);
+	    } else {
+	      hires_revers(0);
+	    }
+	    if(c == 0) {
+	      ctk_blueround_cputc(' ');
+	    } else {
+	      ctk_blueround_cputc(c);
+	    }
+	    hires_revers(0);
+	  }
+	  ctk_blueround_cputc('<');
+	} else {
+	  hires_cputcxy(xpos, ypos, '|');
+	  /*	  hires_gotoxy(xpos + 1, ypos);          */
+	  ctk_blueround_cputsn(text, w->w);
+	  i = hires_wherex();
+	  if(i - xpos - 1 < w->w) {
+	    ctk_blueround_cclear(w->w - (i - xpos) + 1);
+	  }
+	  ctk_blueround_cputc('|');
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len;
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	draw_bitmap_icon(w->widget.icon.bitmap);
+      }
+      x = xpos;
+
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+      
+      hires_gotoxy(x, ypos + 3);
+      ctk_blueround_cputsn(w->widget.icon.title, len);
+    }
+    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(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char h;
+
+  hires_color(colors[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;
+  
+  /*  if(clipy1 >= clipy2) {
+    return;
+    }*/
+  
+  
+  x = window->x;
+  y = window->y + 1;
+
+  ++clipy2;
+  
+  if(clipy2 < y) {
+    return;
+  }
+  
+  hires_color(colors[focus+1]);
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  hires_gotoxy(x, y);
+  ctk_blueround_windowparams.w = window->w;
+  ctk_blueround_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_blueround_windowparams.clipy1 = 0;
+  } else {
+    ctk_blueround_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_blueround_windowparams.clipy2 = clipy2 - y;
+  ctk_blueround_windowparams.color1 = colors[focus+1];
+  ctk_blueround_windowparams.color2 = colors[focus];
+  ctk_blueround_windowparams.title = window->title;
+  ctk_blueround_windowparams.titlelen = window->titlelen;
+
+  ctk_blueround_draw_windowborders();
+  
+#if 0
+  /* Draw window frame. */  
+  if(y >= clipy1) {
+    windowulcorner(x, y);
+    windowupperborder(x + 3 + strlen(window->title),
+		      y, window->w - 5 - strlen(window->title));
+    windowurcorner(x + window->w + 1, y);
+    hires_gotoxy(x + 1, y);
+    hires_color(colors[focus]);
+    ctk_blueround_cputc(' ');
+    ctk_blueround_cputsn(window->title, window->titlelen);
+    ctk_blueround_cputc(' ');
+  }
+
+  h = window->h;
+  
+  if(clipy1 > y1) {
+    if(clipy1 - y1 < h) {
+      h = clipy1 - y1;
+      y1 = clipy1;
+    } else {
+      h = 0;
+    }
+  }
+
+  if(y1 + h >= clipy2) {
+    if(y1 >= clipy2) {
+      h = 0;
+    } else {
+      h = clipy2 - y1;
+    }
+  }
+
+  if(h == 0) {
+    return;
+  }
+  
+  hires_color(colors[focus+1]);  
+  windowsideborder(x, y1, h+1, 0xc0);
+  hires_color(colors[focus]);
+  windowsideborder(x2, y+1, h, 0x0b);
+
+  if(y + window->h >= clipy1 &&
+     y + window->h < clipy2) {
+    windowlowerborder(x1, y2, window->w);
+  }
+
+#endif /* 0 */
+  
+  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(colors[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);
+  }
+  
+  /* Clear dialog 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(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  
+  hires_color(colors[OPENMENUCOLOR]);
+  x = hires_wherex();
+  ctk_blueround_cputsn(m->title, m->titlelen);
+  ctk_blueround_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(colors[ACTIVEMENUCOLOR]);
+    } else {
+      hires_color(colors[MENUCOLOR]);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_blueround_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_blueround_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_blueround_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(colors[MENUCOLOR]);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    hires_color(colors[MENUCOLOR]);    
+    if(m != menus->open) {
+      ctk_blueround_cputsn(m->title, m->titlelen);
+      ctk_blueround_cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+  ctk_blueround_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_blueround_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_blueround_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-blueround.h b/contiki-c64/ctk/ctk-blueround.h
new file mode 100644
index 0000000..bcffd22
--- /dev/null
+++ b/contiki-c64/ctk/ctk-blueround.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. 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-blueround.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_BLUEROUND_H__
+#define __CTK_BLUEROUND_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_BLUEROUND_H__ */
diff --git a/contiki-c64/ctk/ctk-conio-conf.h b/contiki-c64/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..ab06f64
--- /dev/null
+++ b/contiki-c64/ctk/ctk-conio-conf.h
@@ -0,0 +1,169 @@
+/*
+ * 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 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR         COLOR_WHITE
+#define SCREENCOLOR         COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS   COLOR_BLACK
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_RED
+
+#define WIDGETCOLOR_HLINK   COLOR_BLUE
+#define WIDGETCOLOR_FWIN    COLOR_BLACK
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_RED
+#define WIDGETCOLOR_FOCUS   COLOR_BLACK
+
+#define MENUCOLOR           COLOR_BLACK
+#define OPENMENUCOLOR       COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR         COLOR_LIGHTBLUE
+#define SCREENCOLOR         COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_GRAY1
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_CYAN
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 1
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_WHITE
+#define WINDOWCOLOR         COLOR_WHITE
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_WHITE
+#define WIDGETCOLOR_FWIN    COLOR_WHITE
+#define WIDGETCOLOR         COLOR_WHITE
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_WHITE
+
+#define MENUCOLOR           COLOR_WHITE
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR         COLOR_BLUE
+#define SCREENCOLOR         COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTBLUE
+#define WINDOWCOLOR         COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR         COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_LIGHTBLUE
+#define WIDGETCOLOR         COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG  COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS   COLOR_LIGHTBLUE
+
+#define MENUCOLOR           COLOR_LIGHTBLUE
+#define OPENMENUCOLOR       COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR         COLOR_GRAY1
+#define SCREENCOLOR         COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS   COLOR_GRAY3
+#define WINDOWCOLOR         COLOR_GRAY2
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_GRAY3
+#define WIDGETCOLOR         COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_GRAY3
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR         COLOR_BLACK
+#define SCREENCOLOR         COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS   COLOR_LIGHTRED
+#define WINDOWCOLOR         COLOR_RED
+
+#define DIALOGCOLOR         COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK   COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN    COLOR_YELLOW
+#define WIDGETCOLOR         COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG  COLOR_WHITE
+#define WIDGETCOLOR_FOCUS   COLOR_YELLOW
+
+#define MENUCOLOR           COLOR_LIGHTRED
+#define OPENMENUCOLOR       COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-c64/ctk/ctk-conio.c b/contiki-c64/ctk/ctk-conio.c
new file mode 100644
index 0000000..a9cb3cf
--- /dev/null
+++ b/contiki-c64/ctk/ctk-conio.c
@@ -0,0 +1,532 @@
+/*
+ * 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.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "ctk-conio-conf.h"
+
+#include <conio.h>
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+static unsigned char sizex, sizey;
+
+/*-----------------------------------------------------------------------------------*/
+static char tmp[40];
+static void
+cputsn(char *str, unsigned char len)
+{
+  strncpy(tmp, str, len);
+  tmp[len] = 0;
+  cputs(tmp);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  bgcolor(SCREENCOLOR);
+  bordercolor(BORDERCOLOR);
+  screensize(&sizex, &sizey);
+  ctk_draw_clear(0, sizey);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipx,
+	    unsigned char clipy,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len;
+
+  if(focus & CTK_FOCUS_WINDOW) {    
+    textcolor(WIDGETCOLOR_FWIN);
+    if(focus & CTK_FOCUS_WIDGET) {
+      textcolor(WIDGETCOLOR_FOCUS);
+    }
+  } else if(focus & CTK_FOCUS_DIALOG) {
+    textcolor(WIDGETCOLOR_DIALOG);
+    if(focus & CTK_FOCUS_WIDGET) {
+      textcolor(WIDGETCOLOR_FOCUS);
+    }
+  } else {
+    textcolor(WIDGETCOLOR);
+  }
+  
+  xpos = x + w->x;
+  ypos = y + w->y;
+    
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    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->widget.label.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(focus & CTK_FOCUS_WIDGET) {
+	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(focus & CTK_FOCUS_WIDGET) {
+	revers(0);
+      } else {
+	revers(1);
+      }
+      gotoxy(xpos, ypos);
+      textcolor(WIDGETCOLOR_HLINK);
+      cputsn(w->widget.button.text, w->w);
+      revers(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    if(focus & CTK_FOCUS_WIDGET) {
+      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->widget.textentry.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) {
+      if(focus) {
+	revers(1);
+      } else {
+	revers(0);
+      }
+      gotoxy(xpos, ypos);
+      if(w->widget.icon.textmap != NULL) {
+	for(i = 0; i < 3; ++i) {
+	  gotoxy(xpos, ypos);
+	  if(ypos >= clipy1 && ypos < clipy2) {
+	    cputc(w->widget.icon.textmap[0 + 3 * i]);
+	    cputc(w->widget.icon.textmap[1 + 3 * i]);
+	    cputc(w->widget.icon.textmap[2 + 3 * i]);
+	  }
+	  ++ypos;
+	}
+      }
+      x = xpos;
+  
+      len = strlen(w->widget.icon.title);
+      if(x + len >= sizex) {
+	x = sizex - len;
+      }
+
+      gotoxy(x, ypos);
+      if(ypos >= clipy1 && ypos < clipy2) {
+	cputs(w->widget.icon.title);
+      }
+      revers(0);
+    }
+    break;
+
+  default:
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+		unsigned char focus,
+		unsigned char clipy1,
+		unsigned char clipy2)
+{
+  struct ctk_window *win = w->window;
+  unsigned char posx, posy;
+
+  posx = win->x + 1;
+  posy = win->y + 2;
+
+  if(w == win->focused) {
+    focus |= CTK_FOCUS_WIDGET;
+  }
+  
+  draw_widget(w, posx, posy,
+	      posx + win->w,
+	      posy + win->h,
+	      clipy1, clipy2,
+	      focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char i;
+  unsigned char h;
+
+  
+  h = window->y + 2 + window->h;
+  /* Clear window contents. */
+  for(i = window->y + 2; i < h; ++i) {
+    if(i >= clipy1 && i < clipy2) {
+      cclearxy(window->x + 1, i, window->w);
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+		unsigned char clipy1, unsigned char clipy2)
+{
+  unsigned char x, y;
+  unsigned char h;
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  unsigned char x1, y1, x2, y2;
+
+  if(window->y + 1 >= clipy2) {
+    return;
+  }
+    
+  x = window->x;
+  y = window->y + 1;
+  
+  if(focus & CTK_FOCUS_WINDOW) {
+    textcolor(WINDOWCOLOR_FOCUS);
+  } else {
+    textcolor(WINDOWCOLOR);
+  }
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  /* Draw window frame. */  
+  if(y >= clipy1) {
+    cputcxy(x, y, CH_ULCORNER);
+    /*    cputc(' ');
+    cputs(window->title);
+    cputc(' ');*/
+    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(y1 + h >= clipy2) {
+    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);
+  }
+
+  focus = focus & CTK_FOCUS_WINDOW;
+  
+  /* 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);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+  unsigned char x, y;
+  unsigned char i;
+  struct ctk_widget *w;
+  unsigned char wfocus;
+  unsigned char x1, y1, x2, y2;
+  
+  textcolor(DIALOGCOLOR);
+
+  x = dialog->x;
+  y = dialog->y + 1;
+
+
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + dialog->w;
+  y2 = y1 + dialog->h;
+
+
+  /* Draw dialog frame. */
+  
+  cvlinexy(x, y1,
+	   dialog->h);
+  cvlinexy(x2, y1,
+	   dialog->h);
+
+  chlinexy(x1, y,
+	   dialog->w);
+  chlinexy(x1, y2,
+	   dialog->w);
+
+  cputcxy(x, y, CH_ULCORNER);
+  cputcxy(x, y2, CH_LLCORNER);
+  cputcxy(x2, y, CH_URCORNER);
+  cputcxy(x2, y2, CH_LRCORNER);
+  
+  
+  /* Clear window contents. */
+  for(i = y1; i < y2;  ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+
+
+  
+  /* Clear dialog contents. */
+  for(i = y1; i < y2; ++i) {
+    cclearxy(x1, i, dialog->w);
+  }
+  
+  /* Draw inactive widgets. */
+  for(w = dialog->inactive; w != NULL; w = w->next) {
+    draw_widget(w, x1, y1, x2, y2,
+		0, sizey, 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, x2, y2,
+		0, sizey, wfocus);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+  unsigned char i;
+ 
+  for(i = y1; i < y2; ++i) {
+    cclearxy(0, i, sizex);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  textcolor(OPENMENUCOLOR);
+  x = wherex();
+  cputs(m->title);
+  cputc(' ');
+  x2 = wherex();
+  if(x + CTK_CONF_MENUWIDTH > sizex) {
+    x = sizex - CTK_CONF_MENUWIDTH;
+  }
+  
+  
+  for(y = 0; y < m->nitems; ++y) {
+    if(y == m->active) {
+      textcolor(ACTIVEMENUITEMCOLOR);
+      revers(0);
+    } else {
+      textcolor(MENUCOLOR);	  
+    }
+    gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      chline(CTK_CONF_MENUWIDTH);
+    } else {
+      cputs(m->items[y].title);
+    }
+    if(x + CTK_CONF_MENUWIDTH > wherex()) {
+      cclear(x + CTK_CONF_MENUWIDTH - wherex());
+    }
+    revers(1);
+  }
+  gotoxy(x2, 0);
+  textcolor(MENUCOLOR);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;  
+  
+  
+  /* Draw menus */
+  textcolor(MENUCOLOR);
+  gotoxy(0, 0);
+  revers(1);
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    if(m != menus->open) {
+      cputs(m->title);
+      cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+
+
+  if(wherex() + strlen(menus->desktopmenu->title) + 1>= sizex) {
+    gotoxy(sizex - strlen(menus->desktopmenu->title) - 1, 0);
+  } else {
+    cclear(sizex - wherex() -
+	   strlen(menus->desktopmenu->title) - 1);
+  }
+  
+  /* Draw desktopmenu */
+  if(menus->desktopmenu != menus->open) {
+    cputs(menus->desktopmenu->title);
+    cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+  revers(0);
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return sizey;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return sizex;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-conio.h b/contiki-c64/ctk/ctk-conio.h
new file mode 100644
index 0000000..907e812
--- /dev/null
+++ b/contiki-c64/ctk/ctk-conio.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_H__
+#define __CTK_CONIO_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey   cgetc
+
+#define CH_ENTER '\n'
+
+#ifndef CH_F1
+#define CH_F1 CH_ESC
+#endif /* CH_F1 */
+
+#ifndef CH_F3
+#define CH_F3 CH_STOP
+#endif /* CH_F1 */
+
+#ifndef CH_CURS_RIGHT
+#define CH_CURS_RIGHT 254
+#endif /* CH_CURS_RIGHT */
+
+#ifndef CH_CURS_LEFT
+#define CH_CURS_LEFT 255
+#endif /* CH_CURS_LEFT */
+
+#endif /* __CTK_CONIO_H__ */
diff --git a/contiki-c64/ctk/ctk-eyecandy-asm.S b/contiki-c64/ctk/ctk-eyecandy-asm.S
new file mode 100644
index 0000000..32696ab
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy-asm.S
@@ -0,0 +1,883 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		incsp2
+
+	
+	.import		_ctk_eyecandy_cursx
+	.import		_ctk_eyecandy_cursy
+	.import		_ctk_eyecandy_color
+	.import		_ctk_eyecandy_underline
+	.import		_ctk_eyecandy_reversed
+
+	.import		_ctk_eyecandy_yscreenaddr
+	.import		_ctk_eyecandy_yhiresaddr
+
+	.import		_ctk_eyecandy_windowparams
+	
+	.export		_ctk_eyecandy_cclear
+	.export		_ctk_eyecandy_chline
+	.export		_ctk_eyecandy_cputc
+	.export		_ctk_eyecandy_cputsn
+
+	.export		_ctk_eyecandy_draw_buttonleft
+	.export		_ctk_eyecandy_draw_buttonright
+	
+	.export		_ctk_eyecandy_draw_windowborders
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+		
+.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
+	.include "ctk/ctk-eyecandy-conf.inc"
+;---------------------------------------------------------------------
+.code
+setupptrs:	
+	;; Find hires address.	
+	lda _ctk_eyecandy_cursy
+	asl
+	tax
+	lda _ctk_eyecandy_yhiresaddr,x
+	sta ptr2
+	lda _ctk_eyecandy_yhiresaddr+1,x
+	sta ptr2+1
+
+	;; Add X coordinate to the hires address. 
+	lda #0
+	sta ptr1+1
+	lda _ctk_eyecandy_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_eyecandy_cursy
+	asl
+	tax	
+	lda _ctk_eyecandy_yscreenaddr,x
+	clc
+	adc _ctk_eyecandy_cursx
+	sta ptr1
+	lda _ctk_eyecandy_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_eyecandy_cclear:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:		
+		
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_eyecandy_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_eyecandy_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_eyecandy_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------
+_ctk_eyecandy_chline:
+	sta tmpl
+	cmp #0
+	bne @norts
+	rts
+@norts:	
+			
+	jsr setupptrs		
+
+	;; Store color value in color memory
+
+	ldy tmpl
+	dey
+	lda _ctk_eyecandy_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_eyecandy_cursx
+
+	dex
+	bne @loop1
+
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_eyecandy_cputc:
+	sta tmpc
+
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_eyecandy_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_eyecandy_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_eyecandy_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_eyecandy_cursx	
+	
+	jmp restore01		
+;---------------------------------------------------------------------
+_ctk_eyecandy_cputsn:
+	sta tmpl
+	cmp #0
+	bne :+
+	rts
+:		
+	
+	jsr setupptrs
+
+	ldy tmpl
+	dey
+	lda _ctk_eyecandy_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_eyecandy_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_eyecandy_underline
+	beq @nounderline
+	eor #$ff
+@nounderline:
+	sta (ptr2),y
+	dey
+@loop:
+	lda (ptr1),y
+	sta (ptr2),y
+	dey
+	bpl @loop
+	
+	inc _ctk_eyecandy_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_eyecandy_draw_windowborders:
+
+	jsr setupptrs
+
+	lda _ctk_eyecandy_windowparams + wpclipy1
+	beq :+
+	jmp @nofirstline
+:		
+	
+	;; Draw first line of the border, including the window title
+
+	;; Start with filling color memory
+	ldy _ctk_eyecandy_windowparams + wpw
+	iny
+	lda _ctk_eyecandy_windowparams + wpcolor1
+	sta (ptr1),y	
+	dey
+	dey
+	dey
+	sty tmpw	
+
+	ldy _ctk_eyecandy_windowparams + wptitlelen
+	iny
+	iny
+	iny
+:	
+	sta (ptr1),y
+	iny
+	cpy tmpw
+	bcc :-
+
+	inc tmpw
+
+	;; Set color for upper left corner
+	ldy #0
+	lda _ctk_eyecandy_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 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_eyecandy_windowparams + wptitle
+	sta ptr4
+	lda _ctk_eyecandy_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_eyecandy_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 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 urcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+
+@nofirstline:
+
+
+	ldx _ctk_eyecandy_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_eyecandy_windowparams 
+	;; structure		
+
+	lda #1
+	sta tmpy
+	
+	ldx _ctk_eyecandy_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_eyecandy_windowparams + wpw
+	iny
+	sty tmpw
+@bordercloop:
+	ldy tmpw
+	lda _ctk_eyecandy_windowparams + wpcolor2
+	sta (ptr1),y
+	ldy #0
+	lda _ctk_eyecandy_windowparams + wpcolor1
+	sta (ptr1),y
+
+	lda ptr1
+	clc
+	adc #$28
+	sta ptr1
+	bcc :+
+	inc ptr1+1
+:
+	
+	inx
+	cpx _ctk_eyecandy_windowparams + wpclipy2
+	beq @bordercloopend
+	cpx tmph
+	bcc @bordercloop
+	beq @bordercloop	
+@bordercloopend:
+
+	
+	;; Fill color memory for lower border, if clipy2 allows
+	cpx _ctk_eyecandy_windowparams + wpclipy2
+	beq @noclowerborder
+
+	lda ptr1
+	sec
+	sbc #$28
+	sta ptr1
+	bcs :+
+	dec ptr1+1
+:
+		
+	ldy _ctk_eyecandy_windowparams + wpw
+	lda _ctk_eyecandy_windowparams + wpcolor2		
+@lbordercloop:	
+	sta (ptr1),y
+	dey
+	bne @lbordercloop
+	
+@noclowerborder:	
+		
+	;; Draw right border
+	ldx tmpy
+@rborderloop:
+	lda ptr3
+	clc
+	adc #$40
+	sta ptr3
+	lda ptr3+1
+	adc #1
+	sta ptr3+1
+
+	ldy #7
+:
+	lda rborderpattern,y		
+	sta (ptr3),y
+	dey
+	bpl :-
+
+	inx
+	cpx _ctk_eyecandy_windowparams + wpclipy2
+	beq @rborderloopend
+	cpx tmph
+	bne @rborderloop	
+@rborderloopend:
+	
+ 	cpx _ctk_eyecandy_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 lrcornerpattern,y
+	sta (ptr3),y
+	dey
+	bpl :-
+
+@norbordercorner:	
+
+	stx tmpy
+		
+	;; Draw lower border
+	ldx _ctk_eyecandy_windowparams + wpw
+
+@lowerborderloop:
+	lda ptr3
+	sec
+	sbc #$8
+	sta ptr3
+	bcs :+
+	dec ptr3+1
+:	
+
+	lda tmpy
+	cmp _ctk_eyecandy_windowparams + wpclipy2
+	beq @nolowerborder
+	
+	ldy #0
+	lda #$00
+:	
+	sta (ptr3),y
+	iny
+	cpy #4
+	bne :-
+	lda #$ff
+	sta (ptr3),y
+	iny
+	lda #$00
+	sta (ptr3),y
+	iny
+	lda #$ff
+	sta (ptr3),y
+	iny
+	sta (ptr3),y
+@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 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_eyecandy_windowparams + wpclipy1
+	bcc @lborderloopend
+	
+	ldy #7
+:
+	lda 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_eyecandy_draw_buttonleft:
+	jsr setupptrs
+
+	ldy #0
+	lda _ctk_eyecandy_color
+	sta (ptr1),y
+
+:		
+	lda buttonleftpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01
+;---------------------------------------------------------------------	
+_ctk_eyecandy_draw_buttonright:
+	jsr setupptrs
+	ldy #0
+	lda _ctk_eyecandy_color
+	sta (ptr1),y
+
+:		
+	lda buttonrightpattern,y
+	sta (ptr2),y
+	iny
+	cpy #8
+	bne :-
+	
+	jmp restore01	
+;---------------------------------------------------------------------
+	
\ No newline at end of file
diff --git a/contiki-c64/ctk/ctk-eyecandy-asm.h b/contiki-c64/ctk/ctk-eyecandy-asm.h
new file mode 100644
index 0000000..befc96a
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy-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. 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-eyecandy-asm.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_EYECANDY_ASM_H__
+#define __CTK_EYECANDY_ASM_H__
+
+void __fastcall__ ctk_eyecandy_cclear(unsigned char len);
+void __fastcall__ ctk_eyecandy_chline(unsigned char len);
+void __fastcall__ ctk_eyecandy_cputc(unsigned char c);
+void __fastcall__ ctk_eyecandy_cputsn(unsigned char *str,
+				      unsigned char len);
+
+void ctk_eyecandy_draw_buttonleft(void);
+void ctk_eyecandy_draw_buttonright(void);
+
+struct ctk_eyecandy_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_eyecandy_windowparams ctk_eyecandy_windowparams;
+void ctk_eyecandy_draw_windowborder(void);
+
+extern unsigned char ctk_eyecandy_cursx,
+  ctk_eyecandy_cursy,
+  ctk_eyecandy_color,
+  ctk_eyecandy_reversed,
+  ctk_eyecandy_underline;
+
+#endif /* __CTK_EYECANDY_ASM_H__ */
diff --git a/contiki-c64/ctk/ctk-eyecandy-conf.h b/contiki-c64/ctk/ctk-eyecandy-conf.h
new file mode 100644
index 0000000..4c32d13
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy-conf.h
@@ -0,0 +1,120 @@
+/*
+ * 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-eyecandy-conf.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_EYECANDY_CONF_H__
+#define __CTK_EYECANDY_CONF_H__
+
+static unsigned char colors[] = {
+  /* Window background colors. */
+  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),
+
+  /* Separator colors. */
+  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),
+  
+  /* Label colors. */
+  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),
+  
+  /* Button colors.*/
+  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),
+
+  /* Hyperlink colors. */
+  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),
+
+  /* Text entry colors. */
+  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),
+
+  /* Button left corner colors.*/
+  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),
+  
+  /* Button right corner colors.*/
+  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 */
+  COLOR(COLOR_YELLOW, COLOR_BLACK),
+  COLOR(COLOR_BLACK, COLOR_YELLOW),
+  COLOR(COLOR_WHITE, COLOR_BLACK),
+};
+
+#define BGCOLOR1 0x06
+#define BGCOLOR2 0x04
+#define BGCOLOR3 0x0a
+#define BGCOLOR4 0x07
+
+
+
+#endif /* __CTK_EYECANDY_CONF_H__ */
diff --git a/contiki-c64/ctk/ctk-eyecandy-conf.inc b/contiki-c64/ctk/ctk-eyecandy-conf.inc
new file mode 100644
index 0000000..4b13224
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy-conf.inc
@@ -0,0 +1,10 @@
+ulcornerpattern:	.byte $ff,$ff,$c0,$cf,$c0,$c3,$c0,$c0
+titlebarpattern:	.byte $ff,$ff,$00,$ff,$00,$ff,$00,$00
+urcornerpattern:	.byte $ff,$fc,$00,$f0,$00,$c0,$00,$00
+lborderpattern:		.byte $c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0
+rborderpattern:		.byte $0b,$0b,$0b,$0b,$0b,$0b,$0b,$0b
+lrcornerpattern:	.byte $0b,$0b,$0b,$0b,$fb,$03,$ff,$ff
+llcornerpattern:	.byte $c0,$c0,$c0,$c0,$c0,$c0,$80,$00
+
+buttonleftpattern:	.byte $c5,$df,$df,$df,$df,$df,$df,$df	
+buttonrightpattern:	.byte $fb,$fb,$fb,$fb,$fb,$fb,$fb,$a3
diff --git a/contiki-c64/ctk/ctk-eyecandy.c b/contiki-c64/ctk/ctk-eyecandy.c
new file mode 100644
index 0000000..5c216d0
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy.c
@@ -0,0 +1,997 @@
+/*
+ * 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-eyecandy.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-eyecandy.h"
+#include "ctk-eyecandy-asm.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_eyecandy_cursx, ctk_eyecandy_cursy;
+unsigned char ctk_eyecandy_reversed;
+unsigned char ctk_eyecandy_color;
+unsigned char ctk_eyecandy_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_eyecandy_windowparams ctk_eyecandy_windowparams;
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define MENUCOLOR       48
+#define OPENMENUCOLOR   49
+#define ACTIVEMENUCOLOR 50
+
+#include "ctk-eyecandy-conf.h"
+
+
+unsigned short ctk_eyecandy_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_eyecandy_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};
+
+static unsigned char linecolors[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)};
+
+static unsigned char dither48[4*8] =
+  {0x88,0x00,0x22,0x00,
+   0xff,0xff,0xff,0xff,
+   0xff,0xdd,0xff,0x77,
+   0xff,0x55,0xff,0x55,
+   0xee,0x55,0xbb,0x55,
+   0xaa,0x55,0xaa,0x55,
+   0xaa,0x44,0xaa,0x11,
+   0xaa,0x00,0xaa,0x00};
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_eyecandy_cursx
+#define hires_revers(c)   ctk_eyecandy_reversed = c
+#define hires_color(c)   ctk_eyecandy_color = c
+#define hires_underline(c)   ctk_eyecandy_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cvline(unsigned char length)
+{
+  unsigned char i;
+  
+  for(i = 0; i < length; ++i) {
+    ctk_eyecandy_cputc('|');
+    --ctk_eyecandy_cursx;
+    ++ctk_eyecandy_cursy;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+  ctk_eyecandy_cursx = x;
+  ctk_eyecandy_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_eyecandy_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  ctk_eyecandy_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+  hires_gotoxy(x, y);
+  hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+  hires_gotoxy(x, y);
+  ctk_eyecandy_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+clear_line(unsigned char line)
+{
+  lineptr = line;
+  asm("lda _lineptr");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_eyecandy_yhiresaddr,x");
+  asm("sta ptr2");
+  asm("lda _ctk_eyecandy_yhiresaddr+1,x");
+  asm("sta ptr2+1");
+  asm("lda _ctk_eyecandy_yscreenaddr,x");
+  asm("sta ptr1");
+  asm("lda _ctk_eyecandy_yscreenaddr+1,x");
+  asm("sta ptr1+1");
+
+  
+  asm("sei");
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$30");
+  asm("sta $01");
+  asm("ldy #39");
+  asm("ldx _lineptr");
+  asm("lda _linecolors,x");
+  asm("clearlineloop1:");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("bpl clearlineloop1");
+  asm("pla");
+  asm("sta $01");
+  asm("cli");
+
+
+  asm("lda _lineptr");
+  asm("and #7");
+  asm("asl");
+  /*  asm("asl");*/
+  asm("asl");
+  asm("tax");
+  asm("ldy #0");
+  asm("clearlineloop2:");
+  asm("lda _dither48+0,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+1,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+2,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+3,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  /*  asm("lda _dither48+4,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+5,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+6,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+7,x");
+      asm("sta (ptr2),y");
+      asm("iny");*/
+  asm("bne clearlineloop2");
+  
+  asm("inc ptr2+1");
+
+  asm("ldy #0");
+  asm("clearlineloop3:");
+  asm("lda _dither48+0,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+1,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+2,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("lda _dither48+3,x");
+  asm("sta (ptr2),y");
+  asm("iny");
+  /*  asm("lda _dither48+4,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+5,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+6,x");
+      asm("sta (ptr2),y");
+      asm("iny");
+      asm("lda _dither48+7,x");
+      asm("sta (ptr2),y");
+      asm("iny");*/
+  asm("cpy #$40");
+  asm("bne clearlineloop3");
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+nmi2(void)
+{
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("rti");
+}  
+/*-----------------------------------------------------------------------------------*/
+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();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+setup_nmi(void)
+{
+  asm("lda #<_nmi");
+  asm("sta $fffa");
+  asm("lda #>_nmi");
+  asm("sta $fffb");
+  return;
+  nmi();
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+  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 */
+  VIC.bordercolor = 0x06; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x00;  /* $DD00 */
+
+  /* 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");
+  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);
+  
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_bitmap_icon(unsigned char *bitmap)
+{
+  tmpptr = bitmap;
+
+  /* Find screen address. */
+  asm("lda _ctk_eyecandy_cursy");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_eyecandy_yscreenaddr,x");
+  asm("sta ptr1");
+  asm("lda _ctk_eyecandy_yscreenaddr+1,x");
+  asm("sta ptr1+1");
+
+  /* Turn off interrupts, prepare $01 to store color data in RAM under
+     I/O area. */
+  asm("sei");
+  asm("lda $01");
+  asm("sta _tmp01");
+  asm("and #$f8");
+  asm("sta $01");
+
+  /* Actually store color value in color RAM. */
+  asm("ldy _ctk_eyecandy_cursx");
+  asm("lda _ctk_eyecandy_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("tya");
+  asm("clc");
+  asm("adc #$26");
+  asm("tay");
+  asm("lda _ctk_eyecandy_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("tya");
+  asm("clc");
+  asm("adc #$26");
+  asm("tay");
+  asm("lda _ctk_eyecandy_color");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("sta (ptr1),y");
+
+
+
+  /* Find hires address. */
+  asm("lda _ctk_eyecandy_cursy");
+  asm("asl");
+  asm("tax");
+  asm("lda _ctk_eyecandy_yhiresaddr,x");
+  asm("sta ptr2");
+  asm("lda _ctk_eyecandy_yhiresaddr+1,x");
+  asm("sta ptr2+1");
+
+  /* Add X coordinate to the hires address. */
+  asm("lda #0");
+  asm("sta ptr1+1");
+  asm("lda _ctk_eyecandy_cursx");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("asl");
+  asm("rol ptr1+1");
+  asm("clc");
+  asm("adc ptr2");
+  asm("sta ptr2");
+  asm("lda ptr2+1");
+  asm("adc ptr1+1");
+  asm("sta ptr2+1");
+
+  asm("lda _tmpptr");
+  asm("sta ptr1");
+  asm("lda _tmpptr+1");
+  asm("sta ptr1+1");
+
+  asm("ldx #3");
+  asm("iconloop1:");
+  asm("ldy #0");
+  asm("iconloop2:");
+  asm("lda (ptr1),y");
+  asm("sta (ptr2),y");
+  asm("iny");
+  asm("cpy #$18");
+  asm("bne iconloop2");
+  asm("lda ptr1");
+  asm("clc");
+  asm("adc #$18");
+  asm("sta ptr1");
+  asm("lda ptr1+1");
+  asm("adc #0");
+  asm("sta ptr1+1");
+  asm("lda ptr2");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta ptr2");
+  asm("lda ptr2+1");
+  asm("adc #1");
+  asm("sta ptr2+1");
+  asm("dex");
+  asm("bne iconloop1");
+
+  
+  
+  asm("lda _tmp01");
+  asm("sta $01");  
+  asm("cli"); 
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+	    unsigned char x, unsigned char y,
+	    unsigned char clipy1, unsigned char clipy2,
+	    unsigned char focus)
+{
+  unsigned char xpos, ypos, xscroll;
+  unsigned char i, j;
+  char c, *text;
+  unsigned char len;
+
+  xpos = x + w->x;
+  ypos = y + w->y;
+
+  hires_color(colors[w->type * 6 + focus]);
+  
+  switch(w->type) {
+  case CTK_WIDGET_SEPARATOR:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_chlinexy(xpos, ypos, w->w);
+    }
+    break;
+  case CTK_WIDGET_LABEL:
+    text = w->widget.label.text;
+    for(i = 0; i < w->widget.label.h; ++i) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	hires_gotoxy(xpos, ypos);
+	ctk_eyecandy_cputsn(text, w->w);
+	if(w->w - (hires_wherex() - xpos) > 0) {
+	  ctk_eyecandy_cclear(w->w - (hires_wherex() - xpos));
+	}
+      }
+      ++ypos;
+      text += w->w;
+    }
+    break;
+  case CTK_WIDGET_BUTTON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      /*      hires_cputcxy(xpos, ypos, SC_LBRACK);*/
+      /*      if(focus & CTK_FOCUS_WINDOW) {
+	if(focus & CTK_FOCUS_WIDGET) {
+	  hires_color(COLOR(COLOR_GRAY1, COLOR_GRAY3));
+	} else {
+	  hires_color(COLOR(COLOR_WHITE, COLOR_GRAY3));
+	}	
+      } else {
+	if(focus & CTK_FOCUS_WIDGET) {
+	  hires_color(COLOR(COLOR_GRAY1, COLOR_GRAY2));
+	} else {
+	  hires_color(COLOR(COLOR_GRAY3, COLOR_GRAY2));
+	}	
+	}*/
+      hires_color(colors[6 * 6 + focus]);
+      hires_gotoxy(xpos, ypos);
+      ctk_eyecandy_draw_buttonleft();
+      hires_color(colors[w->type * 6 + focus]);
+      hires_gotoxy(xpos + 1, ypos);
+      ctk_eyecandy_cputsn(w->widget.button.text, w->w);
+      hires_color(colors[7 * 6 + focus]);      
+      /*      if(focus & CTK_FOCUS_WINDOW) {
+	if(focus & CTK_FOCUS_WIDGET) {
+	  hires_color(COLOR(COLOR_WHITE, COLOR_GRAY3));
+	} else {
+	  hires_color(COLOR(COLOR_GRAY1, COLOR_GRAY3));
+	}
+      } else {
+	if(focus & CTK_FOCUS_WIDGET) {
+	  hires_color(COLOR(COLOR_GRAY3, COLOR_GRAY2));
+	} else {
+	  hires_color(COLOR(COLOR_GRAY1, COLOR_GRAY2));
+	}
+
+	}*/
+      ctk_eyecandy_draw_buttonright();
+      /*      ctk_eyecandy_cputc(SC_RBRACK);*/
+    }
+    break;
+  case CTK_WIDGET_HYPERLINK:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      hires_underline(1);
+      hires_gotoxy(xpos, ypos);
+      ctk_eyecandy_cputsn(w->widget.button.text, w->w);
+      hires_underline(0);
+    }
+    break;
+  case CTK_WIDGET_TEXTENTRY:
+    text = w->widget.textentry.text;
+    if(focus & CTK_FOCUS_WIDGET &&
+       w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+      hires_revers(1);
+    } else {
+      hires_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->widget.textentry.h; ++j) {
+      if(ypos >= clipy1 && ypos < clipy2) {
+	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+	   w->widget.textentry.ypos == j) {
+	  hires_revers(0);
+	  hires_cputcxy(xpos, ypos, '>');
+	  for(i = 0; i < w->w; ++i) {
+	    c = text[i + xscroll];
+	    if(i == w->widget.textentry.xpos - xscroll) {
+	      hires_revers(1);
+	    } else {
+	      hires_revers(0);
+	    }
+	    if(c == 0) {
+	      ctk_eyecandy_cputc(' ');
+	    } else {
+	      ctk_eyecandy_cputc(c);
+	    }
+	    hires_revers(0);
+	  }
+	  ctk_eyecandy_cputc('<');
+	} else {
+	  hires_cputcxy(xpos, ypos, '|');
+	  /*	  hires_gotoxy(xpos + 1, ypos);          */
+	  ctk_eyecandy_cputsn(text, w->w);
+	  i = hires_wherex();
+	  if(i - xpos - 1 < w->w) {
+	    ctk_eyecandy_cclear(w->w - (i - xpos) + 1);
+	  }
+	  ctk_eyecandy_cputc('|');
+	}
+      }
+      ++ypos;
+      text += w->widget.textentry.len;
+    }
+    hires_revers(0);
+    break;
+  case CTK_WIDGET_ICON:
+    if(ypos >= clipy1 && ypos < clipy2) {
+      if(focus) {
+	hires_color(COLOR(COLOR_BLACK, COLOR_YELLOW));
+      } else {
+	hires_color(COLOR(COLOR_WHITE, COLOR_BLACK));
+      }
+      hires_gotoxy(xpos, ypos);
+      if(w->widget.icon.bitmap != NULL) {
+	draw_bitmap_icon(w->widget.icon.bitmap);
+      }
+      x = xpos;
+
+      len = strlen(w->widget.icon.title);
+      if(x + len >= SCREEN_WIDTH) {
+	x = SCREEN_WIDTH - len;
+      }
+      
+      hires_gotoxy(x, ypos + 3);
+      ctk_eyecandy_cputsn(w->widget.icon.title, len);
+    }
+    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(struct ctk_window *window,
+		      unsigned char focus,
+		      unsigned char clipy1,
+		      unsigned char clipy2)
+{
+  unsigned char h;
+
+  hires_color(colors[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;
+  
+  /*  if(clipy1 >= clipy2) {
+    return;
+    }*/
+  
+  
+  x = window->x;
+  y = window->y + 1;
+
+  ++clipy2;
+  
+  if(clipy2 < y) {
+    return;
+  }
+  
+  hires_color(colors[focus+1]);
+  
+  x1 = x + 1;
+  y1 = y + 1;
+  x2 = x1 + window->w;
+  y2 = y1 + window->h;
+
+  hires_gotoxy(x, y);
+  ctk_eyecandy_windowparams.w = window->w;
+  ctk_eyecandy_windowparams.h = window->h;
+  if(clipy1 < y) {
+    ctk_eyecandy_windowparams.clipy1 = 0;
+  } else {
+    ctk_eyecandy_windowparams.clipy1 = clipy1 - y;
+  }
+  ctk_eyecandy_windowparams.clipy2 = clipy2 - y;
+  ctk_eyecandy_windowparams.color1 = colors[focus+1];
+  ctk_eyecandy_windowparams.color2 = colors[focus];
+  ctk_eyecandy_windowparams.title = window->title;
+  ctk_eyecandy_windowparams.titlelen = window->titlelen;
+
+  ctk_eyecandy_draw_windowborders();
+  
+#if 0
+  /* Draw window frame. */  
+  if(y >= clipy1) {
+    windowulcorner(x, y);
+    windowupperborder(x + 3 + strlen(window->title),
+		      y, window->w - 5 - strlen(window->title));
+    windowurcorner(x + window->w + 1, y);
+    hires_gotoxy(x + 1, y);
+    hires_color(colors[focus]);
+    ctk_eyecandy_cputc(' ');
+    ctk_eyecandy_cputsn(window->title, window->titlelen);
+    ctk_eyecandy_cputc(' ');
+  }
+
+  h = window->h;
+  
+  if(clipy1 > y1) {
+    if(clipy1 - y1 < h) {
+      h = clipy1 - y1;
+      y1 = clipy1;
+    } else {
+      h = 0;
+    }
+  }
+
+  if(y1 + h >= clipy2) {
+    if(y1 >= clipy2) {
+      h = 0;
+    } else {
+      h = clipy2 - y1;
+    }
+  }
+
+  if(h == 0) {
+    return;
+  }
+  
+  hires_color(colors[focus+1]);  
+  windowsideborder(x, y1, h+1, 0xc0);
+  hires_color(colors[focus]);
+  windowsideborder(x2, y+1, h, 0x0b);
+
+  if(y + window->h >= clipy1 &&
+     y + window->h < clipy2) {
+    windowlowerborder(x1, y2, window->w);
+  }
+
+#endif /* 0 */
+  
+  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(colors[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);
+  }
+  
+  /* Clear dialog 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(struct ctk_menu *m)
+{
+  unsigned char x, x2, y;
+  
+  hires_color(colors[OPENMENUCOLOR]);
+  x = hires_wherex();
+  ctk_eyecandy_cputsn(m->title, m->titlelen);
+  ctk_eyecandy_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(colors[ACTIVEMENUCOLOR]);
+    } else {
+      hires_color(colors[MENUCOLOR]);
+    }
+    hires_gotoxy(x, y + 1);
+    if(m->items[y].title[0] == '-') {
+      ctk_eyecandy_chline(CTK_CONF_MENUWIDTH);
+    } else {
+      ctk_eyecandy_cputsn(m->items[y].title,
+			  strlen(m->items[y].title));
+    }
+    ctk_eyecandy_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+    hires_revers(0);
+  }
+  hires_gotoxy(x2, 0);
+  hires_color(colors[MENUCOLOR]);  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+  struct ctk_menu *m;
+  
+  /* Draw menus */
+  
+  hires_gotoxy(0, 0);
+  hires_revers(0);
+  for(m = menus->menus->next; m != NULL; m = m->next) {
+    hires_color(colors[MENUCOLOR]);    
+    if(m != menus->open) {
+      ctk_eyecandy_cputsn(m->title, m->titlelen);
+      ctk_eyecandy_cputc(' ');
+    } else {
+      draw_menu(m);
+    }
+  }
+  ctk_eyecandy_cclear(SCREEN_WIDTH - hires_wherex() -
+		      strlen(menus->desktopmenu->title) - 1);
+  
+  /* Draw desktopmenu */  
+  if(menus->desktopmenu != menus->open) {
+    ctk_eyecandy_cputsn(menus->desktopmenu->title,
+			menus->desktopmenu->titlelen);
+    ctk_eyecandy_cputc(' ');
+  } else {
+    draw_menu(menus->desktopmenu);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+  return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+  return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/ctk-eyecandy.h b/contiki-c64/ctk/ctk-eyecandy.h
new file mode 100644
index 0000000..e4abb77
--- /dev/null
+++ b/contiki-c64/ctk/ctk-eyecandy.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. 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-eyecandy.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __CTK_EYECANDY_H__
+#define __CTK_EYECANDY_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_EYECANDY_H__ */
diff --git a/contiki-c64/ctk/fire.c b/contiki-c64/ctk/fire.c
new file mode 100644
index 0000000..e161635
--- /dev/null
+++ b/contiki-c64/ctk/fire.c
@@ -0,0 +1,129 @@
+/*
+ * 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: fire.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#include <c64.h>
+
+static unsigned char flames[8*17];
+
+static unsigned char *flameptr, *colorptr1, *colorptr2;
+static unsigned char x, y;
+
+
+static unsigned char flamecolors[16] =
+  {COLOR_BLACK,  COLOR_BLACK, COLOR_BLACK,
+   COLOR_RED,    COLOR_LIGHTRED,   COLOR_YELLOW, COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+  COLOR_WHITE};
+   
+
+/*-----------------------------------------------------------------------------------*/
+void
+fire_run(void)
+{
+  
+  /* Calculate new flames. */
+  asm("ldx #0");
+  asm("loop:");
+  asm("lda _flames+7,x");
+  asm("clc");
+  asm("adc _flames+8,x");
+  asm("adc _flames+9,x");
+  asm("adc _flames+16,x");
+  asm("lsr");
+  asm("lsr");
+  asm("sta _flames,x");
+  asm("inx");
+  asm("cpx #(8*15)");
+  asm("bne loop");
+
+  /* Fill last line with pseudo-random data from noise generator on
+     voice 3. */
+  asm("ldx #$05");
+  asm("loop2:");
+  asm("ldy #$20");
+  asm("delay:");
+  asm("dey");
+  asm("bne delay");
+  asm("lda $d41b");
+  asm("and #$0f");
+  asm("sta _flames+8*15+1,x");
+  asm("dex");
+  asm("bpl loop2");
+
+  /* Display flames on screen. */  
+  flameptr = flames;
+  colorptr1 = COLOR_RAM + 40*10;
+  colorptr2 = colorptr1 + 0x20;
+  for(y = 0; y < 15; ++y) {
+    for(x = 0; x < 8; ++x) {
+      *colorptr1 = *colorptr2 = flamecolors[*flameptr++];
+      ++colorptr1;
+      ++colorptr2;
+    }
+    colorptr1 += 0x20;
+    colorptr2 += 0x20;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+fire_init(void)
+{
+  unsigned char *ptr, *cptr;
+  
+  SID.v3.freq = 0xffff;
+  SID.v3.ctrl = 0x80;
+  SID.amp = 0;  
+
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/ctk/fire.h b/contiki-c64/ctk/fire.h
new file mode 100644
index 0000000..cf772c1
--- /dev/null
+++ b/contiki-c64/ctk/fire.h
@@ -0,0 +1,47 @@
+/*
+ * 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: fire.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+#ifndef __FIRE_H__
+#define __FIRE_H__
+
+#define CTK_SCREENSAVER_INIT fire_init
+#define CTK_SCREENSAVER_RUN  fire_run
+
+void fire_init(void);
+void fire_run(void);
+
+#endif /* __FIRE_H__ */
diff --git a/contiki-c64/uip/cs8900a.c b/contiki-c64/uip/cs8900a.c
new file mode 100644
index 0000000..f7c73b0
--- /dev/null
+++ b/contiki-c64/uip/cs8900a.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.1 2003/03/19 16:26:19 adamdunkels 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 RXTXREG (*(u16_t *)0xde00)
+#define PACKETPP (*(u16_t *)0xde0a)
+#define PPDATA (*(u16_t *)0xde0c)
+
+static u16_t len;
+static u8_t r;
+
+
+/*-----------------------------------------------------------------------------------*/
+void
+cs8900a_init(void)
+{
+  /* Turn on transmission and reception of frames. */
+  /* PACKETPP = 0x0112;
+     PPDATA   = 0x00c0; */
+  asm("lda #$12");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda #$c0");
+  asm("sta $de0c");
+  asm("lda #$00");
+  asm("sta $de0d");
+
+  /* Accept valid unicast+broadcast frames. */
+  /* PACKETPP = 0x0104;
+     PPDATA   = 0x0d05; */
+  asm("lda #$04");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda #$05");
+  asm("sta $de0c");
+  asm("lda #$0d");
+  asm("sta $de0d");
+
+  /* Set MAC address. */
+  /* PACKETPP = 0x0158;
+     PPDATA   = (ETHADDR1 << 8) | (ETHADDR0); */
+  asm("lda #$58");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda #%b", UIP_ETHADDR0);
+  asm("sta $de0c");
+  asm("lda #%b", UIP_ETHADDR1);
+  asm("sta $de0d");
+
+  /* PACKETPP = 0x015a;
+     PPDATA   = (ETHADDR3 << 8) | (ETHADDR2); */
+  asm("lda #$5a");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda #%b", UIP_ETHADDR2);
+  asm("sta $de0c");
+  asm("lda #%b", UIP_ETHADDR3);
+  asm("sta $de0d");
+
+  /* PACKETPP = 0x015c;
+     PPDATA   = (ETHADDR5 << 8) | (ETHADDR4); */
+  asm("lda #$5c");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda #%b", UIP_ETHADDR4);
+  asm("sta $de0c");
+  asm("lda #%b", UIP_ETHADDR5);
+  asm("sta $de0d");
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+cs8900a_send(void)
+{
+  if(uip_len >= UIP_BUFSIZE) {
+    asm("inc $d020");
+    return;
+  }
+    
+  /* Transmit command. */
+  asm("lda #$c0");
+  asm("sta $de04");
+  asm("lda #$00");
+  asm("sta $de05");
+  asm("lda _uip_len");
+  asm("sta $de06");
+#if UIP_BUFSIZE > 255  
+  asm("lda _uip_len+1");
+#else
+  asm("lda #0");
+#endif      
+  asm("sta $de07");
+
+  asm("ldx #8");
+  asm("tryagain:");
+  /* Check for avaliable buffer space. */
+  asm("lda #$38");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda $de0d");
+  asm("and #1");
+  asm("bne send");
+
+  /* No space avaliable, skip a received frame and try again. */
+  asm("lda #$02");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda $de0c");
+  asm("ora #$40");
+  asm("sta $de0c");
+
+  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 $de00");
+  asm("lda _uip_buf+1,y");
+  asm("sta $de01");
+  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 $de00");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("sta $de01");
+  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");  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+skip_frame(void)
+{
+  /* PACKETPP = 0x0102;
+     PPDATA   = PPDATA | 0x0040; */
+  asm("lda #$02");
+  asm("sta $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda $de0c");
+  asm("ora #$40");
+  asm("sta $de0c");
+}
+/*-----------------------------------------------------------------------------------*/
+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 $de0a");
+  asm("lda #$01");
+  asm("sta $de0b");
+  asm("lda $de0d");
+  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 $de01");
+  asm("sta _len+1");
+  asm("lda $de00");
+  asm("sta _len");
+  
+  /* Read frame length. */
+  /* len = uip_len = RXTXREG; */
+  asm("lda $de01");
+  asm("sta _len+1");
+  asm("sta _uip_len+1");
+  asm("lda $de00");
+  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 $de00");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda $de01");
+  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 $de00");
+  asm("sta (ptr1),y");
+  asm("iny");
+  asm("lda $de01");
+  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;
+}
diff --git a/contiki-c64/uip/cs8900a.h b/contiki-c64/uip/cs8900a.h
new file mode 100644
index 0000000..b6f1a4c
--- /dev/null
+++ b/contiki-c64/uip/cs8900a.h
@@ -0,0 +1,10 @@
+#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-c64/uip/rs232dev.c b/contiki-c64/uip/rs232dev.c
new file mode 100644
index 0000000..f14a8ad
--- /dev/null
+++ b/contiki-c64/uip/rs232dev.c
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <rs232.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+#  include <cbm.h>
+#elif defined(__ATARI__)
+#  include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END     0300
+#define SLIP_ESC     0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c)  while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c)  (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c)  rs232_put(c)
+
+#define MAX_SIZE UIP_BUFSIZE
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+#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;
+  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, 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_PAR_NONE);
+  rs232_err(err);
+
+  len = 0;
+
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/rs232dev.h b/contiki-c64/uip/rs232dev.h
new file mode 100644
index 0000000..7fd7a21
--- /dev/null
+++ b/contiki-c64/uip/rs232dev.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+
+#if UIP_BUFSIZE > 255
+u16_t rs232dev_poll(void);
+#else 
+u8_t rs232dev_poll(void);
+#endif /* UIP_BUFSIZE > 255 */
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-c64/uip/uip_arch.c b/contiki-c64/uip/uip_arch.c
new file mode 100644
index 0000000..d9d5457
--- /dev/null
+++ b/contiki-c64/uip/uip_arch.c
@@ -0,0 +1,424 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP    6
+
+/*-----------------------------------------------------------------------------------*/
+#if UIP_BUFSIZE > 255
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+  asm("ldy #3");
+  asm("jsr ldaxysp");
+  asm("sta ptr1");
+  asm("stx ptr1+1");
+  asm("ldy #0");
+  asm("lda (sp),y");
+  asm("ldy #3");
+  asm("clc");
+  asm("adc (ptr1),y");
+  asm("sta _uip_acc32+3");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("ldy #1");
+  asm("adc (sp),y");
+  asm("sta _uip_acc32+2");
+  asm("ldy #1");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+1");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc #0");
+  asm("sta _uip_acc32+0");  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add_rcv_nxt(u16_t n) {
+  uip_add32(uip_conn->rcv_nxt, n);
+  uip_conn->rcv_nxt[0] = uip_acc32[0];
+  uip_conn->rcv_nxt[1] = uip_acc32[1];
+  uip_conn->rcv_nxt[2] = uip_acc32[2];
+  uip_conn->rcv_nxt[3] = uip_acc32[3];
+  /*  asm("pha");
+  asm("lda _uip_conn");
+  asm("sta ptr1");
+  asm("lda _uip_conn+1");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("clc");
+  asm("ldy #3");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("txa");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+
+  n=n;*/
+}
+/*-----------------------------------------------------------------------------------*/
+#else /* UIP_BUFSIZE > 255 */
+/*-----------------------------------------------------------------------------------*/
+void
+uip_add32(u8_t *op32, u8_t op8)
+{
+  asm("ldy #2");
+  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("adc #0");
+  asm("sta _uip_acc32+2");
+  asm("dey");
+  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");  
+}
+/*-----------------------------------------------------------------------------------*/
+void 
+uip_add_rcv_nxt(u8_t n) {
+  asm("pha");
+  asm("lda _uip_conn");
+  asm("sta ptr1");
+  asm("lda _uip_conn+1");
+  asm("sta ptr1+1");
+  asm("pla");
+  asm("clc");
+  asm("ldy #3");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+  asm("dey");
+  asm("lda #0");
+  asm("adc (ptr1),y");
+  asm("sta (ptr1),y");
+}
+/*-----------------------------------------------------------------------------------*/
+#endif /* UIP_BUFSIZE > 255 */
+
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+u16_t
+chksum(void) {
+
+  asm("lda #0");
+  asm("sta tmp1");
+  asm("sta tmp1+1");
+  asm("lda _chksum_ptr");
+  asm("sta ptr1");
+  asm("lda _chksum_ptr+1");
+  asm("sta ptr1+1");
+
+
+  asm("lda _chksum_len+1");
+  asm("beq chksumlast");
+
+
+  /* If checksum is > 256, do the first runs. */
+  asm("ldy #0");
+  asm("clc");
+  asm("chksumloop_256:");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("iny");
+  asm("bne chksumloop_256");
+  asm("inc ptr1+1");
+  asm("dec _chksum_len+1");
+  asm("bne chksumloop_256");
+
+  asm("chksum_endloop_256:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop_256");
+  
+  asm("chksumlast:");
+  asm("lda _chksum_len");
+  asm("lsr");
+  asm("bcc chksum_noodd");  
+  asm("ldy _chksum_len");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("clc");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("bcc noinc1");
+  asm("inc tmp1+1");
+  asm("bne noinc1");
+  asm("inc tmp1");
+  asm("noinc1:");
+  asm("dec _chksum_len");
+
+  asm("chksum_noodd:");
+  asm("clc");
+  asm("php");
+  asm("ldy _chksum_len");
+  asm("chksum_loop1:");
+  asm("cpy #0");
+  asm("beq chksum_loop1_end");
+  asm("plp");
+  asm("dey");
+  asm("dey");
+  asm("lda (ptr1),y");
+  asm("adc tmp1");
+  asm("sta tmp1");
+  asm("iny");
+  asm("lda (ptr1),y");
+  asm("adc tmp1+1");
+  asm("sta tmp1+1");
+  asm("dey");
+  asm("php");
+  asm("jmp chksum_loop1");
+  asm("chksum_loop1_end:");
+  asm("plp");
+  
+  asm("chksum_endloop:");
+  asm("lda tmp1");
+  asm("adc #0");
+  asm("sta tmp1");
+  asm("lda tmp1+1");
+  asm("adc #0");
+  asm("sta tmp1+1");
+  asm("bcs chksum_endloop");
+  
+  asm("lda tmp1");
+  asm("ldx tmp1+1");
+}
+/*-----------------------------------------------------------------------------------*/
+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();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{  
+  chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+  chksum_len = 20;  
+  chksum_tmp = chksum();
+
+  chksum_ptr = (u16_t)uip_appdata;
+#ifdef WITH_TFE
+  asm("lda _uip_buf+3+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+3");
+#endif /* WITH_TFE */
+  asm("sec");
+  asm("sbc #40");
+  asm("sta _chksum_len");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+2+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+2");
+#endif /* WITH_TFE */
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+
+  asm("jsr %v", chksum);
+
+  asm("clc");
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("txa");
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+
+  /* Fold carry */
+  /*  asm("bcc noinc");
+  asm("inc _chksum_tmp");
+  asm("noinc:");*/
+  
+  asm("tcpchksum_loop1:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop1");
+
+
+#ifdef WITH_TFE
+  asm("lda _uip_buf+3+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+3");
+#endif /* WITH_TFE */
+  asm("sec");
+  asm("sbc #20");
+  asm("sta _chksum_len");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+2+14");
+#else /* WITH_TFE */
+  asm("lda _uip_buf+2");
+#endif /* WITH_TFE */
+  asm("sbc #0");
+  asm("sta _chksum_len+1");
+  
+  
+  asm("ldy #$0c");
+  asm("clc");
+  asm("php");
+  asm("tcpchksum_loop2:");
+  asm("plp");
+#ifdef WITH_TFE
+  asm("lda _uip_buf+14,y");
+#else /* WITH_TFE */
+  asm("lda _uip_buf,y");
+#endif /* WITH_TFE */  
+  asm("adc _chksum_tmp");
+  asm("sta _chksum_tmp");
+  asm("iny");
+#ifdef WITH_TFE 
+  asm("lda _uip_buf+14,y");
+#else /* WITH_TFE */
+  asm("lda _uip_buf,y");
+#endif /* WITH_TFE */  
+  asm("adc _chksum_tmp+1");
+  asm("sta _chksum_tmp+1");
+  asm("iny");
+  asm("php");
+  asm("cpy #$14");
+  asm("bne tcpchksum_loop2");
+
+  asm("plp");
+  
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #6");  /* IP_PROTO_TCP */
+  asm("sta _chksum_tmp+1");
+
+  
+  asm("lda _chksum_tmp");
+  asm("adc _chksum_len+1");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc _chksum_len");
+  asm("sta _chksum_tmp+1");
+
+  
+
+  asm("tcpchksum_loop3:");
+  asm("lda _chksum_tmp");
+  asm("adc #0");
+  asm("sta _chksum_tmp");
+  asm("lda _chksum_tmp+1");
+  asm("adc #0");
+  asm("sta _chksum_tmp+1");
+  asm("bcs tcpchksum_loop3");
+
+
+  return chksum_tmp;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/uip/uip_arch.h b/contiki-c64/uip/uip_arch.h
new file mode 100644
index 0000000..a3748ac
--- /dev/null
+++ b/contiki-c64/uip/uip_arch.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.1 2003/03/19 16:26:19 adamdunkels Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+#if UIP_BUFSIZE > 255
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+#else
+void uip_add_rcv_nxt(u8_t n);
+void uip_add32(u8_t *op32, u8_t op8);
+#endif /* UIP_BUFSIZE > 255 */
+
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */