Initial revision
diff --git a/contiki-cpc/apps/blueround-dsc.c b/contiki-cpc/apps/blueround-dsc.c
new file mode 100644
index 0000000..f2d245b
--- /dev/null
+++ b/contiki-cpc/apps/blueround-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: blueround-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon blueround_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(blueround_dsc,
+ "Blueround CTK theme",
+ "blueround.prg",
+ blueround_init,
+ &blueround_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char blueroundicon_bitmap[3*3*8] = {
+ 0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00,
+ 0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00,
+ 0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char blueroundicon_textmap[9] = {
+ '(', '=', ')',
+ '|', 'o', '|',
+ '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon blueround_icon =
+ {CTK_ICON("Blueround", blueroundicon_bitmap, blueroundicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm-dsc.c b/contiki-cpc/apps/cgterm-dsc.c
new file mode 100644
index 0000000..acba8ba
--- /dev/null
+++ b/contiki-cpc/apps/cgterm-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: cgterm-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(cgterm_dsc,
+ "Program for connecting to C64 Telnet BBSes",
+ "cgterm.prg",
+ cgterm_init,
+ &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char cgtermicon_bitmap[3*3*8] = {
+ 0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+ 0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+ 0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+ 0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+ 0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+ 0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+ 0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+ 0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+ 0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char cgtermicon_textmap[9] = {
+ 'T', 'e', 'l',
+ 'n', 'e', 't',
+ 'B', 'B', 'S'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon icon =
+ {CTK_ICON("C/G terminal", cgtermicon_bitmap, cgtermicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm.c b/contiki-cpc/apps/cgterm.c
new file mode 100644
index 0000000..fa85a40
--- /dev/null
+++ b/contiki-cpc/apps/cgterm.c
@@ -0,0 +1,243 @@
+#include "contiki.h"
+#include "socket.h"
+#include "ctk-draw.h"
+
+#include <cbm.h>
+#include <c64.h>
+#include <string.h>
+
+static struct {
+ struct socket sout, sin;
+ struct pt inpt, outpt;
+ char outputbuf[200];
+ char inputbuf[200];
+ unsigned short len;
+} s;
+
+#define CURSOR_ON() *(char *)0xcc = 0
+#define CURSOR_OFF() *(char *)0xcc = 1
+static void ctkmode(void);
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send(void))
+{
+ SOCKET_BEGIN(&s.sout);
+
+ SOCKET_SEND(&s.sout, s.outputbuf, s.len);
+ SOCKET_END(&s.sout);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(void))
+{
+ ctk_arch_key_t c;
+ char *ptr;
+
+ PT_BEGIN(&s.outpt);
+
+ while(1) {
+ PT_WAIT_UNTIL(&s.outpt, (ctk_mode_get() == CTK_MODE_EXTERNAL) &&
+ kbhit());
+
+
+ ptr = s.outputbuf;
+ s.len = 0;
+ while(kbhit() && s.len < sizeof(s.outputbuf)) {
+ c = cgetc();
+ *ptr = c;
+ ++ptr;
+ ++s.len;
+ }
+
+ PT_WAIT_THREAD(&s.outpt, send());
+ }
+ PT_END(&s.outpt);
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(void))
+{
+ unsigned short i;
+ char *ptr;
+ char next;
+
+ next = 1;
+ PT_BEGIN(&s.inpt);
+
+ while(1) {
+ /* Wait until data arrives. */
+ next = 0;
+ PT_WAIT_UNTIL(&s.inpt, next && uip_newdata());
+
+ CURSOR_OFF();
+ /* Print it out on the screen. */
+ ptr = (char *)uip_appdata;
+ for(i = 0; i < uip_len; ++i) {
+ cbm_k_bsout(*ptr);
+ ++ptr;
+ }
+ CURSOR_ON();
+ }
+ PT_END(&s.inpt);
+}
+/*---------------------------------------------------------------------------*/
+static void
+appcall(void *state)
+{
+ if(uip_closed() || uip_aborted() || uip_timedout()) {
+ ctkmode();
+ } else if(uip_connected()) {
+ } else {
+ handle_input();
+ handle_output();
+ }
+}
+/*---------------------------------------------------------------------------*/
+static struct uip_conn *
+connect(u16_t *host, u16_t port)
+{
+ SOCKET_INIT(&s.sin, s.inputbuf, sizeof(s.inputbuf));
+ SOCKET_INIT(&s.sout, s.inputbuf, sizeof(s.inputbuf));
+ PT_INIT(&s.inpt);
+ PT_INIT(&s.outpt);
+ return tcp_connect(host, htons(port), NULL);
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler);
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "C/G terminal", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+static struct uip_conn *conn;
+static u16_t serveraddr[2];
+static u16_t serverport;
+/*---------------------------------------------------------------------------*/
+static struct ctk_window window;
+static struct ctk_label hostlabel =
+ {CTK_LABEL(0, 0, 4, 1, "Host")};
+static char host[32];
+static struct ctk_textentry hostentry =
+ {CTK_TEXTENTRY(5, 0, 20, 1, host, sizeof(host) - 1)};
+static struct ctk_label portlabel =
+ {CTK_LABEL(27, 0, 4, 1, "Port")};
+static char port[7];
+static struct ctk_textentry portentry =
+ {CTK_TEXTENTRY(32, 0, 4, 1, port, sizeof(port) - 1)};
+static struct ctk_button connectbutton =
+ {CTK_BUTTON(0, 2, 7, "Connect")};
+static struct ctk_button switchbutton =
+ {CTK_BUTTON(30, 2, 6, "Switch")};
+static struct ctk_label helplabel =
+ {CTK_LABEL(0, 4, 37, 1, "RUN/STOP to return from terminal view")};
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cgterm_init, arg)
+{
+ arg_free(arg);
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*---------------------------------------------------------------------------*/
+static void
+ctkmode(void)
+{
+ ctk_mode_set(CTK_MODE_NORMAL);
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+}
+/*---------------------------------------------------------------------------*/
+static void
+textmode(void)
+{
+ ctk_mode_set(CTK_MODE_EXTERNAL);
+
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x03; /* $DD00 */
+
+ VIC.bordercolor = 0x00; /* $D020 */
+ VIC.bgcolor0 = 0x00; /* $D021 */
+
+ CURSOR_ON();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ u16_t *ipaddr;
+ char *cptr;
+
+ if(ev == tcpip_event) {
+ appcall(data);
+ } else if(ev == EK_EVENT_INIT) {
+ ctk_window_new(&window, 38, 5, "C/G term");
+ CTK_WIDGET_ADD(&window, &hostlabel);
+ CTK_WIDGET_ADD(&window, &hostentry);
+ CTK_WIDGET_ADD(&window, &portlabel);
+ CTK_WIDGET_ADD(&window, &portentry);
+ CTK_WIDGET_ADD(&window, &connectbutton);
+ CTK_WIDGET_ADD(&window, &switchbutton);
+ CTK_WIDGET_ADD(&window, &helplabel);
+ ctk_window_open(&window);
+ } else if(ev == ctk_signal_widget_activate) {
+
+ if(data == (ek_data_t)&switchbutton) {
+ textmode();
+ } else if(data == (ek_data_t)&connectbutton) {
+ serverport = 0;
+ for(cptr = port; *cptr != ' ' && *cptr != 0; ++cptr) {
+ if(*cptr < '0' || *cptr > '9') {
+ return;
+ }
+ serverport = 10 * serverport + *cptr - '0';
+ }
+
+ ipaddr = serveraddr;
+ if(uiplib_ipaddrconv(host, (u8_t *)serveraddr) == 0) {
+ ipaddr = resolv_lookup(host);
+ if(ipaddr == NULL) {
+ resolv_query(host);
+ } else {
+ uip_ipaddr_copy(serveraddr, ipaddr);
+ }
+ }
+ if(ipaddr != NULL) {
+ conn = connect(serveraddr, serverport);
+ if(conn != NULL) {
+ memset((char *)0x0400, 0x20, 40*25);
+ memset((char *)0xd800, 0x01, 40*25);
+ textmode();
+ }
+ }
+ }
+ } else if(ev == resolv_event_found) {
+ ipaddr = resolv_lookup(host);
+ if(ipaddr != NULL) {
+ uip_ipaddr_copy(serveraddr, ipaddr);
+
+ conn = connect(serveraddr, serverport);
+ if(conn != NULL) {
+ memset((char *)0x0400, 0x20, 40*25);
+ memset((char *)0xd800, 0x01, 40*25);
+ textmode();
+ }
+ }
+ } else if(ev == EK_EVENT_REQUEST_EXIT ||
+ ev == ctk_signal_window_close) {
+ ctk_window_close(&window);
+ ek_exit();
+ LOADER_UNLOAD();
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+ if(ctk_mode_get() == CTK_MODE_EXTERNAL) {
+ if(CIA1.prb == 0x7f) {
+ ctkmode();
+ } else if(kbhit() && conn != NULL) {
+ tcpip_poll_tcp(conn);
+ }
+ }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/config.c b/contiki-cpc/apps/config.c
new file mode 100644
index 0000000..9fb37fe
--- /dev/null
+++ b/contiki-cpc/apps/config.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: config.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+
+struct ptentry {
+ char c;
+ char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+ struct ptentry *p;
+
+ /* Loop over the parse table entries in t in order to find one that
+ matches the first character in str. */
+ for(p = t; p->c != 0; ++p) {
+ if(*str == p->c) {
+ /* Skip rest of the characters up to the first space. */
+ while(*str != ' ') {
+ ++str;
+ }
+
+ /* Skip all spaces.*/
+ while(*str == ' ') {
+ ++str;
+ }
+
+ /* Call parse table entry function and return. */
+ return p->pfunc(str);
+ }
+ }
+
+ /* Did not find matching entry in parse table. We just call the
+ default handler supplied by the caller and return. */
+ return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+ /* Skip all characters until the newline. */
+ while(*str != '\n') {
+ ++str;
+ }
+
+ /* Return a pointer to the first character after the newline. */
+ return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+ char *nt;
+
+ /* Nullterminate string. Start with finding newline character. */
+ for(nt = str; *nt != '\r' &&
+ *nt != '\n'; ++nt);
+
+ /* Replace newline with a null char. */
+ *nt = 0;
+
+ /* Remove trailing spaces. */
+ while(nt > str && *(nt - 1) == ' ') {
+ *(nt - 1) = 0;
+ --nt;
+ }
+
+ /* Return pointer to null char. */
+ return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadfile(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+
+ /* Call loader function. */
+ program_handler_load(str, NULL);
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+screensaverconf(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+ program_handler_screensaver(str);
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t addr[2];
+static char *
+ipaddrconf(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+
+
+// if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+// uip_sethostaddr(addr);
+// }
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+// if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+// uip_setnetmask(addr);
+// }
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+// if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+// uip_setdraddr(addr);
+// }
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+ char *nt;
+
+ nt = nullterminate(str);
+// if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+// resolv_conf(addr);
+// }
+
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry configparsetab[] =
+ {{'n', loadfile},
+ {'t', loadfile},
+ {'c', loadfile},
+ {'s', screensaverconf},
+ {'i', ipaddrconf},
+ {'m', netmaskconf},
+ {'r', drconf},
+ {'d', dnsconf},
+ {'#', skipnewline},
+
+ /* Default action */
+ {0, skipnewline}};
+static void
+configscript(void)
+{
+ static char line[40], *lineptr;
+ /* static struct c64_fs_file f;*/
+ int f;
+
+ if((f = cfs_open("config.cfg", 0)) == -1) {
+ return;
+ }
+
+ line[0] = ' ';
+ while(line[0] != '.' &&
+ line[0] != 0) {
+ lineptr = line;
+ do {
+ if(cfs_read(f, lineptr, 1) != 1) {
+ cfs_close(f);
+ return;
+ }
+ ++lineptr;
+ } while(*(lineptr - 1) != '\n' &&
+ *(lineptr - 1) != '\r');
+
+ *lineptr = 0;
+
+ if(line[0] != '.' &&
+ line[0] != 0) {
+ parse(line, configparsetab);
+ }
+
+ }
+ cfs_close(f);
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+ arg_free(arg);
+ program_handler_screensaver(NULL);
+ configscript();
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.c b/contiki-cpc/apps/configedit-dsc.c
new file mode 100644
index 0000000..fcb9250
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+ "Edit Contiki configuration",
+ "confedit.prg",
+ configedit_init,
+ &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char tcpipconficon_bitmap[3*3*8] = {
+ 0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+ 0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+ 0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+ 0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+ 0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+ 0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char tcpipconficon_textmap[9] = {
+ 'C', 'F', 'G',
+ ' ', ' ', ' ',
+ 'C', 'F', 'G'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon configedit_icon =
+ {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.h b/contiki-cpc/apps/configedit-dsc.h
new file mode 100644
index 0000000..368b45c
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-cpc/apps/configedit.c b/contiki-cpc/apps/configedit.c
new file mode 100644
index 0000000..5d43f72
--- /dev/null
+++ b/contiki-cpc/apps/configedit.c
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk-draw-service.h"
+#include "packet-service.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "program-handler.h"
+
+#include "cfs.h"
+
+//#include "cfs-init.h"
+#include "cfs-cpc.h"
+
+#include "loader.h"
+
+#include "log.h"
+
+
+#include <stdio.h>
+
+#include <string.h>
+
+/* TCP/IP configuration window. */
+static struct ctk_window window;
+
+#define LABELMAXWIDTH 12
+
+const static struct ctk_label cfslabel =
+ {CTK_LABEL(0, 1, LABELMAXWIDTH, 1, "Disk driver")};
+static char cfs[25];
+static struct ctk_textentry cfstextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 1, 16, 1, cfs, 24)};
+
+const static struct ctk_label themelabel =
+ {CTK_LABEL(0, 3, LABELMAXWIDTH, 1, "CTK theme")};
+static char theme[25];
+static struct ctk_textentry themetextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 3, 16, 1, theme, 24)};
+
+const static struct ctk_label driverlabel =
+ {CTK_LABEL(0, 5, LABELMAXWIDTH, 1, "Net driver")};
+static char driver[25];
+static struct ctk_textentry drivertextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 5, 16, 1, driver, 24)};
+
+const static struct ctk_label screensaverlabel =
+ {CTK_LABEL(0, 7, LABELMAXWIDTH, 1, "Screensaver")};
+static char screensaver[25];
+struct ctk_textentry screensavertextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 7, 16, 1, screensaver, 24)};
+
+
+const static struct ctk_label ipaddrlabel =
+ {CTK_LABEL(0, 9, LABELMAXWIDTH, 1, "IP address")};
+static char ipaddr[25];
+struct ctk_textentry ipaddrtextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 9, 16, 1, ipaddr, 24)};
+const static struct ctk_label netmasklabel =
+ {CTK_LABEL(0, 11, LABELMAXWIDTH, 1, "Netmask")};
+static char netmask[25];
+static struct ctk_textentry netmasktextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 11, 16, 1, netmask, 24)};
+const static struct ctk_label gatewaylabel =
+ {CTK_LABEL(0, 13, LABELMAXWIDTH, 1, "Gateway")};
+static char gateway[25];
+static struct ctk_textentry gatewaytextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 13, 16, 1, gateway, 24)};
+const static struct ctk_label dnsserverlabel =
+ {CTK_LABEL(0, 15, LABELMAXWIDTH, 1, "DNS server")};
+static char dnsserver[25];
+static struct ctk_textentry dnsservertextentry =
+ {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 15, 16, 1, dnsserver, 24)};
+
+const static struct ctk_button savebutton =
+ {CTK_BUTTON(0, 17, 12, "Save & close")};
+const static struct ctk_button cancelbutton =
+ {CTK_BUTTON(24, 17, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(configedit_sighandler, s, data);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Config editor", NULL, configedit_sighandler, NULL)};
+ static ek_id_t id;*/
+
+EK_EVENTHANDLER(configedit_eventhandler, ev, data);
+EK_PROCESS(p, "Config editor", EK_PRIO_NORMAL,
+ configedit_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+/*-----------------------------------------------------------------------------------*/
+struct ptentry {
+ char c;
+ char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+ struct ptentry *p;
+
+ /* Loop over the parse table entries in t in order to find one that
+ matches the first character in str. */
+ for(p = t; p->c != 0; ++p) {
+ if(*str == p->c) {
+ /* Skip rest of the characters up to the first space. */
+ while(*str != ' ') {
+ ++str;
+ }
+
+ /* Skip all spaces.*/
+ while(*str == ' ') {
+ ++str;
+ }
+
+ /* Call parse table entry function and return. */
+ return p->pfunc(str);
+ }
+ }
+
+ /* Did not find matching entry in parse table. We just call the
+ default handler supplied by the caller and return. */
+ return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+ /* Skip all characters until the newline. */
+ while(*str != '\n') {
+ ++str;
+ }
+
+ /* Return a pointer to the first character after the newline. */
+ return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+ char *nt;
+
+ /* Nullterminate string. Start with finding newline character. */
+ for(nt = str; *nt != '\r' &&
+ *nt != '\n'; ++nt);
+
+ /* Replace newline with a null char. */
+ *nt = 0;
+
+ /* Remove trailing spaces. */
+ while(nt > str && *(nt - 1) == ' ') {
+ *(nt - 1) = 0;
+ --nt;
+ }
+
+ /* Return pointer to null char. */
+ return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char * __fastcall__
+copystr(char *dst, char *src, int len)
+{
+ char *nt = nullterminate(src);
+ strncpy(dst, src, len);
+ return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loaddriver(char *str)
+{
+ return copystr(driver, str, sizeof(driver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadtheme(char *str)
+{
+ return copystr(theme, str, sizeof(theme));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadcfs(char *str)
+{
+ return copystr(cfs, str, sizeof(cfs));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadscreensaver(char *str)
+{
+ return copystr(screensaver, str, sizeof(screensaver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+ipaddrconf(char *str)
+{
+ return copystr(ipaddr, str, sizeof(ipaddr));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+ return copystr(netmask, str, sizeof(netmask));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+ return copystr(gateway, str, sizeof(gateway));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+ return copystr(dnsserver, str, sizeof(dnsserver));
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry initparsetab[] =
+ {{'n', loaddriver},
+ {'t', loadtheme},
+ {'c', loadcfs},
+ {'s', loadscreensaver},
+ {'i', ipaddrconf},
+ {'m', netmaskconf},
+ {'r', drconf},
+ {'d', dnsconf},
+ {'#', skipnewline},
+
+ /* Default action */
+ {0, skipnewline}};
+static void
+initscript(void)
+{
+ char line[40], *lineptr;
+ /* struct c64_fs_file f;*/
+ int f;
+
+ if((f = cfs_open("config.cfg", 0)) == -1) {
+ return;
+ }
+ line[0] = ' ';
+ while(line[0] != '.' &&
+ line[0] != 0) {
+ lineptr = line;
+ do {
+ if(cfs_read(f, lineptr, 1) != 1) {
+ cfs_close(f);
+ return;
+ }
+ ++lineptr;
+ } while(*(lineptr - 1) != '\n' &&
+ *(lineptr - 1) != '\r');
+
+ *lineptr = 0;
+
+ if(line[0] != '.' &&
+ line[0] != 0) {
+ parse(line, initparsetab);
+ }
+
+ }
+ cfs_close(f);
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+static int makeline(char *line, char c, char *str)
+{
+ int len;
+
+ len = strlen(str);
+
+ line[0] = c;
+ line[1] = ' ';
+ strcpy(&line[2], str);
+ line[2 + len] = '\n';
+ line[3 + len] = 0;
+ return len + 3;
+}
+
+#if 0
+struct scriptvar
+{
+ const char *var;
+ char chr;
+};
+
+cstatic struct scriptvar scriptvars[]=
+{
+{cfs,'c'},
+
+
+};
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+savescript(void)
+{
+ char line[40];
+ /* struct c64_fs_file f;*/
+ int f;
+
+ f = cfs_open("@:config.cfg", CFS_WRITE);
+ if(f == -1) {
+ log_message("Could not open config.cfg", "");
+ return;
+ }
+ if(cfs[0] != 0) {
+ int len = makeline(line, 'c',cfs);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'c', cfs));
+ }
+ if(theme[0] != 0) {
+ int len = makeline(line, 't',theme);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 't', theme));
+ }
+ if(driver[0] != 0) {
+ int len = makeline(line, 'n',driver);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'n', driver));
+ }
+ if(ipaddr[0] != 0) {
+ int len = makeline(line, 'i',ipaddr);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'i', ipaddr));
+ }
+ if(netmask[0] != 0) {
+ int len = makeline(line, 'm',netmask);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'm', netmask));
+ }
+ if(gateway[0] != 0) {
+ int len = makeline(line, 'r',gateway);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'r', gateway));
+ }
+ if(dnsserver[0] != 0) {
+ int len = makeline(line, 'd',dnsserver);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 'd', dnsserver));
+ }
+
+ if(screensaver[0] != 0) {
+ int len = makeline(line, 's',screensaver);
+ cfs_write(f, line, len);
+// cfs_write(f, line, makeline(line, 's', screensaver));
+ }
+
+ strcpy(line, ".\n\0\n\n\n");
+ cfs_write(f, line, strlen(line));
+
+ cfs_close(f);
+
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(configedit_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------------*/
+static void
+configedit_quit(void)
+{
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit_services(void)
+{
+ cfs_cpc_init(NULL);
+ ctk_draw_quit();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(configedit_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ /* Create window. */
+ ctk_window_new(&window, 32, 18, "Config editor");
+
+ CTK_WIDGET_ADD(&window, &cfslabel);
+ CTK_WIDGET_ADD(&window, &cfstextentry);
+ CTK_TEXTENTRY_CLEAR(&cfstextentry);
+
+ CTK_WIDGET_ADD(&window, &themelabel);
+ CTK_WIDGET_ADD(&window, &themetextentry);
+ CTK_TEXTENTRY_CLEAR(&themetextentry);
+
+ CTK_WIDGET_ADD(&window, &driverlabel);
+ CTK_WIDGET_ADD(&window, &drivertextentry);
+ CTK_TEXTENTRY_CLEAR(&drivertextentry);
+
+ CTK_WIDGET_ADD(&window, &screensaverlabel);
+ CTK_WIDGET_ADD(&window, &screensavertextentry);
+ CTK_TEXTENTRY_CLEAR(&screensavertextentry);
+
+ CTK_WIDGET_ADD(&window, &ipaddrlabel);
+ CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+ CTK_TEXTENTRY_CLEAR(&ipaddrtextentry);
+
+ CTK_WIDGET_ADD(&window, &netmasklabel);
+ CTK_WIDGET_ADD(&window, &netmasktextentry);
+ CTK_TEXTENTRY_CLEAR(&netmasktextentry);
+
+ CTK_WIDGET_ADD(&window, &gatewaylabel);
+ CTK_WIDGET_ADD(&window, &gatewaytextentry);
+ CTK_TEXTENTRY_CLEAR(&gatewaytextentry);
+
+ CTK_WIDGET_ADD(&window, &dnsserverlabel);
+ CTK_WIDGET_ADD(&window, &dnsservertextentry);
+ CTK_TEXTENTRY_CLEAR(&dnsservertextentry);
+
+
+ CTK_WIDGET_ADD(&window, &savebutton);
+ CTK_WIDGET_ADD(&window, &cancelbutton);
+
+ CTK_WIDGET_FOCUS(&window, &cfstextentry);
+
+ /* Fill the configuration strings with values from the current
+ configuration */
+ initscript();
+
+ ctk_window_open(&window);
+
+ } else if(ev == ctk_signal_button_activate) {
+ if(data == (ek_data_t)&savebutton) {
+ savescript();
+ quit_services();
+ ctk_window_close(&window);
+ configedit_quit();
+ program_handler_load("config.prg", NULL);
+ } else if(data == (ek_data_t)&cancelbutton) {
+ ctk_window_close(&window);
+ configedit_quit();
+ }
+ } else if(ev == ctk_signal_window_close ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ ctk_window_close(&window);
+ configedit_quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/default-dsc.c b/contiki-cpc/apps/default-dsc.c
new file mode 100644
index 0000000..96507ec
--- /dev/null
+++ b/contiki-cpc/apps/default-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: default-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon default_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(default_dsc,
+ "Default CTK theme",
+ "default.prg",
+ default_init,
+ &default_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char defaulticon_bitmap[3*3*8] = {
+ 0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0,
+ 0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00,
+ 0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00,
+ 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
+ 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,
+ 0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char defaulticon_textmap[9] = {
+ '+', '=', '+',
+ '|', 'D', '|',
+ '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon default_icon =
+ {CTK_ICON("Default", defaulticon_bitmap, defaulticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.c b/contiki-cpc/apps/directory-dsc.c
new file mode 100644
index 0000000..d4d1944
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon directory_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(directory_dsc,
+ "Directory reader",
+ "dir.prg",
+ directory_init,
+ &directory_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char directoryicon_bitmap[3*3*8] = {
+ 0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+ 0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+ 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+ 0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+ 0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+ 0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+ 0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char directoryicon_textmap[9] = {
+ '+', '-', '+',
+ '|', 'o', '|',
+ '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon directory_icon =
+ {CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.h b/contiki-cpc/apps/directory-dsc.h
new file mode 100644
index 0000000..da154fe
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+#ifndef __DIRECTORY_DSC_H__
+#define __DIRECTORY_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(directory_dsc);
+
+#endif /* __DIRECTORY_DSC_H__ */
diff --git a/contiki-cpc/apps/enabler-dsc.c b/contiki-cpc/apps/enabler-dsc.c
new file mode 100644
index 0000000..0051476
--- /dev/null
+++ b/contiki-cpc/apps/enabler-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: enabler-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon enabler_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(enabler_dsc,
+ "Colorless grayish CTK theme",
+ "enabler.prg",
+ enabler_init,
+ &enabler_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char enablericon_bitmap[3*3*8] = {
+ 0xff,0xff,0xff,0xfc,0xf0,0xf0,0xe0,0xe0,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0x3f,0x0f,0x0f,0x07,0x07,
+
+ 0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
+
+ 0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char enablericon_textmap[9] = {
+ '(', '=', ')',
+ '|', 'o', '|',
+ '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon enabler_icon =
+ {CTK_ICON("Enabler", enablericon_bitmap, enablericon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/http-user-agent-string b/contiki-cpc/apps/http-user-agent-string
new file mode 100644
index 0000000..1b3104c
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n"
diff --git a/contiki-cpc/apps/http-user-agent-string.c b/contiki-cpc/apps/http-user-agent-string.c
new file mode 100644
index 0000000..d4e1bc9
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+char http_user_agent_fields[100] =
+/* "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x31, 0x2d, 0x72, 0x63, 0x30, 0x20, 0x28, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x20, 0x36, 0x34, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki-cpc/apps/http-user-agent-string.h b/contiki-cpc/apps/http-user-agent-string.h
new file mode 100644
index 0000000..402af57
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+extern char http_user_agent_fields[100];
diff --git a/contiki-cpc/apps/httpd-cgi.c b/contiki-cpc/apps/httpd-cgi.c
new file mode 100644
index 0000000..53c04a8
--- /dev/null
+++ b/contiki-cpc/apps/httpd-cgi.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#ifdef __CBM__
+#include <cbm.h>
+#include <c64.h>
+#endif /* __CBM__ */
+
+#include <stdio.h>
+#include <string.h>
+
+static u8_t file_stats(void);
+static u8_t tcp_stats(void);
+static u8_t processes(void);
+
+static u8_t d64output(void);
+static u8_t diroutput(void);
+
+httpd_cgifunction httpd_cgitab[] = {
+ NULL,
+ tcp_stats, /* CGI function "b" */
+ processes, /* CGI function "c" */
+
+ d64output, /* CGI function "d" */
+};
+
+static const char closed[] = /* "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /* "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
+ 0x44, 0};
+static const char syn_sent[] = /* "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
+ 0x54, 0};
+static const char established[] = /* "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /* "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49,
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /* "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
+ 0x49, 0x54, 0};
+static const char last_ack[] = /* "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
+ 0x4b, 0};
+
+static const char *states[] = {
+ closed,
+ syn_rcvd,
+ syn_sent,
+ established,
+ fin_wait_1,
+ fin_wait_2,
+ closing,
+ time_wait,
+ last_ack};
+
+
+/*-----------------------------------------------------------------------------------*/
+#if 0
+static u8_t
+file_stats(void)
+{
+ /* We use sprintf() to print the number of file accesses to a
+ particular file (given as an argument to the function in the
+ script). We then use uip_send() to actually send the data. */
+ if(uip_acked()) {
+ return 1;
+ }
+ uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", httpd_fs_count(&hs->script[4])));
+ return 0;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+tcp_stats(void)
+{
+ register struct uip_conn *conn;
+
+ if(uip_acked()) {
+ /* If the previously sent data has been acknowledged, we move
+ forward one connection. */
+ if(++hs->count == UIP_CONNS) {
+ /* If all connections has been printed out, we are done and
+ return 1. */
+ return 1;
+ }
+ }
+
+ conn = &uip_conns[hs->count];
+ while((conn->tcpstateflags & TS_MASK) == CLOSED) {
+ if(++hs->count == UIP_CONNS) {
+ /* If all connections has been printed out, we are done and
+ return 1. */
+ return 1;
+ }
+ conn = &uip_conns[hs->count];
+ }
+
+ uip_send(uip_appdata, sprintf((char *)uip_appdata,
+ "<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+ htons(conn->lport),
+ htons(conn->ripaddr[0]) >> 8,
+ htons(conn->ripaddr[0]) & 0xff,
+ htons(conn->ripaddr[1]) >> 8,
+ htons(conn->ripaddr[1]) & 0xff,
+ htons(conn->rport),
+ states[conn->tcpstateflags & TS_MASK],
+ conn->nrtx,
+ conn->timer,
+ (uip_outstanding(conn))? '*':' ',
+ (uip_stopped(conn))? '!':' '));
+
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+processes(void)
+{
+ u8_t i;
+ register struct dispatcher_proc *p;
+ char name[40];
+
+ p = DISPATCHER_PROCS();
+ for(i = 0; i < hs->count; ++i) {
+ if(p != NULL) {
+ p = p->next;
+ }
+ }
+
+ if(uip_acked()) {
+ /* If the previously sent data has been acknowledged, we move
+ forward one connection. */
+ ++hs->count;
+ if(p != NULL) {
+ p = p->next;
+ }
+ if(p == NULL) {
+ /* If all processes have been printed out, we are done and
+ return 1. */
+ return 1;
+ }
+ }
+
+ strncpy(name, p->name, 40);
+ petsciiconv_toascii(name, 40);
+ uip_send(uip_appdata,
+ sprintf((char *)uip_appdata,
+ "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%04x</td><td>0x%04x</td><td>0x%04x</td></tr>\r\n",
+ p->id, name,
+ p->idle, p->signalhandler, p->uiphandler));
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+struct drv_state {
+ u8_t track;
+ u8_t sect;
+};
+
+static struct drv_state ds;
+
+
+#include "c64-dio.h"
+
+static void
+read_sector(void)
+{
+ c64_dio_read_block(ds.track, ds.sect, uip_appdata);
+}
+
+static u8_t
+next_sector(void)
+{
+ ++ds.sect;
+ if(ds.track < 18) {
+ if(ds.sect == 21) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 25) {
+ if(ds.sect == 19) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 31) {
+ if(ds.sect == 18) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 36) {
+ if(ds.sect == 17) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ }
+
+ if(ds.track == 36) {
+ return 1;
+ }
+ return 0;
+}
+
+static u8_t
+d64output(void)
+{
+ if(hs->count == 0) {
+ ds.track = 1;
+ ds.sect = 0;
+ /* c64_dio_init(8);*/
+ }
+
+ if(uip_acked()) {
+ ++hs->count;
+ if(next_sector()) {
+ return 1;
+ }
+ }
+
+ read_sector();
+ uip_send(uip_appdata, 256);
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd-fs.h b/contiki-cpc/apps/httpd-fs.h
new file mode 100644
index 0000000..d641ba2
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 0
+
+struct httpd_fs_file {
+ char *data;
+ int len;
+};
+
+/* file must be allocated by caller and will be filled in
+ by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki-cpc/apps/httpd-fsdata.c b/contiki-cpc/apps/httpd-fsdata.c
new file mode 100644
index 0000000..e0175d0
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fsdata.c
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ */
+static const char data_cgi_processes[] = {
+ /* /cgi/processes */
+ 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0,
+ 0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e,
+ 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31,
+ 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72,
+ 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68,
+ 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62,
+ 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
+ 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x74, 0x20, 0x3c,
+ 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c,
+ 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61,
+ 0x6d, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68,
+ 0x3e, 0x49, 0x64, 0x6c, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64,
+ 0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74,
+ 0x68, 0x3e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x68,
+ 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68,
+ 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x43, 0x50, 0x2f, 0x49,
+ 0x50, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c,
+ 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa,
+ 0x63, 0x20, 0x63, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61,
+ 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f,
+ 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e,
+ 0xa, 0x2e, };
+
+static const char data_cgi_tcp[] = {
+ /* /cgi/tcp */
+ 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
+ 0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e,
+ 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31,
+ 0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63,
+ 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
+ 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c,
+ 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74,
+ 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa,
+ 0x74, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e,
+ 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68,
+ 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x65,
+ 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52,
+ 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73,
+ 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
+ 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x3c, 0x2f,
+ 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 0x6c, 0x61,
+ 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74,
+ 0x72, 0x3e, 0xa, 0x63, 0x20, 0x62, 0xa, 0x74, 0x20, 0x3c,
+ 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20,
+ 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c,
+ 0x61, 0x69, 0x6e, 0xa, 0x2e, };
+
+static const char data_cgi_d64[] = {
+ /* /cgi/d64 */
+ 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0,
+ 0x69, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68,
+ 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69,
+ 0x6e, 0xa, 0x63, 0x20, 0x64, 0xa, 0x2e, 0xa, };
+
+static const char data_index_html[] = {
+ /* /index.html */
+ 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
+ 0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
+ 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74,
+ 0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e,
+ 0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69,
+ 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
+ 0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67,
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69,
+ 0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c,
+ 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31,
+ 0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65,
+ 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72,
+ 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20,
+ 0x73, 0x72, 0x63, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x3c, 0x2f,
+ 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x20, 0x61, 0x6c,
+ 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x63, 0x65, 0x6e, 0x74, 0x65,
+ 0x72, 0x22, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x57, 0x65, 0x6c,
+ 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20,
+ 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
+ 0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
+ 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67,
+ 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x77, 0x65, 0x62, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0x22,
+ 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72,
+ 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c,
+ 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x62, 0x3e, 0x3c, 0x63, 0x65,
+ 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 0x73, 0x65,
+ 0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73,
+ 0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65,
+ 0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x79, 0x6f, 0x75,
+ 0x72, 0x20, 0x43, 0x36, 0x34, 0x21, 0x3c, 0x2f, 0x63, 0x65,
+ 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x3e, 0xa,
+ 0x3c, 0x75, 0x6c, 0x3e, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61,
+ 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x38, 0x2f,
+ 0x22, 0x3e, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x64, 0x69, 0x72,
+ 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3c, 0x2f, 0x61, 0x3e,
+ 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c,
+ 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63,
+ 0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0x22, 0x3e, 0x44, 0x6f,
+ 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x65, 0x6e, 0x74,
+ 0x69, 0x72, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x20, 0x69,
+ 0x6e, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x44, 0x36, 0x34,
+ 0x20, 0x66, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x2e,
+ 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c,
+ 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63,
+ 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e, 0x43, 0x75,
+ 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77,
+ 0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c,
+ 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61,
+ 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67,
+ 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
+ 0x73, 0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20,
+ 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c,
+ 0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x2f,
+ 0x75, 0x6c, 0x3e, 0xa, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f,
+ 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65,
+ 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68,
+ 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a,
+ 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e,
+ 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63,
+ 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c,
+ 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
+ 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f,
+ 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e,
+ 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e,
+ 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x3c, 0x2f, 0x62, 0x6f,
+ 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
+};
+
+static const char data_404_html[] = {
+ /* /404.html */
+ 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
+ 0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
+ 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f,
+ 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65,
+ 0x22, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
+ 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64,
+ 0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20, 0x62,
+ 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e,
+ 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x68,
+ 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69,
+ 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75,
+ 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74,
+ 0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74,
+ 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e,
+ 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79,
+ 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_header_html[] = {
+ /* /header.html */
+ 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
+ 0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
+ 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74,
+ 0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e,
+ 0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69,
+ 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
+ 0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63,
+ 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74,
+ 0x65, 0x22, 0x3e, 0xa, };
+
+static const char data_footer_plain[] = {
+ /* /footer.plain */
+ 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+ 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b,
+ 0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65,
+ 0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d,
+ 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75,
+ 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
+ 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68,
+ 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b,
+ 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64,
+ 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69,
+ 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e,
+ 0x2e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f,
+ 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_webserver_png[] = {
+ /* /webserver.png */
+ 0x2f, 0x77, 0x65, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67,
+ 0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa,
+ 0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52,
+ 00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x1, 00,
+ 00, 00, 00, 0xc8, 0xc, 00, 0x55, 00, 00, 00,
+ 0x2, 0x62, 0x4b, 0x47, 0x44, 00, 0x1, 0xdd, 0x8a, 0x13,
+ 0xa4, 00, 00, 00, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x78,
+ 0xda, 0x1d, 0xc8, 0x21, 0xa, 0x80, 0x30, 00, 0x46, 0xe1,
+ 0xa7, 0xc7, 0x34, 0x78, 0x93, 0x89, 0xb, 0x1e, 0x43, 0x96,
+ 0x8c, 0x62, 0x14, 0x19, 0x6e, 0xc1, 0xe8, 0x19, 0x96, 0x97,
+ 0x8c, 0x6, 0xc3, 0xf8, 0x45, 0xc3, 0x83, 0x8f, 0x87, 0x24,
+ 0x7a, 0x2a, 0xe2, 0x54, 0x8, 0x32, 0x78, 0x25, 0x56, 0x5d,
+ 0xc4, 0xa3, 0xb0, 0x74, 0xf7, 0xff, 0x9c, 0x1e, 0x76, 0xed,
+ 0x8c, 0x79, 0xfb, 0xfb, 0xec, 0xf2, 0x43, 0xc8, 0x86, 0xa5,
+ 0xb9, 0x89, 0x67, 0x61, 0x3d, 0x2e, 0xfc, 0x9c, 0x8, 0x83,
+ 0x21, 0xda, 0x82, 0x6d, 0x2d, 0xaa, 0xf5, 0x2, 0x33, 0x91,
+ 0x35, 0x61, 0x3a, 0xe8, 0xa4, 0x34, 00, 00, 00, 00,
+ 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
+
+static const char data_contiki_png[] = {
+ /* /contiki.png */
+ 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67,
+ 0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa,
+ 0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52,
+ 00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x8, 0x2,
+ 00, 00, 00, 0x6f, 0x15, 0xaa, 0xaf, 00, 00, 00,
+ 0x9, 0x70, 0x48, 0x59, 0x73, 00, 00, 0x1c, 0x1f, 00,
+ 00, 0x1c, 0x1f, 0x1, 0x60, 0xfd, 0x4, 0xda, 00, 00,
+ 00, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xd3, 0x3, 0x9,
+ 0x16, 0x4, 0xd, 0x60, 0xa0, 0x97, 00, 00, 00, 00,
+ 0xad, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xad, 0x94, 0x41,
+ 0xe, 0xc5, 0x20, 0x8, 0x44, 0x9d, 0x1f, 0xee, 0x7f, 0xe5,
+ 0xf9, 0xb, 0x13, 0x6a, 0x1, 0x29, 0xa5, 0xb2, 0x53, 0xca,
+ 0xf0, 0x9c, 0x40, 0x41, 0x72, 0x1c, 0x89, 0x23, 0x42, 0x24,
+ 0xc5, 0xcb, 0x1, 0x48, 0x1a, 0xf8, 0xec, 0xbc, 0x91, 0xe4,
+ 0xa3, 0x79, 0x34, 0x9d, 0x67, 0xd6, 0xcb, 0x5d, 0x42, 0x3e,
+ 0x97, 0xbc, 0x9a, 0x24, 00, 00, 0xfa, 0x8d, 0x98, 0x74,
+ 0x8, 0x12, 0xa, 0x4d, 0xad, 0x8b, 0x43, 0xcf, 0x3d, 0xd7,
+ 0xb5, 0x36, 0xf0, 0xa8, 0x1e, 0x81, 0x47, 0xf3, 0xaa, 0x1,
+ 0xa5, 0xf, 0xb2, 0x66, 0x37, 0x84, 0x6e, 0x44, 0x3d, 0x9c,
+ 0x35, 0x3a, 0x44, 0x61, 0xcb, 0x26, 0x91, 0xef, 0xfa, 0x82,
+ 0x28, 0x9f, 0xb2, 0x77, 0x44, 0x49, 0xb3, 0xd2, 0x1c, 0x55,
+ 0x26, 0x5e, 0x54, 0x42, 0x17, 0xf2, 0x91, 0x25, 0xdc, 0x6a,
+ 0x49, 0xa, 0x4c, 0x99, 0x3f, 0xae, 0xeb, 0x26, 0xeb, 0xd5,
+ 0xe, 0xaa, 0x32, 0x19, 0xd6, 0x23, 0x6f, 0x47, 0x71, 0x2c,
+ 0x7e, 0xa6, 0x40, 0xb7, 0x59, 0x23, 0xa1, 0xdb, 0x7a, 0xb4,
+ 0xfb, 0xfb, 0x25, 0x5a, 0xb6, 0xf8, 0x63, 0x90, 0xc4, 0x11,
+ 0xa1, 0x31, 0xc6, 0x1f, 0x2c, 0x64, 0x9c, 0x21, 0xc5, 0x1a,
+ 0x66, 0x5d, 00, 00, 00, 00, 0x49, 0x45, 0x4e, 0x44,
+ 0xae, 0x42, 0x60, 0x82, };
+
+static const char data_binaryheader_plain[] = {
+ /* /binaryheader.plain */
+ 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73,
+ 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+
+static const char data_dirheader_html[] = {
+ /* /dirheader.html */
+ 0x2f, 0x64, 0x69, 0x72, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
+ 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31,
+ 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64,
+ 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
+ 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
+ 0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
+ 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74,
+ 0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e,
+ 0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73,
+ 0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69,
+ 0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
+ 0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67,
+ 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69,
+ 0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74,
+ 0x65, 0x72, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x46, 0x69, 0x6c,
+ 0x65, 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x64, 0x69, 0x73, 0x6b,
+ 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62,
+ 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
+ 0x31, 0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64,
+ 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0x3c, 0x74, 0x68,
+ 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e,
+ 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x28,
+ 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x29, 0x3c, 0x2f, 0x74,
+ 0x68, 0x3e, };
+
+static const char data_dirfooter_plain[] = {
+ /* /dirfooter.plain */
+ 0x2f, 0x64, 0x69, 0x72, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+ 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f,
+ 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65,
+ 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68,
+ 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c,
+ 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74,
+ 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65,
+ 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61,
+ 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f,
+ 0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70,
+ 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73,
+ 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f,
+ 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f,
+ 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x3c, 0x2f,
+ 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
+ 0x6c, 0x3e, };
+
+const struct httpd_fsdata_file file_cgi_processes[] = {{NULL, data_cgi_processes, data_cgi_processes + 15, sizeof(data_cgi_processes) - 15}};
+
+const struct httpd_fsdata_file file_cgi_tcp[] = {{file_cgi_processes, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
+
+const struct httpd_fsdata_file file_cgi_d64[] = {{file_cgi_tcp, data_cgi_d64, data_cgi_d64 + 9, sizeof(data_cgi_d64) - 9}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_cgi_d64, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_index_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_404_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_footer_plain[] = {{file_header_html, data_footer_plain, data_footer_plain + 14, sizeof(data_footer_plain) - 14}};
+
+const struct httpd_fsdata_file file_webserver_png[] = {{file_footer_plain, data_webserver_png, data_webserver_png + 15, sizeof(data_webserver_png) - 15}};
+
+const struct httpd_fsdata_file file_contiki_png[] = {{file_webserver_png, data_contiki_png, data_contiki_png + 13, sizeof(data_contiki_png) - 13}};
+
+const struct httpd_fsdata_file file_binaryheader_plain[] = {{file_contiki_png, data_binaryheader_plain, data_binaryheader_plain + 20, sizeof(data_binaryheader_plain) - 20}};
+
+const struct httpd_fsdata_file file_dirheader_html[] = {{file_binaryheader_plain, data_dirheader_html, data_dirheader_html + 16, sizeof(data_dirheader_html) - 16}};
+
+const struct httpd_fsdata_file file_dirfooter_plain[] = {{file_dirheader_html, data_dirfooter_plain, data_dirfooter_plain + 17, sizeof(data_dirfooter_plain) - 17}};
+
+#define HTTPD_FS_ROOT file_dirfooter_plain
+
+#define HTTPD_FS_NUMFILES 12
\ No newline at end of file
diff --git a/contiki-cpc/apps/httpd.c b/contiki-cpc/apps/httpd.c
new file mode 100644
index 0000000..9726200
--- /dev/null
+++ b/contiki-cpc/apps/httpd.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+
+#include "http-strings.h"
+
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+#include "httpd-cgi.h"
+
+#include "tcpip.h"
+
+#include <stdio.h>
+
+/* The HTTP server states: */
+#define STATE_DEALLOCATED 0
+#define STATE_INITIAL 1
+#define STATE_GET 2
+#define STATE_HEADERS 3
+#define STATE_SEND_HEADERS 4
+#define STATE_SEND_CONTENT_TYPE 5
+#define STATE_SEND_DATA 6
+
+#define ISO_nl 0x0a
+#define ISO_space 0x20
+#define ISO_slash 0x2f
+
+#ifdef DEBUG
+#include <stdio.h>
+#define PRINT(x) printf("%s", x)
+#define PRINTLN(x) printf("%s\n", x)
+#else /* DEBUG */
+#define PRINT(x)
+#define PRINTLN(x)
+#endif /* DEBUG */
+
+
+#define HTTPD_CONF_NUMCONNS 4
+static struct httpd_state conns[HTTPD_CONF_NUMCONNS];
+u8_t i;
+
+struct http_filetype {
+ const char *ext;
+ unsigned char extlen;
+ const char *type;
+ unsigned char typelen;
+};
+
+static struct http_filetype filetypes[] = {
+ {http_html, sizeof(http_html) - 1,
+ http_content_type_html, sizeof(http_content_type_html) - 1},
+ {http_htm, sizeof(http_htm) - 1,
+ http_content_type_html, sizeof(http_content_type_html) - 1},
+ {http_css, sizeof(http_css) - 1,
+ http_content_type_css, sizeof(http_content_type_css) - 1},
+ {http_png, sizeof(http_png) - 1,
+ http_content_type_png, sizeof(http_content_type_png) - 1},
+ {http_gif, sizeof(http_gif) - 1,
+ http_content_type_gif, sizeof(http_content_type_gif) - 1},
+ {http_jpg, sizeof(http_jpg) - 1,
+ http_content_type_jpg, sizeof(http_content_type_jpg) - 1},
+ {http_txt, sizeof(http_txt) - 1,
+ http_content_type_text, sizeof(http_content_type_text) - 1},
+ {http_text, sizeof(http_text) - 1,
+ http_content_type_text, sizeof(http_content_type_text) - 1},
+ {NULL, 0, NULL, 0}
+};
+#define NUMFILETYPES (sizeof(filetypes) / sizeof(struct http_filetype))
+/*-----------------------------------------------------------------------------*/
+static struct httpd_state *
+alloc_state(void)
+{
+
+ for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+ if(conns[i].state == STATE_DEALLOCATED) {
+ return &conns[i];
+ }
+ }
+
+ /* We are overloaded! XXX: we'll just kick all other connections! */
+ for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+ conns[i].state = STATE_DEALLOCATED;
+ }
+
+ return NULL;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+dealloc_state(struct httpd_state *s)
+{
+ s->state = STATE_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+ httpd_fs_init();
+
+ /* Listen to port 80. */
+ tcp_listen(HTONS(80));
+
+ for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+ conns[i].state = STATE_DEALLOCATED;
+ }
+}
+/*-----------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Buffer an amount of data from the incoming uIP data.
+ *
+ * \param buf A pointer to the buffer.
+ * \param len The length of data to buffer.
+ *
+ * \return Zero if the function wasn't able to buffer to buffer all
+ * data, non-zero otherwise.
+ */
+/*-----------------------------------------------------------------------------*/
+static unsigned char
+buffer(CC_REGISTER_ARG struct httpd_buffer *buf, int len, u8_t c)
+{
+ while(buf->ptr < len &&
+ uip_len > 0) {
+ buf->buf[buf->ptr] = *uip_appdata;
+ ++uip_appdata;
+ --uip_len;
+
+ if(buf->buf[buf->ptr] == c) {
+ return 1;
+ }
+ ++buf->ptr;
+ }
+ return (buf->ptr == len);
+}
+/*-----------------------------------------------------------------------------*/
+static void
+buffer_reset(struct httpd_buffer *buf)
+{
+ buf->ptr = 0;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+newdata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+ int i;
+ struct http_filetype *filetype;
+
+ while(uip_len > 0) {
+ switch(hs->state) {
+
+ case STATE_INITIAL:
+ /* This is the first data that we receive, so we check if we can
+ identify the "GET" request. We call the buffer() function to
+ try to buffer 4 bytes of data from the incoming data stream. If
+ the function isn't able to buffer enough data, we return and
+ will try again next time around. */
+ hs->buf.buf = hs->getbuffer;
+ if(buffer(&(hs->buf), 4, ISO_space)) {
+ if(strncmp(http_get, hs->buf.buf, 4) == 0) {
+ hs->state = STATE_GET;
+ buffer_reset(&(hs->buf));
+ } else {
+ uip_abort();
+ return;
+ }
+ }
+ break;
+
+ case STATE_GET:
+ /* We will read one byte at a time from the GET request until we
+ find a en end of the line (\n\r). The GET request is remembered
+ in the httpd state since we might need to look at it later. */
+ hs->buf.buf = hs->getbuffer;
+ if(buffer(&(hs->buf), sizeof(hs->getbuffer), ISO_nl)) {
+ hs->state = STATE_HEADERS;
+ hs->getlen = hs->buf.ptr - 1;
+ /* Null-terminate GET request string. */
+ hs->getbuffer[hs->getlen] = 0;
+
+ /* If there is a space character in the get request, we find
+ it and null terminate the string there. */
+ for(i = 0; i < hs->getlen; ++i) {
+ if(hs->getbuffer[i] == ISO_space) {
+ hs->getbuffer[i] = 0;
+ hs->getlen = i;
+ break;
+ }
+ }
+ buffer_reset(&(hs->buf));
+ }
+ break;
+
+ case STATE_HEADERS:
+ hs->buf.buf = hs->hdrbuffer;
+ if(buffer(&(hs->buf), sizeof(hs->hdrbuffer), '\n')) {
+ if(hs->buf.ptr == 1) {
+ hs->state = STATE_SEND_HEADERS;
+ if(httpd_fs_open(hs->getbuffer, &hs->file)) {
+ hs->count = sizeof(http_header_200) - 1;
+ hs->dataptr = (char *)http_header_200;
+ hs->contenttype = http_content_type_binary;
+ hs->contentlen = sizeof(http_content_type_binary) - 1;
+ for(filetype = filetypes;
+ filetype->ext != NULL;
+ ++filetype) {
+ if(strncmp(filetype->ext,
+ hs->getbuffer + (hs->getlen - filetype->extlen),
+ filetype->extlen) == 0) {
+ hs->contenttype = filetype->type;
+ hs->contentlen = filetype->typelen;
+ break;
+ }
+ }
+
+ } else if(hs->getbuffer[0] == ISO_slash &&
+ hs->getbuffer[1] == 0) {
+ hs->count = sizeof(http_header_200) - 1;
+ hs->dataptr = (char *)http_header_200;
+ hs->contenttype = http_content_type_html;
+ hs->contentlen = sizeof(http_content_type_html) - 1;
+ httpd_fs_open(http_index_html, &hs->file);
+ } else {
+ hs->count = sizeof(http_header_404) - 1;
+ hs->dataptr = (char *)http_header_404;
+ hs->contenttype = http_content_type_html;
+ hs->contentlen = sizeof(http_content_type_html) - 1;
+ httpd_fs_open(http_404_html, &hs->file);
+ }
+ } else {
+ buffer_reset(&(hs->buf));
+ }
+ }
+ break;
+
+ default:
+ uip_len = 0;
+ break;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+acked(CC_REGISTER_ARG struct httpd_state *hs)
+{
+ hs->poll = 0;
+
+
+ switch(hs->state) {
+
+ case STATE_SEND_HEADERS:
+ if(hs->count >= uip_mss()) {
+ hs->count -= uip_mss();
+ hs->dataptr += uip_mss();
+ } else {
+ hs->count = 0;
+ }
+ if(hs->count == 0) {
+ hs->state = STATE_SEND_CONTENT_TYPE;
+ hs->count = hs->contentlen;
+ hs->dataptr = (char *)hs->contenttype;
+ }
+ break;
+
+ case STATE_SEND_CONTENT_TYPE:
+ if(hs->count >= uip_mss()) {
+ hs->count -= uip_mss();
+ hs->dataptr += uip_mss();
+ } else {
+ hs->count = 0;
+ }
+ if(hs->count == 0) {
+ hs->state = STATE_SEND_DATA;
+ hs->count = hs->file.len;
+ hs->dataptr = hs->file.data;
+ }
+ break;
+
+ case STATE_SEND_DATA:
+ if(hs->count >= uip_mss()) {
+ hs->count -= uip_mss();
+ hs->dataptr += uip_mss();
+ } else {
+ hs->count = 0;
+ }
+ if(hs->count == 0) {
+ uip_close();
+ dealloc_state(hs);
+ }
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+senddata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+ if(hs->state == STATE_SEND_HEADERS ||
+ hs->state == STATE_SEND_CONTENT_TYPE ||
+ hs->state == STATE_SEND_DATA) {
+ uip_send(hs->dataptr,
+ hs->count > uip_mss()? uip_mss(): hs->count);
+ }
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+ register struct httpd_state *hs;
+
+ hs = (struct httpd_state *)(state);
+
+
+ if(uip_connected()) {
+ /* Since we've just been connected, the state pointer should be
+ NULL and we need to allocate a new state object. If we have run
+ out of memory for state objects, we'll have to abort the
+ connection and return. */
+ if(hs == NULL) {
+ hs = alloc_state();
+ if(hs == NULL) {
+ uip_close();
+ return;
+ }
+ tcp_markconn(uip_conn, (void *)hs);
+ }
+ /* Since we have just been connected with the remote host, we
+ reset the state for this connection. The ->count variable
+ contains the amount of data that is yet to be sent to the
+ remote host, and the ->state is set to HTTP_NOGET to signal
+ that we haven't received any HTTP GET request for this
+ connection yet. */
+ hs->state = STATE_INITIAL;
+ hs->count = 0;
+ hs->poll = 0;
+ buffer_reset(&(hs->buf));
+ return;
+ }
+
+ if(uip_closed() ||
+ uip_aborted() ||
+ uip_timedout()) {
+ if(hs != NULL) {
+ dealloc_state(hs);
+ }
+ return;
+ } else if(uip_poll()) {
+ /* If we are polled ten times, we abort the connection. This is
+ because we don't want connections lingering indefinately in
+ the system. */
+ if(hs != NULL) {
+ if(hs->state == STATE_DEALLOCATED) {
+ uip_abort();
+ } else if(hs->poll++ >= 100) {
+ uip_abort();
+ dealloc_state(hs);
+ }
+ }
+ return;
+ }
+
+ if(uip_acked()) {
+ acked(hs);
+ }
+
+ if(uip_newdata()) {
+ newdata(hs);
+ }
+
+ if(uip_rexmit() ||
+ uip_newdata() ||
+ uip_acked()) {
+ senddata(hs);
+ } else if(uip_poll()) {
+ senddata(hs);
+ }
+
+
+}
+/*-----------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd.h b/contiki-cpc/apps/httpd.h
new file mode 100644
index 0000000..08abced
--- /dev/null
+++ b/contiki-cpc/apps/httpd.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "ek.h"
+
+#include "httpd-fs.h"
+
+void httpd_init(void);
+/*DISPATCHER_UIPCALL(httpd_appcall, state);*/
+void httpd_appcall(void *state);
+
+struct httpd_buffer {
+ u8_t *buf;
+ int ptr;
+};
+
+struct httpd_state {
+ u8_t state;
+ u16_t count;
+ u8_t poll;
+ char *dataptr;
+ struct httpd_fs_file file;
+
+ const char *contenttype;
+ int contentlen;
+
+ char *script;
+
+ struct httpd_buffer buf;
+
+ int getlen;
+ u8_t getbuffer[100];
+ u8_t hdrbuffer[100];
+
+ /*
+ union {
+ struct c64_fs_dir d;
+ struct c64_fs_file f;
+ } f;*/
+};
+
+extern struct httpd_state *hs;
+
+void webserver_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff --git a/contiki-cpc/apps/makefsdata b/contiki-cpc/apps/makefsdata
new file mode 100644
index 0000000..83bbc5b
--- /dev/null
+++ b/contiki-cpc/apps/makefsdata
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+open(FILES, "find . -type f |");
+
+
+while($file = <FILES>) {
+
+ # Do not include files in CVS directories nor backup files.
+ if($file =~ /(CVS|~)/) {
+ next;
+ }
+
+ chop($file);
+
+ open(HEADER, "> /tmp/header") || die $!;
+ print(HEADER "HTTP/1.0 200 OK\r\n");
+ print(HEADER "Server: Contiki/pre-1.1 (http://dunkels.com/adam/contiki/)\r\n");
+ if($file =~ /\.html$/) {
+ print(HEADER "Content-type: text/html\r\n");
+ } elsif($file =~ /\.gif$/) {
+ print(HEADER "Content-type: image/gif\r\n");
+ } elsif($file =~ /\.png$/) {
+ print(HEADER "Content-type: image/png\r\n");
+ } elsif($file =~ /\.jpg$/) {
+ print(HEADER "Content-type: image/jpeg\r\n");
+ } elsif($file =~ /\.css$/) {
+ print(HEADER "Content-type: text/css\r\n");
+ } else {
+ print(HEADER "Content-type: text/plain\r\n");
+ }
+ print(HEADER "\r\n");
+ close(HEADER);
+
+ unless($file =~ /\.plain$/ || $file =~ /cgi/) {
+ system("cat /tmp/header $file > /tmp/file");
+ } else {
+ system("cp $file /tmp/file");
+ }
+
+ open(FILE, "/tmp/file");
+ unlink("/tmp/file");
+ unlink("/tmp/header");
+
+ $file =~ s/\.//;
+ $fvar = $file;
+ $fvar =~ s-/-_-g;
+ $fvar =~ s-\.-_-g;
+ print(OUTPUT "static const char data".$fvar."[] = {\n");
+ print(OUTPUT "\t/* $file */\n\t");
+ for($j = 0; $j < length($file); $j++) {
+ printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+ }
+ printf(OUTPUT "0,\n");
+
+
+ $i = 0;
+ while(read(FILE, $data, 1)) {
+ if($i == 0) {
+ print(OUTPUT "\t");
+ }
+ printf(OUTPUT "%#02x, ", unpack("C", $data));
+ $i++;
+ if($i == 10) {
+ print(OUTPUT "\n");
+ $i = 0;
+ }
+ }
+ print(OUTPUT "};\n\n");
+ close(FILE);
+ push(@fvars, $fvar);
+ push(@files, $file);
+}
+
+for($i = 0; $i < @fvars; $i++) {
+ $file = $files[$i];
+ $fvar = $fvars[$i];
+
+ if($i == 0) {
+ $prevfile = "NULL";
+ } else {
+ $prevfile = "file" . $fvars[$i - 1];
+ }
+ print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+ print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+ print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i");
diff --git a/contiki-cpc/apps/makestrings b/contiki-cpc/apps/makestrings
new file mode 100644
index 0000000..e6e8470
--- /dev/null
+++ b/contiki-cpc/apps/makestrings
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+ my $name = shift(@_);
+ open(OUTPUTC, "> $name.c");
+ open(OUTPUTH, "> $name.h");
+
+ open(FILE, "$name");
+
+ while(<FILE>) {
+ if(/(.+) "(.+)"/) {
+ $var = $1;
+ $data = $2;
+
+ $datan = $data;
+ $datan =~ s/\\r/\r/g;
+ $datan =~ s/\\n/\n/g;
+ $datan =~ s/\\0/\0/g;
+
+ printf(OUTPUTC "char $var\[%d] = \n", length($datan) + 1);
+ printf(OUTPUTC "/* \"$data\" */\n");
+ printf(OUTPUTC "{");
+ for($j = 0; $j < length($datan); $j++) {
+ printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+ }
+ printf(OUTPUTC "};\n");
+
+ printf(OUTPUTH "extern char $var\[%d];\n", length($datan) + 1);
+
+ }
+ }
+ close(OUTPUTC);
+ close(OUTPUTH);
+}
+stringify("http-user-agent-string");
+
+exit 0;
+
diff --git a/contiki-cpc/apps/memstat-dsc.c b/contiki-cpc/apps/memstat-dsc.c
new file mode 100644
index 0000000..be3e3bf
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon memstat_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(memstat_dsc,
+ "Memory statistics",
+ "memstat.prg",
+ memstat_init,
+ &memstat_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char memstaticon_bitmap[3*3*8] = {
+ 0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+ 0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+ 0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+ 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+ 0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+ 0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+ 0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+ 0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char memstaticon_textmap[9] = {
+ '0', '0', '1',
+ '0', '1', '0',
+ '1', '0', '1'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon memstat_icon =
+ {CTK_ICON("Memory stats", memstaticon_bitmap, memstaticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/memstat-dsc.h b/contiki-cpc/apps/memstat-dsc.h
new file mode 100644
index 0000000..356c6cc
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.h,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+#ifndef __MEMSTAT_DSC_H__
+#define __MEMSTAT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(memstat_dsc);
+
+#endif /* __MEMSTAT_DSC_H__ */
diff --git a/contiki-cpc/apps/memstat.c b/contiki-cpc/apps/memstat.c
new file mode 100644
index 0000000..0b8f8b0
--- /dev/null
+++ b/contiki-cpc/apps/memstat.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ek.h"
+#include "loader.h"
+
+static struct ctk_window window;
+static struct ctk_label freemsg =
+ {CTK_LABEL(2, 0, 12, 1, "Free memory:")};
+static char freemem[6];
+static struct ctk_label freenum =
+ {CTK_LABEL(18, 0, 5, 1, freemem)};
+
+static struct ctk_label lblockmsg =
+ {CTK_LABEL(2, 2, 14, 1, "Largest block:")};
+static char lblock[6];
+static struct ctk_label lblocknum =
+ {CTK_LABEL(18, 2, 5, 1, lblock)};
+
+const static struct ctk_button updatebutton =
+ {CTK_BUTTON(0, 4, 6, "Update")};
+const static struct ctk_button closebutton =
+ {CTK_BUTTON(17, 4, 5, "Close")};
+
+/*static DISPATCHER_SIGHANDLER(memstat_sighandler, s, data);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Memory statistics", NULL, memstat_sighandler, NULL)};
+ static ek_id_t id;*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data);
+EK_PROCESS(p, "Memory statistics", EK_PRIO_NORMAL,
+ memstat_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+update(void)
+{
+ int mem;
+
+ mem = _heapmemavail();
+ freemem[0] = (mem/10000) % 10 + '0';
+ freemem[1] = (mem/1000) % 10 + '0';
+ freemem[2] = (mem/100) % 10 + '0';
+ freemem[3] = (mem/10) % 10 + '0';
+ freemem[4] = (mem) % 10 + '0';
+
+ mem = _heapmaxavail();
+ lblock[0] = (mem/10000) % 10 + '0';
+ lblock[1] = (mem/1000) % 10 + '0';
+ lblock[2] = (mem/100) % 10 + '0';
+ lblock[3] = (mem/10) % 10 + '0';
+ lblock[4] = (mem) % 10 + '0';
+
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(memstat_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+
+ } else {
+ ctk_window_open(&window);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_window_new(&window, 24, 5, "Memory stats");
+ /* ctk_window_move(&window, 0, 1);*/
+
+ CTK_WIDGET_ADD(&window, &freemsg);
+ CTK_WIDGET_ADD(&window, &freenum);
+
+ CTK_WIDGET_ADD(&window, &lblockmsg);
+ CTK_WIDGET_ADD(&window, &lblocknum);
+
+ CTK_WIDGET_ADD(&window, &updatebutton);
+ CTK_WIDGET_ADD(&window, &closebutton);
+
+ CTK_WIDGET_FOCUS(&window, &updatebutton);
+
+ update();
+
+ ctk_window_open(&window);
+
+ } else if(ev == ctk_signal_button_activate) {
+ if(data == (ek_data_t)&updatebutton) {
+ update();
+ ctk_window_redraw(&window);
+ } else if(data == (ek_data_t)&closebutton) {
+ ctk_window_close(&window);
+ quit();
+ }
+ } else if((ev == ctk_signal_window_close &&
+ data == (ek_data_t)&window) ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/mtest.c b/contiki-cpc/apps/mtest.c
new file mode 100644
index 0000000..173092c
--- /dev/null
+++ b/contiki-cpc/apps/mtest.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtest.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ */
+#include "mt.h"
+
+MTP(t, p, "Test thread");
+/*--------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+test(void *data)
+{
+ while(1) {
+ asm("inc $d020");
+ }
+}
+#pragma optimize(pop)
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(mtest_init, arg)
+{
+ arg_free(arg);
+ mtp_start(&t, test, NULL);
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma-dsc.c b/contiki-cpc/apps/plasma-dsc.c
new file mode 100644
index 0000000..945215b
--- /dev/null
+++ b/contiki-cpc/apps/plasma-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+ "Screensaver with a plasma",
+ "plasma.sav",
+ plasma_init,
+ &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+ '.', ' ', '.',
+ 'o', ' ', 'o',
+ 'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon plasma_icon =
+ {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma.c b/contiki-cpc/apps/plasma.c
new file mode 100644
index 0000000..d4bc8f6
--- /dev/null
+++ b/contiki-cpc/apps/plasma.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+ 128, 131, 134, 137, 140, 143, 146, 149,
+ 152, 156, 159, 162, 165, 168, 171, 174,
+ 176, 179, 182, 185, 188, 191, 193, 196,
+ 199, 201, 204, 206, 209, 211, 213, 216,
+ 218, 220, 222, 224, 226, 228, 230, 232,
+ 234, 236, 237, 239, 240, 242, 243, 245,
+ 246, 247, 248, 249, 250, 251, 252, 252,
+ 253, 254, 254, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 254, 254,
+ 253, 252, 252, 251, 250, 249, 248, 247,
+ 246, 245, 243, 242, 240, 239, 237, 236,
+ 234, 232, 230, 228, 226, 224, 222, 220,
+ 218, 216, 213, 211, 209, 206, 204, 201,
+ 199, 196, 193, 191, 188, 185, 182, 179,
+ 176, 174, 171, 168, 165, 162, 159, 156,
+ 152, 149, 146, 143, 140, 137, 134, 131,
+ 128, 124, 121, 118, 115, 112, 109, 106,
+ 103, 99, 96, 93, 90, 87, 84, 81,
+ 79, 76, 73, 70, 67, 64, 62, 59,
+ 56, 54, 51, 49, 46, 44, 42, 39,
+ 37, 35, 33, 31, 29, 27, 25, 23,
+ 21, 19, 18, 16, 15, 13, 12, 10,
+ 9, 8, 7, 6, 5, 4, 3, 3,
+ 2, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 1, 1,
+ 2, 3, 3, 4, 5, 6, 7, 8,
+ 9, 10, 12, 13, 15, 16, 18, 19,
+ 21, 23, 25, 27, 29, 31, 33, 35,
+ 37, 39, 42, 44, 46, 49, 51, 54,
+ 56, 59, 62, 64, 67, 70, 73, 76,
+ 78, 81, 84, 87, 90, 93, 96, 99,
+ 103, 106, 109, 112, 115, 118, 121, 124,
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+ {
+ 0x00, 0x06, 0x0b, 0x04,
+ 0x0a, 0x0f, 0x07, 0x01,
+ 0x07, 0x0f, 0x0a, 0x08,
+ 0x02, 0x09, 0x00, 0x00,
+ };
+
+#define XSIZE 24
+#define YSIZE 25
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd01 = 0xfe;
+static unsigned char yadd01 = 0x05;
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char xadd1 = 0x04;
+static unsigned char yadd1 = 0x02;
+static unsigned char xadd2 = 0xfc;
+static unsigned char yadd2 = 0xf9;
+
+static unsigned char xadd = 0x03;
+static unsigned char yadd = 0xfe;
+
+static unsigned char movcnt;
+static unsigned char movadd = 0xfb;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Plasma screensaver", idle,
+ sighandler,
+ NULL)};
+ static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+ eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+ unsigned char *ptr, *cptr;
+ static int i;
+
+ /* Make sine tables */
+ for(i = 0; i < 256; ++i) {
+ sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+ sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;
+ }
+
+ /* Make color table */
+ for(i = 0; i < 256; ++i) {
+ colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+ }
+
+
+ /* Fill screen with inverted spaces. */
+ cptr = COLOR_RAM;
+ for(ptr = (unsigned char *)0x0400;
+ ptr != (unsigned char *)0x07e8;
+ ++ptr) {
+ *ptr = 0xa0;
+ *cptr++ = 0x00;
+ }
+
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ VIC.bordercolor = 0x00; /* $D020 */
+ VIC.bgcolor0 = 0x00; /* $D021 */
+ CIA2.pra = 0x03; /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+ static unsigned char i, x, y;
+ register unsigned char *cptr;
+
+ if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+
+ xcnt1 = xcnt01;
+ xcnt2 = xcnt02;
+
+ for(i = 0; i < XSIZE; ++i) {
+ xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+ xcnt1 += xadd1;
+ xcnt2 += xadd2;
+ }
+
+ ycnt1 = ycnt01;
+ ycnt2 = ycnt02;
+
+ for(i = 0; i < YSIZE; ++i) {
+ yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+ ycnt1 += yadd1;
+ ycnt2 += yadd2;
+ }
+
+ xcnt01 += xadd01;
+ xcnt02 += xadd02;
+ ycnt01 += yadd01;
+ ycnt02 += yadd02;
+
+
+ yadd02 = sinetab3[ycnt] / 4;
+ xadd02 = sinetab3[xcnt] / 4;
+
+ ycnt += yadd;
+ xcnt += xadd;
+
+ movcnt += movadd;
+ cptr = (unsigned char *)(0xd800 + sinetab1[movcnt]/16);
+ for(y = 0; y < YSIZE; ++y) {
+ for(x = 0; x < XSIZE; ++x) {
+ *cptr = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+ ++cptr;
+ }
+ cptr += 40 - XSIZE;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+ DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_mode_set(CTK_MODE_SCREENSAVER);
+ ctk_mouse_hide();
+
+ scrninit();
+
+ } else if(ev == ctk_signal_screensaver_stop ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+ /* ctk_mode_set(CTK_MODE_NORMAL);*/
+ quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/apps/ravenpine-dsc.c b/contiki-cpc/apps/ravenpine-dsc.c
new file mode 100644
index 0000000..cd2cea8
--- /dev/null
+++ b/contiki-cpc/apps/ravenpine-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ravenpine-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ravenpine_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ravenpine_dsc,
+ "Terminal green CTK theme",
+ "ravenpine.prg",
+ ravenpine_init,
+ &ravenpine_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ravenpineicon_bitmap[3*3*8] = {
+ 0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+ 0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+ 0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+ 0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+ 0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ravenpineicon_textmap[9] = {
+ '(', '=', ')',
+ '|', 'o', '|',
+ '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ravenpine_icon =
+ {CTK_ICON("Ravenpine", ravenpineicon_bitmap, ravenpineicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/shell.c b/contiki-cpc/apps/shell.c
new file mode 100644
index 0000000..1575708
--- /dev/null
+++ b/contiki-cpc/apps/shell.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include <string.h>
+
+static char showingdir = 0;
+static struct cfs_dir dir;
+static unsigned int totsize;
+
+struct ptentry {
+ char c;
+ void (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+parse(CC_REGISTER_ARG char *str, struct ptentry *t)
+{
+ CC_REGISTER_ARG struct ptentry *p;
+ char *sstr;
+
+ sstr = str;
+
+ /* Loop over the parse table entries in t in order to find one that
+ matches the first character in str. */
+ for(p = t; p->c != 0; ++p) {
+ if(*str == p->c) {
+ /* Skip rest of the characters up to the first space. */
+ while(*str != ' ') {
+ ++str;
+ }
+
+ /* Skip all spaces.*/
+ while(*str == ' ') {
+ ++str;
+ }
+
+ /* Call parse table entry function and return. */
+ p->pfunc(str);
+ return;
+ }
+ }
+
+ /* Did not find matching entry in parse table. We just call the
+ default handler supplied by the caller and return. */
+ p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+inttostr(CC_REGISTER_ARG char *str, unsigned int i)
+{
+ str[0] = '0' + i / 100;
+ if(str[0] == '0') {
+ str[0] = ' ';
+ }
+ str[1] = '0' + (i / 10) % 10;
+ if(str[0] == ' ' && str[1] == '0') {
+ str[1] = ' ';
+ }
+ str[2] = '0' + i % 10;
+ str[3] = ' ';
+ str[4] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes(char *str)
+{
+ static char idstr[5];
+ struct ek_proc *p;
+
+ shell_output("Processes:", "");
+ /* Step through each possible process ID and see if there is a
+ matching process. */
+ for(p = EK_PROCS(); p != NULL; p = p->next) {
+ inttostr(idstr, p->id);
+ shell_output(idstr, (char *)p->name);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+ char *nt;
+
+ /* Nullterminate string. Start with finding newline character. */
+ for(nt = str; *nt != '\r' &&
+ *nt != '\n'; ++nt);
+
+ /* Replace newline with a null char. */
+ *nt = 0;
+
+ /* Remove trailing spaces. */
+ while(nt > str && *(nt - 1) == ' ') {
+ *(nt - 1) = 0;
+ --nt;
+ }
+
+ /* Return pointer to null char. */
+ return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+runfile(char *str)
+{
+ nullterminate(str);
+
+ if(strlen(str) > 0) {
+ /* Call loader function. */
+ program_handler_load(str, NULL);
+ shell_output("Starting program ", str);
+ } else {
+ shell_output("Must supply a program name", "");
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+execfile(char *str)
+{
+ runfile(str);
+ shell_quit(NULL);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(char *str)
+{
+ char procnum, j, c;
+ char procstr[5];
+
+ nullterminate(str);
+
+ procnum = 0;
+
+ for(j = 0; j < 4; ++j) {
+ c = str[j];
+ if(c >= '0' && c <= '9') {
+ procnum = procnum * 10 + (str[j] - '0');
+ } else {
+ break;
+ }
+ }
+ if(procnum != 0) {
+ inttostr(procstr, procnum);
+ shell_output("Killing process ", procstr);
+ ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+ } else {
+ shell_output("Invalid process number", "");
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+ shell_output("Available commands:", "");
+ shell_output("run - start program", "");
+ shell_output("exec - start program & exit shell", "");
+ shell_output("ps - show processes", "");
+ shell_output("kill - kill process", "");
+ shell_output("ls - display directory", "");
+ shell_output("quit - quit shell", "");
+ shell_output("? - show this help", "");
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+directory(char *str)
+{
+ if(cfs_opendir(&dir, "/") != 0) {
+ shell_output("Cannot open directory", "");
+ showingdir = 0;
+ } else {
+ shell_output("Disk directory:", "");
+ showingdir = 1;
+ totsize = 0;
+ ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+none(char *str)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+ {{'e', execfile},
+ {'r', runfile},
+ {'k', killproc},
+ {'p', processes},
+ {'l', directory},
+ {'q', shell_quit},
+ {'?', help},
+
+ /* Default action */
+ {0, none}};
+/*-----------------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+ showingdir = 0;
+ shell_output("Contiki command shell", "");
+ shell_output("Type '?' and return for help", "");
+ shell_prompt("contiki-c64> ");
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+ if(showingdir != 0) {
+ showingdir = 0;
+ shell_output("Directory stopped", "");
+ cfs_closedir(&dir);
+ }
+ parse(cmd, configparsetab);
+ if(showingdir == 0) {
+ shell_prompt("contiki-c64> ");
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_eventhandler(ek_event_t ev, ek_data_t data)
+{
+ static struct cfs_dirent dirent;
+ static char size[10];
+
+ if(ev == EK_EVENT_CONTINUE) {
+ if(showingdir != 0) {
+ if(cfs_readdir(&dir, &dirent) != 0) {
+ cfs_closedir(&dir);
+ showingdir = 0;
+ inttostr(size, totsize);
+ shell_output("Total number of blocks: ", size);
+ shell_prompt("contiki-c64> ");
+ } else {
+ totsize += dirent.size;
+ inttostr(size, dirent.size);
+ shell_output(size, dirent.name);
+ ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+ }
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/springlight-dsc.c b/contiki-cpc/apps/springlight-dsc.c
new file mode 100644
index 0000000..d9fed23
--- /dev/null
+++ b/contiki-cpc/apps/springlight-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: springlight-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon springlight_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(springlight_dsc,
+ "Spring green CTK theme",
+ "springlight.prg",
+ springlight_init,
+ &springlight_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char springlighticon_bitmap[3*3*8] = {
+ 0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+ 0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+ 0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+ 0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+ 0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char springlighticon_textmap[9] = {
+ '(', '=', ')',
+ '|', 'o', '|',
+ '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon springlight_icon =
+ {CTK_ICON("Springlight", springlighticon_bitmap, springlighticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire-dsc.c b/contiki-cpc/apps/ssfire-dsc.c
new file mode 100644
index 0000000..51a3578
--- /dev/null
+++ b/contiki-cpc/apps/ssfire-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+ "Screensaver with two fires",
+ "ssfire.sav",
+ ssfire_init,
+ &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+ '.', ' ', '.',
+ 'o', ' ', 'o',
+ 'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ssfire_icon =
+ {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire.c b/contiki-cpc/apps/ssfire.c
new file mode 100644
index 0000000..ed03af2
--- /dev/null
+++ b/contiki-cpc/apps/ssfire.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+ ssfire_sighandler,
+ NULL)};
+ static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+ ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+
+static const unsigned char flamecolors[16] =
+ {COLOR_BLACK, COLOR_BLACK, COLOR_BLACK,
+ COLOR_RED, COLOR_LIGHTRED, COLOR_YELLOW, COLOR_WHITE,
+ COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE,
+ COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE,
+ COLOR_WHITE};
+
+
+static void fire_init(void);
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+ unsigned char *ptr, *cptr;
+
+ /* Fill screen with inverted spaces. */
+ cptr = COLOR_RAM;
+ for(ptr = (unsigned char *)0x0400;
+ ptr != (unsigned char *)0x07e8;
+ ++ptr) {
+ *ptr = 0xa0;
+ *cptr++ = 0x00;
+ }
+
+ SID.v3.freq = 0xffff;
+ SID.v3.ctrl = 0x80;
+ SID.amp = 0;
+
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ VIC.bordercolor = 0x00; /* $D020 */
+ VIC.bgcolor0 = 0x00; /* $D021 */
+ CIA2.pra = 0x03; /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_mode_set(CTK_MODE_SCREENSAVER);
+ ctk_mouse_hide();
+ fire_init();
+ } else if(ev == ctk_signal_screensaver_stop ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ fire_quit();
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *flameptr, *colorptr1, *colorptr2;
+static unsigned char x, y;
+
+#pragma optimize(push, off)
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+
+ if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+ /* Calculate new flames. */
+ asm("ldx #0");
+ asm("loop:");
+ asm("lda _flames+7,x");
+ asm("clc");
+ asm("adc _flames+8,x");
+ asm("adc _flames+9,x");
+ asm("adc _flames+16,x");
+ asm("lsr");
+ asm("lsr");
+ asm("sta _flames,x");
+ asm("inx");
+ asm("cpx #(8*15)");
+ asm("bne loop");
+
+ /* Fill last line with pseudo-random data from noise generator on
+ voice 3. */
+ asm("ldx #$05");
+ asm("loop2:");
+ asm("ldy #$20");
+ asm("delay:");
+ asm("dey");
+ asm("bne delay");
+ asm("lda $d41b");
+ asm("and #$0f");
+ asm("sta _flames+8*15+1,x");
+ asm("dex");
+ asm("bpl loop2");
+
+ /* Display flames on screen. */
+ flameptr = flames;
+ colorptr1 = COLOR_RAM + 40*10;
+ colorptr2 = colorptr1 + 0x20;
+ for(y = 0; y < 15; ++y) {
+ for(x = 0; x < 8; ++x) {
+ colorptr1[x] = colorptr2[x] = flamecolors[flameptr[x]];
+ }
+ colorptr1 += 0x28;
+ colorptr2 += 0x28;
+ flameptr += 8;
+ }
+
+ }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/apps/themeloader.c b/contiki-cpc/apps/themeloader.c
new file mode 100644
index 0000000..7c00afa
--- /dev/null
+++ b/contiki-cpc/apps/themeloader.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: themeloader.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "loader.h"
+#include "ctk-draw.h"
+#include "ctk-hires-theme.h"
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(themeloader_init, arg)
+{
+ arg_free(arg);
+
+ memcpy(ctk_hires_theme_ptr, &ctk_hires_theme,
+ sizeof(struct ctk_hires_theme));
+ ctk_draw_init();
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/unused/directory.c b/contiki-cpc/apps/unused/directory.c
new file mode 100644
index 0000000..d00245c
--- /dev/null
+++ b/contiki-cpc/apps/unused/directory.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory.c,v 1.1 2006/04/17 15:18:26 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+//#include <cbm.h>
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+#include "loader.h"
+
+#include "program-handler.h"
+
+#define MAX_NUMFILES 40
+#define WIDTH 36
+#define HEIGHT 22
+
+static struct dsc *dscs[MAX_NUMFILES];
+static char filenames[MAX_NUMFILES][16];
+static unsigned char numfiles, morestart;
+
+static struct ctk_window window;
+
+static struct ctk_label description =
+ {CTK_LABEL(0, HEIGHT - 1, WIDTH, 1, "")};
+
+static char autoexit = 1;
+const static struct ctk_button autoexitbutton =
+ {CTK_BUTTON(0, 20, 9, "Auto-exit")};
+const static char autoexiton[] = "is On ";
+const static char autoexitoff[] = "is Off";
+static struct ctk_label autoexitlabel =
+ {CTK_LABEL(12, 20, 6, 1, autoexiton)};
+
+const static struct ctk_button morebutton =
+ {CTK_BUTTON(0, 20, 4, "More")};
+
+const static struct ctk_button backbutton =
+ {CTK_BUTTON(0, 20, 4, "Back")};
+
+const static struct ctk_button reloadbutton =
+ {CTK_BUTTON(30, 20, 6, "Reload")};
+
+static DISPATCHER_SIGHANDLER(directory_sighandler, s, data);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Directory browser", NULL, directory_sighandler, NULL)};
+static ek_id_t id;
+
+static unsigned char width, height;
+
+/*-----------------------------------------------------------------------------------*/
+//static struct cbm_dirent dirent;
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+ ctk_label_set_text(&description, text);
+ CTK_WIDGET_REDRAW(&description);
+}
+/*-----------------------------------------------------------------------------------*/
+#define LFN 9
+static void
+loaddirectory(void)
+{
+#if 0
+ unsigned char i, j;
+
+ if(cbm_opendir(LFN, 8) != 0) {
+ show_statustext("Cannot open directory");
+ } else {
+ i = 0;
+ while(cbm_readdir(LFN, &dirent) == 0) {
+ if(strcmp(&dirent.name[strlen(dirent.name) - 4], ".dsc") == 0) {
+ strncpy(filenames[i], dirent.name, 16);
+ ++i;
+ if(i == MAX_NUMFILES) {
+ break;
+ }
+ }
+ }
+ cbm_closedir(LFN);
+
+ numfiles = i;
+
+ j = 0;
+ for(i = 0; i < numfiles; ++i) {
+ dscs[j] = LOADER_LOAD_DSC(filenames[i]);
+ if(dscs[j] != NULL) {
+ ++j;
+ }
+ }
+ show_statustext("Directory loaded");
+ }
+#endif
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makewindow(unsigned char i)
+{
+ unsigned char x, y;
+
+ ctk_window_clear(&window);
+ CTK_WIDGET_SET_YPOS(&description, height - 3);
+ CTK_WIDGET_SET_WIDTH(&description, width);
+ CTK_WIDGET_ADD(&window, &description);
+
+ morestart = i;
+
+ x = 0; y = 1;
+ for(; dscs[i] != NULL; ++i) {
+
+ if(x + strlen(dscs[i]->icon->title) >= width) {
+ y += 5;
+ x = 0;
+ if(y >= height - 2 - 4) {
+ morestart = i;
+ break;
+ }
+ }
+ CTK_WIDGET_SET_XPOS(dscs[i]->icon, x);
+ CTK_WIDGET_SET_YPOS(dscs[i]->icon, y);
+ CTK_WIDGET_ADD(&window, dscs[i]->icon);
+
+ x += strlen(dscs[i]->icon->title) + 1;
+ }
+ CTK_WIDGET_SET_YPOS(&autoexitbutton, height - 2);
+ CTK_WIDGET_ADD(&window, &autoexitbutton);
+ CTK_WIDGET_SET_YPOS(&autoexitlabel, height - 2);
+ CTK_WIDGET_ADD(&window, &autoexitlabel);
+
+ if(i != morestart) {
+ CTK_WIDGET_SET_YPOS(&backbutton, height - 1);
+ CTK_WIDGET_ADD(&window, &backbutton);
+ } else {
+ CTK_WIDGET_SET_YPOS(&morebutton, height - 1);
+ CTK_WIDGET_ADD(&window, &morebutton);
+ }
+ CTK_WIDGET_SET_XPOS(&reloadbutton, width - 8);
+ CTK_WIDGET_SET_YPOS(&reloadbutton, height - 1);
+ CTK_WIDGET_ADD(&window, &reloadbutton);
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(directory_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = dispatcher_start(&p);
+
+ width = ctk_draw_width() - 4;
+ height = ctk_draw_height() - 4;
+
+ ctk_window_new(&window, width, height, "Directory");
+
+ loaddirectory();
+ makewindow(0);
+
+ dispatcher_listen(ctk_signal_widget_activate);
+ dispatcher_listen(ctk_signal_widget_select);
+ dispatcher_listen(ctk_signal_window_close);
+ }
+ ctk_window_open(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+ unsigned char i;
+
+ ctk_window_close(&window);
+ for(i = 0; dscs[i] != NULL; ++i) {
+ LOADER_UNLOAD_DSC(dscs[i]);
+ }
+ dispatcher_exit(&p);
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static
+DISPATCHER_SIGHANDLER(directory_sighandler, s, data)
+{
+ unsigned char i;
+ DISPATCHER_SIGHANDLER_ARGS(s, data);
+
+ if(s == ctk_signal_widget_activate) {
+ if(data == (ek_data_t)&reloadbutton) {
+ for(i = 0; dscs[i] != NULL; ++i) {
+ LOADER_UNLOAD_DSC(dscs[i]);
+ }
+ loaddirectory();
+ makewindow(0);
+ ctk_window_open(&window);
+ } else if(data == (ek_data_t)&morebutton) {
+ makewindow(morestart);
+ ctk_window_open(&window);
+ } else if(data == (ek_data_t)&backbutton) {
+ makewindow(0);
+ ctk_window_open(&window);
+ } else if(data == (ek_data_t)&autoexitbutton) {
+ autoexit = 1 - autoexit;
+ if(autoexit == 1) {
+ ctk_label_set_text(&autoexitlabel, autoexiton);
+ } else {
+ ctk_label_set_text(&autoexitlabel, autoexitoff);
+ }
+ CTK_WIDGET_REDRAW(&autoexitlabel);
+ } else {
+ for(i = 0; dscs[i] != NULL; ++i) {
+ if(data == (ek_data_t)(dscs[i]->icon)) {
+ program_handler_load(dscs[i]->prgname);
+ if(autoexit) {
+ ctk_window_close(&window);
+ quit();
+ }
+ break;
+ }
+ }
+ }
+ } else if(s == ctk_signal_widget_select) {
+ if(data == (ek_data_t)&reloadbutton) {
+ show_statustext("Reload directory");
+ } else if(data == (ek_data_t)&morebutton) {
+ show_statustext("Show more files");
+ } else if(data == (ek_data_t)&backbutton) {
+ show_statustext("Show first files");
+ } else if(data == (ek_data_t)&autoexitbutton) {
+ show_statustext("Exit when loading program");
+ } else {
+ for(i = 0; dscs[i] != NULL; ++i) {
+ if(data == (ek_data_t)(dscs[i]->icon)) {
+ show_statustext(dscs[i]->description);
+ break;
+ }
+ }
+ }
+ } else if(s == ctk_signal_window_close &&
+ data == (ek_data_t)&window) {
+ quit();
+ } else if(s == dispatcher_signal_quit) {
+ ctk_window_close(&window);
+ quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/vnc-draw-asm.S b/contiki-cpc/apps/vnc-draw-asm.S
new file mode 100644
index 0000000..7522a43
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------
+ .importzp ptr1, ptr2, ptr3, ptr4, sreg
+ .importzp sp
+
+ .import _vnc_draw_datalen
+ .import _vnc_draw_dataptr
+ .import _vnc_draw_bitmapptr
+ .import _vnc_draw_x
+ .import _vnc_draw_y
+;---------------------------------------------------------------------
+.bss
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
diff --git a/contiki-cpc/apps/vnc-draw-asm.h b/contiki-cpc/apps/vnc-draw-asm.h
new file mode 100644
index 0000000..b786fa9
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw-asm.h,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+#ifndef __VNC_DRAW_ASM_H__
+#define __VNC_DRAW_ASM_H__
+
+#include "vnc-draw.h"
+
+void vnc_draw_asm_pixelline(void);
+
+#endif /* __VNC_DRAW_ASM_H__ */
diff --git a/contiki-cpc/apps/vnc-draw.c b/contiki-cpc/apps/vnc-draw.c
new file mode 100644
index 0000000..78520ea
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw.c
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+
+
+#include "vnc-draw.h"
+#include "vnc-draw-asm.h"
+
+#include "vnc-conf.h"
+
+
+static unsigned char conv[256];
+
+const static unsigned char oratab[8] =
+ { 0x80, 0x40, 0x20, 0x10,
+ 0x08, 0x04, 0x02, 0x01 };
+const static unsigned char andtab[8] =
+ { 0x7f, 0xbf, 0xdf, 0xef,
+ 0xf7, 0xfb, 0xfd, 0xfe };
+
+static u8_t *bitmapptrtab[VNC_CONF_VIEWPORT_HEIGHT];
+
+static unsigned short viewport_x,
+ viewport_y, viewport_w, viewport_h;
+
+u8_t vnc_draw_bitmap[(VNC_CONF_VIEWPORT_WIDTH / 8) *
+ VNC_CONF_VIEWPORT_HEIGHT];
+
+
+
+u16_t vnc_draw_x;
+u16_t vnc_draw_y;
+u8_t *vnc_draw_dataptr;
+u8_t *vnc_draw_bitmapptr;
+u16_t vnc_draw_datalen;
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixel(u16_t x, u8_t y, u8_t c)
+{
+ u8_t o, a;
+
+ vnc_draw_bitmapptr = bitmapptrtab[y] + (x & 0x1f8);
+
+ if(c) {
+ o = oratab[x & 7];
+ *vnc_draw_bitmapptr = *vnc_draw_bitmapptr | o;
+ } else {
+ a = andtab[x & 7];
+ *vnc_draw_bitmapptr = *vnc_draw_bitmapptr & a;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixelline(u16_t x, u16_t y, u8_t *data, u16_t datalen)
+{
+ u8_t o, a;
+ register u8_t *bitmapptr;
+
+ vnc_draw_x = x - viewport_x;
+ vnc_draw_y = y - viewport_y;
+
+ /* if(vnc_draw_y & 1) {
+ return;
+ } else {
+ vnc_draw_y /= 2;
+ }*/
+
+
+
+ if(vnc_draw_y >= VNC_CONF_VIEWPORT_HEIGHT ||
+ vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+ return;
+ }
+
+ vnc_draw_datalen = datalen;
+
+ if(vnc_draw_datalen + vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+ vnc_draw_datalen = VNC_CONF_VIEWPORT_WIDTH - vnc_draw_x;
+ if(vnc_draw_datalen == 0) {
+ return;
+ }
+ }
+
+ vnc_draw_dataptr = data;
+
+ /* vnc_draw_bitmapptr = bitmaptab[vnc_draw_y] +
+ (vnc_draw_x & 0x1f8);*/
+
+ for(; vnc_draw_datalen > 0; --vnc_draw_datalen) {
+ /* vnc_draw_pixel(vnc_draw_x, vnc_draw_y,
+ conv[*vnc_draw_dataptr]);*/
+
+ bitmapptr = bitmapptrtab[vnc_draw_y] + (vnc_draw_x & 0x1f8);
+
+ if(conv[*vnc_draw_dataptr]) {
+ o = oratab[vnc_draw_x & 7];
+ *bitmapptr = *bitmapptr | o;
+ } else {
+ a = andtab[vnc_draw_x & 7];
+ *bitmapptr = *bitmapptr & a;
+ }
+ ++vnc_draw_dataptr;
+ ++vnc_draw_x;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_init(void)
+{
+ unsigned int tmp;
+ unsigned int i;
+ unsigned short ptr;
+
+
+ /* Create color conversion table. */
+ for(i = 0; i < 256; ++i) {
+ if(((i & 0xc0) > 0xc0) ||
+ ((i & 0x38) > 0x18) ||
+ ((i & 0x07) > 0x03)) {
+ conv[i] = 0;
+ } else {
+ conv[i] = 1;
+ }
+ }
+
+ memset(vnc_draw_bitmap, 0, sizeof(vnc_draw_bitmap));
+
+ for(i = 0; i < VNC_CONF_VIEWPORT_HEIGHT; ++i) {
+ bitmapptrtab[i] = (u8_t *)((u16_t)vnc_draw_bitmap +
+ ((i & 0xfff8)/8) * VNC_CONF_VIEWPORT_WIDTH +
+ (i & 7));
+ }
+
+ viewport_x = 0;
+ viewport_y = 0;
+
+ viewport_w = VNC_CONF_VIEWPORT_WIDTH;
+ viewport_h = VNC_CONF_VIEWPORT_HEIGHT;
+
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_x(void)
+{
+ return viewport_x;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_y(void)
+{
+ return viewport_y;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_w(void)
+{
+ return viewport_w;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_h(void)
+{
+ return viewport_h;
+}
+/*-----------------------------------------------------------------------------------*/
+#if 0
+signed short
+c64_mouse_x(void)
+{
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+signed short
+c64_mouse_y(void)
+{
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+u8_t
+c64_mouse_buttons(void)
+{
+ return firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_x(unsigned short x)
+{
+ joyx = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_y(unsigned short y)
+{
+ joyy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_x(unsigned short x)
+{
+ viewport_x = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_y(unsigned short y)
+{
+ viewport_y = y;
+}
+/*-----------------------------------------------------------------------------------*/
+
+#endif /* 0 */
+#if 0
+#pragma optimize(push, off)
+void
+c64_scroll_up(unsigned char c)
+{
+ asm("lda $f7");
+ asm("pha");
+ asm("lda $f8");
+ asm("pha");
+ asm("lda $f9");
+ asm("pha");
+ asm("lda $fa");
+ asm("pha");
+ asm("lda $fb");
+ asm("pha");
+ asm("lda $fc");
+ asm("pha");
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$35");
+ asm("sta $01");
+
+ asm("lda #$80");
+ asm("sta $f7");
+ asm("lda #$a2");
+ asm("sta $f8");
+ asm("lda #$00");
+ asm("sta $f9");
+ asm("lda #$a0");
+ asm("sta $fa");
+
+ asm("lda #$80");
+ asm("sta $fb");
+ asm("lda #$e2");
+ asm("sta $fc");
+ asm("lda #$00");
+ asm("sta $fd");
+ asm("lda #$e0");
+ asm("sta $fe");
+
+ asm("ldy #0");
+ asm("loop:");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("bne loop");
+
+ asm("inc $f8");
+ asm("inc $fa");
+ asm("inc $fc");
+ asm("inc $fe");
+
+ asm("lda $fc");
+ asm("cmp #$00");
+ asm("bne loop");
+
+ asm("ldy #0");
+ asm("lda #0");
+ asm("sta $fe00,y");
+ asm("sta $be00,y");
+ asm("sta $fcc0,y");
+ asm("sta $bcc0,y");
+ asm("iny");
+ asm("bne *-13");
+ asm("sta $ff00,y");
+ asm("sta $bf00,y");
+ asm("sta $fdc0,y");
+ asm("sta $bdc0,y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne *-15");
+
+
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+ asm("pla");
+ asm("sta $fc");
+ asm("pla");
+ asm("sta $fb");
+ asm("pla");
+ asm("sta $fa");
+ asm("pla");
+ asm("sta $f9");
+ asm("pla");
+ asm("sta $f8");
+ asm("pla");
+ asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_down(unsigned char c)
+{
+ asm("lda $f7");
+ asm("pha");
+ asm("lda $f8");
+ asm("pha");
+ asm("lda $f9");
+ asm("pha");
+ asm("lda $fa");
+ asm("pha");
+ asm("lda $fb");
+ asm("pha");
+ asm("lda $fc");
+ asm("pha");
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+
+
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$35");
+ asm("sta $01");
+
+ asm("lda #$c0");
+ asm("sta $fb");
+ asm("lda #$fb");
+ asm("sta $fc");
+ asm("lda #$40");
+ asm("sta $fd");
+ asm("lda #$fe");
+ asm("sta $fe");
+
+ asm("lda #$c0");
+ asm("sta $f7");
+ asm("lda #$bb");
+ asm("sta $f8");
+ asm("lda #$40");
+ asm("sta $f9");
+ asm("lda #$be");
+ asm("sta $fa");
+
+
+ asm("ldy #0");
+ asm("loop:");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("iny");
+ asm("bne loop");
+
+ asm("dec $f8");
+ asm("dec $fa");
+ asm("dec $fc");
+ asm("dec $fe");
+
+
+ asm("lda $fe");
+ asm("cmp #$df");
+ asm("bne loop");
+
+ asm("ldy #0");
+ asm("lda #0");
+ asm("sta $e000,y");
+ asm("sta $a000,y");
+ asm("sta $e140,y");
+ asm("sta $a140,y");
+ asm("iny");
+ asm("bne *-13");
+ asm("sta $e100,y");
+ asm("sta $a100,y");
+ asm("sta $e240,y");
+ asm("sta $a240,y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne *-15");
+
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+ asm("pla");
+ asm("sta $fc");
+ asm("pla");
+ asm("sta $fb");
+ asm("pla");
+ asm("sta $fa");
+ asm("pla");
+ asm("sta $f9");
+ asm("pla");
+ asm("sta $f8");
+ asm("pla");
+ asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_right(unsigned char c)
+{
+ asm("lda $f7");
+ asm("pha");
+ asm("lda $f8");
+ asm("pha");
+ asm("lda $f9");
+ asm("pha");
+ asm("lda $fa");
+ asm("pha");
+ asm("lda $fb");
+ asm("pha");
+ asm("lda $fc");
+ asm("pha");
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+
+
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$35");
+ asm("sta $01");
+
+ asm("lda #$00");
+ asm("sta $f7");
+ asm("lda #$a0");
+ asm("sta $f8");
+ asm("lda #$10");
+ asm("sta $f9");
+ asm("lda #$a0");
+ asm("sta $fa");
+
+ asm("lda #$00");
+ asm("sta $fb");
+ asm("lda #$e0");
+ asm("sta $fc");
+ asm("lda #$10");
+ asm("sta $fd");
+ asm("lda #$e0");
+ asm("sta $fe");
+
+ asm("ldx #0");
+
+ asm("loop3:");
+
+ asm("ldy #$ff");
+ asm("loop:");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("dey");
+ asm("cpy #$ff");
+ asm("bne loop");
+
+ asm("inc $f8");
+ asm("inc $fa");
+ asm("inc $fc");
+ asm("inc $fe");
+
+ asm("ldy #$30");
+ asm("loop2:");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("dey");
+ asm("cpy #$ff");
+ asm("bne loop2");
+
+ asm("lda $f7");
+ asm("clc");
+ asm("adc #$40");
+ asm("sta $f7");
+ asm("sta $fb");
+ asm("bcc :+");
+ asm("inc $f8");
+ asm("inc $fc");
+ asm(":");
+
+ asm("lda $f9");
+ asm("clc");
+ asm("adc #$40");
+ asm("sta $f9");
+ asm("sta $fd");
+ asm("bcc :+");
+ asm("inc $fa");
+ asm("inc $fe");
+ asm(":");
+
+
+
+ asm("inx");
+ asm("cpx #24");
+ asm("bne loop3");
+
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+ asm("pla");
+ asm("sta $fc");
+ asm("pla");
+ asm("sta $fb");
+ asm("pla");
+ asm("sta $fa");
+ asm("pla");
+ asm("sta $f9");
+ asm("pla");
+ asm("sta $f8");
+ asm("pla");
+ asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_left(unsigned char c)
+{
+ asm("lda $f7");
+ asm("pha");
+ asm("lda $f8");
+ asm("pha");
+ asm("lda $f9");
+ asm("pha");
+ asm("lda $fa");
+ asm("pha");
+ asm("lda $fb");
+ asm("pha");
+ asm("lda $fc");
+ asm("pha");
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+
+
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$35");
+ asm("sta $01");
+
+ asm("lda #$10");
+ asm("sta $f7");
+ asm("lda #$a0");
+ asm("sta $f8");
+ asm("lda #$00");
+ asm("sta $f9");
+ asm("lda #$a0");
+ asm("sta $fa");
+
+ asm("lda #$10");
+ asm("sta $fb");
+ asm("lda #$e0");
+ asm("sta $fc");
+ asm("lda #$00");
+ asm("sta $fd");
+ asm("lda #$e0");
+ asm("sta $fe");
+
+ asm("ldx #0");
+ asm("loop3:");
+ asm("ldy #0");
+ asm("loop:");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("bne loop");
+
+ asm("inc $f8");
+ asm("inc $fa");
+ asm("inc $fc");
+ asm("inc $fe");
+
+ asm("ldy #0");
+ asm("loop2:");
+ asm("lda ($f7),y");
+ asm("sta ($f9),y");
+ asm("lda ($fb),y");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("cpy #$30");
+ asm("bne loop2");
+
+ asm("lda $f7");
+ asm("clc");
+ asm("adc #$40");
+ asm("sta $f7");
+ asm("sta $fb");
+ asm("bcc :+");
+ asm("inc $f8");
+ asm("inc $fc");
+ asm(":");
+
+ asm("lda $f9");
+ asm("clc");
+ asm("adc #$40");
+ asm("sta $f9");
+ asm("sta $fd");
+ asm("bcc :+");
+ asm("inc $fa");
+ asm("inc $fe");
+ asm(":");
+
+
+ asm("inx");
+ asm("cpx #24");
+ asm("bne loop3");
+
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+ asm("pla");
+ asm("sta $fc");
+ asm("pla");
+ asm("sta $fb");
+ asm("pla");
+ asm("sta $fa");
+ asm("pla");
+ asm("sta $f9");
+ asm("pla");
+ asm("sta $f8");
+ asm("pla");
+ asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
+
+
+#endif /* 0 */
diff --git a/contiki-cpc/apps/welcome.c b/contiki-cpc/apps/welcome.c
new file mode 100644
index 0000000..709da3d
--- /dev/null
+++ b/contiki-cpc/apps/welcome.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+const static struct ctk_label welcomelabel1 =
+ {CTK_LABEL(1, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING "!")};
+const static struct ctk_label welcomelabel2 =
+ {CTK_LABEL(2, 4, 28, 1, "F1 - open menus")};
+const static struct ctk_label welcomelabel3 =
+ {CTK_LABEL(2, 6, 28, 1, "F3 - cycle windows")};
+const static struct ctk_label welcomelabel4 =
+ {CTK_LABEL(2, 8, 28, 1, "F7 - select up")};
+const static struct ctk_label welcomelabel5 =
+ {CTK_LABEL(2, 10, 28, 1, "F4 - select down")};
+const static struct ctk_label welcomelabel6 =
+ {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
+const static struct ctk_label welcomelabel7 =
+ {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+ ctk_dialog_close();
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+ unsigned char width;
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ width = ctk_desktop_width(NULL);
+
+ if(width > 34) {
+ ctk_dialog_new(&welcomedialog, 32, 17);
+ } else {
+ ctk_dialog_new(&welcomedialog, width - 2, 17);
+ }
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);
+
+ ctk_dialog_open(&welcomedialog);
+
+ } else if(ev == EK_EVENT_REQUEST_EXIT ||
+ ev == ctk_signal_keypress) {
+ welcome_quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.c b/contiki-cpc/apps/wget-dsc.c
new file mode 100644
index 0000000..0e0f12d
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+ "Downloads files or D64 disks from the web",
+ "wget.prg",
+ wget_init,
+ &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char wgeticon_bitmap[3*3*8] = {
+ 0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+ 0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+ 0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+ 0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+ 0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+ 0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+ 0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+ 0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+ 0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char wgeticon_textmap[9] = {
+ 'w', 'e', 'b',
+ 'p', 'r', 'g',
+ 'd', '6', '4'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon icon =
+ {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.h b/contiki-cpc/apps/wget-dsc.h
new file mode 100644
index 0000000..1b13211
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2006/04/17 15:18:23 kthacker Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-cpc/apps/wget.c b/contiki-cpc/apps/wget.c
new file mode 100644
index 0000000..20b403e
--- /dev/null
+++ b/contiki-cpc/apps/wget.c
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.1 2006/04/17 15:18:24 kthacker Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "loader.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <c64.h>
+#include <cbm.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "c64-dio.h"
+
+#define USE_KERNAL 0
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+ {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+ {CTK_TEXTENTRY(5, 1, 29, 1, urledit, 78)};
+
+
+static struct ctk_label savefilenamelabel =
+ {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+ {CTK_TEXTENTRY(15, 3, 19, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+ {CTK_BUTTON(0, 5, 13, "Download file")};
+
+static struct ctk_button d64button =
+ {CTK_BUTTON(17, 5, 18, "Download D64 disk")};
+
+static struct ctk_label statustext =
+ {CTK_LABEL(0, 7, 36, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window d64dialog;
+static struct ctk_label overwritelabel =
+ {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+ {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+ {CTK_LABEL(6, 4, 24, 1, "right disk in the drive!")};
+static struct ctk_button overwritebutton =
+ {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+ {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(wget_sighandler, s, data);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Web downloader", NULL, wget_sighandler, webclient_appcall)};
+ static ek_id_t id;*/
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+ wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_D64 2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+
+
+struct drv_state {
+ u8_t track;
+ u8_t sect;
+};
+
+static struct drv_state ds;
+
+static char buffer[256];
+static u16_t bufferptr;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+ if(arg != NULL) {
+ strncpy(url, arg, sizeof(url));
+ strncpy(urledit, arg, sizeof(urledit));
+ petsciiconv_topetscii(urledit, sizeof(urledit));
+ } else {
+#ifdef WGET_CONF_URL
+ strncpy(url, WGET_CONF_URL, sizeof(url));
+ strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL */
+ }
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+ ctk_label_set_text(&statustext, text);
+ CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+ u16_t addr[2];
+ unsigned char i;
+ static char host[32];
+ char *file;
+ register char *urlptr;
+ unsigned short port;
+
+ /* Trim off any spaces in the end of the url. */
+ urlptr = url + strlen(url) - 1;
+ while(*urlptr == ' ' && urlptr > url) {
+ *urlptr = 0;
+ --urlptr;
+ }
+
+ /* Don't even try to go further if the URL is empty. */
+ if(urlptr == url) {
+ return;
+ }
+
+ /* See if the URL starts with http://, otherwise prepend it. */
+ if(strncmp(url, http_http, 7) != 0) {
+ while(urlptr >= url) {
+ *(urlptr + 7) = *urlptr;
+ --urlptr;
+ }
+ strncpy(url, http_http, 7);
+ }
+
+ /* Find host part of the URL. */
+ urlptr = &url[7];
+ for(i = 0; i < sizeof(host); ++i) {
+ if(*urlptr == 0 ||
+ *urlptr == '/' ||
+ *urlptr == ' ' ||
+ *urlptr == ':') {
+ host[i] = 0;
+ break;
+ }
+ host[i] = *urlptr;
+ ++urlptr;
+ }
+
+ /* XXX: Here we should find the port part of the URL, but this isn't
+ currently done because of laziness from the programmer's side
+ :-) */
+
+ /* Find file part of the URL. */
+ while(*urlptr != '/' && *urlptr != 0) {
+ ++urlptr;
+ }
+ if(*urlptr == '/') {
+ file = urlptr;
+ } else {
+ file = "/";
+ }
+
+
+ /* First check if the host is an IP address. */
+ if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
+
+ /* Try to lookup the hostname. If it fails, we initiate a hostname
+ lookup and print out an informative message on the
+ statusbar. */
+ if(resolv_lookup(host) == NULL) {
+ resolv_query(host);
+ show_statustext("Resolving host...");
+ return;
+ }
+ }
+
+ /* The hostname we present in the hostname table, so we send out the
+ initial GET request. */
+ if(webclient_get(host, 80, file) == 0) {
+ show_statustext("Out of memory error.");
+ } else {
+ show_statustext("Connecting...");
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+ int ret;
+ static unsigned char i;
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ /* Create the main window. */
+ ctk_window_new(&window, 36, 8, "Web downloader");
+
+
+ CTK_WIDGET_ADD(&window, &urllabel);
+ CTK_WIDGET_ADD(&window, &urltextentry);
+
+ CTK_WIDGET_ADD(&window, &savefilenamelabel);
+ CTK_WIDGET_ADD(&window, &savefilenametextentry);
+
+ /* CTK_WIDGET_ADD(&window, &filebutton);*/
+
+ CTK_WIDGET_ADD(&window, &d64button);
+
+ CTK_WIDGET_ADD(&window, &statustext);
+
+ dload_state = DLOAD_NONE;
+
+ memset(savefilename, 0, sizeof(savefilename));
+ memset(url, 0, sizeof(url));
+
+ ctk_dialog_new(&d64dialog, 36, 8);
+ CTK_WIDGET_ADD(&d64dialog, &overwritelabel);
+ CTK_WIDGET_ADD(&d64dialog, &makesurelabel1);
+ CTK_WIDGET_ADD(&d64dialog, &makesurelabel2);
+ CTK_WIDGET_ADD(&d64dialog, &overwritebutton);
+ CTK_WIDGET_ADD(&d64dialog, &cancelbutton);
+
+
+ ctk_window_open(&window);
+ } else if(ev == tcpip_event) {
+ webclient_appcall(data);
+ } else if(ev == ctk_signal_button_activate) {
+ if(data == (void *)&filebutton) {
+ /* ret = cbm_open(2, 8, 2, savefilename);
+ if(ret == -1) {*/
+ sprintf(statusmsg, "Open error with '%s'", savefilename);
+ show_statustext(statusmsg);
+ /* } else {
+ strncpy(url, urledit, sizeof(url));
+ petsciiconv_toascii(url, sizeof(url));
+ start_get();
+ dload_bytes = 0;
+ dload_state = DLOAD_FILE;
+ }*/
+ } else if(data == (void *)&d64button) {
+ ctk_dialog_open(&d64dialog);
+ } else if(data == (void *)&cancelbutton) {
+ ctk_dialog_close();
+ } else if(data == (void *)&overwritebutton) {
+ ctk_dialog_close();
+
+ /* Turn of screensaver. */
+ program_handler_screensaver(NULL);
+
+ strncpy(url, urledit, sizeof(url));
+ petsciiconv_toascii(url, sizeof(url));
+ start_get();
+ dload_bytes = 0;
+ dload_state = DLOAD_D64;
+ ds.track = 1;
+ ds.sect = 0;
+ bufferptr = 0;
+#if USE_KERNAL
+#else
+ c64_dio_init(_curunit);
+#endif
+
+ /* c64_dio_init(8);*/
+ }
+ } else if(ev == ctk_signal_hyperlink_activate) {
+ if(dload_state == DLOAD_NONE) {
+ /* open_link(w->widget.hyperlink.url);*/
+ strncpy(urledit,
+ ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+ petsciiconv_topetscii(urledit, sizeof(urledit));
+ CTK_WIDGET_REDRAW(&urltextentry);
+ CTK_WIDGET_FOCUS(&window, &urltextentry);
+ }
+ } else if(ev == resolv_event_found) {
+ /* Either found a hostname, or not. */
+ if((char *)data != NULL &&
+ resolv_lookup((char *)data) != NULL) {
+ start_get();
+ } else {
+ show_statustext("Host not found.");
+ }
+ } else if(ev == ctk_signal_window_close) {
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+ show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+ show_statustext("Connection timed out");
+ if(dload_state == DLOAD_FILE) {
+ cbm_close(2);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{
+ show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{
+ show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+next_sector(void)
+{
+ ++ds.sect;
+ if(ds.track < 18) {
+ if(ds.sect == 21) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 25) {
+ if(ds.sect == 19) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 31) {
+ if(ds.sect == 18) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ } else if(ds.track < 36) {
+ if(ds.sect == 17) {
+ ++ds.track;
+ ds.sect = 0;
+ }
+ }
+
+ if(ds.track == 36) {
+ return 1;
+ }
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+x_open(u8_t f, u8_t d, u8_t cmd, u8_t *fname)
+{
+ u8_t ret;
+
+ ret = cbm_open(f, d, cmd, fname);
+ if(ret != 0) {
+ /* printf("open: error %d\n", ret);*/
+ /* ctk_label_set_text(&statuslabel, "Open err");
+ CTK_WIDGET_REDRAW(&statuslabel);*/
+ show_statustext("Open error");
+ }
+
+}
+static void
+write_sector(u8_t device, u8_t track, u8_t sect, void *mem)
+{
+ u16_t ret;
+ static u8_t cmd[32];
+
+ x_open(15, device, 15, NULL);
+ x_open(2, device, 2, "#");
+
+ ret = cbm_write(2, mem, 256);
+
+ sprintf(cmd, "u2: 2 0 %d %d", track, sect);
+ cbm_write(15, cmd, strlen(cmd));
+ /* printf("%s\n", cmd);*/
+
+
+ /* ret = 0;*/
+ if(ret == -1) {
+ sprintf(statusmsg, "Write error at %d:%d", track, sect);
+ show_statustext(statusmsg);
+ } else {
+ sprintf(statusmsg, "Wrote %d bytes to %d:%d", ret, track, sect);
+ show_statustext(statusmsg);
+ }
+ /* printf("write: wrote %d bytes\n", ret);*/
+
+ cbm_close(2);
+ cbm_close(15);
+}
+
+static void
+write_buffer(void)
+{
+#if USE_KERNAL
+ write_sector(8, ds.track, ds.sect, buffer);
+#else
+ c64_dio_write_block(ds.track, ds.sect, buffer);
+#endif
+ if(next_sector() != 0) {
+ dload_state = DLOAD_NONE;
+ }
+}
+static void
+handle_d64_data(char *data, u16_t len)
+{
+ u16_t bufferlen;
+
+ while(dload_state == DLOAD_D64 &&
+ len > 0) {
+ bufferlen = sizeof(buffer) - bufferptr;
+ if(len < bufferlen) {
+ bufferlen = len;
+ }
+
+ memcpy(&buffer[bufferptr], data, bufferlen);
+
+ data += bufferlen;
+ bufferptr += bufferlen;
+ len -= bufferlen;
+
+ if(bufferptr == sizeof(buffer)) {
+ write_buffer();
+ bufferptr = 0;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+ int ret;
+
+ if(len > 0) {
+ dload_bytes += len;
+ sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+ show_statustext(statusmsg);
+ if(dload_state == DLOAD_D64) {
+ handle_d64_data(data, len);
+ } else if(dload_state == DLOAD_FILE) {
+ ret = cbm_write(2, data, len);
+ if(ret != len) {
+ sprintf(statusmsg, "Wrote only %d bytes", ret);
+ show_statustext(statusmsg);
+ }
+ }
+ }
+
+ if(data == NULL) {
+ if(dload_state == DLOAD_FILE) {
+ cbm_close(2);
+ }
+ dload_state = DLOAD_NONE;
+ sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+ show_statustext(statusmsg);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/arch/amsgraph.h b/contiki-cpc/arch/amsgraph.h
new file mode 100644
index 0000000..a84151b
--- /dev/null
+++ b/contiki-cpc/arch/amsgraph.h
@@ -0,0 +1,18 @@
+/* AMSGRAPH.H A Graphics library for the AMSTRAD CPC range of computers
+ Uses firmware to realize graphics IO..
+
+ 2003 H. Hansen
+
+*/
+
+#ifndef __amsgraph_h__
+#define __amsgraph_h__
+
+void draw(int x, int y);
+void plot(int x, int y);
+void move(int x, int y);
+void gpen(unsigned char pencolor);
+unsigned char getgpen(void);
+
+#endif /* __amsgraph_h__ */
+
diff --git a/contiki-cpc/arch/amshw.h b/contiki-cpc/arch/amshw.h
new file mode 100644
index 0000000..433837e
--- /dev/null
+++ b/contiki-cpc/arch/amshw.h
@@ -0,0 +1,31 @@
+/* Amstrad hardware I/O ports
+
+Although these I/O port addresses are actually partially decoded,
+we use the recommended address here.
+*/
+
+/* Gate Array */
+sfr banked at 0x07F00 IO_GateArray;
+
+/* CRTC */
+sfr banked at 0x0BC00 IO_CRTC_Register;
+sfr banked at 0x0BD00 IO_CRTC_Data;
+
+/* FDD */
+sfr banked at 0x0FA7E IO_FDD_Motor; /* motor state for all floppy disc drives */
+
+/* FDC
+
+NOTE: The Amstrad Floppy Disc Controller is polled for data and has strict timing constraints.
+Therefore it is best to perform all floppy access using assembler code, or using the firmware or
+CP/M functions
+*/
+sfr banked at 0x0FB7E IO_FDC_Status; /* FDC Main Status register */
+sfr banked at 0x0FB7F IO_FDC_Data; /* FDC Data register */
+
+/* PPI */
+sfr banked at 0x0F400 IO_PPI_PortA;
+sfr banked at 0x0F500 IO_PPI_PortB;
+sfr banked at 0x0F600 IO_PPI_PortC;
+sfr banked at 0x0F700 IO_PPI_Control;
+
diff --git a/contiki-cpc/arch/arch.c b/contiki-cpc/arch/arch.c
new file mode 100644
index 0000000..b090326
--- /dev/null
+++ b/contiki-cpc/arch/arch.c
@@ -0,0 +1,18 @@
+#include "clock.h"
+#include "arch.h"
+
+extern clock_time_t _clock_val;
+
+clock_time_t clock_time()
+{
+ return _clock_val;
+}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+int ctk_arch_isprint(char c)
+{
+ return isprint(c);
+}
diff --git a/contiki-cpc/arch/arch.h b/contiki-cpc/arch/arch.h
new file mode 100644
index 0000000..6b1ee94
--- /dev/null
+++ b/contiki-cpc/arch/arch.h
@@ -0,0 +1,11 @@
+extern int _curunit;
+
+
+#define COLOR_BLACK 0
+#define COLOR_GRAY1 1
+#define COLOR_GRAY2 2
+#define COLOR_GRAY3 3
+#define COLOR_WHITE 4
+#define COLOR_YELLOW 5
+#define COLOR_BLUE 6
+#define COLOR_LIGHTBLUE 7
diff --git a/contiki-cpc/arch/clock.s b/contiki-cpc/arch/clock.s
new file mode 100644
index 0000000..f74781e
--- /dev/null
+++ b/contiki-cpc/arch/clock.s
@@ -0,0 +1,29 @@
+ .module clock
+ .area GSINIT
+ call __clock_init
+
+ .globl __clock_val
+ .globl __clock_init
+
+ .area _CODE
+__clock_init::
+ ld hl,#event_block
+ ld b,#0x01
+ ld c,#0x00
+ ld de,#event_routine
+ call #0xbce0 ;; KL NEW FAST TICKER
+ ret
+
+event_routine::
+ push hl
+ ld hl,(__clock_val)
+ inc hl
+ ld (__clock_val),hl
+ pop hl
+ ret
+
+__clock_val:: .dw 0
+
+event_block::
+ .ds 9
+
diff --git a/contiki-cpc/arch/conio.s b/contiki-cpc/arch/conio.s
new file mode 100644
index 0000000..f6a1937
--- /dev/null
+++ b/contiki-cpc/arch/conio.s
@@ -0,0 +1,432 @@
+;*****************************************************************************/
+; CONIO.S - Amstrad CPC version of the Contiki conio.h (derived from
+;borland C) ; To use with the Small Devices C Compiler ; ; 2003 H. Hansen
+;*****************************************************************************/
+
+;; contiki uses coordinates between 0..width-1, 0..height-1
+;; cpc uses coordinates between 1..width, 1..height
+; void clrscr (void);
+; Clear the whole screen and put the cursor into the top left corner
+; TESTED
+
+.globl _clrscr
+ .area _CODE
+
+_clrscr::
+ ld a,#1
+ call 0xBC0E ; SCR SET MODE
+ ret
+
+
+; void gotox (unsigned char x);
+; Set the cursor to the specified X position, leave the Y position untouched
+
+.globl _gotox
+
+_gotox::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc a
+ call 0xBB6F ; TXT SET COLUMN
+ ret
+
+; void gotoy (unsigned char y);
+; Set the cursor to the specified Y position, leave the X position untouched
+
+.globl _gotoy
+
+_gotoy::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc a
+ call 0xBB72 ; TXT SET ROW
+ ret
+
+; void gotoxy (unsigned char x, unsigned char y)
+; Set the cursor to the specified position
+; y pushed first, then x
+
+.globl _gotoxy
+
+_gotoxy::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc hl
+ ld l,(hl)
+ ld h,a
+ inc h
+ inc l
+ call 0xBB75 ; TXT SET CURSOR
+ ret
+
+; unsigned char wherex (void);
+; Return the X position of the cursor
+
+.globl _wherex
+
+_wherex::
+ call 0xBB78 ; TXT GET CURSOR
+ ld l,h
+ dec l
+ ret
+
+; unsigned char wherey (void);
+; Return the Y position of the cursor
+
+.globl _wherey
+
+_wherey::
+ call 0xBB78 ; TXT GET CURSOR
+ dec l
+ ret
+
+.globl _outchar
+
+_outchar::
+ push af
+ push bc
+ push de
+ push hl
+ call 0xbb5d
+ pop hl
+ pop de
+ pop bc
+ pop af
+ ret
+
+; void cputc (char c);
+; Output one character at the current cursor position
+
+.globl _cputc
+
+_cputc::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ call _outchar ; TXT OUTPUT
+ ret
+
+; void cputcxy (unsigned char x, unsigned char y, char c)
+; Same as "gotoxy (x, y); cputc (c);"
+
+.globl _cputcxy
+
+_cputcxy::
+ ld hl,#4
+ add hl,sp
+ ld e,(hl)
+ dec hl
+ ld a,(hl)
+ dec hl
+ ld h,(hl)
+ ld l,a
+ inc h
+ inc l
+ call 0xBB75 ; TXT SET CURSOR
+ ld a,e
+ call _outchar
+ ret
+
+; void cputs (const char* s);
+; Output a NUL terminated string at the current cursor position
+; TESTED
+
+.globl _cputs
+
+_cputs::
+ ld hl,#2
+ add hl,sp
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+
+cputs$:
+ ld a,(de)
+ inc de
+ or a
+ ret z
+ call _outchar
+ jr cputs$
+
+; void cputsxy (unsigned char x, unsigned char y, const char* s);
+; Same as "gotoxy (x, y); puts (s);"
+; TESTED
+.globl _cputsxy
+
+_cputsxy::
+ ld hl,#4
+ add hl,sp
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc hl
+ ld l,(hl)
+ ld h,a
+ inc h
+ inc l
+ call 0xBB75 ; TXT SET CURSOR
+
+ jr cputs$
+
+; int cprintf (const char* format, ...);
+; Like printf, but uses direct screen I/O
+
+; int vcprintf (const char* format, va_list ap);
+; Like vprintf, but uses direct screen I/O
+
+; unsigned char cursor (unsigned char onoff);
+; If onoff is 1, a cursor is display when waiting for keyboard input. If
+; onoff is 0, the cursor is hidden when waiting for keyboard input. The
+; function returns the old cursor setting.
+
+
+; unsigned char revers (unsigned char onoff);
+; Enable/disable reverse character display. This may not be supported by
+; the output device. Return the old setting.
+; TESTED
+
+.globl _revers
+
+_revers::
+ call 0xBB9C ; TXT INVERSE
+ ret
+
+; unsigned char textcolor (unsigned char color);
+; Set the color for text output. The old color setting is returned.
+
+
+
+.globl _textcolor
+
+_textcolor::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ ld d,a
+ call 0xBB93 ; TXT GET PEN
+ ld e,a
+ ld a,d
+ call 0xBB90 ; TXT SET PEN
+ ld l,e
+ ret
+
+; unsigned char bgcolor (unsigned char color);
+; Set the color for the background. The old color setting is returned. */
+
+.globl _bgcolor
+
+_bgcolor::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ ld d,a
+ call 0xBB99 ; TXT GET PAPER
+ ld e,a
+ ld a,d
+ call 0xBB96 ; TXT SET PAPER
+ ld l,e
+ ret
+
+; unsigned char bordercolor (unsigned char color);
+; Set the color for the border. The old color setting is returned.
+
+.globl _bordercolor
+
+_bordercolor::
+
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ push af
+ call 0xBC3B ; SCR GET BORDER
+ pop af
+ ld d,b
+ ld b,a
+ ld c,a
+ push de
+ call 0xBC38 ; SCR SET BORDER
+ pop de
+ ld l,d
+ ret
+
+; void chline (unsigned char length);
+; Output a horizontal line with the given length starting at the current
+; cursor position.
+
+.globl _chline
+
+_chline::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ or a
+ ret z
+ ld b,a
+ ld a,#0x09a
+chlineloop$:
+ call _outchar
+ djnz chlineloop$
+ ret
+
+; void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); chline (length);"
+; TESTED
+
+.globl _chlinexy
+
+_chlinexy::
+ ld hl,#2
+ add hl,sp
+ ld d,(hl)
+ inc hl
+ ld e,(hl)
+ inc hl
+ ld a,(hl)
+ or a
+ ret z
+ ld b,a
+ ld h,d
+ ld l,e
+ inc h
+ inc l
+ call 0xBB75
+ ld a,#0x9a ; Horizontal line char.
+chxyloop$:
+ call _outchar ; TXT OUT
+ djnz chxyloop$
+ ret
+
+; void cvline (unsigned char length);
+; Output a vertical line with the given length at the current cursor
+; position.
+
+.globl _cvline
+
+_cvline::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ or a
+ ret z
+ ld b,a
+ call 0xBB78 ; TXT GET CURSOR
+ ld a,#0x095
+cvloop$:
+ push af
+ push hl
+ call 0xBB75
+ pop hl
+ pop af
+ inc l
+ call _outchar
+ djnz cvloop$
+ ret
+
+; void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); cvline (length);"
+
+.globl _cvlinexy
+
+_cvlinexy::
+ ld hl,#2
+ add hl,sp
+ ld d,(hl)
+ inc hl
+ ld e,(hl)
+ inc hl
+ ld a,(hl)
+ or a
+ ret z
+ ld b,a
+ ld h,d
+ ld l,e
+ inc h
+ inc l
+ ld a,#149
+cvxyloop$:
+ push hl
+ push af
+ call 0xBB75
+ pop af
+ pop hl
+ inc l
+ call _outchar
+ djnz cvxyloop$
+ ret
+
+; void cclear (unsigned char length);
+; Clear part of a line (write length spaces).
+
+.globl _cclear
+
+_cclear::
+ ld hl,#2
+ add hl,sp
+ ld b,(hl)
+ ld a,#0x020 ; White space
+cclearloop$:
+ call _outchar
+ djnz cclearloop$
+ ret
+
+; void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+; Same as "gotoxy (x, y); cclear (length);"
+
+.globl _cclearxy
+
+_cclearxy::
+ ld hl,#2
+ add hl,sp
+ ld d,(hl)
+ inc hl
+ ld e,(hl)
+ inc hl
+ ld b,(hl)
+ ld h,d
+ ld l,e
+ inc h
+ inc l
+ call 0xBB75
+ ld a,#0x020 ; White space
+
+cclearxyloop$:
+ call _outchar
+ djnz cclearxyloop$
+ ret
+
+; void screensize (unsigned char* x, unsigned char* y);
+; Return the current screen size.
+
+.globl _screensize
+
+_screensize::
+
+ ld hl,#2
+ add hl,sp
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+
+ ld a,#40 ; X Size
+ ld (de),a
+
+ ld hl,#4
+ add hl,sp
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+
+ ld a,#24 ; Y Size
+ ld (de),a
+ ret
+
+; void cputhex8 (unsigned char val);
+; void cputhex16 (unsigned val);
+; These shouldn't be here...
diff --git a/contiki-cpc/arch/contiki-uip.link b/contiki-cpc/arch/contiki-uip.link
new file mode 100644
index 0000000..1b20b9d
--- /dev/null
+++ b/contiki-cpc/arch/contiki-uip.link
@@ -0,0 +1,35 @@
+-im contiki
+-k /usr/local/share/sdcc/lib/z80
+-b _CODE=0x0100
+-l z80
+./arch/crt0.o
+./arch/key.o
+./arch/mem.o
+./arch/malloc.o
+./arch/clock.o
+./loader/loader-arch-cpc.o
+./loader/rel.o
+./loader/cfs-cpc.o
+../contiki/lib/cfs.o
+./loader/dir.o
+../contiki/apps/program-handler.o
+../contiki/ctk/ctk.o
+../contiki/ctk/ctk-draw.o
+../contiki/ek/ek-service.o
+../contiki/ek/ek.o
+../contiki/ek/arg.o
+../contiki/lib/cfs.o
+../contiki/lib/list.o
+../contiki/lib/timer.o
+../contiki/uip/tcpip.o
+../contiki/uip/uip.o
+../contiki/uip/resolv.o
+../contiki/uip/uiplib.o
+./uip/uip_arch.o
+./apps/directory-dsc.o
+./apps/configedit-dsc.o
+../contiki/apps/processes-dsc.o
+./arch/main.o
+./arch/arch.o
+./arch/uip.o
+-e
diff --git a/contiki-cpc/arch/contiki.link b/contiki-cpc/arch/contiki.link
new file mode 100644
index 0000000..902e616
--- /dev/null
+++ b/contiki-cpc/arch/contiki.link
@@ -0,0 +1,28 @@
+-im contiki
+-k /usr/local/share/sdcc/lib/z80
+-b _CODE=0x0100
+-l z80
+./arch/crt0.o
+./arch/key.o
+./arch/mem.o
+./arch/malloc.o
+./arch/clock.o
+./loader/loader-arch-cpc.o
+./loader/rel.o
+./loader/cfs-cpc.o
+../contiki/lib/cfs.o
+./loader/dir.o
+../contiki/apps/program-handler.o
+../contiki/ctk/ctk.o
+../contiki/ctk/ctk-draw.o
+../contiki/ek/ek-service.o
+../contiki/ek/ek.o
+../contiki/ek/arg.o
+../contiki/lib/list.o
+../contiki/lib/timer.o
+./apps/directory-dsc.o
+./apps/configedit-dsc.o
+../contiki/apps/processes-dsc.o
+./arch/main.o
+./arch/arch.o
+-e
diff --git a/contiki-cpc/arch/contiki_labels.s b/contiki-cpc/arch/contiki_labels.s
new file mode 100644
index 0000000..8192104
--- /dev/null
+++ b/contiki-cpc/arch/contiki_labels.s
@@ -0,0 +1,346 @@
+__jpbc == 0x0107
+_kbhit == 0x0109
+_cgetc == 0x0115
+_calc_free_ram == 0x011B
+_get_ram_start == 0x0183
+_get_ram_end == 0x0187
+ram_start == 0x018B
+ram_end == 0x018D
+__sdcc_heap_init == 0x018F
+__sdcc_heap_init_start == 0x018F
+__sdcc_heap_init_end == 0x021B
+_malloc == 0x021B
+_malloc_start == 0x021B
+_free == 0x0366
+_free_start == 0x0366
+_malloc_end == 0x0366
+_free_end == 0x03CE
+__clock_init == 0x03CE
+event_routine == 0x03DC
+__clock_val == 0x03E6
+event_block == 0x03E8
+_loader_arch_load == 0x03F1
+_loader_arch_load_start == 0x03F1
+_loader_arch_load_end == 0x0455
+_loader_arch_load_dsc == 0x0455
+_loader_arch_load_dsc_start == 0x0455
+_loader_arch_load_dsc_end == 0x04A7
+_loader_arch_free == 0x04A7
+_loader_arch_free_start == 0x04A7
+_loader_arch_free_end == 0x04BF
+_loader_arch_free_dsc == 0x04BF
+_loader_arch_free_dsc_start == 0x04BF
+_loader_arch_free_dsc_end == 0x04D7
+_get_file_length == 0x04D7
+_load_file == 0x04FB
+_relocate == 0x0519
+_cfs_cpc_init == 0x05B8
+_cfs_cpc_init_start == 0x05B8
+_cfs_cpc_init_end == 0x05DB
+_cfs_find_service == 0x08B2
+_cfs_find_service_start == 0x08B2
+_cfs_find_service_end == 0x08CE
+__readdir == 0x08E8
+fetch_directory == 0x0901
+_program_handler_add == 0x091D
+_program_handler_add_start == 0x091D
+_program_handler_add_end == 0x0977
+_program_handler_init == 0x0A59
+_program_handler_init_start == 0x0A59
+_program_handler_init_end == 0x0AB0
+_pnarg_init == 0x0AB8
+_pnarg_init_start == 0x0AB8
+_pnarg_init_end == 0x0ACB
+_program_handler_load == 0x0B62
+_program_handler_load_start == 0x0B62
+_program_handler_load_end == 0x0BA9
+_program_handler_screensaver == 0x0BB7
+_program_handler_screensaver_sta == 0x0BB7
+_program_handler_screensaver_end == 0x0BE6
+_ctk_restore == 0x109A
+_ctk_restore_start == 0x109A
+_ctk_init_start == 0x10BF
+_ctk_restore_end == 0x10BF
+_ctk_init == 0x10BF
+_ctk_init_end == 0x11F2
+_ctk_mode_set == 0x11FA
+_ctk_mode_set_start == 0x11FA
+_ctk_mode_get == 0x120F
+_ctk_mode_get_start == 0x120F
+_ctk_mode_set_end == 0x120F
+_ctk_mode_get_end == 0x1217
+_ctk_icon_add == 0x1217
+_ctk_icon_add_start == 0x1217
+_ctk_dialog_open == 0x1243
+_ctk_icon_add_end == 0x1243
+_ctk_dialog_open_start == 0x1243
+_ctk_dialog_open_end == 0x126A
+_ctk_dialog_close == 0x126A
+_ctk_dialog_close_start == 0x126A
+_ctk_window_open == 0x1283
+_ctk_window_open_start == 0x1283
+_ctk_dialog_close_end == 0x1283
+_ctk_window_close == 0x139C
+_ctk_window_close_start == 0x139C
+_ctk_window_open_end == 0x139C
+_ctk_window_close_end == 0x14CB
+_ctk_window_clear_start == 0x163B
+_ctk_window_clear == 0x163B
+_ctk_menu_add_start == 0x1695
+_ctk_window_clear_end == 0x1695
+_ctk_menu_add == 0x1695
+_ctk_menu_add_end == 0x1707
+_ctk_menu_remove == 0x1707
+_ctk_menu_remove_start == 0x1707
+_ctk_menu_remove_end == 0x178B
+_ctk_desktop_redraw == 0x18E0
+_ctk_desktop_redraw_start == 0x18E0
+_ctk_window_redraw_start == 0x192F
+_ctk_desktop_redraw_end == 0x192F
+_ctk_window_redraw == 0x192F
+_ctk_window_redraw_end == 0x19AC
+_ctk_window_new == 0x1B5F
+_ctk_window_new_start == 0x1B5F
+_ctk_window_new_end == 0x1B93
+_ctk_dialog_new == 0x1B93
+_ctk_dialog_new_start == 0x1B93
+_ctk_menu_new == 0x1BB9
+_ctk_menu_new_start == 0x1BB9
+_ctk_dialog_new_end == 0x1BB9
+_ctk_menuitem_add == 0x1C1B
+_ctk_menu_new_end == 0x1C1B
+_ctk_menuitem_add_start == 0x1C1B
+_ctk_menuitem_add_end == 0x1C9E
+_ctk_widget_redraw == 0x1DCD
+_ctk_widget_redraw_start == 0x1DCD
+_ctk_widget_add == 0x1DF7
+_ctk_widget_add_start == 0x1DF7
+_ctk_widget_redraw_end == 0x1DF7
+_ctk_desktop_width_start == 0x1EA6
+_ctk_widget_add_end == 0x1EA6
+_ctk_desktop_width == 0x1EA6
+_ctk_desktop_width_end == 0x1EB4
+_ctk_desktop_height == 0x1EB4
+_ctk_desktop_height_start == 0x1EB4
+_ctk_desktop_height_end == 0x1EC2
+_ctk_draw_init == 0x2EFD
+_ctk_draw_init_start == 0x2EFD
+_ctk_draw_clear == 0x2F46
+_ctk_draw_init_end == 0x2F46
+_ctk_draw_clear_start == 0x2F46
+_ctk_draw_clear_window == 0x2F79
+_ctk_draw_clear_window_start == 0x2F79
+_ctk_draw_clear_end == 0x2F79
+_ctk_draw_clear_window_end == 0x2FBA
+_ctk_draw_window == 0x2FBA
+_ctk_draw_window_start == 0x2FBA
+_ctk_draw_dialog_start == 0x2FFB
+_ctk_draw_window_end == 0x2FFB
+_ctk_draw_dialog == 0x2FFB
+_ctk_draw_widget == 0x302B
+_ctk_draw_dialog_end == 0x302B
+_ctk_draw_widget_start == 0x302B
+_ctk_draw_menus_start == 0x306C
+_ctk_draw_widget_end == 0x306C
+_ctk_draw_menus == 0x306C
+_ctk_draw_menus_end == 0x309C
+_ctk_draw_width == 0x309C
+_ctk_draw_width_start == 0x309C
+_ctk_draw_width_end == 0x30BE
+_ctk_draw_height == 0x30BE
+_ctk_draw_height_start == 0x30BE
+_ctk_mouse_xtoc == 0x30E0
+_ctk_mouse_xtoc_start == 0x30E0
+_ctk_draw_height_end == 0x30E0
+_ctk_mouse_ytoc == 0x3115
+_ctk_mouse_ytoc_start == 0x3115
+_ctk_mouse_xtoc_end == 0x3115
+_ctk_draw_quit == 0x314A
+_ctk_mouse_ytoc_end == 0x314A
+_ctk_draw_quit_start == 0x314A
+_ctk_draw_quit_end == 0x3168
+_ek_service_start == 0x3173
+_ek_service_start_start == 0x3173
+_ek_service_find_start == 0x31B2
+_ek_service_start_end == 0x31B2
+_ek_service_find == 0x31B2
+_ek_service_state_start == 0x31DF
+_ek_service_find_end == 0x31DF
+_ek_service_state == 0x31DF
+_ek_service_reset == 0x3229
+_ek_service_reset_start == 0x3229
+_ek_service_state_end == 0x3229
+_ek_service_reset_end == 0x323F
+_ek_alloc_event == 0x323F
+_ek_alloc_event_start == 0x323F
+_ek_alloc_event_end == 0x324A
+_ek_start_start == 0x3369
+_ek_start == 0x3369
+_ek_exit == 0x33F8
+_ek_start_end == 0x33F8
+_ek_exit_start == 0x33F8
+_ek_process == 0x352B
+_ek_process_start == 0x352B
+_ek_exit_end == 0x352B
+_ek_init == 0x3558
+_ek_init_start == 0x3558
+_ek_process_end == 0x3558
+_ek_process_event == 0x35AC
+_ek_init_end == 0x35AC
+_ek_process_event_start == 0x35AC
+_ek_process_poll == 0x3743
+_ek_process_event_end == 0x3743
+_ek_process_poll_start == 0x3743
+_ek_run == 0x378B
+_ek_run_start == 0x378B
+_ek_process_poll_end == 0x378B
+_ek_post == 0x37AD
+_ek_post_start == 0x37AD
+_ek_run_end == 0x37AD
+_ek_post_synch == 0x3828
+_ek_post_synch_start == 0x3828
+_ek_post_end == 0x3828
+_ek_post_synch_end == 0x3887
+_ek_find == 0x3887
+_ek_find_start == 0x3887
+_ek_find_end == 0x38F2
+_ek_replace == 0x38F2
+_ek_replace_start == 0x38F2
+_ek_replace_end == 0x394A
+_ek_procstate == 0x394A
+_ek_procstate_start == 0x394A
+_ek_procstate_end == 0x397F
+_arg_init == 0x397F
+_arg_init_start == 0x397F
+_arg_init_end == 0x3986
+_arg_alloc == 0x3986
+_arg_alloc_start == 0x3986
+_arg_alloc_end == 0x39A4
+_arg_free == 0x39A4
+_arg_free_start == 0x39A4
+_arg_free_end == 0x39C5
+_list_init == 0x39C5
+_list_init_start == 0x39C5
+_list_init_end == 0x39E1
+_list_head == 0x39E1
+_list_head_start == 0x39E1
+_list_copy_start == 0x39FD
+_list_head_end == 0x39FD
+_list_copy == 0x39FD
+_list_copy_end == 0x3A22
+_list_tail == 0x3A22
+_list_tail_start == 0x3A22
+_list_add == 0x3A54
+_list_add_start == 0x3A54
+_list_tail_end == 0x3A54
+_list_push_start == 0x3A95
+_list_add_end == 0x3A95
+_list_push == 0x3A95
+_list_push_end == 0x3AC0
+_list_chop == 0x3AC0
+_list_chop_start == 0x3AC0
+_list_pop == 0x3B46
+_list_pop_start == 0x3B46
+_list_chop_end == 0x3B46
+_list_pop_end == 0x3B71
+_timer_set == 0x3B71
+_timer_set_start == 0x3B71
+_timer_set_end == 0x3B9D
+_timer_reset == 0x3B9D
+_timer_reset_start == 0x3B9D
+_timer_expired == 0x3BBA
+_timer_reset_end == 0x3BBA
+_timer_expired_start == 0x3BBA
+_timer_expired_end == 0x3C04
+_directory_dsc == 0x3C04
+_directory_icon == 0x3C5D
+_configedit_dsc == 0x3C90
+_configedit_icon == 0x3CE9
+_processes_dsc == 0x3D2F
+_processes_icon == 0x3D88
+_uip_fw_forward_start == 0x3DC2
+_uip_fw_forward == 0x3DC2
+_uip_fw_forward_end == 0x3DC5
+_uip_fw_periodic == 0x3DC5
+_uip_fw_periodic_start == 0x3DC5
+_uip_fw_periodic_end == 0x3DC6
+_main_start == 0x3DEF
+_main_end == 0x3E48
+_reset == 0x3E68
+_reset_start == 0x3E68
+_reset_end == 0x3E69
+_clock_time_start == 0x3E6E
+_clock_time == 0x3E6E
+_ctk_arch_isprint == 0x3E72
+_clock_time_end == 0x3E72
+_ctk_arch_isprint_start == 0x3E72
+_ctk_arch_isprint_end == 0x3E8D
+_strcpy == 0x3E8D
+_strcpy_start == 0x3E8D
+_strcpy_end == 0x3EB2
+__divschar_rrx_s == 0x3EB2
+__divschar_rrx_hds == 0x3EB9
+__modschar_rrx_s == 0x3EC0
+__modschar_rrx_hds == 0x3EC7
+__divsint_rrx_s == 0x3ECE
+__divsint_rrx_hds == 0x3EDA
+__modsint_rrx_s == 0x3EE2
+__modsint_rrx_hds == 0x3EEE
+__divuchar_rrx_s == 0x3EF6
+__divuchar_rrx_hds == 0x3EFD
+__moduchar_rrx_s == 0x3F04
+__moduchar_rrx_hds == 0x3F0B
+__divuint_rrx_s == 0x3F12
+__divuint_rrx_hds == 0x3F1E
+__moduint_rrx_s == 0x3F26
+__moduint_rrx_hds == 0x3F32
+.mod8 == 0x3F3A
+.div8 == 0x3F3A
+.mod16 == 0x3F42
+.div16 == 0x3F42
+.modu8 == 0x3F7F
+.divu8 == 0x3F7F
+.modu16 == 0x3F82
+.divu16 == 0x3F82
+_strncmp == 0x3FB3
+_strncmp_start == 0x3FB3
+_strncmp_end == 0x4040
+_isprint == 0x4040
+_isprint_start == 0x4040
+_isprint_end == 0x4062
+_memset == 0x4062
+_memset_start == 0x4062
+_memset_end == 0x40AA
+__mulschar_rrx_s == 0x40AA
+__mulschar_rrx_hds == 0x40B1
+__muluchar_rrx_s == 0x40BD
+__mulint_rrx_s == 0x40CA
+__mulint_rrx_hds == 0x40D6
+__muluchar_rrx_hds == 0x40D6
+_strncpy == 0x40EF
+_strncpy_start == 0x40EF
+_strncpy_end == 0x415E
+_strlen_start == 0x415E
+_strlen == 0x415E
+_strlen_end == 0x417E
+_ctk_signal_keypress == 0x439D
+_ctk_signal_widget_activate == 0x439E
+_ctk_signal_button_activate == 0x439F
+_ctk_signal_widget_select == 0x43A0
+_ctk_signal_button_hover == 0x43A1
+_ctk_signal_hyperlink_activate == 0x43A2
+_ctk_signal_hyperlink_hover == 0x43A3
+_ctk_signal_menu_activate == 0x43A4
+_ctk_signal_window_close == 0x43A5
+_ctk_signal_pointer_move == 0x43A6
+_ctk_signal_pointer_button == 0x43A7
+_ctk_screensaver_timeout == 0x43AA
+_ctk_draw_windowborder_width == 0x43BC
+_ctk_draw_windowborder_height == 0x43BD
+_ctk_draw_windowtitle_height == 0x43BE
+_ek_procs == 0x43C2
+_ek_proclist == 0x43C4
+_ek_current == 0x4404
+_ek_event_quit == 0x4406
+_ek_event_msg == 0x4407
+_ek_poll_request == 0x448B
diff --git a/contiki-cpc/arch/crt0-backup.s b/contiki-cpc/arch/crt0-backup.s
new file mode 100644
index 0000000..b014aa8
--- /dev/null
+++ b/contiki-cpc/arch/crt0-backup.s
@@ -0,0 +1,33 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+ .module crt0
+ .globl _main
+ .globl _progend
+ .area _HEADER (ABS)
+ .org 0x100 ;; Start from address &100
+init:
+
+;; Initialise global variables
+ call gsinit
+ call _main
+
+_exit::
+ ret
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _CODE
+ .area _DATA
+ .area _BSS
+
+ .area _GSINIT
+gsinit::
+
+ .area _GSFINAL
+ ret
+ .area _HEAP
+_progend::
diff --git a/contiki-cpc/arch/crt0-dsc.s b/contiki-cpc/arch/crt0-dsc.s
new file mode 100644
index 0000000..381bc27
--- /dev/null
+++ b/contiki-cpc/arch/crt0-dsc.s
@@ -0,0 +1,26 @@
+;; File: crt0-dsc.s
+
+ .module crt0
+ .globl _main
+
+ .area _HEADER (REL)
+;; .org 0x100 ;; Start from address &100
+
+init:
+_main:
+ ;; Ordering of segments for the linker.
+ .area _HOME (REL)
+ .area _CODE (REL)
+ .area _GSINIT (REL)
+ .area _GSFINAL (REL)
+
+ .area _DATA (REL)
+ .area _BSS (REL)
+ .area _HEAP (REL)
+
+ .area _CODE (REL)
+
+_exit::
+ .area _GSINIT (REL)
+gsinit::
+ .area _GSFINAL (REL)
diff --git a/contiki-cpc/arch/crt0-prg.s b/contiki-cpc/arch/crt0-prg.s
new file mode 100644
index 0000000..8984742
--- /dev/null
+++ b/contiki-cpc/arch/crt0-prg.s
@@ -0,0 +1,16 @@
+;; File: crt0-dsc.s
+
+ .module crt0
+ .area _HEADER (ABS)
+ .area _HOME (REL)
+ .area _CODE (REL)
+ ;; relocation data
+ .dw 0
+ .area _DATA (REL)
+ .area _BSS (REL)
+ .area _HEAP (REL)
+
+ .area _GSINIT (REL)
+gsinit::
+ .area _GSFINAL (REL)
+ ret
diff --git a/contiki-cpc/arch/crt0.s b/contiki-cpc/arch/crt0.s
new file mode 100644
index 0000000..a8aafdb
--- /dev/null
+++ b/contiki-cpc/arch/crt0.s
@@ -0,0 +1,35 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+ .module crt0
+ .globl _main
+ .globl _progend
+ .globl __jpbc
+ .area _HEADER (ABS)
+ ;; Ordering of segments for the linker.
+ .area _CODE
+init:
+
+;; Initialise global variables
+ call gsinit
+ call _main
+
+_exit::
+ ret
+__jpbc:
+ push bc
+ ret
+
+ .area _DATA (REL)
+ .area _BSS (REL)
+
+ .area _GSINIT (REL)
+gsinit::
+
+ .area _GSFINAL (REL)
+ ret
+ .area _HEAP (REL)
+_progend::
diff --git a/contiki-cpc/arch/hires.s b/contiki-cpc/arch/hires.s
new file mode 100644
index 0000000..c482768
--- /dev/null
+++ b/contiki-cpc/arch/hires.s
@@ -0,0 +1,101 @@
+;; Hires:
+;;
+;; Mode 0, 40 columns. Each character is 4 pixels wide and 8 pixels tall.
+;; Each character is two bytes wide and 8 lines tall.
+;;
+;; The graphics for each character is a bitmap defined using
+;; pen 0 and pen 15.
+;;
+;; The bitmap is processed at runtime to convert the font to the
+;; appropiate pixel colours.
+ .area _CODE
+;; This table converts between pen index (0-15) and pixel bitmap.
+.pen_table
+defb #00 ;; pen 0 (%00000000)
+defb #c0 ;; pen 1 (%11000000)
+defb #0c ;; pen 2 (%00001100)
+defb #cc ;; pen 3 (%11001100)
+defb #30 ;; pen 4 (%00110000)
+defb #f0 ;; pen 5 (%11110000)
+defb #3c ;; pen 6 (%00111100)
+defb #fc ;; pen 7 (%11111100)
+defb #03 ;; pen 8 (%00000011)
+defb #c3 ;; pen 9 (%11000011)
+defb #0f ;; pen 10 (%00001111)
+defb #cf ;; pen 11 (%11001111)
+defb #33 ;; pen 12 (%00110011)
+defb #f3 ;; pen 13 (%11110011)
+defb #3f ;; pen 14 (%00111111)
+defb #ff ;; pen 15 (%11111111)
+
+;; A = pen
+.get_pen_mask
+ld hl,pen_table
+add a,l
+ld l,a
+ld a,h
+adc a,0
+ld h,a
+ld a,(hl)
+ret
+
+.set_pen
+call get_pen_mask
+ld (pen_mask+1),a
+ld (pen_mask2+1),a
+ret
+
+.set_paper
+call get_pen_mask
+ld (paper_mask+1),a
+ld (paper_mask2+1),a
+ret
+
+;; enter:
+;; HL = current memory address
+;; exit:
+;; HL = memory address of byte immediatly below
+;; AF corrupt.
+.scr_next_line
+ld a,h
+add a,8
+ld h,a
+ret nc
+ld a,l
+add a,&50
+ld l,a
+ld a,h
+adc a,&c0
+ld h,a
+ret
+
+;; enter:
+;; HL = screen address
+;; DE = character pixel graphics
+;; exit:
+;; AF, BC, HL, DE corrupt
+.plot_char
+ld b,8
+.pc1
+ld a,(de) ;; convert 'on' pixels
+.pen_mask and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask and 1
+or c
+ld (hl),a
+inc l
+ld a,(de)
+.pen_mask2 and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask2 and 1
+or c
+ld (hl),a
+dec l
+call scr_next_line
+djnz pc1
+ret
+
diff --git a/contiki-cpc/arch/key.s b/contiki-cpc/arch/key.s
new file mode 100644
index 0000000..8ca55ad
--- /dev/null
+++ b/contiki-cpc/arch/key.s
@@ -0,0 +1,33 @@
+; unsigned char kbhit (void);
+; Return true if there's a key waiting, return false if not
+; TESTED
+
+.globl _kbhit
+ .area _CODE
+_kbhit::
+ call 0xBB09 ; KM READ KEY
+ ld (key),a
+ ld l,#1
+ ret c
+ ld l,#0
+ ret
+
+; char cgetc (void);
+; Return a character from the keyboard. If there is no character available,
+; the functions waits until the user does press a key. If cursor is set to
+; 1 (see below), a blinking cursor is displayed while waiting.
+; TESTED
+
+.globl _cgetc
+
+_cgetc::
+ ld a,(key)
+ ld l,a
+ ret
+
+;; call 0xBB09
+;; jr nc,_cgetc
+;; ld l,a
+;; ret
+
+key: .db 0
diff --git a/contiki-cpc/arch/main.c b/contiki-cpc/arch/main.c
new file mode 100644
index 0000000..06a0656
--- /dev/null
+++ b/contiki-cpc/arch/main.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main.c,v 1.1 2006/04/17 15:15:44 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "log.h"
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "configedit-dsc.h"
+#include "directory-dsc.h"
+#include "processes-dsc.h"
+
+//#include "cfs-cbm.h"
+#include "cfs-cpc.h"
+
+#include "clock.h"
+
+#include "arch.h"
+
+unsigned char
+uip_fw_forward(void)
+{
+ return 0;
+}
+void
+uip_fw_periodic(void)
+{
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(init_eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ program_handler_load("conio.prg",NULL);
+// program_handler_load("config.prg", NULL);
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+ init_eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+#if LOG_CONF_ENABLED
+void
+log_message(char *part1, char *part2)
+{
+}
+#endif
+void
+main(void)
+{
+
+ log_message("Starting ", CONTIKI_VERSION_STRING);
+
+ ek_init();
+
+ ek_start(&init);
+
+ // log_message(": TCP/IP", "");
+
+ // tcpip_init(NULL);
+
+ // resolv_init(NULL);
+
+ log_message(": CTK GUI", "");
+ ctk_init();
+
+ log_message(": Initial filesystem", "");
+ cfs_cpc_init(NULL);
+
+ program_handler_init();
+
+ program_handler_add(&directory_dsc, "Directory", 1);
+// program_handler_add(&configedit_dsc, "Configuration", 1);
+ program_handler_add(&processes_dsc, "Processes", 1);
+
+
+ log_message("Starting process scheduling", "");
+
+ while(1) {
+ if(ek_run() == 0) {
+ program_handler_load("welcome.prg", NULL);
+ break;
+ }
+ }
+
+ while(1) {
+ ek_run();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+reset(void)
+{
+/* asm("lda #$36");
+ asm("sta $01");
+ asm("jmp $fce2");
+*/
+}
+
diff --git a/contiki-cpc/arch/malloc.c b/contiki-cpc/arch/malloc.c
new file mode 100644
index 0000000..d4e91b5
--- /dev/null
+++ b/contiki-cpc/arch/malloc.c
@@ -0,0 +1,268 @@
+#include <sdcc-lib.h>
+#include <malloc.h>
+
+#if _SDCC_MALLOC_TYPE_MLH
+
+typedef struct _MEMHEADER MEMHEADER;
+
+struct _MEMHEADER
+{
+ MEMHEADER * next;
+ MEMHEADER * prev;
+ unsigned int len;
+ unsigned char mem;
+};
+
+#define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
+
+/* These veriables are defined through the crt0 functions. */
+/* Base of this variable is the first byte of the heap. */
+//extern MEMHEADER _sdcc_heap_start;
+/* Address of this variable is the last byte of the heap. */
+//extern char _sdcc_heap_end;
+
+extern char *get_ram_start();
+extern char *get_ram_end();
+extern void calc_free_ram();
+extern char progend;
+
+static MEMHEADER *firstheader;
+/* setup two headers. One at start of free ram, second at end of free ram.
+ We find free ram range by asking Amstrad's firmware. */
+
+void
+_sdcc_heap_init(void)
+{
+ MEMHEADER *lastheader;
+ unsigned int size;
+ char * ramstart;
+
+ /* ask firmware for free ram */
+ calc_free_ram();
+
+ /* start of ram is either start of range given by firmware,
+ or end of program; whichever is largest */
+ ramstart = get_ram_start();
+ if (ramstart<&progend)
+ ramstart = &progend;
+
+ /* this is our first mem header */
+ firstheader = (MEMHEADER *)ramstart;
+
+ /* this is the size of ram available */
+ size = get_ram_end() - ramstart;
+
+ /* calc address of last header */
+ lastheader = (MEMHEADER *)((char *)firstheader + size - HEADER_SIZE);
+
+ /* setup last header */
+ lastheader->next = NULL;
+ lastheader->prev = firstheader;
+ lastheader->len = 0;
+
+ /* setup first header */
+ firstheader->next = lastheader;
+ firstheader->prev = NULL; //and mark first as first
+ firstheader->len = 0; //Empty and ready.
+}
+
+void *
+malloc (unsigned int size)
+{
+ MEMHEADER * current_header;
+ MEMHEADER * new_header;
+
+ if (size>(0xFFFF-HEADER_SIZE))
+ {
+ return NULL; //To prevent overflow in next line
+ }
+
+ size += HEADER_SIZE; //We need a memory for header too
+ current_header = firstheader;
+
+ while (1)
+ {
+ // current
+ // | len next
+ // v v v
+ //....*****.........******....
+ // ^^^^^^^^^
+ // spare
+
+ if ((((unsigned int)current_header->next) -
+ ((unsigned int)current_header) -
+ current_header->len) >= size)
+ {
+ break; //if spare is more than need
+ }
+ current_header = current_header->next; //else try next
+ if (!current_header->next)
+ {
+ return NULL; //if end_of_list reached
+ }
+ }
+
+ if (!current_header->len)
+ { //This code works only for first_header in the list and only
+ current_header->len = size; //for first allocation
+ return ¤t_header->mem;
+ }
+ else
+ {
+ //else create new header at the begin of spare
+ new_header = (MEMHEADER * )((char *)current_header + current_header->len);
+ new_header->next = current_header->next; //and plug it into the chain
+ new_header->prev = current_header;
+ current_header->next = new_header;
+ if (new_header->next)
+ {
+ new_header->next->prev = new_header;
+ }
+ new_header->len = size; //mark as used
+ return &new_header->mem;
+ }
+}
+
+void
+free (void *p)
+{
+ MEMHEADER *prev_header, *pthis;
+
+ if ( p ) //For allocated pointers only!
+ {
+ pthis = (MEMHEADER * )((char *) p - HEADER_SIZE); //to start of header
+ if ( pthis->prev ) // For the regular header
+ {
+ prev_header = pthis->prev;
+ prev_header->next = pthis->next;
+ if (pthis->next)
+ {
+ pthis->next->prev = prev_header;
+ }
+ }
+ else
+ {
+ pthis->len = 0; //For the first header
+ }
+ }
+}
+
+#else
+
+ //--------------------------------------------------------------------
+ //Written by Dmitry S. Obukhov, 1997
+ //dso@usa.net
+ //--------------------------------------------------------------------
+ //Modified for SDCC by Sandeep Dutta, 1999
+ //sandeep.dutta@usa.net
+ //--------------------------------------------------------------------
+ //malloc and free functions implementation for embedded system
+ //Non-ANSI keywords are C51 specific.
+ // xdata - variable in external memory (just RAM)
+ //--------------------------------------------------------------------
+
+ #define MEMHEADER struct MAH// Memory Allocation Header
+
+ MEMHEADER
+ {
+ MEMHEADER xdata * next;
+ MEMHEADER xdata * prev;
+ unsigned int len;
+ unsigned char mem;
+ };
+
+ #define HEADER_SIZE (sizeof(MEMHEADER)-1)
+
+ //Static here means: can be accessed from this module only
+ static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
+ void init_dynamic_memory(MEMHEADER xdata * array, unsigned int size)
+ {
+
+ //This function MUST be called after the RESET.
+ //Parameters: array - pointer to memory allocated by the linker
+ // size - size of this memory pool
+ //Example:
+ // #define DYNAMIC_MEMORY_SIZE 0x2000
+ // .....
+ // unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
+ // unsigned char xdata * current_buffer;
+ // .....
+ // void main(void)
+ // {
+ // ...
+ // init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
+ // Now it is possible to use malloc.
+ // ...
+ // current_buffer = malloc(0x100);
+ //
+ //
+
+ if ( !array ) /*Reserved memory starts on 0x0000 but it's NULL...*/
+ { //So, we lost one byte!
+ array = (MEMHEADER xdata * )((char xdata * ) array + 1) ;
+ size --;
+ }
+ FIRST_MEMORY_HEADER_PTR = array;
+ //Reserve a mem for last header
+ array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
+ array->next->next = (void xdata * ) NULL; //And mark it as last
+ array->prev = (void xdata * ) NULL; //and mark first as first
+ array->len = 0; //Empty and ready.
+ }
+
+ void xdata * malloc (unsigned int size)
+ {
+ register MEMHEADER xdata * current_header;
+ register MEMHEADER xdata * new_header;
+
+ if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
+ size += HEADER_SIZE; //We need a memory for header too
+ current_header = FIRST_MEMORY_HEADER_PTR;
+ while (1)
+ {
+
+ // current
+ // | len next
+ // v v v
+ //....*****.........******....
+ // ^^^^^^^^^
+ // spare
+
+ if ((((unsigned int)current_header->next) -
+ ((unsigned int)current_header) -
+ current_header->len) >= size) break; //if spare is more than need
+ current_header = current_header->next; //else try next
+ if (!current_header->next) return (void xdata *) NULL; //if end_of_list reached
+ }
+ if (!current_header->len)
+ { //This code works only for first_header in the list and only
+ current_header->len = size; //for first allocation
+ return ((xdata *)&(current_header->mem));
+ } //else create new header at the begin of spare
+ new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len);
+ new_header->next = current_header->next; //and plug it into the chain
+ new_header->prev = current_header;
+ current_header->next = new_header;
+ if (new_header->next) new_header->next->prev = new_header;
+ new_header->len = size; //mark as used
+ return ((xdata *)&(new_header->mem));
+ }
+
+ void free (void xdata * p)
+ {
+ register MEMHEADER xdata * prev_header;
+ if ( p ) //For allocated pointers only!
+ {
+ p = (MEMHEADER xdata * )((char xdata *) p - HEADER_SIZE); //to start of header
+ if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
+ {
+ prev_header = ((MEMHEADER xdata * ) p)->prev;
+ prev_header->next = ((MEMHEADER xdata * ) p)->next;
+ if (((MEMHEADER xdata * ) p)->next)
+ ((MEMHEADER xdata * ) p)->next->prev = prev_header;
+ }
+ else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
+ }
+ }
+ //END OF MODULE
+#endif
diff --git a/contiki-cpc/arch/mem.s b/contiki-cpc/arch/mem.s
new file mode 100644
index 0000000..e994238
--- /dev/null
+++ b/contiki-cpc/arch/mem.s
@@ -0,0 +1,105 @@
+ .globl _calc_free_ram
+ .globl _get_ram_start
+ .globl _get_ram_end
+ .globl __sdcc_heap_init
+
+ .area _GSINIT
+ call __sdcc_heap_init
+
+ .area _CODE
+
+_calc_free_ram::
+ push bc
+ ;; get information about BASIC ROM
+ ld c,#0x0
+ call #0xb915
+ cp #0x80
+ jr nz,gfr
+ ;; must be built in ROM
+
+ ;; v1.0 (BASIC 1.0 in CPC464)
+ ;; v1.1 (BASIC 1.1 in CPC664)
+ ;; v1.2 (BASIC 1.1 in CPC6128 and KC Compact)
+ ;; v1.4 (BASIC 1.1 in CPC+)
+
+ ld a,h
+ cp #0x1
+ ret z
+ ld a,l
+ or a
+ jr z,basic10
+
+ ;; basic 1.1
+
+ ld hl,(#0xb073)
+ inc hl
+ ld bc,(#0xb736)
+ or a
+ sbc hl,bc
+ jr nz,after_himem11
+
+ ld hl,(#0xae6c)
+ ld (ram_start),hl
+
+ ld hl,(#0xb071)
+ ld (ram_end),hl
+gfr:
+ pop bc
+ ret
+
+after_himem11:
+
+ ;; after himem
+ ld hl,(#0xb073)
+ inc hl
+ ld (ram_start),hl
+
+ ;; start of UDG
+ ld hl,(#0xb736)
+ dec hl
+ ld (ram_end),hl
+ pop bc
+ ret
+
+
+basic10:
+ ld hl,(#0xb08f)
+ inc hl
+ ld bc,(#0xb296)
+ or a
+ sbc hl,bc
+ jr nz,after_himem10
+
+ ld hl,(#0xae89)
+ ld (ram_start),hl
+
+ ld hl,(#0xb08d)
+ ld (ram_end),hl
+ pop bc
+ ret
+
+after_himem10:
+
+ ;; after himem
+ ld hl,(#0xb08f)
+ inc hl
+ ld (ram_start),hl
+
+ ;; start of UDG
+ ld hl,(#0xb296)
+ dec hl
+ ld (ram_end),hl
+ pop bc
+ ret
+
+_get_ram_start::
+ ld hl,(ram_start)
+ ret
+_get_ram_end::
+ ld hl,(ram_end)
+ ret
+
+ram_start::
+ .dw 0
+ram_end::
+ .dw 0
diff --git a/contiki-cpc/arch/putchar.s b/contiki-cpc/arch/putchar.s
new file mode 100644
index 0000000..cc98c8d
--- /dev/null
+++ b/contiki-cpc/arch/putchar.s
@@ -0,0 +1,27 @@
+;; File: putchar.s
+;; Modified to suit execution on the Amstrad CPC
+;; by H. Hansen 2003
+;; Original lines has been marked out!
+
+ .area _CODE
+_putchar::
+_putchar_rr_s::
+ ld hl,#2
+ add hl,sp
+
+ ld a,(hl)
+;; ld a,#1
+;; rst 0x08
+ call 0xBB5A
+ ret
+
+_putchar_rr_dbs::
+
+;; ld l,e
+;; ld a,#1
+;; rst 0x08
+
+ ld a,e
+ call 0xBB5A
+ ret
+
\ No newline at end of file
diff --git a/contiki-cpc/arch/uip.c b/contiki-cpc/arch/uip.c
new file mode 100644
index 0000000..76f0d0a
--- /dev/null
+++ b/contiki-cpc/arch/uip.c
@@ -0,0 +1,9 @@
+void chksumi()
+{
+}
+
+void add32i()
+{
+}
+
+
diff --git a/contiki-cpc/arch/unused/clock.c b/contiki-cpc/arch/unused/clock.c
new file mode 100644
index 0000000..caa5657
--- /dev/null
+++ b/contiki-cpc/arch/unused/clock.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock.c,v 1.1 2006/04/17 15:18:29 kthacker Exp $
+ */
+#include <time.h>
+
+clock_time_t
+clock_time(void)
+{
+ return clock();
+}
diff --git a/contiki-cpc/arch/unused/main-rrnet.c b/contiki-cpc/arch/unused/main-rrnet.c
new file mode 100644
index 0000000..0b16c87
--- /dev/null
+++ b/contiki-cpc/arch/unused/main-rrnet.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main-rrnet.c,v 1.1 2006/04/17 15:18:29 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "netconf-dsc.h"
+#include "irc-dsc.h"
+#include "dhcp-dsc.h"
+
+#include "cfs-cbm.h"
+
+#include "clock.h"
+
+#include <cbm.h>
+
+unsigned char
+uip_fw_forward(void)
+{
+ return 0;
+}
+void
+uip_fw_periodic(void)
+{
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ u16_t addr[2];
+ switch(ev) {
+ case EK_EVENT_INIT:
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+ eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+void
+log_message(char *part1, char *part2)
+{
+ while(*part1 != 0) {
+ cbm_k_bsout(*part1++);
+ }
+
+ while(*part2 != 0) {
+ cbm_k_bsout(*part2++);
+ }
+
+
+ cbm_k_bsout('\n');
+}
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+ return clock();
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_curunit(void)
+{
+ asm("lda $ba");
+ asm("sta %v", _curunit);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+void
+main(void)
+{
+
+ setup_curunit();
+
+ log_message("Starting ", CONTIKI_VERSION_STRING);
+
+ ek_init();
+
+ ek_start(&init);
+
+ log_message(": TCP/IP", "");
+
+ tcpip_init(NULL);
+
+ resolv_init(NULL);
+
+ log_message(": CTK GUI", "");
+ ctk_init();
+
+ /* log_message(": Initial filesystem", "");
+ cfs_init_init(NULL);*/
+
+ program_handler_init();
+
+ program_handler_add(&netconf_dsc, "Network config", 1);
+ program_handler_add(&dhcp_dsc, "DHCP", 1);
+ program_handler_add(&irc_dsc, "IRC", 1);
+
+
+ ctk_80col_service_init(NULL);
+ rrnet_drv_init(NULL);
+
+ log_message("Starting process scheduling", "");
+
+ while(1) {
+ ek_run();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/arch/unused/rel.s b/contiki-cpc/arch/unused/rel.s
new file mode 100644
index 0000000..6388d6c
--- /dev/null
+++ b/contiki-cpc/arch/unused/rel.s
@@ -0,0 +1,91 @@
+ .globl _relocate
+ .area _CODE
+
+;; IX = address of relocate data
+_relocate::
+ call relocate_16bit
+ call relocate_8bit ;; lower byte
+ ld c,b
+ call relocate_8bit ;; upper byte
+ ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;;
+relocate_8bit:
+ ld a,0(ix)
+ inc ix
+rel8bit: push af
+ ld e,0(ix)
+ inc ix
+ ld d,0(ix)
+inc ix
+
+ld a,(de)
+add c
+ld (de),a
+pop af
+dec a
+jr nz,rel8bit
+ret
+
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit
+;; value to relocate.
+;;
+;; BC = base address
+;;
+;; NOTE:
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix) ;; number of items to relocate
+inc ix
+
+rel16bit:
+push af
+;; get address of 16-bit value to relocate
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+
+;; get the 16-bit value
+ld a,(de)
+ld l,a
+inc de
+ld a,(de)
+ld h,a
+
+;; add base address; therefore relocating it.
+add hl,bc
+
+;; write relocated value
+ld a,h
+ld (de),a
+dec de
+ld a,l
+ld (de),a
+pop af
+dec a
+jr nz,rel16bit
+ret
+
+;;--------------------------------------------------------------------------
+
+ .area _DATA
+ .area _BSS
+ .area _GSINIT
+ .area _GSFINAL
+
+_relocate_data::
diff --git a/contiki-cpc/contiki-cpc/Makefile b/contiki-cpc/contiki-cpc/Makefile
new file mode 100644
index 0000000..7834d44
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile
@@ -0,0 +1,64 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+CONTIKI=../contiki
+
+usage:
+ @echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+ @echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+ @echo 'is one of the following:'
+ @echo all
+ @echo cpc
+ @echo cpcnet
+ @echo programs
+ @echo netprogs
+ @echo '(Also check the Makefile for more targets to try...)'
+
+all: clean cpc cpcnet programs
+
+programs:
+ $(MAKE) CONTIKI=$(CONTIKI) -f Makefile.programs
+
+netprogs:
+ $(MAKE) CONTIKI=$(CONTIKI) -f Makefile.netprogs
+
+cpc:
+ $(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc
+
+cpcnet:
+ $(MAKE) CONTIKI=$(CONTIKI) -f Makefile.cpc-net
+
+include Makefile.common
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.common b/contiki-cpc/contiki-cpc/Makefile.common
new file mode 100644
index 0000000..0c3c9e9
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.common
@@ -0,0 +1,162 @@
+CC=sdcc
+AS=as-z80
+CL=link-z80
+LD=link-z80
+
+CFLAGSCOMMON= \
+ -I apps \
+ -I conf \
+ -I ctk \
+ -I lib \
+ -I loader \
+ -I uip \
+ -I arch \
+ -I $(CONTIKI)/apps \
+ -I $(CONTIKI)/ctk \
+ -I $(CONTIKI)/ek \
+ -I $(CONTIKI)/lib \
+ -I $(CONTIKI)/ppp \
+ -I $(CONTIKI)/uip \
+ -mz80 -D__fastcall__=/**/ -D__CPC__ -DCLK_TCK=16384 \
+ --no-std-crt0 --opt-code-size --peep-file ~/peeph/peep.def
+
+CLFLAGS=
+OPT=
+AFLAGS = -o -g
+
+%.o: %.c
+ $(CC) $(CFLAGS) $(OPT) -o $*.o $<
+
+%.o: %.s
+ $(AS) $(AFLAGS) $*.o $<
+
+UIP= ../contiki/uip/uip.o \
+ uip/uip_arch.o \
+ ../contiki/uip/resolv.o \
+ ../contiki/uip/tcpip.o \
+ ../contiki/uip/uiplib.o
+
+
+# ../contiki/uip/uip-signal.o
+# ../contiki/uip/uip_main.o \
+
+
+WWW= ../contiki/apps/www.o \
+ ../contiki/apps/webclient.o \
+ ../contiki/apps/http-strings.o \
+ ../contiki/apps/http-user-agent-string.o \
+ ../contiki/apps/htmlparser.o \
+ ../contiki/apps/html-strings.o
+
+EMAIL= ../contiki/apps/email.o \
+ ../contiki/apps/smtp-socket.o \
+ ../contiki/apps/smtp-strings.o \
+ ../contiki/ctk-textedit.o \
+ ../contiki/uip/socket.o \
+ ./lib/lc-asm.o \
+ ../lib/memb.o
+
+WEBSERVER= ../contiki/apps/webserver.o ../contiki/apps/httpd.o \
+ ../contiki/apps/http-strings.o \
+ ../contiki/apps/httpd-fs.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/uipbuf.o \
+ ../contiki/apps/httpd-cgi.o \
+ ../contiki/lib/memb.o \
+ ./lib/lc-asm.o
+
+TELNET= ../contiki/apps/simpletelnet.o ../contiki/apps/telnet.o
+
+WGET= apps/wget.o ../contiki/apps/webclient.o \
+ ../contiki/apps/http-strings.o \
+ ../contiki/apps/http-user-agent-string.o
+
+clean:
+ rm -f ../arch/*.o
+ rm -f ../loader/*.o
+ rm -f ../contiki/ctk/*.o
+ rm -f ../contiki/ctk/*.asm
+ rm -f ../contiki/ctk/*.lst
+ rm -f ../contiki/ctk/*.map
+ rm -f ../contiki/ctk/*.sym
+ rm -f ../contiki/ctk/*.rst
+ rm -f ../contiki/ek/*.o
+ rm -f ../contiki/ek/*.asm
+ rm -f ../contiki/ek/*.lst
+ rm -f ../contiki/ek/*.map
+ rm -f ../contiki/ek/*.sym
+ rm -f ../contiki/ek/*.rst
+ rm -f ../contiki/lib/*.o
+ rm -f ../contiki/lib/*.asm
+ rm -f ../contiki/lib/*.lst
+ rm -f ../contiki/lib/*.map
+ rm -f ../contiki/lib/*.sym
+ rm -f ../contiki/lib/*.rst
+ rm -f ../contiki/apps/*.o
+ rm -f ../contiki/apps/*.ihx
+ rm -f ../contiki/apps/*.lnk
+ rm -f ../contiki/apps/*.asm
+ rm -f ../contiki/apps/*.lst
+ rm -f ../contiki/apps/*.sym
+ rm -f ../contiki/apps/*.prg
+ rm -f ../contiki/apps/*.dsc
+ rm -f ../contiki/apps/*.ams
+ rm -f ../contiki/apps/*.bin
+ rm -f ../contiki/apps/*.map
+ rm -f ../contiki/apps/*.rst
+ rm -f ../contiki/uip/*.o
+ rm -f ../contiki/uip/*.ihx
+ rm -f ../contiki/uip/*.lnk
+ rm -f ../contiki/uip/*.asm
+ rm -f ../contiki/uip/*.lst
+ rm -f ../contiki/uip/*.sym
+ rm -f ../contiki/uip/*.prg
+ rm -f ../contiki/uip/*.dsc
+ rm -f ../contiki/uip/*.ams
+ rm -f ../contiki/uip/*.bin
+ rm -f ./apps/*.o
+ rm -f ./apps/*.ihx
+ rm -f ./apps/*.lnk
+ rm -f ./apps/*.asm
+ rm -f ./apps/*.lst
+ rm -f ./apps/*.sym
+ rm -f ./apps/*.prg
+ rm -f ./apps/*.dsc
+ rm -f ./apps/*.ams
+ rm -f ./apps/*.bin
+ rm -f ./apps/*.map
+ rm -f ./apps/*.rst
+ rm -f ./ctk/*.o
+ rm -f ./ctk/*.ihx
+ rm -f ./ctk/*.lnk
+ rm -f ./ctk/*.asm
+ rm -f ./ctk/*.lst
+ rm -f ./ctk/*.sym
+ rm -f ./ctk/*.prg
+ rm -f ./ctk/*.dsc
+ rm -f ./ctk/*.ams
+ rm -f ./ctk/*.bin
+ rm -f ./ctk/*.map
+ rm -f ./ctk/*.rst
+ rm -f lib/*.o
+ rm -f lib/*.asm
+ rm -f lib/*.lst
+ rm -f lib/*.map
+ rm -f lib/*.sym
+ rm -f loader/*.o
+ rm -f loader/*.asm
+ rm -f loader/*.lst
+ rm -f loader/*.map
+ rm -f loader/*.sym
+ rm -f uip/*.o
+ rm -f uip/*.asm
+ rm -f uip/*.lst
+ rm -f uip/*.map
+ rm -f uip/*.sym
+ rm -f arch/*.o
+ rm -f arch/*.asm
+ rm -f arch/*.lst
+ rm -f arch/*.map
+ rm -f arch/*.sym
+
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.cpc b/contiki-cpc/contiki-cpc/Makefile.cpc
new file mode 100644
index 0000000..3f8a4d7
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.cpc
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+all: contiki
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+ -DWITH_ASCII \
+ -DCTK_CONIO \
+ -DWITH_LOADER_ARCH \
+ -DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+ ../contiki/uip/resolv.o \
+ ../contiki/uip/slipdev.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/tcpdump.o \
+ ../contiki/uip/tcpip.o \
+ ../contiki/uip/uip-fw.o \
+ ../contiki/uip/uip-fw-service.o \
+ ../contiki/uip/uip-split.o \
+ ../contiki/uip/uip.o \
+ ../contiki/uip/uip_arp.o \
+ ../contiki/uip/uiplib.o \
+ ./uip/uip_arch.o \
+ ./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+ ./loader/rel.o \
+ ./arch/key.o \
+ ./arch/mem.o \
+ ./arch/malloc.o \
+ ./arch/clock.o \
+ ./loader/dir.o \
+ ./loader/loader-arch-cpc.o \
+ ./arch/putchar.o \
+ ./arch/uip.o \
+ ./arch/conio.o \
+ ./apps/configedit.o \
+ ./apps/configedit-dsc.o \
+ ../contiki/apps/directory.o \
+ ./apps/directory-dsc.o \
+ ../contiki/apps/processes.o \
+ ../contiki/apps/processes-dsc.o \
+ ../contiki/apps/program-handler.o \
+ ../contiki/ctk/ctk.o \
+ ../contiki/ctk/ctk-conio-service.o \
+ ../contiki/ctk/ctk-draw.o \
+ ../contiki/ctk/ctk-term-in.o \
+ ../contiki/ctk/ctk-term-out.o \
+ ../contiki/ctk/ctk-term.o \
+ ../contiki/ctk/ctk-termtelnet.o \
+ ../contiki/ctk/ctk-vncfont.o \
+ ../contiki/ctk/vnc-server.o \
+ ../contiki/ek/ek-service.o \
+ ../contiki/ek/ek.o \
+ ../contiki/ek/arg.o \
+ ../contiki/ek/mt.o \
+ ../contiki/lib/cfs.o \
+ ../contiki/lib/ctk-filedialog.o \
+ ../contiki/lib/ctk-textedit.o \
+ ../contiki/lib/list.o \
+ ../contiki/lib/memb.o \
+ ../contiki/lib/timer.o \
+ ../contiki/lib/strncasecmp.o \
+ ./loader/cfs-cpc.o \
+ ./arch/main.o \
+ ./arch/arch.o \
+ $(UIP)
+
+
+contiki: $(CONTIKI_OBJ)
+ $(LD) -f arch/contiki.lnk
+ ./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+ ./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+ ./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+ ./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.cpc-net b/contiki-cpc/contiki-cpc/Makefile.cpc-net
new file mode 100644
index 0000000..f76aee2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.cpc-net
@@ -0,0 +1,112 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.cpc-net,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+
+all: contikin
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+ -DWITH_ASCII \
+ -DCTK_CONIO \
+ -DWITH_LOADER_ARCH \
+ -DWITH_LOADER_ARCH=1
+
+UIP_OBJ = ../contiki/uip/dhcpc.o \
+ ../contiki/uip/resolv.o \
+ ../contiki/uip/slipdev.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/tcpdump.o \
+ ../contiki/uip/tcpip.o \
+ ../contiki/uip/uip-fw.o \
+ ../contiki/uip/uip-fw-service.o \
+ ../contiki/uip/uip-split.o \
+ ../contiki/uip/uip.o \
+ ../contiki/uip/uip_arp.o \
+ ../contiki/uip/uiplib.o \
+ ./uip/uip_arch.o \
+ ./lib/lc-asm.o
+
+
+CONTIKI_OBJ= ./arch/crt0.o \
+ ./loader/rel.o \
+ ./arch/key.o \
+ ./arch/mem.o \
+ ./arch/malloc.o \
+ ./arch/clock.o \
+ ./loader/dir.o \
+ ./loader/loader-arch-cpc.o \
+ ./arch/putchar.o \
+ ./arch/uip.o \
+ ./arch/conio.o \
+ ./apps/configedit.o \
+ ./apps/configedit-dsc.o \
+ ../contiki/apps/directory.o \
+ ./apps/directory-dsc.o \
+ ../contiki/apps/processes.o \
+ ../contiki/apps/processes-dsc.o \
+ ../contiki/apps/program-handler.o \
+ ../contiki/ctk/ctk.o \
+ ../contiki/ctk/ctk-conio-service.o \
+ ../contiki/ctk/ctk-draw.o \
+ ../contiki/ctk/ctk-term-in.o \
+ ../contiki/ctk/ctk-term-out.o \
+ ../contiki/ctk/ctk-term.o \
+ ../contiki/ctk/ctk-termtelnet.o \
+ ../contiki/ctk/ctk-vncfont.o \
+ ../contiki/ctk/vnc-server.o \
+ ../contiki/ek/ek-service.o \
+ ../contiki/ek/ek.o \
+ ../contiki/ek/arg.o \
+ ../contiki/ek/mt.o \
+ ../contiki/lib/cfs.o \
+ ../contiki/lib/ctk-filedialog.o \
+ ../contiki/lib/ctk-textedit.o \
+ ../contiki/lib/list.o \
+ ../contiki/lib/memb.o \
+ ../contiki/lib/timer.o \
+ ../contiki/lib/strncasecmp.o \
+ ./loader/cfs-cpc.o \
+ ./arch/main.o \
+ ./arch/arch.o \
+ $(UIP)
+
+
+contikin: $(CONTIKI_OBJ)
+ $(LD) -f arch/contiki-uip.lnk
+ ./bin/make_labels -a _CODE -a _DATA -x _main -x __clock -x _exit contiki.map arch/contiki_labels.s
+ ./bin/makebin -p -b 256 -s 65535 < contiki.ihx > temp/contiki.bin
+ ./bin/addhead -s 256 -t "binary" -x 256 temp/contiki.bin temp/contiki_ams.bin
+ ./bin/cpcxfs contiki.dsk -f -b -p temp/contiki_ams.bin contiki.bin
+
diff --git a/contiki-cpc/contiki-cpc/Makefile.netprogs b/contiki-cpc/contiki-cpc/Makefile.netprogs
new file mode 100644
index 0000000..e05a810
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.netprogs
@@ -0,0 +1,242 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.netprogs,v 1.1 2006/04/17 15:11:35 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+ ../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+ ../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+ ../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+ ../contiki/apps/email.prg ../contiki/apps/email.dsc \
+ ../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+ ../contiki/apps/wget.dsc \
+ ../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+# ../contiki/apps/irc.prg ../contiki/apps/irc.dsc
+# ../contiki/apps/wget.prg
+# ../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: ./arch/crt0-dsc.o \
+ ./arch/crt0-prg.o \
+ ./arch/contiki_labels.o \
+ ./loader/loader-arch-module.o \
+ $(UIP_PRGS)
+
+SYS=cpc
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+ -DWITH_ASCII \
+ -DWITH_CONIO \
+ -DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+ bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+ $(LD) -f $@.lnk
+ bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+ bin/addhead $@.bin $@.bin.ams
+ bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef
+
+%.dsc: %-dsc.o
+ $(MAKE_DSC)
+
+define MAKE_PRG
+ bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+ $(LD) -f $@.lnk
+ bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+ bin/addhead $@.bin $@.bin.ams
+ bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+ ../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+ $(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+ $(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+ $(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+ $(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+ $(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+ $(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+ $(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+ $(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/uipbuf.o \
+ lib/lc-asm.o
+ $(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+ $(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+ ../contiki/lib/ctk-filedialog.o \
+ ../contiki/lib/memb.o
+ $(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+ ../contiki/lib/ctk-textedit.o \
+ ../contiki/apps/smtp-socket.o \
+ ../contiki/apps/smtp-strings.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/uipbuf.o \
+ ./lib/lc-asm.o
+ $(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+ ../contiki/apps/ftpc.o \
+ ../contiki/lib/memb.o
+ $(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+ $(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+ $(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+ $(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+ $(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ ../contiki/apps/shell.o \
+ ../contiki/lib/memb.o \
+ ../contiki/apps/telnetd-gui.o
+ $(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+ $(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+ $(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+ $(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+ $(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+ ../contiki/apps/vnc-viewer.o \
+ ./apps/vnc-draw.o
+
+../contiki/apps/conio.prg: \
+ ../contiki/ctk/ctk-conio-service.o \
+ ./arch/conio.o
+ $(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+ $(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+# cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+ $(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+ $(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/contiki-cpc/Makefile.programs b/contiki-cpc/contiki-cpc/Makefile.programs
new file mode 100644
index 0000000..8e98e91
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/Makefile.programs
@@ -0,0 +1,263 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.1 2006/04/17 15:11:36 kthacker Exp $
+#
+# convert to cpc
+
+UIP_PRGS = ../contiki/apps/www.prg ../contiki/apps/www.dsc \
+ ../contiki/apps/websrv.prg ../contiki/apps/websrv.dsc \
+ ../contiki/apps/stelnet.prg ../contiki/apps/stelnet.dsc \
+ ../contiki/apps/ftp.prg ../contiki/apps/ftp.dsc \
+ ../contiki/apps/email.prg ../contiki/apps/email.dsc \
+ ../contiki/apps/dhcp.prg ../contiki/apps/dhcp.dsc \
+ ../contiki/apps/wget.dsc \
+ ../contiki/apps/vnc.prg ../contiki/apps/vnc.dsc \
+# ../contiki/apps/irc.prg ../contiki/apps/irc.dsc
+# ../contiki/apps/wget.prg
+# ../contiki/apps/telnetd.prg ../contiki/apps/telnetd.dsc \
+
+
+
+all: ./arch/crt0-dsc.o \
+ ./arch/crt0-prg.o \
+ ./arch/contiki_labels.o \
+ ./loader/loader-arch-module.o \
+ ./apps/welcome.prg \
+ ../contiki/apps/conio.prg \
+ ../contiki/apps/about.prg ../contiki/apps/about.dsc \
+ ../contiki/apps/netconf.prg ../contiki/apps/netconf.dsc \
+ ../contiki/apps/process.prg ../contiki/apps/process.dsc \
+ ../contiki/apps/calc.prg ../contiki/apps/calc.dsc \
+ ../contiki/apps/editor.prg ../contiki/apps/editor.dsc \
+ ../contiki/apps/dir.prg ./apps/dir.dsc \
+ ./apps/config.prg \
+ ./apps/confedit.prg \
+ ./apps/confedit.dsc \
+ ../contiki/apps/shell.prg ../contiki/apps/shell.dsc
+# $(UIP_PRGS) \
+
+# ./cfs-cpc.drv \
+# ./ctk-text.drv \
+# ./ctk-default.drv \
+# ./ctk-80col.drv \
+# ./slip.drv slip.dsc \
+# ./cgterm.prg cgterm.dsc \
+
+# ./apps/memstat.prg ./apps/memstat.dsc \
+
+SYS=cpc
+
+include Makefile.common
+
+CFLAGS:=$(CFLAGSCOMMON) --compile-only \
+ -DWITH_ASCII \
+ -DWITH_CONIO \
+ -DWITH_LOADER_ARCH
+
+
+# conversion of intel hex record to binary, cpc binary with header, then inject into disc image
+define MAKE_DSC
+ bin/makelnk -r -o $@.ihx arch/crt0-prg.o $< > $@.lnk
+ $(LD) -f $@.lnk
+ bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+ bin/addhead $@.bin $@.bin.ams
+ bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef
+
+%.dsc: %-dsc.o
+ $(MAKE_DSC)
+
+define MAKE_PRG
+ bin/makelnk -r -m -o $@.ihx -k /usr/local/share/sdcc/lib/z80 -l z80 arch/crt0-prg.o loader/loader-arch-module.o arch/contiki_labels.o $^ > $@.lnk
+ $(LD) -f $@.lnk
+ bin/makebin -p -b 0 -s 65535 < $@.ihx > $@.bin
+ bin/addhead $@.bin $@.bin.ams
+ bin/cpcxfs contiki.dsk -f -b -p $@.bin.ams $(@F)
+endef
+
+../contiki/apps/irc.prg: ../contiki/apps/ircc.o ../contiki/apps/ircc-strings.o \
+ ../contiki/apps/irc.o ../contiki/uip/socket.o ../contiki/uip/uipbuf.o
+ $(MAKE_PRG)
+
+../contiki/apps/irc.dsc: ../contiki/apps/irc-dsc.o
+ $(MAKE_DSC)
+
+./apps/config.prg: apps/config.o
+ $(MAKE_PRG)
+
+./apps/confedit.prg: apps/configedit.o
+ $(MAKE_PRG)
+
+./apps/confedit.dsc: apps/configedit-dsc.o
+ $(MAKE_DSC)
+
+./apps/welcome.prg: apps/welcome.o
+ $(MAKE_PRG)
+
+../contiki/apps/about.prg: ../contiki/apps/about.o
+ $(MAKE_PRG)
+
+../contiki/apps/calc.prg: ../contiki/apps/calc.o
+ $(MAKE_PRG)
+
+./apps/cgterm.prg: ./apps/cgterm.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/uipbuf.o \
+ lib/lc-asm.o
+ $(MAKE_PRG)
+
+./apps/cgterm.dsc: ./apps/cgterm-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/dhcp.prg: ../contiki/apps/dhcp.o ../contiki/uip/dhcpc.o ./lib/lc-asm.o
+ $(MAKE_PRG)
+
+../contiki/apps/editor.prg: ../contiki/apps/editor.o \
+ ../contiki/lib/ctk-filedialog.o \
+ ../contiki/lib/memb.o
+ $(MAKE_PRG)
+
+../contiki/apps/email.prg: ../contiki/apps/email.o \
+ ../contiki/lib/ctk-textedit.o \
+ ../contiki/apps/smtp-socket.o \
+ ../contiki/apps/smtp-strings.o \
+ ../contiki/uip/socket.o \
+ ../contiki/uip/uipbuf.o \
+ ./lib/lc-asm.o
+ $(MAKE_PRG)
+
+../contiki/apps/ftp.prg: ../contiki/apps/ftp.o \
+ ../contiki/apps/ftpc.o \
+ ../contiki/lib/memb.o
+ $(MAKE_PRG)
+
+../contiki/apps/netconf.prg: ../contiki/apps/netconf.o
+ $(MAKE_PRG)
+
+../contiki/apps/process.prg: ../contiki/apps/processes.o
+ $(MAKE_PRG)
+
+../contiki/apps/process.dsc: ../contiki/apps/processes-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/dir.prg: ../contiki/apps/directory.o
+ $(MAKE_PRG)
+
+./apps/dir.dsc: ./apps/directory-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/shell.prg: ../contiki/apps/shell-gui.o ./apps/shell.o
+ $(MAKE_PRG)
+
+../contiki/apps/telnetd.prg: ../contiki/apps/telnetd.o \
+ ../contiki/apps/shell.o \
+ ../contiki/lib/memb.o \
+ ../contiki/apps/telnetd-gui.o
+ $(MAKE_PRG)
+
+../contiki/apps/telnetd.dsc: telnetd-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/www.prg: $(WWW)
+ $(MAKE_PRG)
+
+../contiki/apps/websrv.prg: $(WEBSERVER)
+ $(MAKE_PRG)
+
+../contiki/apps/websrv.dsc: ../contiki/apps/webserver-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/stelnet.prg: $(TELNET)
+ $(MAKE_PRG)
+
+../contiki/apps/stelnet.dsc: ../contiki/apps/telnet-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/wget.prg: $(WGET)
+ $(MAKE_PRG)
+
+../contiki/apps/wget.dsc: apps/wget-dsc.o
+ $(MAKE_DSC)
+
+../contiki/apps/splip.drv: slip-drv.o rs232dev.o
+
+
+VNC=../contiki/apps/vnc.o \
+ ../contiki/apps/vnc-viewer.o \
+ ./apps/vnc-draw.o
+
+../contiki/apps/conio.prg: \
+ ../contiki/ctk/ctk-conio-service.o \
+ ./arch/conio.o
+ $(MAKE_PRG)
+
+#ctk-text.drv: ctk-conio-service.o
+
+ctk-80col.drv: ctk-80col.o
+
+ctk-default.drv: ctk-hires-service.o
+
+default.prg: themeloader.o ctk-hires-theme-default.o
+
+
+
+../contiki/apps/vnc.prg: $(VNC)
+ $(MAKE_PRG)
+
+#blueround.prg: themeloader.o ctk-hires-theme-blueround.o contiki-labels.o
+# cl65 --module -t c64 -o $@ loader-arch-module.o $^
+
+#default.prg: themeloader.o ctk-hires-theme-default.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#enabler.prg: themeloader.o ctk-hires-theme-enabler.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#springlight.prg: themeloader.o ctk-hires-theme-springlight.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+#ravenpine.prg: themeloader.o ctk-hires-theme-ravenpine.o contiki-labels.o
+# cl65 -Ln default-prg.labels --module -t c64 -o $@ loader-arch-module.o $^
+
+
+
+
+./apps/memstat.prg: apps/memstat.o
+ $(MAKE_PRG)
+
+./apps/memstat.dsc: apps/memstat-dsc.o
+ $(MAKE_DSC)
+
+mtest.prg: mtest.o mtp.o mt.o mtarch.o mtarch-asm.o
+
+lc-test: lc-test.o lc-asm.o
diff --git a/contiki-cpc/contiki-cpc/README b/contiki-cpc/contiki-cpc/README
new file mode 100644
index 0000000..854e27f
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/README
@@ -0,0 +1,2 @@
+This is the Amstrad CPC port of Contiki, maintained by Kevin Thacker
+<amstrad@aiind.upv.es>
diff --git a/contiki-cpc/contiki-cpc/arch/contiki_labels.s b/contiki-cpc/contiki-cpc/arch/contiki_labels.s
new file mode 100644
index 0000000..8192104
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/contiki_labels.s
@@ -0,0 +1,346 @@
+__jpbc == 0x0107
+_kbhit == 0x0109
+_cgetc == 0x0115
+_calc_free_ram == 0x011B
+_get_ram_start == 0x0183
+_get_ram_end == 0x0187
+ram_start == 0x018B
+ram_end == 0x018D
+__sdcc_heap_init == 0x018F
+__sdcc_heap_init_start == 0x018F
+__sdcc_heap_init_end == 0x021B
+_malloc == 0x021B
+_malloc_start == 0x021B
+_free == 0x0366
+_free_start == 0x0366
+_malloc_end == 0x0366
+_free_end == 0x03CE
+__clock_init == 0x03CE
+event_routine == 0x03DC
+__clock_val == 0x03E6
+event_block == 0x03E8
+_loader_arch_load == 0x03F1
+_loader_arch_load_start == 0x03F1
+_loader_arch_load_end == 0x0455
+_loader_arch_load_dsc == 0x0455
+_loader_arch_load_dsc_start == 0x0455
+_loader_arch_load_dsc_end == 0x04A7
+_loader_arch_free == 0x04A7
+_loader_arch_free_start == 0x04A7
+_loader_arch_free_end == 0x04BF
+_loader_arch_free_dsc == 0x04BF
+_loader_arch_free_dsc_start == 0x04BF
+_loader_arch_free_dsc_end == 0x04D7
+_get_file_length == 0x04D7
+_load_file == 0x04FB
+_relocate == 0x0519
+_cfs_cpc_init == 0x05B8
+_cfs_cpc_init_start == 0x05B8
+_cfs_cpc_init_end == 0x05DB
+_cfs_find_service == 0x08B2
+_cfs_find_service_start == 0x08B2
+_cfs_find_service_end == 0x08CE
+__readdir == 0x08E8
+fetch_directory == 0x0901
+_program_handler_add == 0x091D
+_program_handler_add_start == 0x091D
+_program_handler_add_end == 0x0977
+_program_handler_init == 0x0A59
+_program_handler_init_start == 0x0A59
+_program_handler_init_end == 0x0AB0
+_pnarg_init == 0x0AB8
+_pnarg_init_start == 0x0AB8
+_pnarg_init_end == 0x0ACB
+_program_handler_load == 0x0B62
+_program_handler_load_start == 0x0B62
+_program_handler_load_end == 0x0BA9
+_program_handler_screensaver == 0x0BB7
+_program_handler_screensaver_sta == 0x0BB7
+_program_handler_screensaver_end == 0x0BE6
+_ctk_restore == 0x109A
+_ctk_restore_start == 0x109A
+_ctk_init_start == 0x10BF
+_ctk_restore_end == 0x10BF
+_ctk_init == 0x10BF
+_ctk_init_end == 0x11F2
+_ctk_mode_set == 0x11FA
+_ctk_mode_set_start == 0x11FA
+_ctk_mode_get == 0x120F
+_ctk_mode_get_start == 0x120F
+_ctk_mode_set_end == 0x120F
+_ctk_mode_get_end == 0x1217
+_ctk_icon_add == 0x1217
+_ctk_icon_add_start == 0x1217
+_ctk_dialog_open == 0x1243
+_ctk_icon_add_end == 0x1243
+_ctk_dialog_open_start == 0x1243
+_ctk_dialog_open_end == 0x126A
+_ctk_dialog_close == 0x126A
+_ctk_dialog_close_start == 0x126A
+_ctk_window_open == 0x1283
+_ctk_window_open_start == 0x1283
+_ctk_dialog_close_end == 0x1283
+_ctk_window_close == 0x139C
+_ctk_window_close_start == 0x139C
+_ctk_window_open_end == 0x139C
+_ctk_window_close_end == 0x14CB
+_ctk_window_clear_start == 0x163B
+_ctk_window_clear == 0x163B
+_ctk_menu_add_start == 0x1695
+_ctk_window_clear_end == 0x1695
+_ctk_menu_add == 0x1695
+_ctk_menu_add_end == 0x1707
+_ctk_menu_remove == 0x1707
+_ctk_menu_remove_start == 0x1707
+_ctk_menu_remove_end == 0x178B
+_ctk_desktop_redraw == 0x18E0
+_ctk_desktop_redraw_start == 0x18E0
+_ctk_window_redraw_start == 0x192F
+_ctk_desktop_redraw_end == 0x192F
+_ctk_window_redraw == 0x192F
+_ctk_window_redraw_end == 0x19AC
+_ctk_window_new == 0x1B5F
+_ctk_window_new_start == 0x1B5F
+_ctk_window_new_end == 0x1B93
+_ctk_dialog_new == 0x1B93
+_ctk_dialog_new_start == 0x1B93
+_ctk_menu_new == 0x1BB9
+_ctk_menu_new_start == 0x1BB9
+_ctk_dialog_new_end == 0x1BB9
+_ctk_menuitem_add == 0x1C1B
+_ctk_menu_new_end == 0x1C1B
+_ctk_menuitem_add_start == 0x1C1B
+_ctk_menuitem_add_end == 0x1C9E
+_ctk_widget_redraw == 0x1DCD
+_ctk_widget_redraw_start == 0x1DCD
+_ctk_widget_add == 0x1DF7
+_ctk_widget_add_start == 0x1DF7
+_ctk_widget_redraw_end == 0x1DF7
+_ctk_desktop_width_start == 0x1EA6
+_ctk_widget_add_end == 0x1EA6
+_ctk_desktop_width == 0x1EA6
+_ctk_desktop_width_end == 0x1EB4
+_ctk_desktop_height == 0x1EB4
+_ctk_desktop_height_start == 0x1EB4
+_ctk_desktop_height_end == 0x1EC2
+_ctk_draw_init == 0x2EFD
+_ctk_draw_init_start == 0x2EFD
+_ctk_draw_clear == 0x2F46
+_ctk_draw_init_end == 0x2F46
+_ctk_draw_clear_start == 0x2F46
+_ctk_draw_clear_window == 0x2F79
+_ctk_draw_clear_window_start == 0x2F79
+_ctk_draw_clear_end == 0x2F79
+_ctk_draw_clear_window_end == 0x2FBA
+_ctk_draw_window == 0x2FBA
+_ctk_draw_window_start == 0x2FBA
+_ctk_draw_dialog_start == 0x2FFB
+_ctk_draw_window_end == 0x2FFB
+_ctk_draw_dialog == 0x2FFB
+_ctk_draw_widget == 0x302B
+_ctk_draw_dialog_end == 0x302B
+_ctk_draw_widget_start == 0x302B
+_ctk_draw_menus_start == 0x306C
+_ctk_draw_widget_end == 0x306C
+_ctk_draw_menus == 0x306C
+_ctk_draw_menus_end == 0x309C
+_ctk_draw_width == 0x309C
+_ctk_draw_width_start == 0x309C
+_ctk_draw_width_end == 0x30BE
+_ctk_draw_height == 0x30BE
+_ctk_draw_height_start == 0x30BE
+_ctk_mouse_xtoc == 0x30E0
+_ctk_mouse_xtoc_start == 0x30E0
+_ctk_draw_height_end == 0x30E0
+_ctk_mouse_ytoc == 0x3115
+_ctk_mouse_ytoc_start == 0x3115
+_ctk_mouse_xtoc_end == 0x3115
+_ctk_draw_quit == 0x314A
+_ctk_mouse_ytoc_end == 0x314A
+_ctk_draw_quit_start == 0x314A
+_ctk_draw_quit_end == 0x3168
+_ek_service_start == 0x3173
+_ek_service_start_start == 0x3173
+_ek_service_find_start == 0x31B2
+_ek_service_start_end == 0x31B2
+_ek_service_find == 0x31B2
+_ek_service_state_start == 0x31DF
+_ek_service_find_end == 0x31DF
+_ek_service_state == 0x31DF
+_ek_service_reset == 0x3229
+_ek_service_reset_start == 0x3229
+_ek_service_state_end == 0x3229
+_ek_service_reset_end == 0x323F
+_ek_alloc_event == 0x323F
+_ek_alloc_event_start == 0x323F
+_ek_alloc_event_end == 0x324A
+_ek_start_start == 0x3369
+_ek_start == 0x3369
+_ek_exit == 0x33F8
+_ek_start_end == 0x33F8
+_ek_exit_start == 0x33F8
+_ek_process == 0x352B
+_ek_process_start == 0x352B
+_ek_exit_end == 0x352B
+_ek_init == 0x3558
+_ek_init_start == 0x3558
+_ek_process_end == 0x3558
+_ek_process_event == 0x35AC
+_ek_init_end == 0x35AC
+_ek_process_event_start == 0x35AC
+_ek_process_poll == 0x3743
+_ek_process_event_end == 0x3743
+_ek_process_poll_start == 0x3743
+_ek_run == 0x378B
+_ek_run_start == 0x378B
+_ek_process_poll_end == 0x378B
+_ek_post == 0x37AD
+_ek_post_start == 0x37AD
+_ek_run_end == 0x37AD
+_ek_post_synch == 0x3828
+_ek_post_synch_start == 0x3828
+_ek_post_end == 0x3828
+_ek_post_synch_end == 0x3887
+_ek_find == 0x3887
+_ek_find_start == 0x3887
+_ek_find_end == 0x38F2
+_ek_replace == 0x38F2
+_ek_replace_start == 0x38F2
+_ek_replace_end == 0x394A
+_ek_procstate == 0x394A
+_ek_procstate_start == 0x394A
+_ek_procstate_end == 0x397F
+_arg_init == 0x397F
+_arg_init_start == 0x397F
+_arg_init_end == 0x3986
+_arg_alloc == 0x3986
+_arg_alloc_start == 0x3986
+_arg_alloc_end == 0x39A4
+_arg_free == 0x39A4
+_arg_free_start == 0x39A4
+_arg_free_end == 0x39C5
+_list_init == 0x39C5
+_list_init_start == 0x39C5
+_list_init_end == 0x39E1
+_list_head == 0x39E1
+_list_head_start == 0x39E1
+_list_copy_start == 0x39FD
+_list_head_end == 0x39FD
+_list_copy == 0x39FD
+_list_copy_end == 0x3A22
+_list_tail == 0x3A22
+_list_tail_start == 0x3A22
+_list_add == 0x3A54
+_list_add_start == 0x3A54
+_list_tail_end == 0x3A54
+_list_push_start == 0x3A95
+_list_add_end == 0x3A95
+_list_push == 0x3A95
+_list_push_end == 0x3AC0
+_list_chop == 0x3AC0
+_list_chop_start == 0x3AC0
+_list_pop == 0x3B46
+_list_pop_start == 0x3B46
+_list_chop_end == 0x3B46
+_list_pop_end == 0x3B71
+_timer_set == 0x3B71
+_timer_set_start == 0x3B71
+_timer_set_end == 0x3B9D
+_timer_reset == 0x3B9D
+_timer_reset_start == 0x3B9D
+_timer_expired == 0x3BBA
+_timer_reset_end == 0x3BBA
+_timer_expired_start == 0x3BBA
+_timer_expired_end == 0x3C04
+_directory_dsc == 0x3C04
+_directory_icon == 0x3C5D
+_configedit_dsc == 0x3C90
+_configedit_icon == 0x3CE9
+_processes_dsc == 0x3D2F
+_processes_icon == 0x3D88
+_uip_fw_forward_start == 0x3DC2
+_uip_fw_forward == 0x3DC2
+_uip_fw_forward_end == 0x3DC5
+_uip_fw_periodic == 0x3DC5
+_uip_fw_periodic_start == 0x3DC5
+_uip_fw_periodic_end == 0x3DC6
+_main_start == 0x3DEF
+_main_end == 0x3E48
+_reset == 0x3E68
+_reset_start == 0x3E68
+_reset_end == 0x3E69
+_clock_time_start == 0x3E6E
+_clock_time == 0x3E6E
+_ctk_arch_isprint == 0x3E72
+_clock_time_end == 0x3E72
+_ctk_arch_isprint_start == 0x3E72
+_ctk_arch_isprint_end == 0x3E8D
+_strcpy == 0x3E8D
+_strcpy_start == 0x3E8D
+_strcpy_end == 0x3EB2
+__divschar_rrx_s == 0x3EB2
+__divschar_rrx_hds == 0x3EB9
+__modschar_rrx_s == 0x3EC0
+__modschar_rrx_hds == 0x3EC7
+__divsint_rrx_s == 0x3ECE
+__divsint_rrx_hds == 0x3EDA
+__modsint_rrx_s == 0x3EE2
+__modsint_rrx_hds == 0x3EEE
+__divuchar_rrx_s == 0x3EF6
+__divuchar_rrx_hds == 0x3EFD
+__moduchar_rrx_s == 0x3F04
+__moduchar_rrx_hds == 0x3F0B
+__divuint_rrx_s == 0x3F12
+__divuint_rrx_hds == 0x3F1E
+__moduint_rrx_s == 0x3F26
+__moduint_rrx_hds == 0x3F32
+.mod8 == 0x3F3A
+.div8 == 0x3F3A
+.mod16 == 0x3F42
+.div16 == 0x3F42
+.modu8 == 0x3F7F
+.divu8 == 0x3F7F
+.modu16 == 0x3F82
+.divu16 == 0x3F82
+_strncmp == 0x3FB3
+_strncmp_start == 0x3FB3
+_strncmp_end == 0x4040
+_isprint == 0x4040
+_isprint_start == 0x4040
+_isprint_end == 0x4062
+_memset == 0x4062
+_memset_start == 0x4062
+_memset_end == 0x40AA
+__mulschar_rrx_s == 0x40AA
+__mulschar_rrx_hds == 0x40B1
+__muluchar_rrx_s == 0x40BD
+__mulint_rrx_s == 0x40CA
+__mulint_rrx_hds == 0x40D6
+__muluchar_rrx_hds == 0x40D6
+_strncpy == 0x40EF
+_strncpy_start == 0x40EF
+_strncpy_end == 0x415E
+_strlen_start == 0x415E
+_strlen == 0x415E
+_strlen_end == 0x417E
+_ctk_signal_keypress == 0x439D
+_ctk_signal_widget_activate == 0x439E
+_ctk_signal_button_activate == 0x439F
+_ctk_signal_widget_select == 0x43A0
+_ctk_signal_button_hover == 0x43A1
+_ctk_signal_hyperlink_activate == 0x43A2
+_ctk_signal_hyperlink_hover == 0x43A3
+_ctk_signal_menu_activate == 0x43A4
+_ctk_signal_window_close == 0x43A5
+_ctk_signal_pointer_move == 0x43A6
+_ctk_signal_pointer_button == 0x43A7
+_ctk_screensaver_timeout == 0x43AA
+_ctk_draw_windowborder_width == 0x43BC
+_ctk_draw_windowborder_height == 0x43BD
+_ctk_draw_windowtitle_height == 0x43BE
+_ek_procs == 0x43C2
+_ek_proclist == 0x43C4
+_ek_current == 0x4404
+_ek_event_quit == 0x4406
+_ek_event_msg == 0x4407
+_ek_poll_request == 0x448B
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-backup.s b/contiki-cpc/contiki-cpc/arch/crt0-backup.s
new file mode 100644
index 0000000..b014aa8
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-backup.s
@@ -0,0 +1,33 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+ .module crt0
+ .globl _main
+ .globl _progend
+ .area _HEADER (ABS)
+ .org 0x100 ;; Start from address &100
+init:
+
+;; Initialise global variables
+ call gsinit
+ call _main
+
+_exit::
+ ret
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _CODE
+ .area _DATA
+ .area _BSS
+
+ .area _GSINIT
+gsinit::
+
+ .area _GSFINAL
+ ret
+ .area _HEAP
+_progend::
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-dsc.s b/contiki-cpc/contiki-cpc/arch/crt0-dsc.s
new file mode 100644
index 0000000..381bc27
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-dsc.s
@@ -0,0 +1,26 @@
+;; File: crt0-dsc.s
+
+ .module crt0
+ .globl _main
+
+ .area _HEADER (REL)
+;; .org 0x100 ;; Start from address &100
+
+init:
+_main:
+ ;; Ordering of segments for the linker.
+ .area _HOME (REL)
+ .area _CODE (REL)
+ .area _GSINIT (REL)
+ .area _GSFINAL (REL)
+
+ .area _DATA (REL)
+ .area _BSS (REL)
+ .area _HEAP (REL)
+
+ .area _CODE (REL)
+
+_exit::
+ .area _GSINIT (REL)
+gsinit::
+ .area _GSFINAL (REL)
diff --git a/contiki-cpc/contiki-cpc/arch/crt0-prg.s b/contiki-cpc/contiki-cpc/arch/crt0-prg.s
new file mode 100644
index 0000000..8984742
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0-prg.s
@@ -0,0 +1,16 @@
+;; File: crt0-dsc.s
+
+ .module crt0
+ .area _HEADER (ABS)
+ .area _HOME (REL)
+ .area _CODE (REL)
+ ;; relocation data
+ .dw 0
+ .area _DATA (REL)
+ .area _BSS (REL)
+ .area _HEAP (REL)
+
+ .area _GSINIT (REL)
+gsinit::
+ .area _GSFINAL (REL)
+ ret
diff --git a/contiki-cpc/contiki-cpc/arch/crt0.s b/contiki-cpc/contiki-cpc/arch/crt0.s
new file mode 100644
index 0000000..a8aafdb
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/crt0.s
@@ -0,0 +1,35 @@
+;; File: crt0.s
+;; Generic crt0.s for a Z80
+;; From SDCC..
+;; Modified to suit execution on the Amstrad CPC!
+;; by H. Hansen 2003
+
+ .module crt0
+ .globl _main
+ .globl _progend
+ .globl __jpbc
+ .area _HEADER (ABS)
+ ;; Ordering of segments for the linker.
+ .area _CODE
+init:
+
+;; Initialise global variables
+ call gsinit
+ call _main
+
+_exit::
+ ret
+__jpbc:
+ push bc
+ ret
+
+ .area _DATA (REL)
+ .area _BSS (REL)
+
+ .area _GSINIT (REL)
+gsinit::
+
+ .area _GSFINAL (REL)
+ ret
+ .area _HEAP (REL)
+_progend::
diff --git a/contiki-cpc/contiki-cpc/arch/hires.s b/contiki-cpc/contiki-cpc/arch/hires.s
new file mode 100644
index 0000000..c482768
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/hires.s
@@ -0,0 +1,101 @@
+;; Hires:
+;;
+;; Mode 0, 40 columns. Each character is 4 pixels wide and 8 pixels tall.
+;; Each character is two bytes wide and 8 lines tall.
+;;
+;; The graphics for each character is a bitmap defined using
+;; pen 0 and pen 15.
+;;
+;; The bitmap is processed at runtime to convert the font to the
+;; appropiate pixel colours.
+ .area _CODE
+;; This table converts between pen index (0-15) and pixel bitmap.
+.pen_table
+defb #00 ;; pen 0 (%00000000)
+defb #c0 ;; pen 1 (%11000000)
+defb #0c ;; pen 2 (%00001100)
+defb #cc ;; pen 3 (%11001100)
+defb #30 ;; pen 4 (%00110000)
+defb #f0 ;; pen 5 (%11110000)
+defb #3c ;; pen 6 (%00111100)
+defb #fc ;; pen 7 (%11111100)
+defb #03 ;; pen 8 (%00000011)
+defb #c3 ;; pen 9 (%11000011)
+defb #0f ;; pen 10 (%00001111)
+defb #cf ;; pen 11 (%11001111)
+defb #33 ;; pen 12 (%00110011)
+defb #f3 ;; pen 13 (%11110011)
+defb #3f ;; pen 14 (%00111111)
+defb #ff ;; pen 15 (%11111111)
+
+;; A = pen
+.get_pen_mask
+ld hl,pen_table
+add a,l
+ld l,a
+ld a,h
+adc a,0
+ld h,a
+ld a,(hl)
+ret
+
+.set_pen
+call get_pen_mask
+ld (pen_mask+1),a
+ld (pen_mask2+1),a
+ret
+
+.set_paper
+call get_pen_mask
+ld (paper_mask+1),a
+ld (paper_mask2+1),a
+ret
+
+;; enter:
+;; HL = current memory address
+;; exit:
+;; HL = memory address of byte immediatly below
+;; AF corrupt.
+.scr_next_line
+ld a,h
+add a,8
+ld h,a
+ret nc
+ld a,l
+add a,&50
+ld l,a
+ld a,h
+adc a,&c0
+ld h,a
+ret
+
+;; enter:
+;; HL = screen address
+;; DE = character pixel graphics
+;; exit:
+;; AF, BC, HL, DE corrupt
+.plot_char
+ld b,8
+.pc1
+ld a,(de) ;; convert 'on' pixels
+.pen_mask and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask and 1
+or c
+ld (hl),a
+inc l
+ld a,(de)
+.pen_mask2 and 1
+ld c,a
+ld a,(de)
+cpl
+.paper_mask2 and 1
+or c
+ld (hl),a
+dec l
+call scr_next_line
+djnz pc1
+ret
+
diff --git a/contiki-cpc/contiki-cpc/arch/key.s b/contiki-cpc/contiki-cpc/arch/key.s
new file mode 100644
index 0000000..8ca55ad
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/key.s
@@ -0,0 +1,33 @@
+; unsigned char kbhit (void);
+; Return true if there's a key waiting, return false if not
+; TESTED
+
+.globl _kbhit
+ .area _CODE
+_kbhit::
+ call 0xBB09 ; KM READ KEY
+ ld (key),a
+ ld l,#1
+ ret c
+ ld l,#0
+ ret
+
+; char cgetc (void);
+; Return a character from the keyboard. If there is no character available,
+; the functions waits until the user does press a key. If cursor is set to
+; 1 (see below), a blinking cursor is displayed while waiting.
+; TESTED
+
+.globl _cgetc
+
+_cgetc::
+ ld a,(key)
+ ld l,a
+ ret
+
+;; call 0xBB09
+;; jr nc,_cgetc
+;; ld l,a
+;; ret
+
+key: .db 0
diff --git a/contiki-cpc/contiki-cpc/arch/main.c b/contiki-cpc/contiki-cpc/arch/main.c
new file mode 100644
index 0000000..a7f8d2c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/main.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system
+ *
+ * $Id: main.c,v 1.1 2006/04/17 15:11:44 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+#include "log.h"
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "configedit-dsc.h"
+#include "directory-dsc.h"
+#include "processes-dsc.h"
+
+//#include "cfs-cbm.h"
+#include "cfs-cpc.h"
+
+#include "clock.h"
+
+#include "arch.h"
+
+unsigned char
+uip_fw_forward(void)
+{
+ return 0;
+}
+void
+uip_fw_periodic(void)
+{
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(init_eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ program_handler_load("conio.prg",NULL);
+// program_handler_load("config.prg", NULL);
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+ init_eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+#if LOG_CONF_ENABLED
+void
+log_message(char *part1, char *part2)
+{
+}
+#endif
+void
+main(void)
+{
+
+ log_message("Starting ", CONTIKI_VERSION_STRING);
+
+ ek_init();
+
+ ek_start(&init);
+
+ // log_message(": TCP/IP", "");
+
+ // tcpip_init(NULL);
+
+ // resolv_init(NULL);
+
+ log_message(": CTK GUI", "");
+ ctk_init();
+
+ log_message(": Initial filesystem", "");
+ cfs_cpc_init(NULL);
+
+ program_handler_init();
+
+ program_handler_add(&directory_dsc, "Directory", 1);
+// program_handler_add(&configedit_dsc, "Configuration", 1);
+ program_handler_add(&processes_dsc, "Processes", 1);
+
+
+ log_message("Starting process scheduling", "");
+
+ while(1) {
+ if(ek_run() == 0) {
+ program_handler_load("welcome.prg", NULL);
+ break;
+ }
+ }
+
+ while(1) {
+ ek_run();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+reset(void)
+{
+/* asm("lda #$36");
+ asm("sta $01");
+ asm("jmp $fce2");
+*/
+}
+
diff --git a/contiki-cpc/contiki-cpc/arch/malloc.c b/contiki-cpc/contiki-cpc/arch/malloc.c
new file mode 100644
index 0000000..d4e91b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/malloc.c
@@ -0,0 +1,268 @@
+#include <sdcc-lib.h>
+#include <malloc.h>
+
+#if _SDCC_MALLOC_TYPE_MLH
+
+typedef struct _MEMHEADER MEMHEADER;
+
+struct _MEMHEADER
+{
+ MEMHEADER * next;
+ MEMHEADER * prev;
+ unsigned int len;
+ unsigned char mem;
+};
+
+#define HEADER_SIZE (sizeof(MEMHEADER)-sizeof(char))
+
+/* These veriables are defined through the crt0 functions. */
+/* Base of this variable is the first byte of the heap. */
+//extern MEMHEADER _sdcc_heap_start;
+/* Address of this variable is the last byte of the heap. */
+//extern char _sdcc_heap_end;
+
+extern char *get_ram_start();
+extern char *get_ram_end();
+extern void calc_free_ram();
+extern char progend;
+
+static MEMHEADER *firstheader;
+/* setup two headers. One at start of free ram, second at end of free ram.
+ We find free ram range by asking Amstrad's firmware. */
+
+void
+_sdcc_heap_init(void)
+{
+ MEMHEADER *lastheader;
+ unsigned int size;
+ char * ramstart;
+
+ /* ask firmware for free ram */
+ calc_free_ram();
+
+ /* start of ram is either start of range given by firmware,
+ or end of program; whichever is largest */
+ ramstart = get_ram_start();
+ if (ramstart<&progend)
+ ramstart = &progend;
+
+ /* this is our first mem header */
+ firstheader = (MEMHEADER *)ramstart;
+
+ /* this is the size of ram available */
+ size = get_ram_end() - ramstart;
+
+ /* calc address of last header */
+ lastheader = (MEMHEADER *)((char *)firstheader + size - HEADER_SIZE);
+
+ /* setup last header */
+ lastheader->next = NULL;
+ lastheader->prev = firstheader;
+ lastheader->len = 0;
+
+ /* setup first header */
+ firstheader->next = lastheader;
+ firstheader->prev = NULL; //and mark first as first
+ firstheader->len = 0; //Empty and ready.
+}
+
+void *
+malloc (unsigned int size)
+{
+ MEMHEADER * current_header;
+ MEMHEADER * new_header;
+
+ if (size>(0xFFFF-HEADER_SIZE))
+ {
+ return NULL; //To prevent overflow in next line
+ }
+
+ size += HEADER_SIZE; //We need a memory for header too
+ current_header = firstheader;
+
+ while (1)
+ {
+ // current
+ // | len next
+ // v v v
+ //....*****.........******....
+ // ^^^^^^^^^
+ // spare
+
+ if ((((unsigned int)current_header->next) -
+ ((unsigned int)current_header) -
+ current_header->len) >= size)
+ {
+ break; //if spare is more than need
+ }
+ current_header = current_header->next; //else try next
+ if (!current_header->next)
+ {
+ return NULL; //if end_of_list reached
+ }
+ }
+
+ if (!current_header->len)
+ { //This code works only for first_header in the list and only
+ current_header->len = size; //for first allocation
+ return ¤t_header->mem;
+ }
+ else
+ {
+ //else create new header at the begin of spare
+ new_header = (MEMHEADER * )((char *)current_header + current_header->len);
+ new_header->next = current_header->next; //and plug it into the chain
+ new_header->prev = current_header;
+ current_header->next = new_header;
+ if (new_header->next)
+ {
+ new_header->next->prev = new_header;
+ }
+ new_header->len = size; //mark as used
+ return &new_header->mem;
+ }
+}
+
+void
+free (void *p)
+{
+ MEMHEADER *prev_header, *pthis;
+
+ if ( p ) //For allocated pointers only!
+ {
+ pthis = (MEMHEADER * )((char *) p - HEADER_SIZE); //to start of header
+ if ( pthis->prev ) // For the regular header
+ {
+ prev_header = pthis->prev;
+ prev_header->next = pthis->next;
+ if (pthis->next)
+ {
+ pthis->next->prev = prev_header;
+ }
+ }
+ else
+ {
+ pthis->len = 0; //For the first header
+ }
+ }
+}
+
+#else
+
+ //--------------------------------------------------------------------
+ //Written by Dmitry S. Obukhov, 1997
+ //dso@usa.net
+ //--------------------------------------------------------------------
+ //Modified for SDCC by Sandeep Dutta, 1999
+ //sandeep.dutta@usa.net
+ //--------------------------------------------------------------------
+ //malloc and free functions implementation for embedded system
+ //Non-ANSI keywords are C51 specific.
+ // xdata - variable in external memory (just RAM)
+ //--------------------------------------------------------------------
+
+ #define MEMHEADER struct MAH// Memory Allocation Header
+
+ MEMHEADER
+ {
+ MEMHEADER xdata * next;
+ MEMHEADER xdata * prev;
+ unsigned int len;
+ unsigned char mem;
+ };
+
+ #define HEADER_SIZE (sizeof(MEMHEADER)-1)
+
+ //Static here means: can be accessed from this module only
+ static MEMHEADER xdata * FIRST_MEMORY_HEADER_PTR;
+ void init_dynamic_memory(MEMHEADER xdata * array, unsigned int size)
+ {
+
+ //This function MUST be called after the RESET.
+ //Parameters: array - pointer to memory allocated by the linker
+ // size - size of this memory pool
+ //Example:
+ // #define DYNAMIC_MEMORY_SIZE 0x2000
+ // .....
+ // unsigned char xdata dynamic_memory_pool[DYNAMIC_MEMORY_SIZE];
+ // unsigned char xdata * current_buffer;
+ // .....
+ // void main(void)
+ // {
+ // ...
+ // init_dynamic_memory(dynamic_memory_pool,DYNAMIC_MEMORY_SIZE);
+ // Now it is possible to use malloc.
+ // ...
+ // current_buffer = malloc(0x100);
+ //
+ //
+
+ if ( !array ) /*Reserved memory starts on 0x0000 but it's NULL...*/
+ { //So, we lost one byte!
+ array = (MEMHEADER xdata * )((char xdata * ) array + 1) ;
+ size --;
+ }
+ FIRST_MEMORY_HEADER_PTR = array;
+ //Reserve a mem for last header
+ array->next = (MEMHEADER xdata * )(((char xdata * ) array) + size - HEADER_SIZE);
+ array->next->next = (void xdata * ) NULL; //And mark it as last
+ array->prev = (void xdata * ) NULL; //and mark first as first
+ array->len = 0; //Empty and ready.
+ }
+
+ void xdata * malloc (unsigned int size)
+ {
+ register MEMHEADER xdata * current_header;
+ register MEMHEADER xdata * new_header;
+
+ if (size>(0xFFFF-HEADER_SIZE)) return (void xdata *) NULL; //To prevent overflow in next line
+ size += HEADER_SIZE; //We need a memory for header too
+ current_header = FIRST_MEMORY_HEADER_PTR;
+ while (1)
+ {
+
+ // current
+ // | len next
+ // v v v
+ //....*****.........******....
+ // ^^^^^^^^^
+ // spare
+
+ if ((((unsigned int)current_header->next) -
+ ((unsigned int)current_header) -
+ current_header->len) >= size) break; //if spare is more than need
+ current_header = current_header->next; //else try next
+ if (!current_header->next) return (void xdata *) NULL; //if end_of_list reached
+ }
+ if (!current_header->len)
+ { //This code works only for first_header in the list and only
+ current_header->len = size; //for first allocation
+ return ((xdata *)&(current_header->mem));
+ } //else create new header at the begin of spare
+ new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len);
+ new_header->next = current_header->next; //and plug it into the chain
+ new_header->prev = current_header;
+ current_header->next = new_header;
+ if (new_header->next) new_header->next->prev = new_header;
+ new_header->len = size; //mark as used
+ return ((xdata *)&(new_header->mem));
+ }
+
+ void free (void xdata * p)
+ {
+ register MEMHEADER xdata * prev_header;
+ if ( p ) //For allocated pointers only!
+ {
+ p = (MEMHEADER xdata * )((char xdata *) p - HEADER_SIZE); //to start of header
+ if ( ((MEMHEADER xdata * ) p)->prev ) // For the regular header
+ {
+ prev_header = ((MEMHEADER xdata * ) p)->prev;
+ prev_header->next = ((MEMHEADER xdata * ) p)->next;
+ if (((MEMHEADER xdata * ) p)->next)
+ ((MEMHEADER xdata * ) p)->next->prev = prev_header;
+ }
+ else ((MEMHEADER xdata * ) p)->len = 0; //For the first header
+ }
+ }
+ //END OF MODULE
+#endif
diff --git a/contiki-cpc/contiki-cpc/arch/mem.s b/contiki-cpc/contiki-cpc/arch/mem.s
new file mode 100644
index 0000000..e994238
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/mem.s
@@ -0,0 +1,105 @@
+ .globl _calc_free_ram
+ .globl _get_ram_start
+ .globl _get_ram_end
+ .globl __sdcc_heap_init
+
+ .area _GSINIT
+ call __sdcc_heap_init
+
+ .area _CODE
+
+_calc_free_ram::
+ push bc
+ ;; get information about BASIC ROM
+ ld c,#0x0
+ call #0xb915
+ cp #0x80
+ jr nz,gfr
+ ;; must be built in ROM
+
+ ;; v1.0 (BASIC 1.0 in CPC464)
+ ;; v1.1 (BASIC 1.1 in CPC664)
+ ;; v1.2 (BASIC 1.1 in CPC6128 and KC Compact)
+ ;; v1.4 (BASIC 1.1 in CPC+)
+
+ ld a,h
+ cp #0x1
+ ret z
+ ld a,l
+ or a
+ jr z,basic10
+
+ ;; basic 1.1
+
+ ld hl,(#0xb073)
+ inc hl
+ ld bc,(#0xb736)
+ or a
+ sbc hl,bc
+ jr nz,after_himem11
+
+ ld hl,(#0xae6c)
+ ld (ram_start),hl
+
+ ld hl,(#0xb071)
+ ld (ram_end),hl
+gfr:
+ pop bc
+ ret
+
+after_himem11:
+
+ ;; after himem
+ ld hl,(#0xb073)
+ inc hl
+ ld (ram_start),hl
+
+ ;; start of UDG
+ ld hl,(#0xb736)
+ dec hl
+ ld (ram_end),hl
+ pop bc
+ ret
+
+
+basic10:
+ ld hl,(#0xb08f)
+ inc hl
+ ld bc,(#0xb296)
+ or a
+ sbc hl,bc
+ jr nz,after_himem10
+
+ ld hl,(#0xae89)
+ ld (ram_start),hl
+
+ ld hl,(#0xb08d)
+ ld (ram_end),hl
+ pop bc
+ ret
+
+after_himem10:
+
+ ;; after himem
+ ld hl,(#0xb08f)
+ inc hl
+ ld (ram_start),hl
+
+ ;; start of UDG
+ ld hl,(#0xb296)
+ dec hl
+ ld (ram_end),hl
+ pop bc
+ ret
+
+_get_ram_start::
+ ld hl,(ram_start)
+ ret
+_get_ram_end::
+ ld hl,(ram_end)
+ ret
+
+ram_start::
+ .dw 0
+ram_end::
+ .dw 0
diff --git a/contiki-cpc/contiki-cpc/arch/putchar.s b/contiki-cpc/contiki-cpc/arch/putchar.s
new file mode 100644
index 0000000..cc98c8d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/putchar.s
@@ -0,0 +1,27 @@
+;; File: putchar.s
+;; Modified to suit execution on the Amstrad CPC
+;; by H. Hansen 2003
+;; Original lines has been marked out!
+
+ .area _CODE
+_putchar::
+_putchar_rr_s::
+ ld hl,#2
+ add hl,sp
+
+ ld a,(hl)
+;; ld a,#1
+;; rst 0x08
+ call 0xBB5A
+ ret
+
+_putchar_rr_dbs::
+
+;; ld l,e
+;; ld a,#1
+;; rst 0x08
+
+ ld a,e
+ call 0xBB5A
+ ret
+
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/arch/uip.c b/contiki-cpc/contiki-cpc/arch/uip.c
new file mode 100644
index 0000000..76f0d0a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/arch/uip.c
@@ -0,0 +1,9 @@
+void chksumi()
+{
+}
+
+void add32i()
+{
+}
+
+
diff --git a/contiki-cpc/contiki-cpc/conf/FILES b/contiki-cpc/contiki-cpc/conf/FILES
new file mode 100644
index 0000000..72ec6f2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/FILES
@@ -0,0 +1,30 @@
+The contiki/conf/ directory contains example configuration
+files.
+
+cc-conf.h.example
+
+ An example configuration file for C compiler tweaks.
+
+clock-conf.h.example
+
+ An example configuration file for the clock module.
+
+ctk-conf.h.example
+
+ An example configuration file for the CTK GUI module.
+
+ek-conf.h.example
+
+ An example configuration file for the Contiki event kernel.
+
+telnetd-conf.h.example
+
+ An example configuration file for the telnet server.
+
+uip-conf.h.example
+
+ An example configuration file for the uIP TCP/IP stack.
+
+www-conf.h.example
+
+ An example configuration file for the web browser.
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/conf/cc-conf.h b/contiki-cpc/contiki-cpc/conf/cc-conf.h
new file mode 100644
index 0000000..8ba952a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/cc-conf.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2006/04/17 15:11:45 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+/* This file is used to configure stuff that depends on the
+ capabilities of the C compiler used. */
+
+/* CC_CONF_REGISTER_ARGS: 1 or 0; 1 if the C compiler can handle the
+ "register" keyword in function argument, 0 otherwise. */
+#define CC_CONF_REGISTER_ARGS 0
+
+/* CC_CONF_FUNCTION_POINTR_ARGS: 1 or 0; 1 if the C compiler can
+ handle function arguments with function pointers, 0 otherwise. */
+#define CC_CONF_FUNCTION_POINTER_ARGS 1
+
+/* CC_CONF_FASTCALL: if the C compiler supports the fastcall keyword,
+ it should be defined here. If the C compiler does not support it,
+ leave the definition blank.
+
+ Example:
+ #define CC_CONF_FASTCALL fastcall */
+#define CC_CONF_FASTCALL
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/contiki-cpc/conf/cc-conf.h.old b/contiki-cpc/contiki-cpc/conf/cc-conf.h.old
new file mode 100644
index 0000000..c416ebf
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/cc-conf.h.old
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h.old,v 1.1 2006/04/17 15:11:45 kthacker Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define register /**/
+#define CC_CONF_REGISTER_ARGS 0
+#define CC_CONF_FUNCTION_POINTER_ARGS 0
+
+#define CC_CONF_FASTCALL /*fastcall*/
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-cpc/contiki-cpc/conf/clock-conf.h b/contiki-cpc/contiki-cpc/conf/clock-conf.h
new file mode 100644
index 0000000..a690e15
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND CLK_TCK
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-conf.h
new file mode 100644
index 0000000..8496fc2
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+ window. */
+#define CTK_CONF_WINDOWSWITCH_KEY CH_F2
+
+/* Defines which key that is to be used for switching to the prevoius
+ widget. */
+#define CTK_CONF_WIDGETUP_KEY CH_F7
+
+/* Defines which key that is to be used for switching to the next
+ widget. */
+#define CTK_CONF_WIDGETDOWN_KEY CH_F4
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT 0 /* 1342 bytes */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS 1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS 1
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS 1
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS 1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH 16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS 10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER 0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old b/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old
new file mode 100644
index 0000000..5c832c9
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+ window. */
+#define CTK_CONF_WINDOWSWITCH_KEY CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT 0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS 1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE 0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS 1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH 16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS 10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER 0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-term-conf.h
diff --git a/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h b/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h
new file mode 100644
index 0000000..fd45e81
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ctk-vncserver-conf.h
@@ -0,0 +1 @@
+#define CTK_VNCSERVER_CONF_MAX_ICONS 1
diff --git a/contiki-cpc/contiki-cpc/conf/ek-conf.h b/contiki-cpc/contiki-cpc/conf/ek-conf.h
new file mode 100644
index 0000000..bfbcfb1
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ek-conf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_EVENTS 32 /* Must be 2^n */
+#define EK_CONF_NUMEVENTS EK_CONF_EVENTS
+
+typedef unsigned char ek_num_events_t;
+
+#define EK_CONF_MAXPROCS 32
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/ek-conf.h.old b/contiki-cpc/contiki-cpc/conf/ek-conf.h.old
new file mode 100644
index 0000000..a64bbe7
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/ek-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_signal_t;
+typedef unsigned char ek_id_t;
+
+/* ek_ticks_t: should be defined to be the largest type that fits the
+ highest timeout value used by the system. For example, if all
+ timeouts are between 1 and 150, the ek_ticks_t can be typedef'd as
+ "unsigned char", but if the maximum timeout is over 256, "unsigned
+ short" is a better choise. */
+typedef unsigned short ek_ticks_t;
+
+/* ek_clock_t: should be defined to be the native clock ticks type
+ used by the underlying system. (Look for time_t or similar.) */
+typedef unsigned long ek_clock_t;
+
+#define EK_CONF_NUMSIGNALS 16 /* Must be 2^n */
+typedef unsigned char ek_num_signals_t;
+
+#define EK_CONF_NUMTIMERS 4 /* Must be 2^n */
+typedef unsigned char ek_num_timers_t;
+
+#define EK_CONF_NUMLISTENERS 16 /* Must be 2^n */
+typedef unsigned char ek_num_listeners_t;
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/irc-conf.h b/contiki-cpc/contiki-cpc/conf/irc-conf.h
new file mode 100644
index 0000000..056f71a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/irc-conf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#define IRC_CONF_WIDTH 78
+#define IRC_CONF_HEIGHT 21
+
+#define IRC_CONF_SYSTEM_STRING "c64"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/libconio-conf.h b/contiki-cpc/contiki-cpc/conf/libconio-conf.h
new file mode 100644
index 0000000..d420d5c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/libconio-conf.h
@@ -0,0 +1,2 @@
+#define LIBCONIO_CONF_SCREEN_WIDTH 40
+#define LIBCONIO_CONF_SCREEN_HEIGHT 25
diff --git a/contiki-cpc/contiki-cpc/conf/log-conf.h b/contiki-cpc/contiki-cpc/conf/log-conf.h
new file mode 100644
index 0000000..1036014
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/log-conf.h
@@ -0,0 +1 @@
+#define LOG_CONF_ENABLED 0
diff --git a/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h b/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h
new file mode 100644
index 0000000..235b1c6
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/shell-gui-conf.h
@@ -0,0 +1,2 @@
+#define SHELL_GUI_CONF_XSIZE 20
+#define SHELL_GUI_CONF_YSIZE 20
diff --git a/contiki-cpc/contiki-cpc/conf/telnetd-conf.h b/contiki-cpc/contiki-cpc/conf/telnetd-conf.h
new file mode 100644
index 0000000..8355598
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/telnetd-conf.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: telnetd-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __TELNETD_CONF_H__
+#define __TELNETD_CONF_H__
+
+#define TELNETD_CONF_LINELEN 36
+#define TELNETD_CONF_NUMLINES 24
+
+#endif /* __TELNETD_CONF_H__ */
+
+
+
+
+
+
+
+
diff --git a/contiki-cpc/contiki-cpc/conf/uip-conf.h b/contiki-cpc/contiki-cpc/conf/uip-conf.h
new file mode 100644
index 0000000..8955c6d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/uip-conf.h
@@ -0,0 +1,93 @@
+/**
+ * \file
+ * uIP configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file contains configuration options for the uIP TCP/IP
+ * stack. Each Contiki port will contain its own uip-conf.h file
+ * containing architecture specific configuration options.
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+#define __UIP_CONF_H__
+
+/**
+ * The maximum number of TCP connections.
+ *
+ * Since the TCP connections are statically allocated, turning this
+ * configuration knob down results in less RAM used. Each TCP
+ * connection requires approximatly 30 bytes of memory.
+ */
+#define UIP_CONF_MAX_CONNECTIONS 40
+
+/**
+ * The maximum number of listening TCP ports.
+ *
+ * Each listening TCP port requires 2 bytes of memory.
+ */
+#define UIP_CONF_MAX_LISTENPORTS 40
+
+/**
+ * The size of the uIP packet buffer.
+ *
+ * The uIP packet buffer should not be smaller than 60 bytes, and does
+ * not need to be larger than 1500 bytes. Lower size results in lower
+ * TCP throughput, larger size results in higher TCP throughput.
+ */
+#define UIP_CONF_BUFFER_SIZE 400
+
+/**
+ * The host byte order.
+ *
+ * Used for telling uIP if the architecture has LITTLE_ENDIAN or
+ * BIG_ENDIAN byte order. x86 CPUs have LITTLE_ENDIAN byte order,
+ * whereas Motorola CPUs have BIG_ENDIAN. Check the documentation of
+ * the CPU to find out the byte order.
+ */
+#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
+
+
+/**
+ * IP address configuration through ping.
+ *
+ * uIP features IP address configuration using an ICMP echo (ping)
+ * packet. In this mode, the destination IP address of the first ICMP
+ * echo packet that is received is used to set the host IP address.
+ */
+#define UIP_CONF_PINGADDRCONF 0
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/uip-conf.h.old b/contiki-cpc/contiki-cpc/conf/uip-conf.h.old
new file mode 100644
index 0000000..8de8b7a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/uip-conf.h.old
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE 310
+
+#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/vnc-conf.h b/contiki-cpc/contiki-cpc/conf/vnc-conf.h
new file mode 100644
index 0000000..1e6906a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/vnc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS 8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old b/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old
new file mode 100644
index 0000000..fedc904
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/vnc-conf.h.old
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-conf.h.old,v 1.1 2006/04/17 15:11:46 kthacker Exp $
+ *
+ */
+
+
+#ifndef __VNC_CONF_H__
+
+#define VNC_CONF_VIEWPORT_WIDTH (32*8)
+#define VNC_CONF_VIEWPORT_HEIGHT (16*8)
+
+#define VNC_CONF_REFRESH_ROWS 8
+
+#endif /* __VNC_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/www-conf.h b/contiki-cpc/contiki-cpc/conf/www-conf.h
new file mode 100644
index 0000000..5178724
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/www-conf.h
@@ -0,0 +1,110 @@
+/**
+ * \file
+ * The Contiki web browser configuration file.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2002-2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+/**
+ * The width of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+
+/**
+ * The height of the web page viewing area, measured in characters.
+ */
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/**
+ * The size of the "Back" history.
+ */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/**
+ * The maximum length of the URLs the web browser will handle.
+ */
+#define WWW_CONF_MAX_URLLEN 100
+
+/**
+ * The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ * a single web page view.
+ *
+ * \note This does not limit the total number of widgets in a web
+ * page, only the number of widget that are visible simultaneously.
+ */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 20
+
+/**
+ * Turns support for the \<center\> tag on or off, and must be on for
+ * HTML forms to work.
+ */
+#define WWW_CONF_RENDERSTATE 1
+
+/**
+ * Toggles support for HTML forms.
+ */
+#define WWW_CONF_FORMS 1
+
+/**
+ * Maximum length of HTML form action URLs.
+ */
+#define WWW_CONF_MAX_FORMACTIONLEN 40
+
+/**
+ * Maximum length of HTML form name.
+ */
+#define WWW_CONF_MAX_FORMNAMELEN 20
+
+/**
+ * Maximum length of HTML form input name.
+ */
+#define WWW_CONF_MAX_INPUTNAMELEN 20
+
+/**
+ * Maximum length of HTML form input value.
+ */
+#define WWW_CONF_MAX_INPUTVALUELEN (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+/**
+ * The defaule home page.
+ */
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/conf/www-conf.h.old b/contiki-cpc/contiki-cpc/conf/www-conf.h.old
new file mode 100644
index 0000000..9ac8b4b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/conf/www-conf.h.old
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h.old,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://contiki.c64.org/"
+
+/* The size of the HTML viewing area. */
+#define WWW_CONF_WEBPAGE_WIDTH 36
+#define WWW_CONF_WEBPAGE_HEIGHT 17
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 65
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 26
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS 1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN 30
+#define WWW_CONF_MAX_FORMNAMELEN 20
+#define WWW_CONF_MAX_INPUTNAMELEN 20
+
+#define WWW_CONF_MAX_INPUTVALUELEN (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/conio.h b/contiki-cpc/contiki-cpc/ctk/conio.h
new file mode 100644
index 0000000..e8c3cdb
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/conio.h
@@ -0,0 +1,66 @@
+/*
+ CONIO.H - Console I/O library for the Amsrad CPC
+ To use with the Small Devices C Compiler
+ CONIO.H is a implementation of the Contiki CONIO.H (Derived from the borland CONIO.H)
+
+ 2003 H. Hansen
+*/
+
+#ifndef __conio_h__
+#define __conio_h__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "arch.h"
+
+#define CH_ULCORNER 0x096
+#define CH_URCORNER 0x09c
+#define CH_LLCORNER 0x093
+#define CH_LRCORNER 0x099
+
+void clrscr (void);
+
+unsigned char kbhit (void);
+
+void gotox (unsigned char x);
+
+void gotoy (unsigned char y);
+
+void gotoxy (unsigned char x, unsigned char y);
+
+unsigned char wherex (void);
+
+unsigned char wherey (void);
+
+void cputc (char c);
+
+void cputcxy (unsigned char x, unsigned char y, char c);
+
+void cputs (char* s);
+
+char cgetc (void);
+
+void revers ();
+
+void textcolor (unsigned char color);
+
+void bgcolor (unsigned char color);
+
+void bordercolor (unsigned char color);
+
+void chline (unsigned char length);
+
+void chlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cvline (unsigned char length);
+
+void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+
+void cclear (unsigned char length);
+
+void cclearxy (unsigned char x, unsigned char y, unsigned char length);
+
+void screensize (unsigned char* x, unsigned char* y);
+
+#endif /* __conio_h__ */
+
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-arch.h b/contiki-cpc/contiki-cpc/ctk/ctk-arch.h
new file mode 100644
index 0000000..b043013
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-arch.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#if CTK_HIRES
+#include "ctk-hires.h"
+#endif
+
+#if CTK_CONIO
+#include "ctk-conio.h"
+#endif
+
+#if CTK_VNCSERVER
+#include "ctk-vncarch.h"
+#endif
+
+#include <ctype.h>
+
+//#define ctk_arch_isprint(c) isprint(c)
+
+#include "ctk-arch2.h"
+
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h b/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h
new file mode 100644
index 0000000..1d39254
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-arch2.h
@@ -0,0 +1,39 @@
+/*#include "fire.h"*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//char *strncpy(char *, const char *, unsigned int);
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+// have to undefine because of it being defined in
+// ctk-conio.h
+#undef CH_ENTER
+#undef CH_F1
+#undef CH_F3
+#undef CH_CURS_LEFT
+#undef CH_CURS_RIGHT
+
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F2 0x032
+#define CH_F3 0x033
+#define CH_F4 0x034
+#define CH_F5 0x035
+#define CH_F6 0x036
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+#define CH_TAB 0x09
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC CH_STOP
+
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old b/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old
new file mode 100644
index 0000000..84666d0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-conf.h.old
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h.old,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+//typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#undef CH_ENTER
+#define CH_ENTER 0x0d
+#define CH_STOP 0x01b
+#define CH_F1 0x031
+#define CH_F3 0x033
+#define CH_F5 0x035
+#define CH_F7 0x037
+#define CH_DEL 0x07f
+
+#define CH_CURS_LEFT 0x0f2
+#define CH_CURS_DOWN 0x0f1
+#define CH_CURS_RIGHT 0x0f3
+#define CH_CURS_UP 0x0f0
+
+#define CH_ESC 0x01b
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY CH_F1
+
+/* Defines which key that is to be used for switching the frontmost
+ window. */
+#define CTK_CONF_WINDOWSWITCH_KEY CH_F3
+
+
+#define CTK_CONF_WIDGETUP_KEY CH_F5
+#define CTK_CONF_WIDGETDOWN_KEY CH_F7
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#define CTK_CONF_MOUSE_SUPPORT 0 /* 1342 bytes */
+
+/* Toggles support for desktop icons. */
+#define CTK_CONF_ICONS 1 /* 107 bytes */
+
+/* Toggles support for movable windows. */
+#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
+
+/* Toggles support for multiline text entry editing. */
+#define CTK_CONF_TEXTENTRY_MULTILINE 0 /* 118 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS 1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH 16
+/* The maximum number of menu items in each menu. */
+#define CTK_CONF_MAXMENUITEMS 10
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER 0
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h b/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h
new file mode 100644
index 0000000..89c47c5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/ctk-conio-conf.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR 0
+#define SCREENCOLOR 0
+
+#define BACKGROUNDCOLOR 0
+
+
+#define WINDOWCOLOR_FOCUS 1 /* colour of window which has focus */
+#define WINDOWCOLOR 2 /* colour of window which doesn't have focus */
+
+#define DIALOGCOLOR 1
+
+#define WIDGETCOLOR_HLINK 3
+#define WIDGETCOLOR_FWIN 2 /* colour of widget */
+#define WIDGETCOLOR 2
+#define WIDGETCOLOR_DIALOG 2
+#define WIDGETCOLOR_FOCUS 3 /* colour of widge which has focus */
+
+// 0 = blue
+// 1 = yellow
+// 2 = cyan
+// 3 = red
+
+#define MENUCOLOR 2
+#define OPENMENUCOLOR 1
+#define ACTIVEMENUITEMCOLOR 3
+
+#endif
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S
new file mode 100644
index 0000000..4df6cad
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.S
@@ -0,0 +1,986 @@
+
+;---------------------------------------------------------------------
+ .importzp ptr1, ptr2, ptr3, ptr4, sreg
+ .importzp sp
+
+ .import pushax
+ .import incsp2
+
+ .import _ctk_80col_screencolors
+ .import _ctk_80col_screenpattern
+
+ .import _ctk_80col_lefttab
+ .import _ctk_80col_righttab
+
+ .import _ctk_80col_cursx
+ .import _ctk_80col_cursy
+ .import _ctk_80col_color
+ .import _ctk_80col_underline
+ .import _ctk_80col_reversed
+
+ .import _ctk_80col_yscreenaddr
+ .import _ctk_80col_yhiresaddr
+
+ .import _ctk_80col_windowparams
+
+ .import _ctk_80col_bitmapptr
+
+ .import _ctk_80col_versionstring
+ .import _ctk_80col_versionstring_len
+
+ .import _ctk_80col_theme
+
+ .export _ctk_80col_cclear
+ .export _ctk_80col_chline
+ .export _ctk_80col_cputc
+ .export _ctk_80col_cputsn
+
+ .export _ctk_80col_clear_line
+ .export _ctk_80col_draw_bitmapline
+
+ .export _ctk_80col_draw_windowborders
+
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+ ;; Offsets in the theme struct
+
+ ulcornerpattern = 8
+ titlebarpattern = ulcornerpattern+8
+ urcornerpattern = titlebarpattern+8
+ rborderpattern = urcornerpattern+8
+ lrcornerpattern = rborderpattern+8
+ lowerborderpattern = lrcornerpattern+8
+ llcornerpattern = lowerborderpattern+8
+ lborderpattern = llcornerpattern+8
+
+
+ buttonleftpattern = lborderpattern+8
+ buttonrightpattern = buttonleftpattern+8
+
+
+.bss
+tmp01: .res 1
+tmpl: .res 1
+tmpf: .res 1
+tmpc: .res 1
+tmpw: .res 1
+tmpptr: .res 2
+
+tmpy: .res 1
+tmph: .res 1
+
+ ;; Window border parameters
+w: .res 1
+wpw = 0
+h: .res 1
+wph = 1
+clipy1: .res 1
+wpclipy1 = 2
+clipy2: .res 1
+wpclipy2 = 3
+color1: .res 1
+wpcolor1 = 4
+color2: .res 1
+wpcolor2 = 5
+titlecolor: .res 1
+wptitlecolor = 6
+titlelen: .res 1
+wptitlelen = 7
+title: .res 2
+wptitle = 8
+
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:
+ ;; Find hires address.
+ lda _ctk_80col_cursy
+ asl
+ tax
+ lda _ctk_80col_yhiresaddr,x
+ sta ptr2
+ lda _ctk_80col_yhiresaddr+1,x
+ sta ptr2+1
+
+ ;; Add X coordinate to the hires address.
+ lda #0
+ sta ptr1+1
+ lda _ctk_80col_cursx
+ asl
+ rol ptr1+1
+; asl
+; rol ptr1+1
+ asl
+ rol ptr1+1
+ clc
+ adc ptr2
+ and #$f8
+ sta ptr2
+ lda ptr2+1
+ adc ptr1+1
+ sta ptr2+1
+
+ ;; Find screen address.
+ lda _ctk_80col_cursy
+ asl
+ tax
+ lda _ctk_80col_cursx
+ lsr
+ clc
+ adc _ctk_80col_yscreenaddr,x
+ sta ptr1
+ lda _ctk_80col_yscreenaddr+1,x
+ adc #0
+ sta ptr1+1
+
+ ;; Turn off interrupts, prepare $01 to store color data in RAM
+ ;; under I/O area.
+ sei
+ lda $01
+ sta tmp01
+ and #$f8
+ sta $01
+ rts
+;---------------------------------------------------------------------
+restore01:
+ lda tmp01
+ sta $01
+ cli
+ rts
+;---------------------------------------------------------------------
+_ctk_80col_cclear:
+ sta tmpl
+ cmp #0
+ bne @norts
+ rts
+@norts:
+
+ jsr setupptrs
+
+ ldy tmpl
+ lda _ctk_80col_color
+:
+ sta (ptr1),y
+ dey
+ bpl :-
+
+ ;; Store either $00 or $ff in hires memory, depending on the
+ ;; reversed flag
+
+ ldx tmpl
+ lda _ctk_80col_reversed
+ beq @noff
+ lda #$ff
+@noff:
+ sta tmpf
+
+
+@loop1:
+ ldy #7
+ lda tmpf
+@loop2:
+ sta (ptr2),y
+ dey
+ bpl @loop2
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc @noinc
+ inc ptr2+1
+@noinc:
+
+ inc _ctk_80col_cursx
+
+ dex
+ bpl @loop1
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_chline:
+ sta tmpl
+ cmp #0
+ bne @norts
+ rts
+@norts:
+
+ jsr setupptrs
+
+ ;; Store horizontal line pattern in hires memory
+ ldx tmpl
+@loop1:
+ ldy #0
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$ff
+ sta (ptr2),y
+ iny
+ lda #$ff
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc @noinc
+ inc ptr2+1
+@noinc:
+
+ inc _ctk_80col_cursx
+
+ dex
+ bne @loop1
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_cputc:
+ sta tmpc
+
+ jsr setupptrs
+
+ ;; Turn on font ROM
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+ lda #0
+ sta ptr1+1
+
+ ;; Convert from PETSCII to screen encoding
+ lda tmpc
+ eor #$e0
+ clc
+ adc #$20
+ bpl @cont
+ adc #$40
+ bpl @cont
+ eor #$a0
+@cont:
+ ldx _ctk_80col_reversed
+ beq :+
+ eor #$80
+:
+
+ ;; Convert to address in character ROM
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ sta ptr1
+ lda #$d8
+ adc ptr1+1
+ sta ptr1+1
+
+ lda _ctk_80col_cursx
+ and #1
+ beq @left
+
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_80col_underline
+ beq @rightnounderline
+ eor #$ff
+@rightnounderline:
+ tax
+ lda (ptr2),y
+ and #$f0
+ ora _ctk_80col_righttab,x
+ sta (ptr2),y
+ dey
+@rightloop:
+ lda (ptr1),y
+ tax
+ lda (ptr2),y
+ and #$f0
+ ora _ctk_80col_righttab,x
+ sta (ptr2),y
+ dey
+ bpl @rightloop
+
+ inc _ctk_80col_cursx
+
+ jmp restore01
+
+@left:
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_80col_underline
+ beq @nounderline
+ eor #$ff
+@nounderline:
+ tax
+ lda (ptr2),y
+ and #$0f
+ ora _ctk_80col_lefttab,x
+ sta (ptr2),y
+ dey
+@loop:
+ lda (ptr1),y
+ tax
+ lda (ptr2),y
+ and #$0f
+ ora _ctk_80col_lefttab,x
+ sta (ptr2),y
+ dey
+ bpl @loop
+
+
+
+ inc _ctk_80col_cursx
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_cputsn:
+ sta tmpl
+ cmp #0
+ bne :+
+ jmp incsp2
+:
+
+ jsr setupptrs
+
+ ;; Turn on font ROM
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+ ;; Output each character from the string
+ lda #0
+ sta tmpc
+ ldy #0
+ lda (sp),y
+ sta ptr3
+ iny
+ lda (sp),y
+ sta ptr3+1
+
+@loop1:
+
+
+ lda #0
+ sta ptr1+1
+
+ ldy tmpc
+ lda (ptr3),y
+ bne :+
+ jmp @end
+:
+
+ ;; Convert from PETSCII to screen encoding
+ eor #$e0
+ clc
+ adc #$20
+ bpl @cont
+ adc #$40
+ bpl @cont
+ eor #$a0
+@cont:
+ ldx _ctk_80col_reversed
+ beq :+
+ eor #$80
+:
+
+ ;; Convert to address in character ROM
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ sta ptr1
+ lda #$d8
+ adc ptr1+1
+ sta ptr1+1
+
+ lda _ctk_80col_cursx
+ and #1
+ beq @left
+
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_80col_underline
+ beq @rightnounderline
+ eor #$ff
+@rightnounderline:
+ tax
+ lda (ptr2),y
+ and #$f0
+ ora _ctk_80col_righttab,x
+ sta (ptr2),y
+ dey
+@rightloop:
+ lda (ptr1),y
+ tax
+ lda (ptr2),y
+ and #$f0
+ ora _ctk_80col_righttab,x
+ sta (ptr2),y
+ dey
+ bpl @rightloop
+
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc :+
+ inc ptr2+1
+:
+
+ inc _ctk_80col_cursx
+
+ jmp @loopend
+
+@left:
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_80col_underline
+ beq @nounderline
+ eor #$ff
+@nounderline:
+ tax
+ lda (ptr2),y
+ and #$0f
+ ora _ctk_80col_lefttab,x
+ sta (ptr2),y
+ dey
+@loop:
+ lda (ptr1),y
+ tax
+ lda (ptr2),y
+ and #$0f
+ ora _ctk_80col_lefttab,x
+ sta (ptr2),y
+ dey
+ bpl @loop
+
+ inc _ctk_80col_cursx
+@loopend:
+ inc tmpc
+ lda tmpc
+ cmp tmpl
+ beq :+
+ jmp @loop1
+:
+
+@end:
+ jsr restore01
+
+ jmp incsp2
+;---------------------------------------------------------------------
+_ctk_80col_clear_line:
+ sta tmpl
+ asl
+ tax
+ lda _ctk_80col_yscreenaddr,x
+ sta ptr1
+ lda _ctk_80col_yscreenaddr+1,x
+ sta ptr1+1
+ lda _ctk_80col_yhiresaddr,x
+ sta ptr2
+ lda _ctk_80col_yhiresaddr+1,x
+ sta ptr2+1
+
+ sei
+ lda $01
+ sta tmp01
+ and #$f8
+ sta $01
+
+ ldy #39
+ ldx tmpl
+ lda _ctk_80col_screencolors,x
+:
+ sta (ptr1),y
+ dey
+ bpl :-
+
+ lda tmpl
+ asl
+ asl
+ asl
+ tax
+ ldy #0
+:
+ lda _ctk_80col_screenpattern,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+1,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+2,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+3,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+4,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+5,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+6,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+7,x
+ sta (ptr2),y
+ iny
+ bne :-
+
+ inc ptr2+1
+
+:
+ lda _ctk_80col_screenpattern,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+1,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+2,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+3,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+4,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+5,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+6,x
+ sta (ptr2),y
+ iny
+ lda _ctk_80col_screenpattern+7,x
+ sta (ptr2),y
+ iny
+ cpy #$40
+ bne :-
+
+ lda tmpl
+ cmp #24
+ bne :+
+
+ sta _ctk_80col_cursy
+ lda #2
+ sta _ctk_80col_cursx
+
+ jsr restore01
+
+ lda #<_ctk_80col_versionstring
+ ldx #>_ctk_80col_versionstring
+ jsr pushax
+ lda _ctk_80col_versionstring_len
+ jmp _ctk_80col_cputsn
+:
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_draw_bitmapline:
+ sta tmpl
+ cmp #0
+ bne :+
+ rts
+:
+
+ jsr setupptrs
+
+ ldy #0
+ lda _ctk_80col_color
+:
+ sta (ptr1),y
+ iny
+ cpy tmpl
+ bne :-
+
+ lda _ctk_80col_bitmapptr
+ sta ptr1
+ lda _ctk_80col_bitmapptr+1
+ sta ptr1+1
+
+ ldy #0
+ ldx #0
+:
+ lda (ptr1),y
+ sta (ptr2),y
+ iny
+ inx
+ cpx #8
+ bne :-
+
+ ldx #0
+
+ dec tmpl
+ bne :-
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_80col_draw_windowborders:
+
+ jsr setupptrs
+
+ lda _ctk_80col_windowparams + wpclipy1
+ beq :+
+ jmp @nofirstline
+:
+
+ ;; Draw first line of the border, including the window title
+
+ ;; Start with filling color memory
+ lda _ctk_80col_windowparams + wpw
+ sta tmpw
+
+
+ ldy #0
+ lda _ctk_80col_windowparams + wptitlecolor
+:
+ sta (ptr1),y
+ iny
+ cpy tmpw
+ bcc :-
+
+ dec tmpw
+
+ ;; Set color for upper right corner
+ sta (ptr1),y
+ iny
+ sta (ptr1),y
+
+
+ ;; Turn on font ROM for drawing the title
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+ ;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+ ;; reuse it later.
+ lda ptr2
+ sta ptr3
+ lda ptr2+1
+ sta ptr3+1
+
+ ;; Draw upper left corner
+ ldy #7
+:
+ lda _ctk_80col_theme+ulcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ clc
+ adc #$8
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+
+
+ ;; Draw window title bar pattern
+@titlebarloop:
+ ldy #7
+:
+ lda _ctk_80col_theme+titlebarpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ clc
+ adc #$8
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ ;; Loop until we are three characters away from right border
+ ;; to avoid flickering since we would be overwriting the close
+ ;; button.
+ dec tmpw
+ bpl @titlebarloop
+
+ ;; Draw upper right corner piece
+ ldy #7
+:
+ lda _ctk_80col_theme+urcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+
+@nofirstline:
+
+
+ ldx _ctk_80col_windowparams + wph
+ inx
+ stx tmph
+
+ ;; Draw left and right borders
+
+ ;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+ ;; First check how much we actually should draw by inspecting
+ ;; the clipy1 and clipy2 fields in the _ctk_80col_windowparams
+ ;; structure
+
+ lda #1
+ sta tmpy
+
+ ldx _ctk_80col_windowparams + wpclipy1
+@clipy1loop:
+ cpx #0
+ beq @clipy1loopend
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ inc tmpy
+
+ dex
+ jmp @clipy1loop
+@clipy1loopend:
+
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+
+ ldx tmpy
+ ldy _ctk_80col_windowparams + wpw
+ iny
+ sty tmpw
+@bordercloop:
+ cpx _ctk_80col_windowparams + wpclipy2
+ beq @bordercloopend
+
+ ldy tmpw
+ lda _ctk_80col_windowparams + wpcolor2
+ sta (ptr1),y
+ ldy #0
+ lda _ctk_80col_windowparams + wpcolor1
+ sta (ptr1),y
+
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+
+ inx
+ cpx tmph
+ bcc @bordercloop
+ beq @bordercloop
+@bordercloopend:
+
+
+ ;; Fill color memory for lower border, if clipy2 allows
+ cpx _ctk_80col_windowparams + wpclipy2
+ beq @noclowerborder
+
+ lda ptr1
+ sec
+ sbc #$28
+ sta ptr1
+ bcs :+
+ dec ptr1+1
+:
+
+ ldy _ctk_80col_windowparams + wpw
+ lda _ctk_80col_windowparams + wpcolor2
+@lbordercloop:
+ sta (ptr1),y
+ dey
+ bne @lbordercloop
+
+@noclowerborder:
+
+ ;; Draw right border
+ ldx tmpy
+@rborderloop:
+ cpx _ctk_80col_windowparams + wpclipy2
+ beq @rborderloopend
+
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ ldy #7
+:
+ lda _ctk_80col_theme+rborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ inx
+ cpx tmph
+ bne @rborderloop
+@rborderloopend:
+
+ cpx _ctk_80col_windowparams + wpclipy2
+ beq @norbordercorner
+
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ ;; Draw lower right corner, if clipy2 allows it
+ ldy #7
+:
+ lda _ctk_80col_theme+lrcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+@norbordercorner:
+
+ stx tmpy
+
+ ;; Draw lower border
+ ldx _ctk_80col_windowparams + wpw
+
+@lowerborderloop:
+ lda ptr3
+ sec
+ sbc #$8
+ sta ptr3
+ bcs :+
+ dec ptr3+1
+:
+
+ lda tmpy
+ cmp _ctk_80col_windowparams + wpclipy2
+ beq @nolowerborder
+
+ ldy #7
+:
+ lda _ctk_80col_theme+lowerborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+@nolowerborder:
+
+ dex
+ bne @lowerborderloop
+
+ lda ptr3
+ sec
+ sbc #$8
+ sta ptr3
+ bcs :+
+ dec ptr3+1
+:
+
+
+ ldx tmpy
+ cpx tmph
+ bne @nolbordercorner
+
+ ;; Draw lower left corner, if clipy2 allows it
+ ldy #7
+:
+ lda _ctk_80col_theme+llcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ sec
+ sbc #$40
+ sta ptr3
+ lda ptr3+1
+ sbc #1
+ sta ptr3+1
+
+@nolbordercorner:
+
+ ;; Draw left border
+
+
+
+@lborderloop:
+ cpx #1
+ beq @lborderloopend
+ cpx _ctk_80col_windowparams + wpclipy1
+ bcc @lborderloopend
+
+ ldy #7
+:
+ lda _ctk_80col_theme+lborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ sec
+ sbc #$40
+ sta ptr3
+ lda ptr3+1
+ sbc #1
+ sta ptr3+1
+
+ dex
+ jmp @lborderloop
+
+@lborderloopend:
+
+
+ jmp restore01
+;---------------------------------------------------------------------
+
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h
new file mode 100644
index 0000000..21787d4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-asm.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-80col-asm.h,v 1.1 2006/04/17 15:11:47 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_80COL_ASM_H__
+#define __CTK_80COL_ASM_H__
+
+void __fastcall__ ctk_80col_cclear(unsigned char len);
+void __fastcall__ ctk_80col_chline(unsigned char len);
+void __fastcall__ ctk_80col_cputc(unsigned char c);
+void __fastcall__ ctk_80col_cputsn(unsigned char *str,
+ unsigned char len);
+
+void ctk_80col_draw_buttonleft(void);
+void ctk_80col_draw_buttonright(void);
+
+struct ctk_80col_windowparams {
+ unsigned char w;
+ unsigned char h;
+ unsigned char clipy1;
+ unsigned char clipy2;
+ unsigned char color1;
+ unsigned char color2;
+ unsigned char titlecolor;
+ unsigned char titlelen;
+ char *title;
+};
+extern struct ctk_80col_windowparams ctk_80col_windowparams;
+void ctk_80col_draw_windowborders(void);
+
+extern unsigned char ctk_80col_cursx,
+ ctk_80col_cursy,
+ ctk_80col_color,
+ ctk_80col_reversed,
+ ctk_80col_underline;
+
+
+void __fastcall__ ctk_80col_draw_bitmapline(unsigned char len);
+
+void __fastcall__ ctk_80col_clear_line(unsigned char len);
+
+#endif /* __CTK_80COL_ASM_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h
new file mode 100644
index 0000000..ffc168c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col-theme.h
@@ -0,0 +1,83 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-80col-theme.h,v 1.1 2006/04/17 15:11:48 kthacker Exp $
+ *
+ */
+#ifndef __CTK_80COL_THEME_H__
+#define __CTK_80COL_THEME_H__
+
+struct ctk_80col_theme {
+ /* Version string. */
+ char version[8];
+
+ /* Window borders patterns. */
+ unsigned char ulcorner[8], /* Upper left corner. */
+ titlebar[8], /* Title bar pattern. */
+ urcorner[8], /* Upper right corner. */
+ rightborder[8], /* Right border. */
+ lrcorner[8], /* Lower right corner. */
+ lowerborder[8], /* Lower border. */
+ llcorner[8], /* Lower left corner. */
+ leftborder[8]; /* Left border. */
+
+ /* Button corner patterns. */
+ unsigned char buttonleftpattern[8],
+ buttonrightpattern[8];
+
+ /* Menu border patterns. */
+ unsigned char menuleftpattern[8],
+ menurightpattern[8];
+
+
+
+ /* Window and widget colors. */
+ unsigned char windowcolors[6],
+ separatorcolors[6],
+ labelcolors[6],
+ buttoncolors[6],
+ hyperlinkcolors[6],
+ textentrycolors[6],
+ bitmapcolors[6],
+ textmapcolors[6],
+ iconcolors[6];
+
+ /* Menu colors. */
+ unsigned char menucolor,
+ openmenucolor,
+ activemenucolor;
+
+};
+
+extern struct ctk_80col_theme ctk_80col_theme;
+extern struct ctk_80col_theme *ctk_80col_theme_ptr;
+
+#endif /* __CTK_80COL_THEME_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c
new file mode 100644
index 0000000..44a8c6f
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-80col.c
@@ -0,0 +1,1197 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: ctk-80col.c,v 1.1 2006/04/17 15:11:49 kthacker Exp $
+ */
+
+#include "contiki.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+
+#include "ctk-80col-asm.h"
+
+#include "ctk-80col-theme.h"
+
+#include <string.h>
+
+unsigned char ctk_80col_cursx, ctk_80col_cursy;
+unsigned char ctk_80col_reversed;
+unsigned char ctk_80col_color;
+unsigned char *ctk_80col_bitmapptr;
+unsigned char ctk_80col_underline = 0;
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH 80
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR 0xe000
+
+unsigned char ctk_80col_lefttab[256];
+unsigned char ctk_80col_righttab[256];
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define COLOR_DIALOG 0x01
+#define COLOR_FOCUS_WINDOW 0xbf
+#define COLOR_BACKGROUND_WINDOW 0x0c
+
+#define color(c) ctk_80col_color = c
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+unsigned char ctk_80col_screencolors[25] =
+ {COLOR(BGCOLOR4,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,1)};
+
+unsigned char ctk_80col_screenpattern[25*8] =
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+unsigned short ctk_80col_yscreenaddr[25] =
+ {0 * 40 + SCREENADDR, 1 * 40 + SCREENADDR,
+ 2 * 40 + SCREENADDR, 3 * 40 + SCREENADDR,
+ 4 * 40 + SCREENADDR, 5 * 40 + SCREENADDR,
+ 6 * 40 + SCREENADDR, 7 * 40 + SCREENADDR,
+ 8 * 40 + SCREENADDR, 9 * 40 + SCREENADDR,
+ 10 * 40 + SCREENADDR, 11 * 40 + SCREENADDR,
+ 12 * 40 + SCREENADDR, 13 * 40 + SCREENADDR,
+ 14 * 40 + SCREENADDR, 15 * 40 + SCREENADDR,
+ 16 * 40 + SCREENADDR, 17 * 40 + SCREENADDR,
+ 18 * 40 + SCREENADDR, 19 * 40 + SCREENADDR,
+ 20 * 40 + SCREENADDR, 21 * 40 + SCREENADDR,
+ 22 * 40 + SCREENADDR, 23 * 40 + SCREENADDR,
+ 24 * 40 + SCREENADDR};
+
+unsigned short ctk_80col_yhiresaddr[25] =
+ {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+ 2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+ 4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+ 6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+ 8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+ 10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+ 12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+ 14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+ 16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+ 18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+ 20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+ 22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+ 24 * 320 + HIRESADDR};
+
+
+struct ctk_80col_theme ctk_80col_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0xff,0xc0,0x80,0xbf,0x80,0xbf,0x80,0x80},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0xff,0x03,0x01,0xfd,0x01,0xfd,0x01,0x01},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x01,0x01,0x01,0x01,0x01,0x01,0x03,0xff},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xff},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+
+ /* buttonright[8]; */
+ {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0x0f,0x3f,0x3f,0x7f,0x7f,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xf0,0xfc,0xfc,0xfe,0xfe,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_BLACK),
+ COLOR(COLOR_GRAY2, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_WHITE),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_WHITE)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_WHITE),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_YELLOW, COLOR_BLACK),
+
+ /* openmenucolor, */
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+
+ /* activemenucolor; */
+ COLOR(COLOR_BLACK, COLOR_WHITE),
+
+ };
+char ctk_80col_versionstring[] = CONTIKI_VERSION_STRING;
+char ctk_80col_versionstring_len = sizeof(CONTIKI_VERSION_STRING) - 1;
+
+struct ctk_80col_windowparams ctk_80col_windowparams;
+
+/*---------------------------------------------------------------------------*/
+/*void
+ctk_arch_draw_char(char c,
+ unsigned char xpos,
+ unsigned char ypos,
+ unsigned char reversedflag,
+ unsigned char color)
+{
+ ctk_80col_cursx = xpos;
+ ctk_80col_cursy = ypos;
+ ctk_80col_reversed = reversedflag;
+ ctk_80col_color = color;
+
+ ctk_80col_cputc(c);
+}*/
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("rti");
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+ asm("sei");
+ asm("pha");
+ asm("inc $d020");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$36");
+ asm("sta $01");
+ asm("lda #>_nmi2");
+ asm("pha");
+ asm("lda #<_nmi2");
+ asm("pha");
+ asm("php");
+ asm("jmp ($0318)");
+
+ nmi2();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+ asm("lda #<_nmi");
+ asm("sta $fffa");
+ asm("lda #>_nmi");
+ asm("sta $fffb");
+ return;
+ nmi();
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+void reset(void);
+void
+quit(void)
+{
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x03; /* $DD00 */
+
+ VIC.bordercolor = 0x0e; /* $D020 */
+ VIC.bgcolor0 = 0x06; /* $D021 */
+
+ memset((char *)0xd800, 0x0e, 40*25);
+
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+ctk_80col_init(void)
+{
+ int i;
+
+ setup_nmi();
+
+ /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+ hires/colors. */
+ VIC.ctrl1 = 0x3b; /* $D011 */
+ VIC.addr = 0x78; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x00; /* $DD00 */
+
+ VIC.bordercolor = 0x06; /* $D020 */
+ VIC.bgcolor0 = 0x0b; /* $D021 */
+
+ /* Fill color memory. */
+ asm("sei");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$30");
+ asm("sta $01");
+ asm("ldx #0");
+ asm("lda #$0");
+ asm("fillcolorloop:");
+ asm("sta $dc00,x");
+ asm("sta $dd00,x");
+ asm("sta $de00,x");
+ asm("sta $df00,x");
+ asm("inx");
+ asm("bne fillcolorloop");
+
+ /* Setup sprite pointers */
+ asm("ldx #$fd");
+ asm("stx $dff8");
+ asm("inx");
+ asm("stx $dff9");
+ asm("pla");
+ asm("sta $01");
+ asm("cli");
+
+ /* Fill hires memory with 0. */
+
+ memset((char *)0xe000, 0, 8000);
+
+ for(i = 0; i < 256; ++i) {
+#if 0
+ ctk_80col_lefttab[i] =
+ ((i & 0x40) << 1) |
+ ((i & 0x20) << 1) |
+ ((i & 0x08) << 2) |
+ ((i & 0x02) << 3);
+ ctk_80col_righttab[i] =
+ ((i & 0x40) >> 3) |
+ ((i & 0x20) >> 3) |
+ ((i & 0x08) >> 2) |
+ ((i & 0x02) >> 1);
+#else
+ ctk_80col_lefttab[i] =
+ ((i & 0x40) << 1) |
+ ((i & 0x10) << 2) |
+ ((i & 0x04) << 3) |
+ ((i & 0x01) << 4);
+ ctk_80col_righttab[i] =
+ ((i & 0x40) >> 3) |
+ ((i & 0x10) >> 2) |
+ ((i & 0x04) >> 1) |
+ ((i & 0x01));
+#endif
+ }
+
+#if 0
+ /* Setup mouse pointer sprite. */
+ asm("lda %v+%w", ctk_80col_theme,
+ offsetof(struct ctk_80col_theme, pointermaskcolor));
+ asm("sta $d027");
+ asm("lda %v+%w", ctk_80col_theme,
+ offsetof(struct ctk_80col_theme, pointercolor));
+ asm("sta $d028");
+
+ ptr1 = ctk_80col_theme.pointer;
+ ptr2 = (unsigned char *)0xff40;
+
+ for(i = 0; i < 0x80; ++i) {
+ *ptr2++ = *ptr1++;
+ }
+#endif
+ return;
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+/*static unsigned char cursx, cursy;
+ static unsigned char reversed;*/
+
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+cputc(char c)
+{
+ /* ctk_arch_draw_char(c, cursx, cursy, reversed, 0);*/
+ ctk_80col_cputc(c);
+ /* ++cursx;*/
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherex(void)
+{
+ return ctk_80col_cursx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+wherey(void)
+{
+ return ctk_80col_cursy;
+}
+/*-----------------------------------------------------------------------------------*/
+/*void
+clrscr(void)
+{
+ unsigned char x, y;
+
+ for(x = 0; x < SCREEN_WIDTH; ++x) {
+ for(y = 0; y < SCREEN_HEIGHT; ++y) {
+ gotoxy(x, y);
+ cputc(' ');
+ }
+ }
+}*/
+/*-----------------------------------------------------------------------------------*/
+#define revers(c) ctk_80col_reversed = c
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+_cputs(char *str)
+{
+ char *ptr = str;
+
+ while(*ptr != 0) {
+ cputc(*ptr++);
+ }
+
+ /* int i;
+ for(i = 0; i < strlen(str); ++i) {
+ cputc(str[i]);
+ }*/
+}
+/*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+cclear(unsigned char length)
+{
+ int i;
+ for(i = 0; i < length; ++i) {
+ cputc(' ');
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chline(unsigned char length)
+{
+ int i;
+ for(i = 0; i < length; ++i) {
+ cputc('-');
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvline(unsigned char length)
+{
+ int i;
+ for(i = 0; i < length; ++i) {
+ cputc('|');
+ --ctk_80col_cursx;
+ ++ctk_80col_cursy;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+gotoxy(unsigned char x, unsigned char y)
+{
+ ctk_80col_cursx = x;
+ ctk_80col_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+ gotoxy(x, y);
+ cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ gotoxy(x, y);
+ chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ gotoxy(x, y);
+ cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+_cputsxy(unsigned char x, unsigned char y, char *str)
+{
+ gotoxy(x, y);
+ _cputs(str);
+}
+/*-----------------------------------------------------------------------------------*/
+void CC_FASTCALL
+cputcxy(unsigned char x, unsigned char y, char c)
+{
+ gotoxy(x, y);
+ cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+/*void CC_FASTCALL
+screensize(unsigned char *x, unsigned char *y)
+{
+ *x = SCREEN_WIDTH;
+ *y = SCREEN_HEIGHT;
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*static unsigned char sizex, sizey;*/
+/*-----------------------------------------------------------------------------------*/
+static void
+_cputsn(char *str, unsigned char len)
+{
+ /* char c;
+
+ while(len > 0) {
+ --len;
+ c = *str;
+ if(c == 0) {
+ break;
+ }
+ cputc(c);
+ ++str;
+ }*/
+ ctk_80col_cputsn(str, len);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_init(void)
+{
+ ctk_80col_init();
+
+ /* screensize(&sizex, &sizey);*/
+
+ ctk_draw_clear(0, SCREEN_HEIGHT);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+ unsigned char x, unsigned char y,
+ unsigned char clipx,
+ unsigned char clipy,
+ unsigned char clipy1, unsigned char clipy2,
+ unsigned char focus)
+{
+ unsigned char xpos, ypos, xscroll;
+ unsigned char i, j;
+ char c, *text;
+ unsigned char len, wfocus;
+
+ wfocus = 0;
+ if(focus & CTK_FOCUS_WINDOW) {
+ if(focus & CTK_FOCUS_WIDGET) {
+ wfocus = 1;
+ }
+ } else if(focus & CTK_FOCUS_DIALOG) {
+ if(focus & CTK_FOCUS_WIDGET) {
+ wfocus = 1;
+ }
+ } else {
+ }
+
+ xpos = x + w->x;
+ ypos = y + w->y;
+
+ switch(w->type) {
+ case CTK_WIDGET_SEPARATOR:
+ if(ypos >= clipy1 && ypos < clipy2) {
+ chlinexy(xpos, ypos, w->w);
+ }
+ break;
+ case CTK_WIDGET_LABEL:
+ text = w->widget.label.text;
+ for(i = 0; i < w->h; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ gotoxy(xpos, ypos);
+ _cputsn(text, w->w);
+ if(w->w - (wherex() - xpos) > 0) {
+ cclear(w->w - (wherex() - xpos));
+ }
+ }
+ ++ypos;
+ text += w->w;
+ }
+ break;
+ case CTK_WIDGET_BUTTON:
+ if(ypos >= clipy1 && ypos < clipy2) {
+ if(wfocus != 0) {
+ revers(1);
+ } else {
+ revers(0);
+ }
+ cputcxy(xpos, ypos, '[');
+ _cputsn(w->widget.button.text, w->w);
+ cputc(']');
+ revers(0);
+ }
+ break;
+ case CTK_WIDGET_HYPERLINK:
+ if(ypos >= clipy1 && ypos < clipy2) {
+ if(wfocus != 0) {
+ revers(0);
+ } else {
+ revers(1);
+ }
+ gotoxy(xpos, ypos);
+ _cputsn(w->widget.button.text, w->w);
+ revers(0);
+ }
+ break;
+ case CTK_WIDGET_TEXTENTRY:
+ text = w->widget.textentry.text;
+ if(wfocus != 0) {
+ revers(1);
+ } else {
+ revers(0);
+ }
+ xscroll = 0;
+ if(w->widget.textentry.xpos >= w->w - 1) {
+ xscroll = w->widget.textentry.xpos - w->w + 1;
+ }
+ for(j = 0; j < w->h; ++j) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+ w->widget.textentry.ypos == j) {
+ revers(0);
+ cputcxy(xpos, ypos, '>');
+ for(i = 0; i < w->w; ++i) {
+ c = text[i + xscroll];
+ if(i == w->widget.textentry.xpos - xscroll) {
+ revers(1);
+ } else {
+ revers(0);
+ }
+ if(c == 0) {
+ cputc(' ');
+ } else {
+ cputc(c);
+ }
+ revers(0);
+ }
+ cputc('<');
+ } else {
+ cvlinexy(xpos, ypos, 1);
+ gotoxy(xpos + 1, ypos);
+ _cputsn(text, w->w);
+ i = wherex();
+ if(i - xpos - 1 < w->w) {
+ cclear(w->w - (i - xpos) + 1);
+ }
+ cvline(1);
+ }
+ }
+ ++ypos;
+ text += w->w;
+ }
+ revers(0);
+ break;
+ case CTK_WIDGET_ICON:
+ if(ypos >= clipy1 && ypos < clipy2) {
+ color(ctk_80col_theme.iconcolors[focus]);
+
+ /* if(focus & 1) {
+
+ revers(1);
+ } else {
+ revers(0);
+ }*/
+ /* gotoxy(xpos, ypos);*/
+ if(xpos >= 73) {
+ xpos = 73;
+ }
+ if(xpos <= 2) {
+ xpos = 2;
+ }
+ if(w->widget.icon.textmap != NULL) {
+ ctk_80col_bitmapptr = w->widget.icon.bitmap;
+ for(i = 0; i < 3; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ gotoxy(xpos, ypos);
+ ctk_80col_draw_bitmapline(3);
+ }
+ ctk_80col_bitmapptr += 3 * 8;
+ ++ypos;
+ }
+ }
+ x = xpos;
+
+ len = strlen(w->widget.icon.title);
+ if(x + len >= SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - len;
+ }
+
+ if(ypos >= clipy1 && ypos < clipy2) {
+ len = strlen(w->widget.icon.title);
+ gotoxy((x & 0xfe) + 1, ypos);
+ ctk_80col_cclear((len - 1)/ 2);
+ gotoxy(x, ypos);
+ ctk_80col_cputsn(w->widget.icon.title, len);
+ }
+ revers(0);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ struct ctk_window *win = w->window;
+ unsigned char posx, posy;
+
+ posx = (win->x & 0xfe) + 1;
+ posy = win->y + 2;
+
+ if(w == win->focused) {
+ focus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, posx, posy,
+ posx + win->w,
+ posy + win->h,
+ clipy1, clipy2,
+ focus);
+
+#ifdef CTK_CONIO_CONF_UPDATE
+ CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ unsigned char i;
+ unsigned char h;
+
+ if(focus & CTK_FOCUS_WINDOW) {
+ color(COLOR_FOCUS_WINDOW);
+ } else {
+ color(COLOR_BACKGROUND_WINDOW);
+ }
+
+ h = window->y + 2 + window->h;
+ /* Clear window contents. */
+ for(i = window->y + 2; i < h; ++i) {
+ if(i >= clipy1 && i < clipy2) {
+ gotoxy((window->x & 0xfe) + 1, i);
+ ctk_80col_cclear((window->w + 1)/2);
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+ unsigned char clipy1, unsigned char clipy2,
+ unsigned char x1, unsigned char x2,
+ unsigned char y1, unsigned char y2)
+{
+ struct ctk_widget *w;
+ unsigned char wfocus;
+
+ /* Draw inactive widgets. */
+ for(w = window->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1, x2, y2,
+ clipy1, clipy2,
+ focus);
+ }
+
+ /* Draw active widgets. */
+ for(w = window->active; w != NULL; w = w->next) {
+ wfocus = focus;
+ if(w == window->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, x1, y1, x2, y2,
+ clipy1, clipy2,
+ wfocus);
+ }
+
+#ifdef CTK_CONIO_CONF_UPDATE
+ CTK_CONIO_CONF_UPDATE();
+#endif /* CTK_CONIO_CONF_UPDATE */
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
+ unsigned char clipy1, unsigned char clipy2)
+{
+ unsigned char x, y;
+ unsigned char h;
+ unsigned char x1, y1, x2, y2;
+
+
+ if(window->y + 1 >= clipy2) {
+ return;
+ }
+
+ x = window->x & 0xfe;
+ y = window->y + 1;
+
+/* if(focus & CTK_FOCUS_WINDOW) {
+ } else {
+ }*/
+
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + window->w;
+ y2 = y1 + window->h;
+
+ /* Draw window frame. */
+ gotoxy(x, y);
+ ctk_80col_windowparams.w = (window->w-1)/2;
+ ctk_80col_windowparams.h = window->h;
+ if(clipy1 < y) {
+ ctk_80col_windowparams.clipy1 = 0;
+ } else {
+ ctk_80col_windowparams.clipy1 = clipy1 - y;
+ }
+ ctk_80col_windowparams.clipy2 = clipy2 - y + 1;
+ ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[focus];
+ ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[focus];
+ ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[focus+1];
+ ctk_80col_windowparams.title = window->title;
+ ctk_80col_windowparams.titlelen = window->titlelen/2;
+
+ if(ctk_80col_windowparams.clipy1 < ctk_80col_windowparams.clipy2 &&
+ ctk_80col_windowparams.clipy2 > 0) {
+ ctk_80col_draw_windowborders();
+ }
+ /*
+ if(y >= clipy1) {
+ cputcxy(x, y, CH_ULCORNER);
+ gotoxy(wherex() + window->titlelen + 2, wherey());
+ chline(window->w - (wherex() - x) - 2);
+ cputcxy(x2, y, CH_URCORNER);
+ }
+
+ h = window->h;
+
+ if(clipy1 > y1) {
+ if(clipy1 - y1 < h) {
+ h = clipy1 - y1;
+ y1 = clipy1;
+ } else {
+ h = 0;
+ }
+ }
+
+ if(clipy2 < y1 + h) {
+ if(y1 >= clipy2) {
+ h = 0;
+ } else {
+ h = clipy2 - y1;
+ }
+ }
+
+ cvlinexy(x, y1, h);
+ cvlinexy(x2, y1, h);
+
+ if(y + window->h >= clipy1 &&
+ y + window->h < clipy2) {
+ cputcxy(x, y2, CH_LLCORNER);
+ chlinexy(x1, y2, window->w);
+ cputcxy(x2, y2, CH_LRCORNER);
+ }
+ */
+ if(ctk_mode_get() != CTK_MODE_WINDOWMOVE) {
+ draw_window_contents(window, focus & CTK_FOCUS_WINDOW, clipy1, clipy2,
+ x1, x2, y + 1, y2);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(struct ctk_window *dialog)
+{
+ unsigned char x, y;
+ unsigned char i;
+ unsigned char x1, y1, x2, y2;
+
+
+ x = dialog->x & 0xfe;
+ y = dialog->y + 1;
+
+
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + dialog->w;
+ y2 = y1 + dialog->h;
+
+
+ /* Draw dialog frame. */
+
+ /* cvlinexy(x, y1,
+ dialog->h);
+ cvlinexy(x2, y1,
+ dialog->h);
+
+ chlinexy(x1, y,
+ dialog->w);
+ chlinexy(x1, y2,
+ dialog->w);
+
+ cputcxy(x, y, CH_ULCORNER);
+ cputcxy(x, y2, CH_LLCORNER);
+ cputcxy(x2, y, CH_URCORNER);
+ cputcxy(x2, y2, CH_LRCORNER);
+ */
+ gotoxy(x, y);
+ ctk_80col_windowparams.w = (dialog->w-1)/2;
+ ctk_80col_windowparams.h = dialog->h;
+ ctk_80col_windowparams.clipy1 = 0;
+ ctk_80col_windowparams.clipy2 = SCREEN_HEIGHT;
+ ctk_80col_windowparams.color1 = ctk_80col_theme.windowcolors[4];
+ ctk_80col_windowparams.color2 = ctk_80col_theme.windowcolors[4];
+ ctk_80col_windowparams.titlecolor = ctk_80col_theme.windowcolors[5];
+
+ ctk_80col_draw_windowborders();
+
+ /* Clear dialog contents. */
+ color(COLOR_DIALOG);
+ for(i = y1; i < y2; ++i) {
+ gotoxy((x1 & 0xfe) + 2, i);
+ ctk_80col_cclear((dialog->w + 1)/2 - 2);
+ /* cclearxy(x1, i, dialog->w);*/
+ }
+
+ draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, SCREEN_HEIGHT,
+ x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+ unsigned char i;
+
+
+ for(i = y1; i < y2; ++i) {
+
+ ctk_80col_clear_line(i);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m)
+{
+ unsigned char x, x2, y;
+
+ color(ctk_80col_theme.openmenucolor);
+
+ revers(0);
+ x = wherex();
+ _cputs(m->title);
+ cputc(' ');
+ x2 = wherex();
+ if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH - 2;
+ }
+
+ for(y = 0; y < m->nitems; ++y) {
+ if(y == m->active) {
+ color(ctk_80col_theme.activemenucolor);
+ } else {
+ color(ctk_80col_theme.openmenucolor);
+ }
+ gotoxy(x, y + 1);
+ ctk_80col_cclear(CTK_CONF_MENUWIDTH/2);
+
+ gotoxy(x, y + 1);
+ if(m->items[y].title[0] == '-') {
+ chline(CTK_CONF_MENUWIDTH);
+ } else {
+ /* _cputs(m->items[y].title);*/
+ ctk_80col_cputsn(m->items[y].title, m->items[y].titlelen);
+ }
+ /* if(x + CTK_CONF_MENUWIDTH > wherex()) {
+ cclear(x + CTK_CONF_MENUWIDTH - wherex());
+ }*/
+
+ }
+ gotoxy(x2, 0);
+ revers(1);
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+ struct ctk_menu *m;
+
+ memcpy((char *)0xe000, ctk_80col_theme.menuleftpattern, 8);
+ /* Draw menus */
+ gotoxy(2, 0);
+
+ revers(1);
+ for(m = menus->menus->next; m != NULL; m = m->next) {
+ color(ctk_80col_theme.menucolor);
+ if(m != menus->open) {
+ /* _cputs(m->title);*/
+ ctk_80col_cputsn(m->title, m->titlelen);
+ cputc(' ');
+ } else {
+ draw_menu(m);
+ }
+ }
+
+ color(ctk_80col_theme.menucolor);
+
+ if(wherex() + strlen(menus->desktopmenu->title) + 2 >= SCREEN_WIDTH) {
+ gotoxy(SCREEN_WIDTH - strlen(menus->desktopmenu->title) - 2, 0);
+ } else {
+ cclear(SCREEN_WIDTH - wherex() -
+ strlen(menus->desktopmenu->title) - 2);
+ }
+
+ /* Draw desktopmenu */
+ if(menus->desktopmenu != menus->open) {
+ ctk_80col_cputsn(menus->desktopmenu->title, menus->desktopmenu->titlelen);
+ } else {
+ draw_menu(menus->desktopmenu);
+ }
+
+ /* gotoxy(78, 0);
+ color(ctk_80col_screencolors[0]);
+ cputc(' ');
+ cputc(' '); */
+
+ revers(0);
+ memcpy((char *)0xe138, ctk_80col_theme.menurightpattern, 8);
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+ return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+ return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+ return x / 4;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+ return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+ {CTK_DRAW_SERVICE_VERSION,
+ 1,
+ 1,
+ 1,
+ s_ctk_draw_init,
+ s_ctk_draw_clear,
+ s_ctk_draw_clear_window,
+ s_ctk_draw_window,
+ s_ctk_draw_dialog,
+ s_ctk_draw_widget,
+ s_ctk_draw_menus,
+ s_ctk_draw_width,
+ s_ctk_draw_height,
+ s_ctk_mouse_xtoc,
+ s_ctk_mouse_ytoc,
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": 80col", EK_PRIO_NORMAL,
+ eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_80col_service_init, arg)
+{
+ ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ s_ctk_draw_init();
+ ctk_restore();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x03; /* $DD00 */
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ quit();
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S
new file mode 100644
index 0000000..8d52510
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.S
@@ -0,0 +1,934 @@
+
+;---------------------------------------------------------------------
+ .importzp ptr1, ptr2, ptr3, ptr4, sreg
+ .importzp sp
+
+ .import incsp2
+
+
+ .import _ctk_hires_cursx
+ .import _ctk_hires_cursy
+ .import _ctk_hires_color
+ .import _ctk_hires_underline
+ .import _ctk_hires_reversed
+
+ .import _ctk_hires_yscreenaddr
+ .import _ctk_hires_yhiresaddr
+
+ .import _ctk_hires_windowparams
+
+ .import _ctk_hires_bitmapptr
+
+ .import _ctk_hires_theme
+
+ .export _ctk_hires_cclear
+ .export _ctk_hires_chline
+ .export _ctk_hires_cputc
+ .export _ctk_hires_cputsn
+
+ .export _ctk_hires_draw_buttonleft
+ .export _ctk_hires_draw_buttonright
+
+ .export _ctk_hires_draw_windowborders
+
+ .export _ctk_hires_draw_bitmapline
+;---------------------------------------------------------------------
+
+ptr5 = sreg
+
+ ;; Offsets in the theme struct
+
+ ulcornerpattern = 8
+ titlebarpattern = ulcornerpattern+8
+ urcornerpattern = titlebarpattern+8
+ rborderpattern = urcornerpattern+8
+ lrcornerpattern = rborderpattern+8
+ lowerborderpattern = lrcornerpattern+8
+ llcornerpattern = lowerborderpattern+8
+ lborderpattern = llcornerpattern+8
+
+
+ buttonleftpattern = lborderpattern+8
+ buttonrightpattern = buttonleftpattern+8
+
+
+.bss
+tmp01: .res 1
+tmpl: .res 1
+tmpf: .res 1
+tmpc: .res 1
+tmpw: .res 1
+tmpptr: .res 2
+
+tmpy: .res 1
+tmph: .res 1
+
+ ;; Window border parameters
+w: .res 1
+wpw = 0
+h: .res 1
+wph = 1
+clipy1: .res 1
+wpclipy1 = 2
+clipy2: .res 1
+wpclipy2 = 3
+color1: .res 1
+wpcolor1 = 4
+color2: .res 1
+wpcolor2 = 5
+titlelen: .res 1
+wptitlelen = 6
+title: .res 2
+wptitle = 7
+
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
+setupptrs:
+ ;; Find hires address.
+ lda _ctk_hires_cursy
+ asl
+ tax
+ lda _ctk_hires_yhiresaddr,x
+ sta ptr2
+ lda _ctk_hires_yhiresaddr+1,x
+ sta ptr2+1
+
+ ;; Add X coordinate to the hires address.
+ lda #0
+ sta ptr1+1
+ lda _ctk_hires_cursx
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ clc
+ adc ptr2
+ sta ptr2
+ lda ptr2+1
+ adc ptr1+1
+ sta ptr2+1
+
+
+ ;; Find screen address.
+ lda _ctk_hires_cursy
+ asl
+ tax
+ lda _ctk_hires_yscreenaddr,x
+ clc
+ adc _ctk_hires_cursx
+ sta ptr1
+ lda _ctk_hires_yscreenaddr+1,x
+ adc #0
+ sta ptr1+1
+
+ ;; Turn off interrupts, prepare $01 to store color data in RAM
+ ;; under I/O area.
+ sei
+ lda $01
+ sta tmp01
+ and #$f8
+ sta $01
+ rts
+;---------------------------------------------------------------------
+restore01:
+ lda tmp01
+ sta $01
+ cli
+ rts
+;---------------------------------------------------------------------
+_ctk_hires_cclear:
+ sta tmpl
+ cmp #0
+ bne @norts
+ rts
+@norts:
+
+ jsr setupptrs
+
+ ;; Store color value in color memory
+
+ ldy tmpl
+ dey
+ lda _ctk_hires_color
+@loop0:
+ sta (ptr1),y
+ dey
+ bpl @loop0
+
+ ;; Store either $00 or $ff in hires memory, depending on the
+ ;; reversed flag
+
+ ldx tmpl
+ lda _ctk_hires_reversed
+ beq @noff
+ lda #$ff
+@noff:
+ sta tmpf
+@loop1:
+ ldy #7
+ lda tmpf
+@loop2:
+ sta (ptr2),y
+ dey
+ bpl @loop2
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc @noinc
+ inc ptr2+1
+@noinc:
+
+ inc _ctk_hires_cursx
+
+ dex
+ bne @loop1
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_chline:
+ sta tmpl
+ cmp #0
+ bne @norts
+ rts
+@norts:
+
+ jsr setupptrs
+
+ ;; Store color value in color memory
+
+ ldy tmpl
+ dey
+ lda _ctk_hires_color
+@loop0:
+ sta (ptr1),y
+ dey
+ bpl @loop0
+
+ ;; Store horizontal line pattern in hires memory
+ ldx tmpl
+@loop1:
+ ldy #0
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$ff
+ sta (ptr2),y
+ iny
+ lda #$ff
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+ iny
+ lda #$00
+ sta (ptr2),y
+
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc @noinc
+ inc ptr2+1
+@noinc:
+
+ inc _ctk_hires_cursx
+
+ dex
+ bne @loop1
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_cputc:
+ sta tmpc
+
+ jsr setupptrs
+
+ ldy #0
+ lda _ctk_hires_color
+ sta (ptr1),y
+
+ ;; Turn on font ROM
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+ lda #0
+ sta ptr1+1
+
+ ;; Convert from PETSCII to screen encoding
+ lda tmpc
+ eor #$e0
+ clc
+ adc #$20
+ bpl @cont
+ adc #$40
+ bpl @cont
+ eor #$a0
+@cont:
+ ldx _ctk_hires_reversed
+ beq :+
+ eor #$80
+:
+
+ ;; Convert to address in character ROM
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ sta ptr1
+ lda #$d8
+ adc ptr1+1
+ sta ptr1+1
+
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_hires_underline
+ beq @nounderline
+ eor #$ff
+@nounderline:
+ sta (ptr2),y
+ dey
+@loop:
+ lda (ptr1),y
+ sta (ptr2),y
+ dey
+ bpl @loop
+
+ inc _ctk_hires_cursx
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_cputsn:
+ sta tmpl
+ cmp #0
+ bne :+
+ rts
+:
+
+ jsr setupptrs
+
+ ldy tmpl
+ dey
+ lda _ctk_hires_color
+@loop0:
+ sta (ptr1),y
+ dey
+ bpl @loop0
+
+ ;; Turn on font ROM
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+
+ ;; Output each character from the string
+ lda #0
+ sta tmpc
+ ldy #0
+ lda (sp),y
+ sta ptr3
+ iny
+ lda (sp),y
+ sta ptr3+1
+
+@loop1:
+
+ lda #0
+ sta ptr1+1
+
+ ldy tmpc
+ lda (ptr3),y
+ beq @end
+
+ ;; Convert from PETSCII to screen encoding
+ eor #$e0
+ clc
+ adc #$20
+ bpl @cont
+ adc #$40
+ bpl @cont
+ eor #$a0
+@cont:
+ ldx _ctk_hires_reversed
+ beq :+
+ eor #$80
+:
+
+ ;; Convert to address in character ROM
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ asl
+ rol ptr1+1
+ sta ptr1
+ lda #$d8
+ adc ptr1+1
+ sta ptr1+1
+
+ ;; Print on hires screen, bottom-up. If we should underline,
+ ;; we do this by eor:ing the bottom line with #$ff
+ ldy #7
+ lda (ptr1),y
+ ldx _ctk_hires_underline
+ beq @nounderline
+ eor #$ff
+@nounderline:
+ sta (ptr2),y
+ dey
+@loop:
+ lda (ptr1),y
+ sta (ptr2),y
+ dey
+ bpl @loop
+
+ inc _ctk_hires_cursx
+
+ lda ptr2
+ clc
+ adc #8
+ sta ptr2
+ bcc :+
+ inc ptr2+1
+:
+ inc tmpc
+ lda tmpc
+ cmp tmpl
+ bne @loop1
+
+@end:
+ jsr restore01
+
+ jmp incsp2
+
+;---------------------------------------------------------------------
+_ctk_hires_draw_windowborders:
+
+ jsr setupptrs
+
+ lda _ctk_hires_windowparams + wpclipy1
+ beq :+
+ jmp @nofirstline
+:
+
+ ;; Draw first line of the border, including the window title
+
+ ;; Start with filling color memory
+ ldy _ctk_hires_windowparams + wpw
+ iny
+ lda _ctk_hires_windowparams + wpcolor1
+ sta (ptr1),y
+ dey
+ dey
+ dey
+ sty tmpw
+
+ ldy _ctk_hires_windowparams + wptitlelen
+ iny
+ iny
+ iny
+:
+ sta (ptr1),y
+ iny
+ cpy tmpw
+ bcc :-
+
+ inc tmpw
+
+ ;; Set color for upper left corner
+ ldy #0
+ lda _ctk_hires_windowparams + wpcolor1
+ sta (ptr1),y
+
+
+ ;; Turn on font ROM for drawing the title
+ lda tmp01
+ and #$f8
+ ora #$01
+ sta $01
+
+ ;; Use a temporary pointer (ptr3) rather than ptr2 so we can
+ ;; reuse it later.
+ lda ptr2
+ sta ptr3
+ lda ptr2+1
+ sta ptr3+1
+
+ ;; Draw upper left corner
+ ldy #7
+:
+ lda _ctk_hires_theme+ulcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ ;; Draw first empty char left of the title
+ ldy #8
+ lda #0
+:
+; sta (ptr3),y
+ iny
+ cpy #$10
+ bne :-
+
+ lda ptr3
+ clc
+ adc #$10
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ dec tmpw
+
+ ;; Draw the title
+ lda _ctk_hires_windowparams + wptitle
+ sta ptr4
+ lda _ctk_hires_windowparams + wptitle+1
+ sta ptr4+1
+
+
+ lda #0
+ sta tmpc
+@titleloop:
+ lda #0
+ sta ptr5+1
+
+ ldy tmpc
+ lda (ptr4),y
+
+
+ ;; Convert from PETSCII to screen encoding
+ eor #$e0
+ clc
+ adc #$20
+ bpl @cont
+ adc #$40
+ bpl @cont
+ eor #$a0
+@cont:
+ ;; Convert to address in character ROM
+ asl
+ rol ptr5+1
+ asl
+ rol ptr5+1
+ asl
+ rol ptr5+1
+ sta ptr5
+ lda #$d8
+ adc ptr5+1
+ sta ptr5+1
+
+ ;; Print on hires screen, character by character, bottom-up.
+ ldy #7
+:
+ lda (ptr5),y
+; sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ clc
+ adc #8
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ dec tmpw
+
+ inc tmpc
+ lda tmpc
+ cmp _ctk_hires_windowparams + wptitlelen
+ bne @titleloop
+
+ ;; Draw empty char after the title
+ ldy #7
+ lda #0
+:
+; sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ clc
+ adc #$8
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ dec tmpw
+
+ ;; Draw window title bar pattern
+@titlebarloop:
+ ldy #7
+:
+ lda _ctk_hires_theme+titlebarpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ clc
+ adc #$8
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ ;; Loop until we are three characters away from right border
+ ;; to avoid flickering since we would be overwriting the close
+ ;; button.
+ dec tmpw
+ lda tmpw
+ cmp #3
+ bcs @titlebarloop
+
+ lda ptr3
+ clc
+ adc #$18
+ sta ptr3
+ bcc :+
+ inc ptr3+1
+:
+ ;; Draw upper right corner piece
+ ldy #7
+:
+ lda _ctk_hires_theme+urcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+
+@nofirstline:
+
+
+ ldx _ctk_hires_windowparams + wph
+ inx
+ stx tmph
+
+ ;; Draw left and right borders
+
+ ;; Fill color memory (pointer in ptr1, setup by setupptrs)
+
+ ;; First check how much we actually should draw by inspecting
+ ;; the clipy1 and clipy2 fields in the _ctk_hires_windowparams
+ ;; structure
+
+ lda #1
+ sta tmpy
+
+ ldx _ctk_hires_windowparams + wpclipy1
+@clipy1loop:
+ cpx #0
+ beq @clipy1loopend
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ inc tmpy
+
+ dex
+ jmp @clipy1loop
+@clipy1loopend:
+
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+
+ ldx tmpy
+ ldy _ctk_hires_windowparams + wpw
+ iny
+ sty tmpw
+@bordercloop:
+ cpx _ctk_hires_windowparams + wpclipy2
+ beq @bordercloopend
+
+ ldy tmpw
+ lda _ctk_hires_windowparams + wpcolor2
+ sta (ptr1),y
+ ldy #0
+ lda _ctk_hires_windowparams + wpcolor1
+ sta (ptr1),y
+
+ lda ptr1
+ clc
+ adc #$28
+ sta ptr1
+ bcc :+
+ inc ptr1+1
+:
+
+ inx
+ cpx tmph
+ bcc @bordercloop
+ beq @bordercloop
+@bordercloopend:
+
+
+ ;; Fill color memory for lower border, if clipy2 allows
+ cpx _ctk_hires_windowparams + wpclipy2
+ beq @noclowerborder
+
+ lda ptr1
+ sec
+ sbc #$28
+ sta ptr1
+ bcs :+
+ dec ptr1+1
+:
+
+ ldy _ctk_hires_windowparams + wpw
+ lda _ctk_hires_windowparams + wpcolor2
+@lbordercloop:
+ sta (ptr1),y
+ dey
+ bne @lbordercloop
+
+@noclowerborder:
+
+ ;; Draw right border
+ ldx tmpy
+@rborderloop:
+ cpx _ctk_hires_windowparams + wpclipy2
+ beq @rborderloopend
+
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ ldy #7
+:
+ lda _ctk_hires_theme+rborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ inx
+ cpx tmph
+ bne @rborderloop
+@rborderloopend:
+
+ cpx _ctk_hires_windowparams + wpclipy2
+ beq @norbordercorner
+
+ lda ptr3
+ clc
+ adc #$40
+ sta ptr3
+ lda ptr3+1
+ adc #1
+ sta ptr3+1
+
+ ;; Draw lower right corner, if clipy2 allows it
+ ldy #7
+:
+ lda _ctk_hires_theme+lrcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+@norbordercorner:
+
+ stx tmpy
+
+ ;; Draw lower border
+ ldx _ctk_hires_windowparams + wpw
+
+@lowerborderloop:
+ lda ptr3
+ sec
+ sbc #$8
+ sta ptr3
+ bcs :+
+ dec ptr3+1
+:
+
+ lda tmpy
+ cmp _ctk_hires_windowparams + wpclipy2
+ beq @nolowerborder
+
+ ldy #7
+:
+ lda _ctk_hires_theme+lowerborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+@nolowerborder:
+
+ dex
+ bne @lowerborderloop
+
+ lda ptr3
+ sec
+ sbc #$8
+ sta ptr3
+ bcs :+
+ dec ptr3+1
+:
+
+
+ ldx tmpy
+ cpx tmph
+ bne @nolbordercorner
+
+ ;; Draw lower left corner, if clipy2 allows it
+ ldy #7
+:
+ lda _ctk_hires_theme+llcornerpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ sec
+ sbc #$40
+ sta ptr3
+ lda ptr3+1
+ sbc #1
+ sta ptr3+1
+
+@nolbordercorner:
+
+ ;; Draw left border
+
+
+
+@lborderloop:
+ cpx #1
+ beq @lborderloopend
+ cpx _ctk_hires_windowparams + wpclipy1
+ bcc @lborderloopend
+
+ ldy #7
+:
+ lda _ctk_hires_theme+lborderpattern,y
+ sta (ptr3),y
+ dey
+ bpl :-
+
+ lda ptr3
+ sec
+ sbc #$40
+ sta ptr3
+ lda ptr3+1
+ sbc #1
+ sta ptr3+1
+
+ dex
+ jmp @lborderloop
+
+@lborderloopend:
+
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_draw_buttonleft:
+ jsr setupptrs
+
+ ldy #0
+ lda _ctk_hires_color
+ sta (ptr1),y
+
+:
+ lda _ctk_hires_theme+buttonleftpattern,y
+ sta (ptr2),y
+ iny
+ cpy #8
+ bne :-
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_draw_buttonright:
+ jsr setupptrs
+ ldy #0
+ lda _ctk_hires_color
+ sta (ptr1),y
+
+:
+ lda _ctk_hires_theme+buttonrightpattern,y
+ sta (ptr2),y
+ iny
+ cpy #8
+ bne :-
+
+ jmp restore01
+;---------------------------------------------------------------------
+_ctk_hires_draw_bitmapline:
+ sta tmpl
+ cmp #0
+ bne :+
+ rts
+:
+
+ jsr setupptrs
+
+ ldy #0
+ lda _ctk_hires_color
+:
+ sta (ptr1),y
+ iny
+ cpy tmpl
+ bne :-
+
+ lda _ctk_hires_bitmapptr
+ sta ptr1
+ lda _ctk_hires_bitmapptr+1
+ sta ptr1+1
+
+ ldy #0
+ ldx #0
+:
+ lda (ptr1),y
+ sta (ptr2),y
+ iny
+ inx
+ cpx #8
+ bne :-
+
+ ldx #0
+
+ dec tmpl
+ bne :-
+
+ jmp restore01
+;---------------------------------------------------------------------
+
\ No newline at end of file
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h
new file mode 100644
index 0000000..58fea69
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-asm.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-asm.h,v 1.1 2006/04/17 15:11:49 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_ASM_H__
+#define __CTK_HIRES_ASM_H__
+
+void __fastcall__ ctk_hires_cclear(unsigned char len);
+void __fastcall__ ctk_hires_chline(unsigned char len);
+void __fastcall__ ctk_hires_cputc(unsigned char c);
+void __fastcall__ ctk_hires_cputsn(unsigned char *str,
+ unsigned char len);
+
+void ctk_hires_draw_buttonleft(void);
+void ctk_hires_draw_buttonright(void);
+
+struct ctk_hires_windowparams {
+ unsigned char w;
+ unsigned char h;
+ unsigned char clipy1;
+ unsigned char clipy2;
+ unsigned char color1;
+ unsigned char color2;
+ unsigned char titlelen;
+ char *title;
+};
+extern struct ctk_hires_windowparams ctk_hires_windowparams;
+void ctk_hires_draw_windowborders(void);
+
+extern unsigned char ctk_hires_cursx,
+ ctk_hires_cursy,
+ ctk_hires_color,
+ ctk_hires_reversed,
+ ctk_hires_underline;
+
+
+void __fastcall__ ctk_hires_draw_bitmapline(unsigned char len);
+
+#endif /* __CTK_HIRES_ASM_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c
new file mode 100644
index 0000000..c35b3cd
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-service.c
@@ -0,0 +1,931 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires-service.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-draw-service.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH 40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR 0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+/*unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;*/
+
+static void s_ctk_draw_clear(unsigned char y1, unsigned char y2);
+
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+ {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+ 2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+ 4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+ 6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+ 8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+ 10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+ 12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+ 14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+ 16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+ 18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+ 20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+ 22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+ 24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+ {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+ 2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+ 4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+ 6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+ 8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+ 10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+ 12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+ 14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+ 16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+ 18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+ 20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+ 22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+ 24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c) ctk_hires_reversed = c
+#define hires_color(c) ctk_hires_color = c
+#define hires_underline(c) ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+ static unsigned char i;
+
+ for(i = 0; i < length; ++i) {
+ ctk_hires_cputc('|');
+ --ctk_hires_cursx;
+ ++ctk_hires_cursy;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+ ctk_hires_cursx = x;
+ ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+clear_line(unsigned char line)
+{
+ lineptr = line;
+ asm("lda %v", lineptr);
+ asm("asl");
+ asm("tax");
+ asm("lda %v,x", ctk_hires_yhiresaddr);
+ asm("sta ptr2");
+ asm("lda %v+1,x", ctk_hires_yhiresaddr);
+ asm("sta ptr2+1");
+ asm("lda %v,x", ctk_hires_yscreenaddr);
+ asm("sta ptr1");
+ asm("lda %v+1,x", ctk_hires_yscreenaddr);
+ asm("sta ptr1+1");
+
+
+ asm("sei");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$30");
+ asm("sta $01");
+ asm("ldy #39");
+ asm("ldx %v", lineptr);
+ asm("lda %v+%w,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+ asm("clearlineloop1:");
+ asm("sta (ptr1),y");
+ asm("dey");
+ asm("bpl clearlineloop1");
+ asm("pla");
+ asm("sta $01");
+ asm("cli");
+
+
+ asm("lda %v", lineptr);
+ /* asm("and #7");*/
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("tax");
+ asm("ldy #0");
+ asm("clearlineloop2:");
+ asm("lda %v+%w+0,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+1,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+2,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+3,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+4,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+5,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+6,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+7,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("bne clearlineloop2");
+
+ asm("inc ptr2+1");
+
+ asm("ldy #0");
+ asm("clearlineloop3:");
+ asm("lda %v+%w+0,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+1,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+2,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+3,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+4,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+5,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+6,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+7,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne clearlineloop3");
+
+
+ if(lineptr == 24) {
+ hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+ hires_gotoxy(0, 24);
+ ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+ sizeof(CONTIKI_VERSION_STRING) - 1);
+ }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("rti");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+ asm("sei");
+ asm("pha");
+ asm("inc $d020");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$36");
+ asm("sta $01");
+ asm("lda #>_nmi2");
+ asm("pha");
+ asm("lda #<_nmi2");
+ asm("pha");
+ asm("php");
+ asm("jmp ($0318)");
+
+ nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+ asm("lda #<_nmi");
+ asm("sta $fffa");
+ asm("lda #>_nmi");
+ asm("sta $fffb");
+ return;
+ nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+s_ctk_draw_init(void)
+{
+ unsigned char i, *ptr1, *ptr2;
+
+
+ setup_nmi();
+
+ /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+ hires/colors. */
+ VIC.ctrl1 = 0x3b; /* $D011 */
+ VIC.addr = 0x78; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x00; /* $DD00 */
+
+ VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+ VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */
+
+ /* Fill color memory. */
+ asm("sei");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$30");
+ asm("sta $01");
+ asm("ldx #0");
+ asm("lda #$c0");
+ asm("fillcolorloop:");
+ asm("sta $dc00,x");
+ asm("sta $dd00,x");
+ asm("sta $de00,x");
+ asm("sta $df00,x");
+ asm("inx");
+ asm("bne fillcolorloop");
+
+ /* Setup sprite pointers */
+ asm("ldx #$fd");
+ asm("stx $dff8");
+ asm("inx");
+ asm("stx $dff9");
+ asm("pla");
+ asm("sta $01");
+ asm("cli");
+
+ /* Fill hires memory with 0. */
+
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+ asm("lda #0");
+ asm("sta $fd");
+ asm("lda #$e0");
+ asm("sta $fe");
+ asm("ldy #0");
+ asm("lda #0");
+ asm("clrscrnloop:");
+ asm("lda #$55");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("lda #$aa");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("bne clrscrnloop");
+ asm("inc $fe");
+ asm("lda $fe");
+ asm("cmp #$ff");
+ asm("bne clrscrnloop");
+
+ asm("ldy #$00");
+ asm("clrscrnloop2:");
+ asm("lda #$55");
+ asm("sta $ff00,y");
+ asm("iny");
+ asm("lda #$aa");
+ asm("sta $ff00,y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne clrscrnloop2");
+
+
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+
+
+ s_ctk_draw_clear(0, SCREEN_HEIGHT);
+
+ /* Setup mouse pointer sprite. */
+ asm("lda %v+%w", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, pointermaskcolor));
+ asm("sta $d027");
+ asm("lda %v+%w", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, pointercolor));
+ asm("sta $d028");
+
+ ptr1 = ctk_hires_theme.pointer;
+ ptr2 = (unsigned char *)0xff40;
+
+ for(i = 0; i < 0x80; ++i) {
+ *ptr2++ = *ptr1++;
+ }
+
+ return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+ unsigned char x, unsigned char y,
+ unsigned char clipy1, unsigned char clipy2,
+ unsigned char afocus)
+{
+ static unsigned char xpos, ypos, xscroll;
+ static unsigned char i;
+ static char c;
+ static unsigned char len;
+ static unsigned char tmp;
+ static unsigned char yclipped;
+ static unsigned char focus;
+ char *text;
+
+ xpos = x + w->x;
+ ypos = y + w->y;
+
+ yclipped = 0;
+ if(ypos >= clipy1 && ypos < clipy2) {
+ yclipped = 1;
+ }
+ focus = afocus;
+
+
+ switch(w->type) {
+ case CTK_WIDGET_SEPARATOR:
+ hires_color(ctk_hires_theme.separatorcolors[focus]);
+ if(yclipped) {
+ hires_chlinexy(xpos, ypos, w->w);
+ }
+ break;
+ case CTK_WIDGET_LABEL:
+ hires_color(ctk_hires_theme.labelcolors[focus]);
+ text = w->widget.label.text;
+ for(i = 0; i < w->h; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_cputsn(text, w->w);
+ tmp = w->w - (hires_wherex() - xpos);
+ if(tmp > 0) {
+ ctk_hires_cclear(tmp);
+ }
+ }
+ ++ypos;
+ text += w->w;
+ }
+ break;
+ case CTK_WIDGET_BUTTON:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_buttonleft();
+ hires_color(ctk_hires_theme.buttoncolors[focus]);
+ hires_gotoxy(xpos + 1, ypos);
+ ctk_hires_cputsn(w->widget.button.text, w->w);
+ hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+ ctk_hires_draw_buttonright();
+ }
+ break;
+ case CTK_WIDGET_HYPERLINK:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+ hires_underline(1);
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_cputsn(w->widget.button.text, w->w);
+ hires_underline(0);
+ }
+ break;
+ case CTK_WIDGET_TEXTENTRY:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.textentrycolors[focus]);
+
+ if((focus & CTK_FOCUS_WIDGET) &&
+ w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+ hires_revers(1);
+ } else {
+ hires_revers(0);
+ }
+ xscroll = 0;
+ tmp = w->w - 1;
+ if(w->widget.textentry.xpos >= tmp) {
+ xscroll = w->widget.textentry.xpos - tmp;
+ }
+ text = w->widget.textentry.text;
+ if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+ hires_revers(0);
+ hires_cputcxy(xpos, ypos, '>');
+ text += xscroll;
+ for(i = 0; i < w->w; ++i) {
+ c = *text;
+ if(i == w->widget.textentry.xpos - xscroll) {
+ hires_revers(1);
+ } else {
+ hires_revers(0);
+ }
+ if(c == 0) {
+ ctk_hires_cputc(' ');
+ } else {
+ ctk_hires_cputc(c);
+ }
+ hires_revers(0);
+ ++text;
+ }
+ ctk_hires_cputc('<');
+ } else {
+ hires_cputcxy(xpos, ypos, '|');
+ /* hires_gotoxy(xpos + 1, ypos); */
+ ctk_hires_cputsn(text, w->w);
+ i = hires_wherex();
+ tmp = i - xpos - 1;
+ if(tmp < w->w) {
+ ctk_hires_cclear(w->w - tmp);
+ }
+ ctk_hires_cputc('|');
+ }
+ }
+ hires_revers(0);
+ break;
+ case CTK_WIDGET_ICON:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.iconcolors[focus]);
+
+ x = xpos;
+ len = strlen(w->widget.icon.title);
+ if(x + len >= SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - len;
+ }
+
+ tmp = ypos + 3;
+
+ if(tmp < clipy2) {
+ hires_gotoxy(x, tmp);
+ ctk_hires_cputsn(w->widget.icon.title, len);
+ }
+
+ hires_gotoxy(xpos, ypos);
+ if(w->widget.icon.bitmap != NULL) {
+ ctk_hires_bitmapptr = w->widget.icon.bitmap;
+ for(i = 0; i < 3; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_bitmapline(3);
+ }
+ ctk_hires_bitmapptr += 3 * 8;
+ ++ypos;
+ }
+
+ /* draw_bitmap_icon(w->widget.icon.bitmap);*/
+ }
+
+ }
+ break;
+ case CTK_WIDGET_BITMAP:
+ hires_color(ctk_hires_theme.bitmapcolors[focus]);
+ ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+ for(i = 0; i < w->h; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_bitmapline(w->w);
+ }
+ ctk_hires_bitmapptr += w->w * 8;
+ ++ypos;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_widget(struct ctk_widget *w,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ struct ctk_window *win = w->window;
+ unsigned char posx, posy;
+
+ posx = win->x + 1;
+ posy = win->y + 2;
+
+ if(w == win->focused) {
+ focus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, posx, posy,
+ clipy1, clipy2,
+ focus);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear_window(register struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ static unsigned char h;
+
+ hires_color(ctk_hires_theme.windowcolors[focus]);
+
+ h = window->y + 2 + window->h;
+ /* Clear window contents. */
+ for(i = window->y + 2; i < h; ++i) {
+ if(i >= clipy1 && i <= clipy2) {
+ hires_cclearxy(window->x + 1, i, window->w);
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_window(register struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1, unsigned char clipy2)
+{
+ register struct ctk_widget *w;
+
+ x = window->x;
+ y = window->y + 1;
+
+ ++clipy2;
+
+ if(clipy2 <= y) {
+ return;
+ }
+
+ /* hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+
+ x1 = x + 1;
+ y1 = y + 1;
+ /* x2 = x1 + window->w;
+ y2 = y1 + window->h;*/
+
+ hires_gotoxy(x, y);
+ ctk_hires_windowparams.w = window->w;
+ ctk_hires_windowparams.h = window->h;
+ if(clipy1 < y) {
+ ctk_hires_windowparams.clipy1 = 0;
+ } else {
+ ctk_hires_windowparams.clipy1 = clipy1 - y;
+ }
+ ctk_hires_windowparams.clipy2 = clipy2 - y;
+ ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+ ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+ ctk_hires_windowparams.title = window->title;
+ ctk_hires_windowparams.titlelen = window->titlelen;
+
+ if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+ ctk_hires_windowparams.clipy2 > 0) {
+ ctk_hires_draw_windowborders();
+ }
+
+ focus = focus & CTK_FOCUS_WINDOW;
+
+ /* Draw inactive widgets. */
+ for(w = window->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1,
+ clipy1, clipy2,
+ focus);
+ }
+
+ /* Draw active widgets. */
+ for(w = window->active; w != NULL; w = w->next) {
+ wfocus = focus;
+ if(w == window->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+ draw_widget(w, x1, y1,
+ clipy1, clipy2,
+ wfocus);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_dialog(register struct ctk_window *dialog)
+{
+ register struct ctk_widget *w;
+
+ hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+ /* x = (SCREEN_WIDTH - dialog->w) / 2;
+ y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+ x = dialog->x;
+ y = dialog->y + 1;
+
+
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + dialog->w;
+ y2 = y1 + dialog->h;
+
+
+ /* Draw dialog frame. */
+
+ hires_cvlinexy(x, y1, dialog->h);
+ hires_cvlinexy(x2, y1, dialog->h);
+
+ hires_chlinexy(x1, y, dialog->w);
+ hires_chlinexy(x1, y2, dialog->w);
+
+ hires_cputcxy(x, y, CH_ULCORNER);
+ hires_cputcxy(x, y2, CH_LLCORNER);
+ hires_cputcxy(x2, y, CH_URCORNER);
+ hires_cputcxy(x2, y2, CH_LRCORNER);
+
+
+ /* Clear window contents. */
+ for(i = y1; i < y2; ++i) {
+ hires_cclearxy(x1, i, dialog->w);
+ }
+
+ /* Draw inactive widgets. */
+ for(w = dialog->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1,
+ 0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+ }
+
+
+ /* Draw active widgets. */
+ for(w = dialog->active; w != NULL; w = w->next) {
+ wfocus = CTK_FOCUS_DIALOG;
+ if(w == dialog->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+ draw_widget(w, x1, y1,
+ 0, SCREEN_HEIGHT, wfocus);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+ for(i = y1; i < y2; ++i) {
+ clear_line(i);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+ static unsigned char x, x2, y;
+
+ hires_color(ctk_hires_theme.openmenucolor);
+ x = hires_wherex();
+ ctk_hires_cputsn(m->title, m->titlelen);
+ ctk_hires_cputc(' ');
+ x2 = hires_wherex();
+ if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+ }
+ for(y = 0; y < m->nitems; ++y) {
+ if(y == m->active) {
+ hires_color(ctk_hires_theme.activemenucolor);
+ } else {
+ hires_color(ctk_hires_theme.menucolor);
+ }
+ hires_gotoxy(x, y + 1);
+ if(m->items[y].title[0] == '-') {
+ ctk_hires_chline(CTK_CONF_MENUWIDTH);
+ } else {
+ ctk_hires_cputsn(m->items[y].title,
+ strlen(m->items[y].title));
+ }
+ ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+ hires_revers(0);
+ }
+ hires_gotoxy(x2, 0);
+ hires_color(ctk_hires_theme.menucolor);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+s_ctk_draw_menus(struct ctk_menus *menus)
+{
+ struct ctk_menu *m;
+
+ /* Draw menus */
+ hires_color(ctk_hires_theme.menucolor);
+ hires_gotoxy(0, 0);
+ hires_revers(0);
+ ctk_hires_cputc(' ');
+ for(m = menus->menus->next; m != NULL; m = m->next) {
+ if(m != menus->open) {
+ ctk_hires_cputsn(m->title, m->titlelen);
+ ctk_hires_cputc(' ');
+ } else {
+ draw_menu(m);
+ }
+ }
+ ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+ strlen(menus->desktopmenu->title) - 1);
+
+ /* Draw desktopmenu */
+ if(menus->desktopmenu != menus->open) {
+ ctk_hires_cputsn(menus->desktopmenu->title,
+ menus->desktopmenu->titlelen);
+ ctk_hires_cputc(' ');
+ } else {
+ draw_menu(menus->desktopmenu);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_height(void)
+{
+ return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+s_ctk_draw_width(void)
+{
+ return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_xtoc(unsigned short x)
+{
+ return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned short
+s_ctk_mouse_ytoc(unsigned short y)
+{
+ return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+static const struct ctk_draw_service_interface interface =
+ {CTK_DRAW_SERVICE_VERSION,
+ 1,
+ 1,
+ 1,
+ s_ctk_draw_init,
+ s_ctk_draw_clear,
+ s_ctk_draw_clear_window,
+ s_ctk_draw_window,
+ s_ctk_draw_dialog,
+ s_ctk_draw_widget,
+ s_ctk_draw_menus,
+ s_ctk_draw_width,
+ s_ctk_draw_height,
+ s_ctk_mouse_xtoc,
+ s_ctk_mouse_ytoc,
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME ": hires", EK_PRIO_NORMAL,
+ eventhandler, NULL, (void *)&interface);
+
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ctk_conio_service_init, arg)
+{
+ ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
+}
+/*--------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ s_ctk_draw_init();
+ ctk_restore();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ VIC.ctrl1 = 0x1b; /* $D011 */
+ VIC.addr = 0x17; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x03; /* $DD00 */
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ }
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
new file mode 100644
index 0000000..10fc27e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-blueround.c
@@ -0,0 +1,313 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-blueround.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x06
+#define BGCOLOR2 0x00
+#define BGCOLOR3 0x06
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},
+
+ /* buttonright[8]; */
+ {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+ COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_CYAN)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_CYAN),
+ COLOR(COLOR_BLUE, COLOR_WHITE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+ COLOR(COLOR_LIGHTBLUE, COLOR_WHITE)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLACK, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLACK, COLOR_CYAN),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_CYAN),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_BLUE, COLOR_BLACK),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLACK),
+ COLOR(COLOR_LIGHTBLUE, COLOR_CYAN)},
+
+
+ /* Button corner colors. */
+ /* unsigned char buttonleftcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+ /* buttonrightcolors[6]; */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE)},
+
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_BLUE, COLOR_LIGHTBLUE),
+
+ /* openmenucolor, */
+ COLOR(COLOR_LIGHTBLUE, COLOR_BLUE),
+
+ /* activemenucolor; */
+ COLOR(COLOR_CYAN, COLOR_BLUE),
+
+ /* Border and screen colors. */
+ /* unsigned char bordercolor,*/
+ 0,
+
+ /* screencolor; */
+ 0,
+
+ /* Pointer sprite 0 color */
+ /*unsigned char pointermaskcolor,*/
+ 3,
+
+ /* Pointer sprite 1 color */
+ /* pointercolor; */
+ 6,
+
+
+ /* Pointer sprite. */
+ /* unsigned char pointer[128]; */
+ {0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00,
+ 0x60, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x78, 0x00, 0x00,
+ 0x7c, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x58, 0x00, 0x00,
+ 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00,
+
+ 0xc0, 0x00, 0x00,
+ 0xe0, 0x00, 0x00,
+ 0xf0, 0x00, 0x00,
+ 0xf8, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0x3c, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00 },
+
+
+
+ /* Background pattern fill. */
+ /* unsigned char backgroundpattern[8*25]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+ 0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+ 0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+ 0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+ 0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+ 0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+ 0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+ 0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+ 0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x10,0x38,0x10,0x00,0x00,0x00,
+ 0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,
+ 0x00,0x18,0x3c,0x7e,0x7e,0x3c,0x18,0x00,
+ 0x00,0x3c,0x7e,0x7e,0x7e,0x7e,0x3c,0x00,
+ 0x3c,0x7e,0xff,0xff,0xff,0xff,0x7e,0x3c,
+ 0x7e,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ },
+
+ /* Background colors. */
+ /* unsigned char backgroundpatterncolors[25]; */
+ {
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+
+ COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+ COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+ COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+ COLOR(BGCOLOR2,BGCOLOR3),COLOR(BGCOLOR2,BGCOLOR3),
+
+ COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+ COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+ COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+ COLOR(BGCOLOR3,BGCOLOR4),COLOR(BGCOLOR3,BGCOLOR4),
+
+ COLOR(BGCOLOR4,BGCOLOR4)},
+
+
+
+ };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
new file mode 100644
index 0000000..ad8b430
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-default.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-default.c,v 1.1 2006/04/17 15:11:51 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 7
+#define BGCOLOR2 10
+#define BGCOLOR3 4
+#define BGCOLOR4 6
+
+struct ctk_hires_theme ctk_hires_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0xc5,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf,0xdf},
+
+ /* buttonright[8]; */
+ {0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xa3},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY3),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_WHITE),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_WHITE),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_WHITE)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_YELLOW),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+ /* Button corner colors. */
+ /* unsigned char buttonleftcolors[6], */
+ {COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_GRAY3),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY3),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+
+ /* buttonrightcolors[6]; */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY3),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY3)},
+
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_YELLOW, COLOR_BLACK),
+
+ /* openmenucolor, */
+ COLOR(COLOR_BLACK, COLOR_YELLOW),
+
+ /* activemenucolor; */
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+
+ /* Border and screen colors. */
+ /* unsigned char bordercolor,*/
+ 6,
+
+ /* screencolor; */
+ 0,
+
+ /* Pointer sprite 0 color */
+ 0,
+
+ /* Pointer sprite 1 color */
+ 1,
+
+
+ /* Pointer sprite. */
+ /* unsigned char pointer[128]; */
+ {0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00,
+ 0x60, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x78, 0x00, 0x00,
+ 0x7c, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x58, 0x00, 0x00,
+ 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00,
+
+ 0xc0, 0x00, 0x00,
+ 0xe0, 0x00, 0x00,
+ 0xf0, 0x00, 0x00,
+ 0xf8, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0x3c, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00 },
+
+
+
+ /* Background pattern fill. */
+ /* unsigned char backgroundpattern[8*25]; */
+ {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+ /* Background colors. */
+ /* unsigned char backgroundpatterncolors[25]; */
+ {COLOR(BGCOLOR1,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+
+
+
+ };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
new file mode 100644
index 0000000..996a558
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-enabler.c
@@ -0,0 +1,303 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-enabler.c,v 1.1 2006/04/17 15:11:52 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x0f
+#define BGCOLOR2 0x0c
+#define BGCOLOR3 0x0b
+#define BGCOLOR4 0x00
+
+struct ctk_hires_theme ctk_hires_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0xff,0xfc,0xf0,0xf0,0xe0,0xe0,0xe0,0xe0},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0xff,0x3f,0x0f,0x0f,0x07,0x07,0x07,0x07},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0x03,0x0f,0x1f,0x1f,0x1f,0x1f,0x0f,0x03},
+
+ /* buttonright[8]; */
+ {0xc0,0xf0,0xf8,0xf8,0xf8,0xf8,0xf0,0xc0},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY2, COLOR_GRAY3),
+ COLOR(COLOR_GRAY2, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GRAY2, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_GRAY2),
+ COLOR(COLOR_WHITE, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_WHITE)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY3, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+ /* Button corner colors. */
+ /* unsigned char buttonleftcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY3),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+ /* buttonrightcolors[6]; */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY3),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_GRAY3),
+ COLOR(COLOR_WHITE, COLOR_GRAY1)},
+
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+
+ /* openmenucolor, */
+ COLOR(COLOR_GRAY1, COLOR_GRAY3),
+
+ /* activemenucolor; */
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+
+ /* Border and screen colors. */
+ /* unsigned char bordercolor,*/
+ 0,
+
+ /* screencolor; */
+ 0,
+
+ /* Pointer sprite 0 color */
+ 0,
+
+ /* Pointer sprite 1 color */
+ 1,
+
+
+ /* Pointer sprite. */
+ /* unsigned char pointer[128]; */
+ {0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00,
+ 0x60, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x78, 0x00, 0x00,
+ 0x7c, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x58, 0x00, 0x00,
+ 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00,
+
+ 0xc0, 0x00, 0x00,
+ 0xe0, 0x00, 0x00,
+ 0xf0, 0x00, 0x00,
+ 0xf8, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0x3c, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00 },
+
+
+
+ /* Background pattern fill. */
+ /* unsigned char backgroundpattern[8*25]; */
+ {0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,
+ 0xff,0x55,0xff,0x55,0xff,0x55,0xff,0x55,
+ 0xee,0x55,0xbb,0x55,0xee,0x55,0xbb,0x55,
+ 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,
+ 0xaa,0x44,0xaa,0x11,0xaa,0x44,0xaa,0x11,
+ 0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,
+ 0x88,0x00,0x22,0x00,0x88,0x00,0x22,0x00},
+
+ /* Background colors. */
+ /* unsigned char backgroundpatterncolors[25]; */
+ {COLOR(BGCOLOR1,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR2,BGCOLOR1),COLOR(BGCOLOR2,BGCOLOR1),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR3,BGCOLOR2),COLOR(BGCOLOR3,BGCOLOR2),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3),
+ COLOR(BGCOLOR4,BGCOLOR3),COLOR(BGCOLOR4,BGCOLOR3)},
+
+
+
+ };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
new file mode 100644
index 0000000..71dd3fe
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-ravenpine.c
@@ -0,0 +1,288 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-ravenpine.c,v 1.1 2006/04/17 15:11:52 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x00
+#define BGCOLOR2 0x05
+
+
+struct ctk_hires_theme ctk_hires_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0x00,0xfc,0xfc,0x0c,0x0c,0x0c,0x0c,0x0c},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x0c,0x0c,0x0c,0x0c,0x0c,0xfc,0xfc,0x00},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0x3e,0x30,0x30,0x30,0x30,0x30,0x30,0x3c},
+
+ /* buttonright[8]; */
+ {0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_BLACK, COLOR_BLUE),
+ COLOR(COLOR_GREEN, COLOR_LIGHTBLUE),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+ COLOR(COLOR_LIGHTGREEN, COLOR_LIGHTBLUE)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_WHITE)},
+
+
+ /* Button corner colors. */
+ /* unsigned char buttonleftcolors[6], */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+ /* buttonrightcolors[6]; */
+ {COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GRAY1),
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_GREEN, COLOR_BLACK),
+
+ /* openmenucolor, */
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+
+ /* activemenucolor; */
+ COLOR(COLOR_LIGHTGREEN, COLOR_GREEN),
+
+ /* Border and screen colors. */
+ /* unsigned char bordercolor,*/
+ 0,
+
+ /* screencolor; */
+ 0,
+
+ /* Pointer sprite 0 color */
+ COLOR_LIGHTGREEN,
+
+ /* Pointer sprite 1 color */
+ COLOR_GREEN,
+
+
+ /* Pointer sprite. */
+ /* unsigned char pointer[128]; */
+ {0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00,
+ 0x60, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x78, 0x00, 0x00,
+ 0x7c, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x58, 0x00, 0x00,
+ 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00,
+
+ 0xc0, 0x00, 0x00,
+ 0xe0, 0x00, 0x00,
+ 0xf0, 0x00, 0x00,
+ 0xf8, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0x3c, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00 },
+
+
+
+ /* Background pattern fill. */
+ /* unsigned char backgroundpattern[8*25]; */
+ {
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,
+ },
+ /* Background colors. */
+ /* unsigned char backgroundpatterncolors[25]; */
+ {COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+
+
+
+ };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
new file mode 100644
index 0000000..0dcdf2e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme-springlight.c
@@ -0,0 +1,284 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme-springlight.c,v 1.1 2006/04/17 15:11:53 kthacker Exp $
+ *
+ */
+
+#include <conio.h>
+#include "ctk-hires-theme.h"
+
+#define COLOR(bg, fg) ((fg << 4) | (bg))
+
+#define BGCOLOR1 0x05
+#define BGCOLOR2 0x0d
+
+
+struct ctk_hires_theme ctk_hires_theme =
+ {
+ /* Version string. */
+ /* char version[8]; */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+
+ /* Window borders patterns. */
+ /* unsigned char ulcorner[8], */ /* Upper left corner. */
+ {0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40},
+
+ /* titlebar[8], */ /* Title bar pattern. */
+ {0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00},
+
+ /* urcorner[8], */ /* Upper right corner. */
+ {0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00},
+
+ /* rightborder[8], */ /* Right border. */
+ {0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
+
+ /* lrcorner[8], */ /* Lower right corner. */
+ {0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00},
+
+ /* lowerborder[8], */ /* Lower border. */
+ {0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00},
+
+ /* llcorner[8], */ /* Lower left corner. */
+ {0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00},
+
+ /* leftborder[8]; */ /* Left border. */
+ {0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40},
+
+ /* Button corner patterns. */
+ /* unsigned char buttonleft[8], */
+ {0x0f,0x18,0x10,0x10,0x10,0x10,0x10,0x00},
+
+ /* buttonright[8]; */
+ {0x00,0x08,0x08,0x08,0x08,0x08,0x18,0xf0},
+
+ /* Menu border patterns. */
+ /* unsigned char menuleftpattern[8], */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* menurightpatterns[8]; */
+ {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+
+ /* Window and widget colors. */
+ /* unsigned char windowcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_GREEN),
+ COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+
+ /* separatorcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GRAY1, COLOR_GRAY2),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1)},
+
+ /* labelcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK)},
+
+ /* buttoncolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_GREEN),
+ COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+ /* hyperlinkcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GRAY2, COLOR_LIGHTBLUE),
+ COLOR(COLOR_GREEN, COLOR_CYAN),
+ COLOR(COLOR_GREEN, COLOR_BLUE),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLUE),
+ COLOR(COLOR_BLUE, COLOR_LIGHTGREEN)},
+
+ /* textentrycolors[6], */
+ {COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_GREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_LIGHTGREEN, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* bitmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_GRAY1),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK),
+ COLOR(COLOR_GRAY3, COLOR_BLACK)},
+
+ /* textmapcolors[6], */
+ {COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_GRAY2, COLOR_GRAY1),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_WHITE, COLOR_BLACK)},
+
+ /* iconcolors[6]; */
+ {COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_GREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+ COLOR(COLOR_GRAY1, COLOR_LIGHTGREEN),
+ COLOR(COLOR_WHITE, COLOR_BLACK),
+ COLOR(COLOR_BLACK, COLOR_YELLOW)},
+
+
+ /* Button corner colors. */
+ /* unsigned char buttonleftcolors[6], */
+ {COLOR(COLOR_GRAY1, COLOR_GREEN),
+ COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2)},
+
+ /* buttonrightcolors[6]; */
+ {COLOR(COLOR_GRAY1, COLOR_BLACK),
+ COLOR(COLOR_GRAY1, COLOR_GREEN),
+ COLOR(COLOR_GREEN, COLOR_GRAY1),
+ COLOR(COLOR_GREEN, COLOR_LIGHTGREEN),
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY2),
+ COLOR(COLOR_LIGHTGREEN, COLOR_WHITE)},
+
+
+ /* Menu colors. */
+ /* unsigned char menucolor,*/
+ COLOR(COLOR_LIGHTGREEN, COLOR_GRAY1),
+
+ /* openmenucolor, */
+ COLOR(COLOR_BLACK, COLOR_GREEN),
+
+ /* activemenucolor; */
+ COLOR(COLOR_BLACK, COLOR_LIGHTGREEN),
+
+ /* Border and screen colors. */
+ /* unsigned char bordercolor,*/
+ 5,
+
+ /* screencolor; */
+ 0,
+
+ /* Pointer sprite 0 color */
+ COLOR_WHITE,
+
+ /* Pointer sprite 1 color */
+ COLOR_GREEN,
+
+
+ /* Pointer sprite. */
+ /* unsigned char pointer[128]; */
+ {0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00,
+ 0x60, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x78, 0x00, 0x00,
+ 0x7c, 0x00, 0x00,
+ 0x70, 0x00, 0x00,
+ 0x58, 0x00, 0x00,
+ 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00,
+
+ 0xc0, 0x00, 0x00,
+ 0xe0, 0x00, 0x00,
+ 0xf0, 0x00, 0x00,
+ 0xf8, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfe, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0xfc, 0x00, 0x00,
+ 0x3c, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
+ 0x00 },
+
+
+
+ /* Background pattern fill. */
+ /* unsigned char backgroundpattern[8*25]; */
+ {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+255, 255, 223, 255, 255, 247, 255, 255, 191, 247, 255, 255, 219, 255, 255, 187,
+255, 239, 251, 191, 239, 253, 223, 251, 223, 253, 183, 255, 213, 127, 237, 191,
+245, 95, 245, 223, 181, 255, 85, 255, 85, 219, 118, 219, 109, 219, 182, 109, 219, 182, 109, 219, 170, 109, 219, 170, 181, 173, 85, 218, 85, 173, 170, 85, 170, 85, 170, 85, 170, 85, 170, 85, 170, 146, 85, 146, 170, 82, 138, 50, 74, 164, 73,
+146, 84, 137, 82, 4, 169, 18, 164, 2, 168, 18, 68, 18, 160, 10, 32, 74, 0, 42, 128, 18, 64, 20, 0, 82, 0, 4, 80, 4, 0, 72, 2, 0, 16, 132, 0, 0, 72, 0, 0, 4, 64, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+
+ /* Background colors. */
+ /* unsigned char backgroundpatterncolors[25]; */
+ {COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2),
+ COLOR(BGCOLOR1,BGCOLOR2),COLOR(BGCOLOR1,BGCOLOR2)},
+
+
+
+ };
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h
new file mode 100644
index 0000000..8659e07
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires-theme.h
@@ -0,0 +1,105 @@
+ /*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS for the C64
+ *
+ * $Id: ctk-hires-theme.h,v 1.1 2006/04/17 15:11:53 kthacker Exp $
+ *
+ */
+#ifndef __CTK_HIRES_THEME_H__
+#define __CTK_HIRES_THEME_H__
+
+struct ctk_hires_theme {
+ /* Version string. */
+ char version[8];
+
+ /* Window borders patterns. */
+ unsigned char ulcorner[8], /* Upper left corner. */
+ titlebar[8], /* Title bar pattern. */
+ urcorner[8], /* Upper right corner. */
+ rightborder[8], /* Right border. */
+ lrcorner[8], /* Lower right corner. */
+ lowerborder[8], /* Lower border. */
+ llcorner[8], /* Lower left corner. */
+ leftborder[8]; /* Left border. */
+
+ /* Button corner patterns. */
+ unsigned char buttonleftpattern[8],
+ buttonrightpattern[8];
+
+ /* Menu border patterns. */
+ unsigned char menuleftpattern[8],
+ menurightpatterns[8];
+
+
+
+ /* Window and widget colors. */
+ unsigned char windowcolors[6],
+ separatorcolors[6],
+ labelcolors[6],
+ buttoncolors[6],
+ hyperlinkcolors[6],
+ textentrycolors[6],
+ bitmapcolors[6],
+ textmapcolors[6],
+ iconcolors[6];
+
+
+ /* Button corner colors. */
+ unsigned char buttonleftcolors[6],
+ buttonrightcolors[6];
+
+ /* Menu colors. */
+ unsigned char menucolor,
+ openmenucolor,
+ activemenucolor;
+
+ /* Border and screen colors. */
+ unsigned char bordercolor,
+ screencolor;
+
+ /* Pointer sprite colors. */
+ unsigned char pointermaskcolor,
+ pointercolor;
+
+ /* Pointer sprite. */
+ unsigned char pointer[128];
+
+ /* Background pattern fill. */
+ unsigned char backgroundpattern[8*25];
+
+ /* Background colors. */
+ unsigned char backgroundpatterncolors[25];
+
+};
+
+extern struct ctk_hires_theme ctk_hires_theme;
+extern struct ctk_hires_theme *ctk_hires_theme_ptr;
+
+#endif /* __CTK_HIRES_THEME_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c
new file mode 100644
index 0000000..49a2b8c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.c
@@ -0,0 +1,872 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.c,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#include "contiki-version.h"
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-hires.h"
+#include "ctk-hires-asm.h"
+
+#include "ctk-hires-theme.h"
+
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#define SCREEN_HEIGHT 25
+#define SCREEN_WIDTH 40
+
+#define SCREENADDR 0xdc00
+#define HIRESADDR 0xe000
+
+static unsigned char lineptr;
+
+unsigned char ctk_hires_cursx, ctk_hires_cursy;
+unsigned char ctk_hires_reversed;
+unsigned char ctk_hires_color;
+unsigned char ctk_hires_underline;
+
+/*static unsigned char cchar;
+
+static unsigned char tmp01;
+static unsigned char tmph, tmpl, tmpborder;
+static unsigned char *tmpptr;*/
+
+
+static unsigned char x, y, i;
+/*static unsigned char h;*/
+static unsigned char wfocus;
+static unsigned char x1, y1, x2, y2;
+
+struct ctk_hires_windowparams ctk_hires_windowparams;
+unsigned char *ctk_hires_bitmapptr;
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+/*-----------------------------------------------------------------------------------*/
+/* Tables. */
+
+unsigned short ctk_hires_yscreenaddr[25] =
+ {0 * SCREEN_WIDTH + SCREENADDR, 1 * SCREEN_WIDTH + SCREENADDR,
+ 2 * SCREEN_WIDTH + SCREENADDR, 3 * SCREEN_WIDTH + SCREENADDR,
+ 4 * SCREEN_WIDTH + SCREENADDR, 5 * SCREEN_WIDTH + SCREENADDR,
+ 6 * SCREEN_WIDTH + SCREENADDR, 7 * SCREEN_WIDTH + SCREENADDR,
+ 8 * SCREEN_WIDTH + SCREENADDR, 9 * SCREEN_WIDTH + SCREENADDR,
+ 10 * SCREEN_WIDTH + SCREENADDR, 11 * SCREEN_WIDTH + SCREENADDR,
+ 12 * SCREEN_WIDTH + SCREENADDR, 13 * SCREEN_WIDTH + SCREENADDR,
+ 14 * SCREEN_WIDTH + SCREENADDR, 15 * SCREEN_WIDTH + SCREENADDR,
+ 16 * SCREEN_WIDTH + SCREENADDR, 17 * SCREEN_WIDTH + SCREENADDR,
+ 18 * SCREEN_WIDTH + SCREENADDR, 19 * SCREEN_WIDTH + SCREENADDR,
+ 20 * SCREEN_WIDTH + SCREENADDR, 21 * SCREEN_WIDTH + SCREENADDR,
+ 22 * SCREEN_WIDTH + SCREENADDR, 23 * SCREEN_WIDTH + SCREENADDR,
+ 24 * SCREEN_WIDTH + SCREENADDR};
+
+unsigned short ctk_hires_yhiresaddr[25] =
+ {0 * 320 + HIRESADDR, 1 * 320 + HIRESADDR,
+ 2 * 320 + HIRESADDR, 3 * 320 + HIRESADDR,
+ 4 * 320 + HIRESADDR, 5 * 320 + HIRESADDR,
+ 6 * 320 + HIRESADDR, 7 * 320 + HIRESADDR,
+ 8 * 320 + HIRESADDR, 9 * 320 + HIRESADDR,
+ 10 * 320 + HIRESADDR, 11 * 320 + HIRESADDR,
+ 12 * 320 + HIRESADDR, 13 * 320 + HIRESADDR,
+ 14 * 320 + HIRESADDR, 15 * 320 + HIRESADDR,
+ 16 * 320 + HIRESADDR, 17 * 320 + HIRESADDR,
+ 18 * 320 + HIRESADDR, 19 * 320 + HIRESADDR,
+ 20 * 320 + HIRESADDR, 21 * 320 + HIRESADDR,
+ 22 * 320 + HIRESADDR, 23 * 320 + HIRESADDR,
+ 24 * 320 + HIRESADDR};
+extern struct ctk_hires_theme ctk_hires_theme;
+struct ctk_hires_theme *ctk_hires_theme_ptr = &ctk_hires_theme;
+/*-----------------------------------------------------------------------------------*/
+#define hires_wherex() ctk_hires_cursx
+#define hires_revers(c) ctk_hires_reversed = c
+#define hires_color(c) ctk_hires_color = c
+#define hires_underline(c) ctk_hires_underline = c
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvline(unsigned char length)
+{
+ static unsigned char i;
+
+ for(i = 0; i < length; ++i) {
+ ctk_hires_cputc('|');
+ --ctk_hires_cursx;
+ ++ctk_hires_cursy;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_gotoxy(unsigned char x, unsigned char y)
+{
+ ctk_hires_cursx = x;
+ ctk_hires_cursy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cclearxy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_cclear(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_chlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_chline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cvlinexy(unsigned char x, unsigned char y, unsigned char length)
+{
+ hires_gotoxy(x, y);
+ hires_cvline(length);
+}
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+hires_cputcxy(unsigned char x, unsigned char y, char c)
+{
+ hires_gotoxy(x, y);
+ ctk_hires_cputc(c);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+clear_line(unsigned char line)
+{
+ lineptr = line;
+ asm("lda %v", lineptr);
+ asm("asl");
+ asm("tax");
+ asm("lda %v,x", ctk_hires_yhiresaddr);
+ asm("sta ptr2");
+ asm("lda %v+1,x", ctk_hires_yhiresaddr);
+ asm("sta ptr2+1");
+ asm("lda %v,x", ctk_hires_yscreenaddr);
+ asm("sta ptr1");
+ asm("lda %v+1,x", ctk_hires_yscreenaddr);
+ asm("sta ptr1+1");
+
+
+ asm("sei");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$30");
+ asm("sta $01");
+ asm("ldy #39");
+ asm("ldx %v", lineptr);
+ asm("lda %v+%w,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpatterncolors));
+ asm("clearlineloop1:");
+ asm("sta (ptr1),y");
+ asm("dey");
+ asm("bpl clearlineloop1");
+ asm("pla");
+ asm("sta $01");
+ asm("cli");
+
+
+ asm("lda %v", lineptr);
+ /* asm("and #7");*/
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("tax");
+ asm("ldy #0");
+ asm("clearlineloop2:");
+ asm("lda %v+%w+0,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+1,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+2,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+3,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+4,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+5,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+6,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+7,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("bne clearlineloop2");
+
+ asm("inc ptr2+1");
+
+ asm("ldy #0");
+ asm("clearlineloop3:");
+ asm("lda %v+%w+0,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+1,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+2,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+3,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+4,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+5,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+6,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("lda %v+%w+7,x", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, backgroundpattern));
+ asm("sta (ptr2),y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne clearlineloop3");
+
+
+ if(lineptr == 24) {
+ hires_color(ctk_hires_theme.backgroundpatterncolors[24]);
+ hires_gotoxy(0, 24);
+ ctk_hires_cputsn(CONTIKI_VERSION_STRING,
+ sizeof(CONTIKI_VERSION_STRING) - 1);
+ }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi2(void)
+{
+ asm("pla");
+ asm("sta $01");
+ asm("pla");
+ asm("rti");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+nmi(void)
+{
+ asm("sei");
+ asm("pha");
+ asm("inc $d020");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$36");
+ asm("sta $01");
+ asm("lda #>_nmi2");
+ asm("pha");
+ asm("lda #<_nmi2");
+ asm("pha");
+ asm("php");
+ asm("jmp ($0318)");
+
+ nmi2();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+setup_nmi(void)
+{
+ asm("lda #<_nmi");
+ asm("sta $fffa");
+ asm("lda #>_nmi");
+ asm("sta $fffb");
+ return;
+ nmi();
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_draw_init(void)
+{
+ unsigned char i, *ptr1, *ptr2;
+
+
+ setup_nmi();
+
+ /* Turn on hires mode, bank 0 ($c000 - $ffff) and $e000/$c000 for
+ hires/colors. */
+ VIC.ctrl1 = 0x3b; /* $D011 */
+ VIC.addr = 0x78; /* $D018 */
+ VIC.ctrl2 = 0xc8; /* $D016 */
+ CIA2.pra = 0x00; /* $DD00 */
+
+ VIC.bordercolor = ctk_hires_theme.bordercolor; /* $D020 */
+ VIC.bgcolor0 = ctk_hires_theme.screencolor; /* $D021 */
+
+ /* Fill color memory. */
+ asm("sei");
+ asm("lda $01");
+ asm("pha");
+ asm("lda #$30");
+ asm("sta $01");
+ asm("ldx #0");
+ asm("lda #$c0");
+ asm("fillcolorloop:");
+ asm("sta $dc00,x");
+ asm("sta $dd00,x");
+ asm("sta $de00,x");
+ asm("sta $df00,x");
+ asm("inx");
+ asm("bne fillcolorloop");
+
+ /* Setup sprite pointers */
+ asm("ldx #$fd");
+ asm("stx $dff8");
+ asm("inx");
+ asm("stx $dff9");
+ asm("pla");
+ asm("sta $01");
+ asm("cli");
+
+ /* Fill hires memory with 0. */
+
+ asm("lda $fd");
+ asm("pha");
+ asm("lda $fe");
+ asm("pha");
+ asm("lda #0");
+ asm("sta $fd");
+ asm("lda #$e0");
+ asm("sta $fe");
+ asm("ldy #0");
+ asm("lda #0");
+ asm("clrscrnloop:");
+ asm("lda #$55");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("lda #$aa");
+ asm("sta ($fd),y");
+ asm("iny");
+ asm("bne clrscrnloop");
+ asm("inc $fe");
+ asm("lda $fe");
+ asm("cmp #$ff");
+ asm("bne clrscrnloop");
+
+ asm("ldy #$00");
+ asm("clrscrnloop2:");
+ asm("lda #$55");
+ asm("sta $ff00,y");
+ asm("iny");
+ asm("lda #$aa");
+ asm("sta $ff00,y");
+ asm("iny");
+ asm("cpy #$40");
+ asm("bne clrscrnloop2");
+
+
+ asm("pla");
+ asm("sta $fe");
+ asm("pla");
+ asm("sta $fd");
+
+
+ ctk_draw_clear(0, SCREEN_HEIGHT);
+
+ /* Setup mouse pointer sprite. */
+ asm("lda %v+%w", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, pointermaskcolor));
+ asm("sta $d027");
+ asm("lda %v+%w", ctk_hires_theme,
+ offsetof(struct ctk_hires_theme, pointercolor));
+ asm("sta $d028");
+
+ ptr1 = ctk_hires_theme.pointer;
+ ptr2 = (unsigned char *)0xff40;
+
+ for(i = 0; i < 0x80; ++i) {
+ *ptr2++ = *ptr1++;
+ }
+
+ return;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+static void __fastcall__
+draw_widget(register struct ctk_widget *w,
+ unsigned char x, unsigned char y,
+ unsigned char clipy1, unsigned char clipy2,
+ unsigned char afocus)
+{
+ static unsigned char xpos, ypos, xscroll;
+ static unsigned char i;
+ static char c;
+ static unsigned char len;
+ static unsigned char tmp;
+ static unsigned char yclipped;
+ static unsigned char focus;
+ char *text;
+
+ xpos = x + w->x;
+ ypos = y + w->y;
+
+ yclipped = 0;
+ if(ypos >= clipy1 && ypos < clipy2) {
+ yclipped = 1;
+ }
+ focus = afocus;
+
+
+ switch(w->type) {
+ case CTK_WIDGET_SEPARATOR:
+ hires_color(ctk_hires_theme.separatorcolors[focus]);
+ if(yclipped) {
+ hires_chlinexy(xpos, ypos, w->w);
+ }
+ break;
+ case CTK_WIDGET_LABEL:
+ hires_color(ctk_hires_theme.labelcolors[focus]);
+ text = w->widget.label.text;
+ for(i = 0; i < w->h; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_cputsn(text, w->w);
+ tmp = w->w - (hires_wherex() - xpos);
+ if(tmp > 0) {
+ ctk_hires_cclear(tmp);
+ }
+ }
+ ++ypos;
+ text += w->w;
+ }
+ break;
+ case CTK_WIDGET_BUTTON:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.buttonleftcolors[focus]);
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_buttonleft();
+ hires_color(ctk_hires_theme.buttoncolors[focus]);
+ hires_gotoxy(xpos + 1, ypos);
+ ctk_hires_cputsn(w->widget.button.text, w->w);
+ hires_color(ctk_hires_theme.buttonrightcolors[focus]);
+ ctk_hires_draw_buttonright();
+ }
+ break;
+ case CTK_WIDGET_HYPERLINK:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.hyperlinkcolors[focus]);
+ hires_underline(1);
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_cputsn(w->widget.button.text, w->w);
+ hires_underline(0);
+ }
+ break;
+ case CTK_WIDGET_TEXTENTRY:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.textentrycolors[focus]);
+
+ if((focus & CTK_FOCUS_WIDGET) &&
+ w->widget.textentry.state != CTK_TEXTENTRY_EDIT) {
+ hires_revers(1);
+ } else {
+ hires_revers(0);
+ }
+ xscroll = 0;
+ tmp = w->w - 1;
+ if(w->widget.textentry.xpos >= tmp) {
+ xscroll = w->widget.textentry.xpos - tmp;
+ }
+ text = w->widget.textentry.text;
+ if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+ hires_revers(0);
+ hires_cputcxy(xpos, ypos, '>');
+ text += xscroll;
+ for(i = 0; i < w->w; ++i) {
+ c = *text;
+ if(i == w->widget.textentry.xpos - xscroll) {
+ hires_revers(1);
+ } else {
+ hires_revers(0);
+ }
+ if(c == 0) {
+ ctk_hires_cputc(' ');
+ } else {
+ ctk_hires_cputc(c);
+ }
+ hires_revers(0);
+ ++text;
+ }
+ ctk_hires_cputc('<');
+ } else {
+ hires_cputcxy(xpos, ypos, '|');
+ /* hires_gotoxy(xpos + 1, ypos); */
+ ctk_hires_cputsn(text, w->w);
+ i = hires_wherex();
+ tmp = i - xpos - 1;
+ if(tmp < w->w) {
+ ctk_hires_cclear(w->w - tmp);
+ }
+ ctk_hires_cputc('|');
+ }
+ }
+ hires_revers(0);
+ break;
+ case CTK_WIDGET_ICON:
+ if(yclipped) {
+ hires_color(ctk_hires_theme.iconcolors[focus]);
+
+ x = xpos;
+ len = strlen(w->widget.icon.title);
+ if(x + len >= SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - len;
+ }
+
+ tmp = ypos + 3;
+
+ if(tmp < clipy2) {
+ hires_gotoxy(x, tmp);
+ ctk_hires_cputsn(w->widget.icon.title, len);
+ }
+
+ hires_gotoxy(xpos, ypos);
+ if(w->widget.icon.bitmap != NULL) {
+ ctk_hires_bitmapptr = w->widget.icon.bitmap;
+ for(i = 0; i < 3; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_bitmapline(3);
+ }
+ ctk_hires_bitmapptr += 3 * 8;
+ ++ypos;
+ }
+
+ /* draw_bitmap_icon(w->widget.icon.bitmap);*/
+ }
+
+ }
+ break;
+ case CTK_WIDGET_BITMAP:
+ hires_color(ctk_hires_theme.bitmapcolors[focus]);
+ ctk_hires_bitmapptr = w->widget.bitmap.bitmap;
+ for(i = 0; i < w->h; ++i) {
+ if(ypos >= clipy1 && ypos < clipy2) {
+ hires_gotoxy(xpos, ypos);
+ ctk_hires_draw_bitmapline(w->w);
+ }
+ ctk_hires_bitmapptr += w->w * 8;
+ ++ypos;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ struct ctk_window *win = w->window;
+ unsigned char posx, posy;
+
+ posx = win->x + 1;
+ posy = win->y + 2;
+
+ if(w == win->focused) {
+ focus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, posx, posy,
+ clipy1, clipy2,
+ focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(register struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ static unsigned char h;
+
+ hires_color(ctk_hires_theme.windowcolors[focus]);
+
+ h = window->y + 2 + window->h;
+ /* Clear window contents. */
+ for(i = window->y + 2; i < h; ++i) {
+ if(i >= clipy1 && i <= clipy2) {
+ hires_cclearxy(window->x + 1, i, window->w);
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(register struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1, unsigned char clipy2)
+{
+ register struct ctk_widget *w;
+
+ x = window->x;
+ y = window->y + 1;
+
+ ++clipy2;
+
+ if(clipy2 <= y) {
+ return;
+ }
+
+ /* hires_color(ctk_hires_theme.windowcolors[focus+1]);*/
+
+ x1 = x + 1;
+ y1 = y + 1;
+ /* x2 = x1 + window->w;
+ y2 = y1 + window->h;*/
+
+ hires_gotoxy(x, y);
+ ctk_hires_windowparams.w = window->w;
+ ctk_hires_windowparams.h = window->h;
+ if(clipy1 < y) {
+ ctk_hires_windowparams.clipy1 = 0;
+ } else {
+ ctk_hires_windowparams.clipy1 = clipy1 - y;
+ }
+ ctk_hires_windowparams.clipy2 = clipy2 - y;
+ ctk_hires_windowparams.color1 = ctk_hires_theme.windowcolors[focus+1];
+ ctk_hires_windowparams.color2 = ctk_hires_theme.windowcolors[focus];
+ ctk_hires_windowparams.title = window->title;
+ ctk_hires_windowparams.titlelen = window->titlelen;
+
+ if(ctk_hires_windowparams.clipy1 < ctk_hires_windowparams.clipy2 &&
+ ctk_hires_windowparams.clipy2 > 0) {
+ ctk_hires_draw_windowborders();
+ }
+
+ focus = focus & CTK_FOCUS_WINDOW;
+
+ /* Draw inactive widgets. */
+ for(w = window->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1,
+ clipy1, clipy2,
+ focus);
+ }
+
+ /* Draw active widgets. */
+ for(w = window->active; w != NULL; w = w->next) {
+ wfocus = focus;
+ if(w == window->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+ draw_widget(w, x1, y1,
+ clipy1, clipy2,
+ wfocus);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(register struct ctk_window *dialog)
+{
+ register struct ctk_widget *w;
+
+ hires_color(ctk_hires_theme.windowcolors[CTK_FOCUS_DIALOG]);
+
+ /* x = (SCREEN_WIDTH - dialog->w) / 2;
+ y = (SCREEN_HEIGHT - 1 - dialog->h) / 2; */
+ x = dialog->x;
+ y = dialog->y + 1;
+
+
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + dialog->w;
+ y2 = y1 + dialog->h;
+
+
+ /* Draw dialog frame. */
+
+ hires_cvlinexy(x, y1, dialog->h);
+ hires_cvlinexy(x2, y1, dialog->h);
+
+ hires_chlinexy(x1, y, dialog->w);
+ hires_chlinexy(x1, y2, dialog->w);
+
+ hires_cputcxy(x, y, CH_ULCORNER);
+ hires_cputcxy(x, y2, CH_LLCORNER);
+ hires_cputcxy(x2, y, CH_URCORNER);
+ hires_cputcxy(x2, y2, CH_LRCORNER);
+
+
+ /* Clear window contents. */
+ for(i = y1; i < y2; ++i) {
+ hires_cclearxy(x1, i, dialog->w);
+ }
+
+ /* Draw inactive widgets. */
+ for(w = dialog->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1,
+ 0, SCREEN_HEIGHT, CTK_FOCUS_DIALOG);
+ }
+
+
+ /* Draw active widgets. */
+ for(w = dialog->active; w != NULL; w = w->next) {
+ wfocus = CTK_FOCUS_DIALOG;
+ if(w == dialog->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+ draw_widget(w, x1, y1,
+ 0, SCREEN_HEIGHT, wfocus);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+ for(i = y1; i < y2; ++i) {
+ clear_line(i);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(register struct ctk_menu *m)
+{
+ static unsigned char x, x2, y;
+
+ hires_color(ctk_hires_theme.openmenucolor);
+ x = hires_wherex();
+ ctk_hires_cputsn(m->title, m->titlelen);
+ ctk_hires_cputc(' ');
+ x2 = hires_wherex();
+ if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
+ x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
+ }
+ for(y = 0; y < m->nitems; ++y) {
+ if(y == m->active) {
+ hires_color(ctk_hires_theme.activemenucolor);
+ } else {
+ hires_color(ctk_hires_theme.menucolor);
+ }
+ hires_gotoxy(x, y + 1);
+ if(m->items[y].title[0] == '-') {
+ ctk_hires_chline(CTK_CONF_MENUWIDTH);
+ } else {
+ ctk_hires_cputsn(m->items[y].title,
+ strlen(m->items[y].title));
+ }
+ ctk_hires_cclear(x + CTK_CONF_MENUWIDTH - hires_wherex());
+ hires_revers(0);
+ }
+ hires_gotoxy(x2, 0);
+ hires_color(ctk_hires_theme.menucolor);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+ struct ctk_menu *m;
+
+ /* Draw menus */
+ hires_color(ctk_hires_theme.menucolor);
+ hires_gotoxy(0, 0);
+ hires_revers(0);
+ ctk_hires_cputc(' ');
+ for(m = menus->menus->next; m != NULL; m = m->next) {
+ if(m != menus->open) {
+ ctk_hires_cputsn(m->title, m->titlelen);
+ ctk_hires_cputc(' ');
+ } else {
+ draw_menu(m);
+ }
+ }
+ ctk_hires_cclear(SCREEN_WIDTH - hires_wherex() -
+ strlen(menus->desktopmenu->title) - 1);
+
+ /* Draw desktopmenu */
+ if(menus->desktopmenu != menus->open) {
+ ctk_hires_cputsn(menus->desktopmenu->title,
+ menus->desktopmenu->titlelen);
+ ctk_hires_cputc(' ');
+ } else {
+ draw_menu(menus->desktopmenu);
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+ return SCREEN_HEIGHT;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+ return SCREEN_WIDTH;
+}
+/*-----------------------------------------------------------------------------------*/
+/*unsigned char
+ctk_arch_isprint(char c)
+{
+ return isprint(c);
+}*/
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h
new file mode 100644
index 0000000..5d8db4b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-hires.h,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#ifndef __CTK_HIRES_H__
+#define __CTK_HIRES_H__
+
+#include <conio.h>
+
+typedef char ctk_arch_key_t;
+
+#define ctk_arch_keyavail kbhit
+#define ctk_arch_getkey cgetc
+
+#define CH_ENTER '\n'
+
+#endif /* __CTK_HIRES_H__ */
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c
new file mode 100644
index 0000000..d3e8f03
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-hires2.c
@@ -0,0 +1,30 @@
+void ctk_hires_cputc(unsigned char ch)
+{
+}
+
+void ctk_hires_cclear(unsigned char len)
+{
+}
+
+void ctk_hires_chline(unsigned char len)
+{
+}
+void ctk_hires_cputsn(unsigned char *str, unsigned char len)
+{
+}
+
+void ctk_hires_draw_buttonleft()
+{
+}
+
+void ctk_hires_draw_buttonright()
+{
+}
+
+void ctk_hires_draw_bitmapline(unsigned char len)
+{
+}
+
+void ctk_hires_draw_windowborders()
+{
+}
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S
new file mode 100644
index 0000000..eeef7b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-1351.S
@@ -0,0 +1,149 @@
+
+;---------------------------------------------------------------------
+ ;; The 1351 mouse code was taken from the CC65 libraries,
+ ;; written by Ullrich von Bassewitz
+;---------------------------------------------------------------------
+
+ .macpack generic
+
+ .import _ctk_mouse_joyx, _ctk_mouse_joyy
+ .import _ctk_mouse_firebutton
+ .export _ctk_mouse_1351
+;---------------------------------------------------------------------
+.bss
+OldValue: .res 1 ; Temp for MoveCheck routine
+NewValue: .res 1 ; Temp for MoveCheck routine
+YCorr: .res 1 ; Correction for Y coordinate
+
+OldPotX: .res 1 ; Old hw counter values
+OldPotY: .res 1
+
+SID_ADConv1 = $D419
+SID_ADConv2 = $D41A
+CIA1_PRA = $DC00
+CIA1_PRB = $DC01
+CIA1_DDRB = $DC03
+
+
+;---------------------------------------------------------------------
+.data
+XMin: .word 0 ; X1 value of bounding box
+YMin: .word 0 ; Y1 value of bounding box
+XMax: .word 319 ; X2 value of bounding box
+YMax: .word 199 ; Y2 value of bounding box
+
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+;---------------------------------------------------------------------
+ ;; Most of the mouse code is taken from the CC65 libraries written by
+ ;; Ullrich von Bassewitz
+MoveCheck:
+ sty OldValue
+ sta NewValue
+ ldx #$00
+
+ sub OldValue ; a = mod64 (new - old)
+ and #%01111111
+ cmp #%01000000 ; if (a > 0)
+ bcs @L1 ;
+ lsr a ; a /= 2;
+ beq @L2 ; if (a != 0)
+ ldy NewValue ; y = NewValue
+ rts ; return
+
+@L1: ora #%11000000 ; else or in high order bits
+ cmp #$FF ; if (a != -1)
+ beq @L2
+ sec
+ ror a ; a /= 2
+ dex ; high byte = -1 (X = $FF)
+ ldy NewValue
+ rts
+
+@L2: txa ; A = $00
+ rts
+
+;---------------------------------------------------------------------
+_ctk_mouse_1351:
+ lda SID_ADConv1 ; Get mouse X movement
+ ldy OldPotX
+ jsr MoveCheck ; Calculate movement vector
+ sty OldPotX
+
+; Calculate the new X coordinate (--> a/y)
+
+ add _ctk_mouse_joyx
+ tay ; Remember low byte
+ txa
+ adc _ctk_mouse_joyx+1
+ tax
+
+; Limit the X coordinate to the bounding box
+
+ cpy XMin
+ sbc XMin+1
+ bpl @L1
+ ldy XMin
+ ldx XMin+1
+ jmp @L2
+@L1: txa
+
+ cpy XMax
+ sbc XMax+1
+ bmi @L2
+ ldy XMax
+ ldx XMax+1
+@L2: sty _ctk_mouse_joyx
+ stx _ctk_mouse_joyx+1
+; Calculate the Y movement vector
+
+ lda SID_ADConv2 ; Get mouse Y movement
+ ldy OldPotY
+ jsr MoveCheck ; Calculate movement
+ sty OldPotY
+
+; Calculate the new Y coordinate (--> a/y)
+
+ sta OldValue
+ lda _ctk_mouse_joyy
+ sub OldValue
+ tay
+ stx OldValue
+ lda _ctk_mouse_joyy+1
+ sbc OldValue
+ tax
+
+ cpy YMin
+ sbc YMin+1
+ bpl @L3
+ ldy YMin
+ ldx YMin+1
+ jmp @L4
+@L3: txa
+
+ cpy YMax
+ sbc YMax+1
+ bmi @L4
+ ldy YMax
+ ldx YMax+1
+@L4: sty _ctk_mouse_joyy
+ stx _ctk_mouse_joyy+1
+
+ ;; Get mouse button
+ lda #$7F
+ sta CIA1_PRA
+ lda CIA1_PRB ; Read joystick #0
+ ldx #0
+ and #$1F
+ eor #$1F
+
+ ora _ctk_mouse_firebutton
+ sta _ctk_mouse_firebutton
+
+ lda #0
+ sta CIA1_PRA
+ sta CIA1_DDRB
+ rts
+;---------------------------------------------------------------------
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S
new file mode 100644
index 0000000..6aa53b4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-asm.S
@@ -0,0 +1,48 @@
+
+;---------------------------------------------------------------------
+ ;; The 1351 mouse code was taken from the CC65 libraries,
+ ;; written by Ullrich von Bassewitz
+;---------------------------------------------------------------------
+
+ .macpack generic
+
+ .import _ctk_mouse_joyx, _ctk_mouse_joyy
+ .import _ctk_mouse_firebutton
+ .export _ctk_mouse_asm_irq
+ .import _ctk_mouse_joy, _ctk_mouse_1351
+;---------------------------------------------------------------------
+
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+_ctk_mouse_asm_irq:
+ lda #0
+ sta _ctk_mouse_firebutton
+
+ jsr _ctk_mouse_joy
+ ;; jsr_ctk_mouse_1351
+
+ ; lda _ctk_mouse_joybutton
+ ; ora _ctk_mouse_1351button
+ ; sta _ctk_mouse_firebutton
+
+ lda _ctk_mouse_joyy
+ clc
+ adc #$32
+ sta $d001
+ sta $d003
+
+ lda _ctk_mouse_joyx
+ clc
+ adc #$18
+ sta $d000
+ sta $d002
+ lda #0
+ adc _ctk_mouse_joyx+1
+ and #1
+ beq :+
+ lda #3
+:
+ sta $d010
+ jmp $ea31
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S
new file mode 100644
index 0000000..963ca36
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse-joy.S
@@ -0,0 +1,135 @@
+
+;---------------------------------------------------------------------
+
+ .macpack generic
+
+ .import _ctk_mouse_joyx, _ctk_mouse_joyy
+ .import _ctk_mouse_firebutton
+ .export _ctk_mouse_joy
+;---------------------------------------------------------------------
+.bss
+lastjoydy: .res 1
+lastjoydx: .res 1
+joydycnt: .res 1
+joydxcnt: .res 1
+
+;---------------------------------------------------------------------
+.code
+
+;---------------------------------------------------------------------
+_ctk_mouse_joy:
+ ldy $dc02
+ lda #0
+ sta $dc02
+ lda $dc00
+ sty $dc02
+ ldy #0
+ ldx #0
+ lsr
+ bcs nodey
+ dey
+nodey:
+ lsr
+ bcs noiny
+ iny
+noiny:
+ lsr
+ bcs nodex
+ dex
+nodex:
+ lsr
+ bcs noinx
+ inx
+noinx:
+ and #1
+ eor #1
+ ora _ctk_mouse_firebutton
+ sta _ctk_mouse_firebutton
+
+ cpy lastjoydy
+ sty lastjoydy
+ bne noydy
+ tya
+ pha
+ inc joydycnt
+ lda joydycnt
+ cmp #$1f
+ bmi nostajoydycnt
+ lda #$20
+ sta joydycnt
+nostajoydycnt:
+ lsr
+ lsr
+ lsr
+ lsr
+ tay
+ pla
+asldeyloop:
+ asl
+ dey
+ bpl asldeyloop
+ tay
+ jmp ydy
+noydy:
+ lda #0
+ sta joydycnt
+ydy:
+
+ tya
+ clc
+ adc _ctk_mouse_joyy
+
+ cmp #240
+ bcc :+
+ lda #0
+:
+
+ cmp #200
+ bcc :+
+ lda #199
+:
+ sta _ctk_mouse_joyy
+
+ cpx lastjoydx
+ stx lastjoydx
+ bne noxdx
+ txa
+ pha
+ inc joydxcnt
+ lda joydxcnt
+ cmp #$1f
+ bmi nostajoydxcnt
+ lda #$20
+ sta joydxcnt
+nostajoydxcnt:
+ lsr
+ lsr
+ lsr
+ lsr
+ tax
+ pla
+asldexloop:
+ asl
+ dex
+ bpl asldexloop
+ tax
+ jmp xdx
+noxdx:
+ lda #0
+ sta joydxcnt
+xdx:
+
+ txa
+ clc
+ adc _ctk_mouse_joyx
+ sta _ctk_mouse_joyx
+ php
+ lda #$ff
+ cpx #0
+ bmi nolda02
+ lda #0
+nolda02:
+ plp
+ adc _ctk_mouse_joyx+1
+ sta _ctk_mouse_joyx+1
+ rts
diff --git a/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c
new file mode 100644
index 0000000..98ef49c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/ctk/unused/ctk-mouse.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse.c,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-mouse.h"
+#include "ctk-conf.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+
+unsigned short ctk_mouse_joyy, ctk_mouse_joyx;
+unsigned char ctk_mouse_firebutton;
+
+extern void ctk_mouse_asm_irq(void);
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_init(void)
+{
+ /* Place mouse pointer at the middle of the screen. */
+ ctk_mouse_joyx = 160;
+ ctk_mouse_joyy = 100;
+
+ /* Setup and start IRQ */
+ asm("sei");
+ asm("lda #<%v", ctk_mouse_asm_irq);
+ asm("sta $0314");
+ asm("lda #>%v", ctk_mouse_asm_irq);
+ asm("sta $0315");
+ asm("cli");
+
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_x(void)
+{
+ if(ctk_mouse_joyx >= 342) {
+ ctk_mouse_joyx = 0;
+ } else if(ctk_mouse_joyx >= 320) {
+ ctk_mouse_joyx = 319;
+ }
+ return ctk_mouse_joyx;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned short
+ctk_mouse_y(void)
+{
+ return ctk_mouse_joyy;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_button(void)
+{
+ return ctk_mouse_firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_xtoc(unsigned short x)
+{
+ return x / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_mouse_ytoc(unsigned short y)
+{
+ return y / 8;
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_hide(void)
+{
+ /* Turn off sprites 0 and 1 */
+ asm("lda #0");
+ asm("sta $d015");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+ctk_mouse_show(void)
+{
+ /* Turn on sprites 0 and 1 */
+ asm("lda #3");
+ asm("sta $d015");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#endif /* CTK_CONF_MOUSE_SUPPORT */
diff --git a/contiki-cpc/contiki-cpc/lib/lc-asm.s b/contiki-cpc/contiki-cpc/lib/lc-asm.s
new file mode 100644
index 0000000..05f773d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/lc-asm.s
@@ -0,0 +1,30 @@
+;---------------------------------------------------------------------
+;; .globl ptr1
+;---------------------------------------------------------------------
+_lc_set::
+;; sta ptr1
+;; stx ptr1+1
+;; tsx
+;; lda $0102,x
+;; ldy #$01
+;; sta (ptr1),y
+;; lda $0101,x
+;; dey
+;; sta (ptr1),y
+
+ ret
+;---------------------------------------------------------------------
+_lc_resume::
+;; sta ptr1
+;; stx ptr1+1
+;; ldy #$01
+;; lda (ptr1),y
+;; beq :+
+;; tsx
+;; sta $0102,x
+;; dey
+;; lda (ptr1),y
+;; sta $0101,x
+
+ ret
+;---------------------------------------------------------------------
diff --git a/contiki-cpc/contiki-cpc/lib/lc.h b/contiki-cpc/contiki-cpc/lib/lc.h
new file mode 100644
index 0000000..a90c7ae
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/lc.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels and Oliver Schmidt
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>, Oliver Schmidt <ol.sc0web.de>
+ *
+ * $Id: lc.h,v 1.1 2006/04/17 15:11:54 kthacker Exp $
+ */
+/* Local continuations: a form of continuation that only works locally
+ within a function.
+*/
+
+#ifndef __LC_H__
+#define __LC_H__
+
+#include "cc.h"
+
+typedef void * lc_t;
+
+void __fastcall__ lc_set(lc_t *lc);
+void __fastcall__ lc_resume(lc_t *lc);
+
+#define LC_SET(lc) lc_set(&(lc))
+#define LC_RESUME(lc) lc_resume(&(lc))
+#define LC_INIT(lc) (lc) = NULL
+#define LC_END(lc)
+
+#endif /* __LC_H__ */
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch-asm.S b/contiki-cpc/contiki-cpc/lib/mtarch-asm.S
new file mode 100644
index 0000000..22ab609
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch-asm.S
@@ -0,0 +1,245 @@
+;---------------------------------------------------------------------
+ .importzp ptr1
+ .importzp sp
+ .import __ZP_START__
+
+
+ .import _mtarch_asm_threadstack
+ .import _mtarch_asm_threadsp
+ .import _mtarch_asm_threadspreg
+ .import _mtarch_asm_threadzp
+
+ .export _mtarch_asm_exec
+ .export _mtarch_yield
+ .export _mtarch_asm_start
+ .export _mtarch_pstart, _mtarch_pstop
+
+;---------------------------------------------------------------------
+.bss
+kernelsp: .res 2
+kernelspreg: .res 1
+
+oldirq: .res 2
+
+ zpsize = 32
+.code
+;---------------------------------------------------------------------
+ ;; Switch to thread defined by threadsp, threadstack and threadspreg.
+ ;; The kernel stack is swapped onto the threadstack, and the
+ ;; sp and spreg are saved to the local variables "kernelsp" and
+ ;; "kernelspreg". Also, the zeropage variables are saved.
+
+_mtarch_asm_exec:
+ sei
+ ;; Save current stack pointer
+ lda sp
+ sta kernelsp
+ lda sp+1
+ sta kernelsp+1
+
+ tsx
+ stx kernelspreg
+
+ lda _mtarch_asm_threadzp
+ sta ptr1
+ lda _mtarch_asm_threadzp+1
+ sta ptr1+1
+
+ ldy #0
+:
+ lda <__ZP_START__,y
+ tax
+ lda (ptr1),y
+ sta <__ZP_START__,y
+ txa
+ sta (ptr1),y
+ iny
+ cpy #zpsize
+ bne :-
+
+ lda _mtarch_asm_threadstack
+ sta ptr1
+ lda _mtarch_asm_threadstack+1
+ sta ptr1+1
+
+ ldy kernelspreg ; determine the smallest of the two stack pointers,
+ cpy _mtarch_asm_threadspreg ; as we only need to swap the used part of the stack
+ bcc :+
+ ldy _mtarch_asm_threadspreg
+
+:
+ lda $0100,y
+ tax
+ lda (ptr1),y
+ sta $0100,y
+ txa
+ sta (ptr1),y
+ iny
+ bne :-
+
+ lda _mtarch_asm_threadsp
+ sta sp
+ lda _mtarch_asm_threadsp+1
+ sta sp+1
+
+ ldx _mtarch_asm_threadspreg
+ txs
+
+; jsr _mtarch_pstart
+
+ lda $0314
+ sta oldirq
+ lda $0315
+ sta oldirq+1
+
+ lda #<irq
+ sta $0314
+ lda #>irq
+ sta $0315
+
+
+ pla
+ tay
+ pla
+ tax
+ pla
+
+ rti
+
+ ;; Switch from thread defined by threadsp, threadstack and threadspreg.
+ ;; The kernel stack is swapped back from the threadstack, and the
+ ;; sp and spreg are restored from the local variables "kernelsp" and
+ ;; "kernelspreg".
+yield:
+ sei
+ lda sp
+ sta _mtarch_asm_threadsp
+ lda sp+1
+ sta _mtarch_asm_threadsp+1
+
+ tsx
+ stx _mtarch_asm_threadspreg
+
+ lda _mtarch_asm_threadzp
+ sta ptr1
+ lda _mtarch_asm_threadzp+1
+ sta ptr1+1
+
+ ldy kernelspreg ; determine the smallest of the two stack pointers,
+ cpy _mtarch_asm_threadspreg ; as we only need to swap the used part of the stack
+ bcc :+
+ ldy _mtarch_asm_threadspreg
+
+:
+ lda <__ZP_START__,y
+ tax
+ lda (ptr1),y
+ sta <__ZP_START__,y
+ txa
+ sta (ptr1),y
+ iny
+ cpy #zpsize
+ bne :-
+
+ lda _mtarch_asm_threadstack
+ sta ptr1
+ lda _mtarch_asm_threadstack+1
+ sta ptr1+1
+
+ ldy #0
+:
+ lda $0100,y
+ tax
+ lda (ptr1),y
+ sta $0100,y
+ txa
+ sta (ptr1),y
+ iny
+ bne :-
+
+ lda kernelsp
+ sta sp
+ lda kernelsp+1
+ sta sp+1
+
+ ldx kernelspreg
+ txs
+
+ cli
+
+ rts
+;---------------------------------------------------------------------
+ ;; Simulate an IRQ by pushing CPU status and CPu registers
+ ;; onto the stack. Then call the yield function to yield the
+ ;; process.
+_mtarch_yield:
+ php
+ pha
+ txa
+ pha
+ tya
+ pha
+
+ tsx
+
+ ; the rts adds 1 to the PC
+ ; saved on the stack. We want
+ lda $0105,x ; the stack to look like is would
+ clc ; do inside of an interrupt.
+ adc #1 ; (this is what the 'rts' does,
+ sta $0105,x ; but not the 'rti')
+ lda $0106,x
+ adc #0
+ sta $0106,x
+
+
+ jmp yield
+;---------------------------------------------------------------------
+_mtarch_asm_start:
+ lda _mtarch_asm_threadzp
+ sta ptr1
+ lda _mtarch_asm_threadzp+1
+ sta ptr1+1
+
+ ldy #0
+:
+ lda <__ZP_START__,y
+ sta (ptr1),y
+ iny
+ cpy #zpsize
+ bne :-
+ rts
+
+;---------------------------------------------------------------------
+irq:
+ lda oldirq
+ sta $0314
+ lda oldirq+1
+ sta $0315
+ jmp yield
+;---------------------------------------------------------------------
+ ;; Setup preemption IRQ
+_mtarch_pstart:
+ sei
+ lda $0314
+ sta oldirq
+ lda $0315
+ sta oldirq+1
+
+ lda #<irq
+ sta $0314
+ lda #>irq
+ sta $0315
+ cli
+ rts
+;---------------------------------------------------------------------
+_mtarch_pstop:
+ sei
+ lda oldirq
+ sta $0314
+ lda oldirq+1
+ sta $0315
+ cli
+ rts
+;---------------------------------------------------------------------
+
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch.c b/contiki-cpc/contiki-cpc/lib/mtarch.c
new file mode 100644
index 0000000..dc8e3cd
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.c,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#include "mtarch.h"
+#include <string.h>
+
+unsigned char mtarch_asm_threadspreg;
+unsigned char *mtarch_asm_threadsp;
+unsigned char *mtarch_asm_threadzp;
+unsigned char *mtarch_asm_threadstack;
+
+void mtarch_asm_start(void);
+void mtarch_asm_exec(void);
+
+
+/*--------------------------------------------------------------------------*/
+void
+mtarch_start(struct mtarch_thread *thread,
+ void (* function)(void *data),
+ void *data)
+{
+ memset(thread->cpustack, 0, sizeof(thread->cpustack));
+ memset(thread->cstack, 0, sizeof(thread->cstack));
+
+ /* Create a CPU stack frame with the appropriate values... */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((unsigned short)function) >> 8; /* high byte of return address. */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((unsigned short)function) & 0xff; /* low byte of return address. */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21; /* processor flags. */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 5] = /* a register */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 6] = /* x register */
+ thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0; /* y register */
+ thread->spreg = MTARCH_CPUSTACKSIZE - 8;
+
+ /* Setup the C stack with the data pointer. */
+ thread->sp = &thread->cstack[MTARCH_CSTACKSIZE - 1];
+
+ mtarch_asm_threadzp = &(thread->zp);
+ mtarch_asm_start();
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_exec(struct mtarch_thread *thread)
+{
+ /* Switch processor stack. The call to mtarch_asm_switch() will not
+ return until the process that we switch to calls yield(). */
+ mtarch_asm_threadspreg = thread->spreg;
+ mtarch_asm_threadsp = thread->sp;
+
+ mtarch_asm_threadstack = &(thread->cpustack[0]);
+ mtarch_asm_threadzp = &(thread->zp[0]);
+
+ mtarch_asm_exec();
+
+ thread->sp = mtarch_asm_threadsp;
+ thread->spreg = mtarch_asm_threadspreg;
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_init(void) {
+
+}
+/*--------------------------------------------------------------------------*/
+void
+mtarch_remove(void)
+{
+
+}
diff --git a/contiki-cpc/contiki-cpc/lib/mtarch.h b/contiki-cpc/contiki-cpc/lib/mtarch.h
new file mode 100644
index 0000000..44a8424
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/lib/mtarch.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtarch.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#ifndef __MTARCH_H__
+#define __MTARCH_H__
+
+#define MTARCH_CPUSTACKSIZE 256
+#define MTARCH_CSTACKSIZE 256
+#define MTARCH_ZPSIZE 32
+
+struct mtarch_thread {
+ unsigned char spreg;
+ unsigned char *sp;
+ unsigned char cpustack[MTARCH_CPUSTACKSIZE];
+ unsigned char cstack[MTARCH_CSTACKSIZE];
+ unsigned char zp[MTARCH_ZPSIZE];
+};
+
+#endif /* __MTARCH_H__ */
+
diff --git a/contiki-cpc/contiki-cpc/loader/cfs-cpc.c b/contiki-cpc/contiki-cpc/loader/cfs-cpc.c
new file mode 100644
index 0000000..7976d7e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/cfs-cpc.c
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.c,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+extern void _readdir(void *);
+
+struct cpc_dir
+{
+ char *buffer;
+ char *ptr;
+};
+
+//#include <cbm.h>
+#include <string.h>
+
+static int s_open(const char *n, int f);
+static void s_close(int f);
+static int s_read(int f, char *b, unsigned int l);
+static int s_write(int f, char *b, unsigned int l);
+static int s_opendir(struct cfs_dir *p, const char *n);
+static int s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+ {
+ CFS_SERVICE_VERSION,
+ s_open,
+ s_close,
+ s_read,
+ s_write,
+ s_opendir,
+ s_readdir,
+ s_closedir
+ };
+
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+ cpc_cfs_eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_cpc_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(cpc_cfs_eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ log_message("Starting KERNAL CFS", "");
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, &interface);
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+ // if(cbm_open(2, 8, f, n) == 0) {
+ // return 2;
+ // }
+ return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+ // cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+ return 0; //return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+ return 0; // return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+ struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+
+ char *buffer = malloc(2048);
+
+ if (buffer)
+ {
+ cpcdir->buffer = buffer;
+ cpcdir->ptr = buffer;
+ _readdir(buffer);
+ return 0;
+ }
+ return 1;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+ int i;
+ int size;
+ int npos;
+ struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+ char *ptr = cpcdir->ptr;
+
+ if (ptr[0]!=0xff)
+ return 1;
+
+ ptr++;
+
+ npos = 0;
+ for (i=0; i<8; i++)
+ {
+ char ch = ptr[0]&0x07f;
+ ptr++;
+ e->name[npos] = ch;
+ npos++;
+ }
+ e->name[npos] = '.';
+ npos++;
+ for (i=0; i<3; i++)
+ {
+ char ch = ptr[0]&0x07f;
+ ptr++;
+ e->name[npos] = ch;
+ npos++;
+ }
+ e->name[npos] = '\0';
+
+ size = (ptr[0]&0x0ff) + ((ptr[1]&0x0ff)<<8);
+ size = size*1024;
+ ptr+=2;
+ e->size = size;
+ cpcdir->ptr = ptr;
+
+ return 0;
+
+/* 1 = if no more dir entries
+ 0 = more dir entries */
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+ struct cpc_dir *cpcdir = (struct cpc_dir *)p;
+ free(cpcdir->buffer);
+ return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/cfs-cpc.h b/contiki-cpc/contiki-cpc/loader/cfs-cpc.h
new file mode 100644
index 0000000..ddf55a0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/cfs-cpc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cpc.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ */
+#ifndef __CFS_CPC_H__
+#define __CFS_CPC_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cpc_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/dir.s b/contiki-cpc/contiki-cpc/loader/dir.s
new file mode 100644
index 0000000..2de266a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/dir.s
@@ -0,0 +1,99 @@
+;; This example shows how to perform a directory of a disc
+;; and extract the filenames.
+;;
+;; This code is public domain and can freely be used in your
+;; own programs.
+;;
+;; Written by Kevin Thacker. 2002
+
+
+
+;;------------------------------------------------------------------
+
+;; firmware function to catalog a disc or cassette
+cas_catalog == 0xbc9b
+;; firmware function to disable text output
+txt_vdu_enable == 0xbb54
+;; firmware function to enable text output
+txt_vdu_disable == 0xbb57
+;; firmware function to find a RSX
+kl_find_command == 0xbcd4
+
+ .globl __readdir
+ .area _CODE
+
+;;------------------------------------------------------------------
+;; find BIOS SET MESSAGE command
+;; this is used to disable disc messages.
+;; this is compatible with other DOSs that also provide this command
+__readdir::
+
+ld hl,#cmd_bios_set_message
+call kl_find_command
+ret nc
+
+;; command found
+
+;; store address of command
+ld (bios_set_message),hl
+ld a,c
+;; store "rom select" of command
+ld (bios_set_message+2),a
+
+;;------------------------------------------------------------------
+
+;; do CAT
+ld hl,#2
+add hl,sp
+ld e,(hl)
+inc hl
+ld d,(hl)
+call fetch_directory
+ret
+
+
+;;------------------------------------------------------------------
+;; display files from data generated by CAS CATALOG function
+
+;; perform a CAT command
+
+fetch_directory::
+push de
+;; disable disc messages. Error messages will not be displayed.
+ld a,#0xff
+rst 0x018 ;; KL FAR CALL
+.dw bios_set_message
+
+;; disable text output
+call txt_vdu_disable
+
+pop de
+
+;; initialise in case of an error
+xor a
+ld (de),a
+
+;; do catalog
+call cas_catalog
+
+;; enable text output
+call txt_vdu_enable
+
+;; enable disc messages. Error messages will be displayed
+ld a,#0x0
+rst 0x018 ;; KL FAR CALL
+.dw bios_set_message
+ret
+
+
+;;------------------------------------------------------------------
+
+;; this is initialised when the "BIOS SET MESSAGE" RSX has been found.
+bios_set_message:
+.dw 0 ;; address of function
+.db 0 ;; "rom select" for function
+
+
+cmd_bios_set_message:
+.db #0x01+#0x80 ;; this is the "BIOS SET MESSAGE" RSX
+
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c b/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c
new file mode 100644
index 0000000..84d12be
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch-cpc.c
@@ -0,0 +1,93 @@
+#include "loader-arch.h"
+#include "rel.h"
+#include <stddef.h>
+#include <malloc.h>
+
+extern void *progend;
+
+struct prg_hdr {
+ char *relocatedata;
+ char arch[8];
+ char version[8];
+ char initfunc[1];
+};
+
+struct dsc_hdr {
+ char *relocatedata;
+ struct dsc dscdata;
+};
+
+unsigned char loader_arch_load(const char *name, char *arg)
+{
+ char *loadaddr;
+ struct prg_hdr *prghdr;
+ int length;
+
+ /* get length of file */
+ length = get_file_length(name);
+ if (length==0)
+ return LOADER_ERR_OPEN;
+
+ /* allocate memory */
+ loadaddr = malloc(length);
+ if (loadaddr==NULL)
+ return LOADER_ERR_MEM;
+
+ /* load the file */
+ load_file(name,loadaddr);
+
+ prghdr = (struct prg_hdr *)loadaddr;
+
+ /* relocate it */
+ relocate(prghdr->relocatedata,loadaddr);
+
+ ((void (*)(char *))prghdr->initfunc)(arg);
+
+ return LOADER_OK;
+}
+
+struct dsc *loader_arch_load_dsc(const char *name)
+{
+ char *loadaddr;
+ struct dsc_hdr *dschdr;
+ int length;
+
+ /* get length of file */
+ length = get_file_length(name);
+ if (length==0)
+ return NULL;
+
+ /* allocate memory */
+ loadaddr = malloc(length);
+ if (loadaddr==NULL)
+ return NULL;
+
+ /* load the file */
+ load_file(name, loadaddr);
+
+ dschdr = (struct dsc_hdr *)loadaddr;
+ /* relocate it */
+ relocate(dschdr->relocatedata, loadaddr);
+
+ return &dschdr->dscdata;
+}
+
+void loader_arch_free(void *loadaddr)
+{
+ /* free module */
+ /* we're given the start of 'arch' member of the prg_hdr,
+ calculate the real start address and then free the block */
+ void *header = (void *)((char *)loadaddr - offsetof(struct prg_hdr,arch));
+ free(header);
+}
+
+void loader_arch_free_dsc(struct dsc *dscdata)
+{
+ /* we're given the start of 'dsc' member of the dsc_hdr,
+ calculate the real start address and then free the block */
+ void *header = (void *)((char *)dscdata - 2);
+//offsetof(struct
+//dsc_hdr,dscdata));
+ free(header);
+}
+
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch-module.s b/contiki-cpc/contiki-cpc/loader/loader-arch-module.s
new file mode 100644
index 0000000..2539b86
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch-module.s
@@ -0,0 +1,16 @@
+;; This is the header for Contiki program files
+;;
+;; This must always be at at the start of the file
+;; The order of the data must not change.
+;;
+.globl _loader_appinit
+ .area _CODE
+
+_loader_arch_loadaddr::
+arch: .byte 0,0,0,0,0,1,1,1
+version: .byte 0,0,0,0,0,1,1,1
+
+;; The position of the init function can be anywhere in the file.
+;; This jump is always in the same place, and points to the actual init function.
+ call gsinit
+ jp _loader_appinit
diff --git a/contiki-cpc/contiki-cpc/loader/loader-arch.h b/contiki-cpc/contiki-cpc/loader/loader-arch.h
new file mode 100644
index 0000000..efce757
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/loader-arch.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.h,v 1.1 2006/04/17 15:11:55 kthacker Exp $
+ *
+ */
+#ifndef __LOADER_ARCH_H__
+#define __LOADER_ARCH_H__
+
+#include "dsc.h"
+
+unsigned char loader_arch_load(const char *name, char *arg);
+struct dsc *loader_arch_load_dsc(const char *name);
+void loader_arch_free(void *addr);
+void loader_arch_free_dsc(struct dsc *);
+
+extern void *loader_arch_loadaddr;
+
+#define LOADER_LOAD_DSC(name) loader_arch_load_dsc(name)
+#define LOADER_LOAD(name, arg) loader_arch_load(name, arg)
+#define LOADER_UNLOAD() loader_arch_free(&loader_arch_loadaddr)
+#define LOADER_UNLOAD_DSC(dsc) loader_arch_free_dsc(dsc)
+
+#endif /* __LOADER_ARCH_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/rel.h b/contiki-cpc/contiki-cpc/loader/rel.h
new file mode 100644
index 0000000..fd3c264
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/rel.h
@@ -0,0 +1,3 @@
+int get_file_length(const char *);
+void load_file(const char *, void *);
+void relocate(void *relocate_data, void *base);
diff --git a/contiki-cpc/contiki-cpc/loader/rel.s b/contiki-cpc/contiki-cpc/loader/rel.s
new file mode 100644
index 0000000..be8f085
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/rel.s
@@ -0,0 +1,219 @@
+ .area _CODE
+ .globl _get_file_length
+ .globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+
+ ;; HL = address of null terminated string
+ call count_string_length
+ ld de,#0x0c000 ;; points to unused 2k buffer
+ call 0x0bc77 ;; cas in open
+ push bc ;; BC = length of file
+ call 0x0bc7d ;; cas in abandon
+ pop hl
+ ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+ push hl
+ ld b,#0
+csl: ld a,(hl)
+ or a
+ jr z,csl2
+ inc hl
+ inc b
+ jr csl
+csl2:
+ pop hl
+ ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+ ld hl,#5
+ add hl,sp
+ ld d,(hl)
+ dec hl
+ ld e,(hl)
+ dec hl
+
+ push de
+ ld a,(hl)
+ dec hl
+ ld l,(hl)
+ ld h,a
+
+ call count_string_length
+ ld de,#0x0c000
+ call 0x0bc77 ;; cas in open
+ pop hl ;; load address
+ call 0x0bc83 ;; cas in direct
+ call 0x0bc7a ;; cas in close
+ ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+ ld hl,#5
+ add hl,sp
+ push ix
+ ld b,(hl) ;; base address
+ dec hl
+ ld c,(hl)
+ dec hl
+ ld a,(hl)
+ .db #0x0dd
+ ld h,a
+ dec hl
+ ld a,(hl)
+ .db #0x0dd
+ ld l,a ;; IX is offset of table from start of loaded file
+ add ix,bc ;; relocate IX to give absolute address of table.
+
+ push bc
+ pop hl
+ call relocate_16bit
+ push bc
+ pop hl
+ call relocate_8bitl ;; lower byte
+ push bc
+ pop hl
+ call relocate_8bith ;; upper byte
+ pop ix
+ ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;;
+relocate_8bith:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bh
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bith
+
+r8bh:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get low byte of address
+ld e,0(ix)
+inc ix
+
+;; get high byte to relocate
+ld d,(hl)
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),d
+jr relocate_8bith
+
+relocate_8bitl:
+ld a,0(ix)
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r8bl
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_8bitl
+
+r8bl:
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+ld e,(hl)
+ld d,#0x0
+ex de,hl
+add hl,bc
+ex de,hl
+ld (hl),e
+jr relocate_8bitl
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit
+;; value to relocate.
+;;
+;; BC = base address
+;;
+;; NOTE:
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix) ;; number of items to relocate
+inc ix
+or a
+ret z
+cp #0x0ff
+jr nz,r16
+ld e,0(ix)
+inc ix
+ld d,0(ix)
+inc ix
+add hl,de
+jr relocate_16bit
+
+r16:
+;; add offset
+add a,l
+ld l,a
+ld a,h
+adc a,#0x0
+ld h,a
+
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+jr relocate_16bit
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S
new file mode 100644
index 0000000..86b9639
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.S
@@ -0,0 +1,505 @@
+
+
+ .export _c64_dio_asm_init
+ .export _c64_dio_asm_read_block
+ .export _c64_dio_asm_write_block
+
+ .export _c64_dio_asm_track, _c64_dio_asm_sector
+
+ .export _c64_dio_asm_ptr
+
+ .importzp ptr1, ptr2
+
+ ;; job code $80 read, $90 write
+
+
+ciout = $ffa8
+listen = $ffb1
+second = $ff93
+unlsn = $ffae
+
+nbytes = 34
+esc = $42
+
+blockread = 1
+blockwrite = 2
+
+errok = 0
+errerr = 1
+
+.data
+_c64_dio_asm_track: .byte 0
+_c64_dio_asm_sector: .byte 0
+_c64_dio_asm_ptr: .byte 0,0
+
+.code
+;---------------------------------------
+_c64_dio_asm_read_block:
+
+ lda #blockread
+ jsr send
+
+ lda _c64_dio_asm_track
+ jsr send
+ lda _c64_dio_asm_sector
+ jsr send
+
+
+ jsr recv
+ cmp #errok
+ bne readerr
+
+ lda _c64_dio_asm_ptr
+ sta ptr1
+ lda _c64_dio_asm_ptr+1
+ sta ptr1+1
+ ldy #0
+readl:
+ jsr recv
+ sta (ptr1),y
+ iny
+ bne readl
+ clc
+ lda #0
+ tax
+ rts
+readerr:
+ ; sta $07c0
+ jsr recv
+ ; sta $07c1
+ ldx #0
+ rts
+;---------------------------------------
+_c64_dio_asm_write_block:
+
+ lda #blockwrite
+ jsr send
+
+ lda _c64_dio_asm_track
+ jsr send
+ lda _c64_dio_asm_sector
+ jsr send
+
+
+ lda _c64_dio_asm_ptr
+ sta ptr1
+ lda _c64_dio_asm_ptr+1
+ sta ptr1+1
+ ldy #0
+writel:
+ lda (ptr1),y
+ jsr send
+ iny
+ bne writel
+
+ jsr recv
+ cmp #errok
+ bne writeerr
+ lda #0
+ tax
+ rts
+
+writeerr:
+ ; sta $07c0
+ jsr recv
+ ; sta $07c1
+ ldx #0
+ rts
+;---------------------------------------
+_c64_dio_asm_init:
+ sta devnr
+ lda #$00
+ sta drvmem
+ lda #$05
+ sta drvmem+1
+
+ lda #<drive
+ sta ptr1
+ lda #>drive
+ sta ptr1+1
+
+ ; lda devnr
+ ; ldx #<icmd
+ ; ldy #>icmd
+ ; jsr drvcmd
+ ; jsr unlsn
+
+mwl:
+ lda devnr
+ ldx #<mwcmd
+ ldy #>mwcmd
+ jsr drvcmd
+
+ ldy #0
+ lda (ptr1),y
+ jsr ciout
+ iny
+ cpy #nbytes
+ bne *-8
+
+ jsr unlsn
+
+ lda drvmem
+ clc
+ adc #nbytes
+ sta drvmem
+ lda drvmem+1
+ adc #0
+ sta drvmem+1
+
+ lda ptr1
+ clc
+ adc #nbytes
+ sta ptr1
+ tax
+ lda ptr1+1
+ adc #0
+ sta ptr1+1
+ cpx #<driveend
+ sbc #>driveend
+ bcc mwl
+
+ lda devnr
+ ldx #<mecmd
+ ldy #>mecmd
+ jsr drvcmd
+ jsr unlsn
+
+ rts
+;---------------------------------------
+drvcmd:
+ stx ptr2
+ sty ptr2+1
+ jsr listen
+ lda #$6f
+ jsr second
+
+ ldy #0
+ lda (ptr2),y
+ sta drvcmdcmp+1
+ inc ptr2
+ bne *+4
+ inc ptr2+1
+
+ ldy #0
+ lda (ptr2),y
+ jsr ciout
+ iny
+drvcmdcmp: cpy #0
+ bne *-8
+ rts
+;---------------------------------------
+devnr: .byte 8
+mwcmd: .byte 6
+ .byte $4d, $2d, $57
+drvmem: .word $0500
+ .byte nbytes
+ .byte 0
+mecmd: .byte 2
+ .byte $55, $33
+ .byte 0
+;---------------------------------------
+send:
+
+ sta ptr2
+ ldx #7
+sendl:
+ lsr ptr2
+
+
+ lda $dd00
+ and #$df
+ ora #$10
+ bcc *+4
+ eor #$30
+ sta $dd00
+
+ lda #$c0
+ bit $dd00
+ bne *-3
+
+ lda $dd00
+ and #$cf
+ sta $dd00
+
+ lda $dd00
+ and #$c0
+ eor #$c0
+ bne *-7
+
+ dex
+ bpl sendl
+
+ ldx $d020
+ lda #1
+ sta $d020
+ stx $d020
+
+ rts
+;---------------------------------------
+recv:
+ ldx $d020
+ lda #0
+ sta $d020
+ stx $d020
+
+ ldx #7
+recvl:
+ lda $dd00
+ and #$c0
+ eor #$c0
+ beq *-7
+ asl a
+
+ lda $dd00
+ and #$df
+ ora #$10
+ bcs *+4
+ eor #$30
+ sta $dd00
+ ror ptr2
+
+ lda #$c0
+ bit $dd00
+ beq *-3
+
+ lda $dd00
+ and #$cf
+ sta $dd00
+
+ dex
+ bpl recvl
+ lda ptr2
+ rts
+;---------------------------------------
+
+;---------------------------------------
+;the code residing in the drive:
+;---------------------------------------
+dtmp = $46
+dtmp2 = $97
+dbuf = $0300
+dbufcmd = $00
+dbuftrack = $06
+dbufsect = $07
+
+retries = 10
+bretries = 2
+;---------------------------------------
+drive :
+ .org $0500
+
+
+
+ cld
+ tsx
+ stx dstack
+ sei
+ jsr ledoff
+
+drivel:
+ jsr dload
+ jsr ledoff
+ cli
+ jmp drivel
+;---------------------------------------
+ledon:
+ lda $1c00
+ ora #$08
+ sta $1c00
+ rts
+ledoff:
+ lda $1c00
+ and #$f7
+ sta $1c00
+ rts
+;---------------------------------------
+drecv:
+ ldx #7
+drecvl:
+ lda $1800
+ bmi atn
+ and #5
+ beq *-7
+ lsr a
+ lda #2
+ bcc *+4
+ lda #8
+ sta $1800
+ ror dtmp
+ lda $1800
+ bmi atn
+ and #5
+ eor #5
+ beq *-9
+ lda #0
+ sta $1800
+ dex
+ bpl drecvl
+ lda dtmp
+ rts
+;---------------------------------------
+atn:
+ ldx dstack
+ txs
+ cli
+ rts
+;---------------------------------------
+dsend:
+ sta dtmp
+ ldx #7
+dsendl:
+ lsr dtmp
+ lda #2
+ bcs *+4
+ lda #8
+ sta $1800
+
+ lda $1800
+ bmi atn
+ and #5
+ eor #5
+ bne *-9
+
+ sta $1800
+
+ lda #5
+ bit $1800
+ bne *-3
+ dex
+ bpl dsendl
+ rts
+;---------------------------------------
+dload:
+ ldy #0
+
+ jsr drecv
+ sta dcmd
+
+ jsr ledon
+
+ jsr drecv
+ sta dbuftrack
+
+ jsr drecv
+ sta dbufsect
+
+ lda dcmd
+ cmp #blockwrite
+ bne dblockread
+dblockwrite:
+ ldy #0
+drecvpl:
+ jsr drecv
+ sta dbuf,y
+ iny
+ bne drecvpl
+
+ jmp dputsect
+
+dblockread:
+ jsr dgetsect
+
+dsendpage:
+ ldy #0
+dsendpl:
+ lda dbuf,y
+ jsr dsend
+ iny
+ bne dsendpl
+ rts
+;---------------------------------------
+dgetsect:
+ ; stx dbuftrack
+ ; sty dbufsect
+ ldx #retries
+dgetsectl:
+ lda #$80
+ sta dbufcmd
+
+ cli
+:
+ lda dbufcmd
+ bmi :-
+ sei
+ cmp #1
+ beq dgsnoerr
+
+ cpx #0
+ beq dgsserr
+ dex
+ cpx #bretries
+ bcs dgetsectl
+ pha
+ lda #$c0
+ sta dbufcmd
+ cli
+:
+ lda dbufcmd
+ bmi :-
+ pla
+ cpx #0
+ bne dgetsectl
+
+dgsserr:
+ pha
+ lda #errerr
+ jsr dsend
+ pla
+ jsr dsend
+ rts
+dgsnoerr:
+ lda #errok
+ jsr dsend
+ rts
+;---------------------------------------
+dputsect:
+ ; stx dbuftrack
+ ; sty dbufsect
+ ldx #retries
+dputsectl:
+ lda #$90
+ sta dbufcmd
+
+ cli
+:
+ lda dbufcmd
+ bmi :-
+ sei
+ cmp #1
+ beq dpsnoerr
+
+ cpx #0
+ beq dpsserr
+ dex
+ cpx #bretries
+ bcs dputsectl
+ pha
+ lda #$c0
+ sta dbufcmd
+ cli
+:
+ lda dbufcmd
+ bmi :-
+ pla
+ cpx #0
+ bne dputsectl
+
+dpsserr:
+ pha
+ lda #errerr
+ jsr dsend
+ pla
+ jsr dsend
+ rts
+dpsnoerr:
+ lda #errok
+ jsr dsend
+ rts
+;---------------------------------------
+led: .byte 0,0
+dstack: .byte 0
+dcmd: .byte 0
+.RELOC
+driveend:
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h
new file mode 100644
index 0000000..c00355a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio-asm.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio-asm.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_ASM_H__
+#define __C64_DIO_ASM_H__
+
+extern unsigned char c64_dio_asm_track,
+ c64_dio_asm_sector;
+
+extern unsigned char *c64_dio_asm_ptr;
+
+void __fastcall__ c64_dio_asm_init(unsigned char drive);
+unsigned char c64_dio_asm_read_block(void);
+unsigned char c64_dio_asm_write_block(void);
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c
new file mode 100644
index 0000000..ff09e03
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.c
@@ -0,0 +1,119 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ *
+ */
+
+/**
+ * \file
+ * C64 direct disk I/O.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.c,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read a block of data (256 bytes) from the disk.
+ *
+ * \param track The track of the disk block to be read.
+ *
+ * \param sector The sector of the disk block to be read.
+ *
+ * \param ptr A pointer to a buffer than must be able to accomodate
+ * 256 bytes of data.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * read.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_read_block(unsigned char track,
+ unsigned char sector,
+ unsigned char *ptr)
+{
+ c64_dio_asm_track = track;
+ c64_dio_asm_sector = sector;
+ c64_dio_asm_ptr = ptr;
+ return c64_dio_asm_read_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write a block of data (256 bytes) to the disk.
+ *
+ * \param track The track of the disk block to be written.
+ *
+ * \param sector The sector of the disk block to be written.
+ *
+ * \param ptr A pointer to a buffer containing the 256 bytes of data
+ * to be written.
+ *
+ * \return An error code or C64_DIO_OK if the data was successfully
+ * written.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_dio_write_block(unsigned char track,
+ unsigned char sector,
+ unsigned char *ptr)
+{
+ c64_dio_asm_track = track;
+ c64_dio_asm_sector = sector;
+ c64_dio_asm_ptr = ptr;
+ return c64_dio_asm_write_block();
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Initialize the direct disk I/O routines for a particular disk drive.
+ *
+ * This function must be called before any of the other direct disk
+ * I/O functions can be used.
+ *
+ * \param drive The drive number of the disk drive for which the
+ * direct disk I/O should be enabled.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_dio_init(unsigned char drive)
+{
+ c64_dio_asm_init(drive);
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h
new file mode 100644
index 0000000..6773c0e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-dio.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: c64-dio.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_DIO_H__
+#define __C64_DIO_H__
+
+void c64_dio_init(unsigned char drive);
+
+unsigned char c64_dio_read_block(unsigned char track,
+ unsigned char sector,
+ unsigned char *buf);
+
+unsigned char c64_dio_write_block(unsigned char track,
+ unsigned char sector,
+ unsigned char *buf);
+
+#define C64_DIO_OK 0
+
+#endif /* __C64_DIO_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c
new file mode 100644
index 0000000..7b8577c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.c
@@ -0,0 +1,205 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * "Raw" C64 file system access.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file provides functions that allow reading data from files
+ * without updating the file descriptor pointer. The functions are not
+ * automatically included in the core Contiki code and therefore
+ * application programs that use tham must manually link with this
+ * file.
+ *
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: c64-fs-raw.c,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+
+#include "c64-fs-raw.h"
+
+#include <string.h>
+
+struct directory_entry {
+ unsigned char type;
+ unsigned char track, sect;
+ unsigned char name[16];
+ unsigned char reltrack, relsect, relreclen;
+ unsigned char unused1, unused2, unused3, unused4;
+ unsigned char tmptrack, tmpsect;
+ unsigned char blockslo, blockshi;
+};
+
+
+extern unsigned char _c64_fs_dirbuf[256];
+extern unsigned char _c64_fs_dirbuftrack, _c64_fs_dirbufsect;
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack, _c64_fs_filebufsect;
+
+void _c64_fs_readdirbuf(unsigned char track, unsigned char sect);
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from a file without updating the file descriptor pointer.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller, but does not update the file
+ * description pointer like the c64_fs_read() function does.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_read_raw(register struct c64_fs_file *f, char *buf, int len)
+{
+ int i;
+ unsigned char fptr, ftrack, fsect;
+
+ /* Check if current block is already in buffer, and if not read it
+ from disk. */
+ if(_c64_fs_filebuftrack != f->track ||
+ _c64_fs_filebufsect != f->sect) {
+ _c64_fs_filebuftrack = f->track;
+ _c64_fs_filebufsect = f->sect;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect, _c64_fs_filebuf);
+ }
+
+ if(_c64_fs_filebuf[0] == 0 &&
+ f->ptr == _c64_fs_filebuf[1]) {
+ return 0; /* EOF */
+ }
+
+ fptr = f->ptr;
+ ftrack = f->track;
+ fsect = f->sect;
+
+ for(i = 0; i < len; ++i) {
+ *buf = _c64_fs_filebuf[fptr];
+
+ ++fptr;
+ if(_c64_fs_filebuf[0] == 0) {
+ if(fptr == _c64_fs_filebuf[1]) {
+ /* End of file reached, we return the amount of bytes read so
+ far. */
+ return i + 1;
+ }
+ } else if(fptr == 0) {
+
+ /* Read new block into buffer and set buffer state
+ accordingly. */
+ _c64_fs_filebuftrack = ftrack = _c64_fs_filebuf[0];
+ _c64_fs_filebufsect = fsect = _c64_fs_filebuf[1];
+ fptr = 2;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect, _c64_fs_filebuf);
+ }
+
+ ++buf;
+ }
+ return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the file descriptior pointer forward in the file.
+ *
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param len The number of bytes the pointer should be moved forward.
+ *
+ * \return The number of bytes that the pointer actually was moved, or
+ * 0 if an end of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_read_next(register struct c64_fs_file *f, int len)
+{
+ int i;
+
+ /* Check if current block is already in buffer, and if not read it
+ from disk. */
+ if(_c64_fs_filebuftrack != f->track ||
+ _c64_fs_filebufsect != f->sect) {
+ _c64_fs_filebuftrack = f->track;
+ _c64_fs_filebufsect = f->sect;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect, _c64_fs_filebuf);
+ }
+
+ if(_c64_fs_filebuf[0] == 0 &&
+ f->ptr == _c64_fs_filebuf[1]) {
+ return 0; /* EOF */
+ }
+
+ for(i = 0; i < len; ++i) {
+
+ ++f->ptr;
+ if(_c64_fs_filebuf[0] == 0) {
+ if(f->ptr == _c64_fs_filebuf[1]) {
+ /* End of file reached, we return the amount of bytes read so
+ far. */
+ return i + 1;
+ }
+ } else if(f->ptr == 0) {
+ /* Read new block into buffer and set buffer state
+ accordingly. */
+ _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+ _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+ f->ptr = 2;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect, _c64_fs_filebuf);
+ }
+ }
+ return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h
new file mode 100644
index 0000000..9e434d6
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-raw.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: c64-fs-raw.h,v 1.1 2006/04/17 15:11:56 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_RAW_H__
+#define __C64_FS_RAW_H__
+
+#include "c64-fs.h"
+
+int __fastcall__ c64_fs_read_raw(struct c64_fs_file *f,
+ char *buf, int len);
+
+int c64_fs_read_next(struct c64_fs_file *f, int len);
+
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c
new file mode 100644
index 0000000..8f74c00
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs-write.c
@@ -0,0 +1,121 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Implementation of C64 file writes.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * The functions in this file are not included in the core Contiki
+ * code, but must be explicitly linked by an application that that
+ * wishes to be able to write to files.
+ */
+
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: c64-fs-write.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-fs.h"
+#include <string.h>
+
+/* An *UGLY* implementation of c64_fs_write that only can be used to
+ overwrite a single block file. */
+
+extern unsigned char _c64_fs_filebuf[256];
+extern unsigned char _c64_fs_filebuftrack,
+ _c64_fs_filebufsect;
+
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Write data to an open file.
+ *
+ * \note This function currently does not support writing to other than a single block file (cannot be more than 254 bytes long).
+ *
+ * \param f A pointer to a file descriptor previously opened with c64_fs_open().
+ *
+ * \param buf A pointer to a buffer with data that should be written
+ * to the file.
+ *
+ * \param len The length of the data that should be written.
+ *
+ * \return The number of bytes actually written.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+int __fastcall__
+c64_fs_write(register struct c64_fs_file *f, char *buf, int len)
+{
+ int i;
+
+ if(len <= 0) {
+ return 0;
+ }
+
+ /* Check if current block is already in buffer, and if not read it
+ from disk. */
+ if(_c64_fs_filebuftrack != f->track ||
+ _c64_fs_filebufsect != f->sect) {
+ _c64_fs_filebuftrack = f->track;
+ _c64_fs_filebufsect = f->sect;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect,
+ _c64_fs_filebuf);
+ }
+
+ i = 256 - f->ptr;
+ if(len < i) {
+ i = len;
+ }
+
+ memcpy(&_c64_fs_filebuf[f->ptr], buf, i);
+
+ f->ptr += i;
+ if(_c64_fs_filebuf[0] == 0 &&
+ f->ptr > _c64_fs_filebuf[1]) {
+ _c64_fs_filebuf[1] = f->ptr;
+ }
+
+ c64_dio_write_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect,
+ _c64_fs_filebuf);
+
+ return i;
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c
new file mode 100644
index 0000000..d0b8f47
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.c
@@ -0,0 +1,411 @@
+/**
+ * \defgroup c64fs C64 file system and disk functions.
+ * @{
+ *
+ * The C64 file system functions are divided into two categories:
+ * those that deal with C64 files and the C64 disk directory, and
+ * those that allow direct block access to the disk. The former
+ * functions can be used for accessing regular files, whereas the
+ * latter functions are used e.g. to download D64 files onto 1541
+ * disks.
+ *
+ * \note The C64 filesystem functions currently only work with the
+ * 1541/1541-II/1571 and compatible drives, and not with the IDE64
+ * hard disks or the 1581/FD2000 3.5" drives.
+ *
+ *
+ */
+
+/**
+ * \file
+ * C64 file system operations interface for Contiki.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: c64-fs.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+
+#include "c64-dio.h"
+#include "c64-dio-asm.h"
+#include "c64-fs.h"
+
+#include <string.h>
+#include <stdio.h>
+
+struct directory_entry {
+ unsigned char type;
+ unsigned char track, sect;
+ unsigned char name[16];
+ unsigned char reltrack, relsect, relreclen;
+ unsigned char unused1, unused2, unused3, unused4;
+ unsigned char tmptrack, tmpsect;
+ unsigned char blockslo, blockshi;
+};
+
+unsigned char _c64_fs_dirbuf[256];
+unsigned char _c64_fs_dirbuftrack = 0, _c64_fs_dirbufsect = 0;
+
+unsigned char _c64_fs_filebuf[256];
+unsigned char _c64_fs_filebuftrack = 0, _c64_fs_filebufsect = 0;
+
+static struct c64_fs_dirent lastdirent;
+
+static struct c64_fs_dir opendir;
+static struct c64_fs_dirent opendirent;
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open a file.
+ *
+ * The file description must be allocated by the caller and a pointer
+ * to it is passed to this function.
+ *
+ * \param name A pointer to the name of the file to be opened.
+ * \param f A pointer to the file descriptor struct.
+ *
+ * \retval 0 If the file was successfully opened.
+ * \retval -1 If the file does not exist.
+ */
+/*-----------------------------------------------------------------------------------*/
+int
+c64_fs_open(const char *name, register struct c64_fs_file *f)
+{
+ /* First check if we already have the file cached. If so, we don't
+ need to do an expensive directory lookup. */
+ if(strncmp(lastdirent.name, name, 16) == 0) {
+ f->track = lastdirent.track;
+ f->sect = lastdirent.sect;
+ f->ptr = 2;
+ return 0;
+ }
+
+ /* Not in cache, so we walk through directory instead. */
+ c64_fs_opendir(&opendir);
+
+ do {
+ c64_fs_readdir_dirent(&opendir, &opendirent);
+ if(strncmp(opendirent.name, name, 16) == 0) {
+ f->track = opendirent.track;
+ f->sect = opendirent.sect;
+ f->ptr = 2;
+ return 0;
+ }
+ } while(c64_fs_readdir_next(&opendir) == 0);
+
+ /* The file was not found in the directory. We flush the directory
+ buffer cache now in order to prevent a nasty problem from
+ happening: If the first directory block of an empty disk was
+ cached, *all* subsequent file opens would return "file not
+ found". */
+ _c64_fs_dirbuftrack = 0; /* There are no disk blocks on track 0. */
+ return -1;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read data from an open file.
+ *
+ * This function reads data from an open file into a buffer than must
+ * be allocated by the caller.
+ *
+ * \param f A pointer to a file descriptor structure that must have
+ * been opened with c64_fs_open().
+ *
+ * \param buf A pointer to the buffer in which the data should be placed.
+ *
+ * \param len The maxiumum amount of bytes to read.
+ *
+ * \return The number of bytes that actually was read, or 0 if an end
+ * of file was encountered.
+ */
+/*-----------------------------------------------------------------------------------*/
+#if !NOASM
+#pragma optimize(push, off)
+#endif /* !NOASM */
+int __fastcall__
+c64_fs_read(register struct c64_fs_file *f, char *buf, int len)
+{
+ static int i;
+
+ /* Check if current block is already in buffer, and if not read it
+ from disk. */
+
+#if NOASM
+ if(f->track != _c64_fs_filebuftrack ||
+ _c64_fs_filebufsect != f->sect) {
+ _c64_fs_filebuftrack = f->track;
+ _c64_fs_filebufsect = f->sect;
+ c64_dio_read_block(_c64_fs_filebuftrack, _c64_fs_filebufsect,
+ _c64_fs_filebuf);
+ }
+#else /* NOASM */
+ asm("ldy #%b", offsetof(struct c64_fs_file, track));
+ asm("lda (regbank+%b),y", 4);
+ asm("cmp %v", _c64_fs_filebuftrack);
+ asm("bne doblock");
+
+ asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+ asm("lda (regbank+%b),y", 4);
+ asm("cmp %v", _c64_fs_filebufsect);
+ asm("bne doblock");
+
+ asm("jmp noblock");
+
+ asm("doblock:");
+
+ asm("ldy #%b", offsetof(struct c64_fs_file, track));
+ asm("lda (regbank+%b),y", 4);
+ asm("sta %v", _c64_fs_filebuftrack);
+ asm("sta %v", c64_dio_asm_track);
+
+ asm("ldy #%b", offsetof(struct c64_fs_file, sect));
+ asm("lda (regbank+%b),y", 4);
+ asm("sta %v", _c64_fs_filebufsect);
+ asm("sta %v", c64_dio_asm_sector);
+
+ asm("lda #<(%v)", _c64_fs_filebuf);
+ asm("sta %v", c64_dio_asm_ptr);
+ asm("lda #>(%v)", _c64_fs_filebuf);
+ asm("sta %v+1", c64_dio_asm_ptr);
+
+ asm("jsr %v", c64_dio_asm_read_block);
+
+ asm("noblock:");
+
+#endif /* NOASM */
+
+ if(_c64_fs_filebuf[0] == 0 &&
+ f->ptr == _c64_fs_filebuf[1]) {
+ return 0; /* EOF */
+ }
+
+ for(i = 0; i < len; ++i) {
+#if NOASM
+ *buf = _c64_fs_filebuf[f->ptr];
+ ++f->ptr;
+#else /* NOASM */
+ asm("ldy #%o+1", buf);
+ asm("jsr ldaxysp");
+ asm("sta ptr2");
+ asm("stx ptr2+1");
+
+ asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+ asm("lda (regbank+%b),y", 4);
+ asm("tax");
+
+ asm("ldy #0");
+ asm("lda %v,x", _c64_fs_filebuf);
+ asm("sta (ptr2),y");
+
+ asm("inx");
+ asm("txa");
+ asm("ldy #%b", offsetof(struct c64_fs_file, ptr));
+ asm("sta (regbank+%b),y", 4);
+#endif /* NOASM */
+
+
+ if(_c64_fs_filebuf[0] == 0) {
+ if(f->ptr == _c64_fs_filebuf[1]) {
+ /* End of file reached, we return the amount of bytes read so
+ far. */
+ return i + 1;
+ }
+ } else if(f->ptr == 0) {
+
+ /* Read new block into buffer and set buffer state
+ accordingly. */
+ _c64_fs_filebuftrack = f->track = _c64_fs_filebuf[0];
+ _c64_fs_filebufsect = f->sect = _c64_fs_filebuf[1];
+ f->ptr = 2;
+ c64_dio_read_block(_c64_fs_filebuftrack,
+ _c64_fs_filebufsect, _c64_fs_filebuf);
+ }
+
+ ++buf;
+ }
+ return i;
+}
+#if !NOASM
+#pragma optimize(pop)
+#endif /* !NOASM */
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close an open file.
+ *
+ * \param f A pointer to a file descriptor struct that previously has
+ * been opened with c64_fs_open().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_close(struct c64_fs_file *f)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Read a directory buffer into the _c64_fs_dirbuf buffer.
+ *
+ * This function is shared between this and the c64-fs-raw module.
+ *
+ * \param track The track of the directory block.
+ * \param sect The sector of the directory block.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+_c64_fs_readdirbuf(unsigned char track, unsigned char sect)
+{
+ if(_c64_fs_dirbuftrack == track &&
+ _c64_fs_dirbufsect == sect) {
+ /* Buffer already contains requested block, return. */
+ return;
+ }
+ c64_dio_read_block(track, sect, _c64_fs_dirbuf);
+ _c64_fs_dirbuftrack = track;
+ _c64_fs_dirbufsect = sect;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Open the disk directory for reading.
+ *
+ * The caller must supply a pointer to a directory descriptor.
+ *
+ * \param d A pointer to a directory description that must be
+ * allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_opendir(register struct c64_fs_dir *d)
+{
+ d->track = 18;
+ d->sect = 1;
+ d->ptr = 2;
+
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Read the current directory entry.
+ *
+ * This function reads the directory entry to which the directory
+ * descriptor currently points into a struct c64_fs_dirent supplied by
+ * the caller.
+ *
+ * The function c64_fs_readdir_next() is used to move the directory
+ * entry pointer forward in the directory.
+ *
+ * \param d A pointer to a directory descriptor previously opened with c64_fs_opendir().
+ *
+ * \param f A pointer to a directory entry that must have been
+ * previously allocated by the caller.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_readdir_dirent(register struct c64_fs_dir *d,
+ register struct c64_fs_dirent *f)
+{
+ struct directory_entry *de;
+ int i;
+ register char *nameptr;
+
+ _c64_fs_readdirbuf(d->track, d->sect);
+ de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+ nameptr = de->name;
+ for(i = 0; i < 16; ++i) {
+ if(*nameptr == 0xa0) {
+ *nameptr = 0;
+ break;
+ }
+ ++nameptr;
+ }
+ strncpy(f->name, de->name, 16);
+ f->track = de->track;
+ f->sect = de->sect;
+ f->size = de->blockslo + (de->blockshi >> 8);
+ memcpy(&lastdirent, f, sizeof(struct c64_fs_dirent));
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Move the directory pointer forward.
+ *
+ * This function moves the directory entry pointer in the directory
+ * descriptor forward so that it points to the next file.
+ *
+ * \param d A pointer to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ *
+ * \retval 1 If there are no more directory entried in the directory.
+ * \retval 0 There were more directory entries and the pointer has
+ * been moved to point to the next one.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+c64_fs_readdir_next(struct c64_fs_dir *d)
+{
+ struct directory_entry *de;
+ again:
+ _c64_fs_readdirbuf(d->track, d->sect);
+ if(d->ptr == 226) {
+ if(_c64_fs_dirbuf[0] == 0) {
+ return 1;
+ }
+ d->track = _c64_fs_dirbuf[0];
+ d->sect = _c64_fs_dirbuf[1];
+ d->ptr = 2;
+ } else {
+ d->ptr += 32;
+ }
+
+ de = (struct directory_entry *)&_c64_fs_dirbuf[d->ptr];
+ if(de->type == 0) {
+ goto again;
+ }
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Close a directory descriptor previously opened by c64_fs_opendir().
+ *
+ * \param d A poitner to a directory descriptor previously opened with
+ * c64_fs_opendir().
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+c64_fs_closedir(struct c64_fs_dir *d)
+{
+
+}
+/*-----------------------------------------------------------------------------------*/
+/** @} */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h
new file mode 100644
index 0000000..bfacb70
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/c64-fs.h
@@ -0,0 +1,97 @@
+/**
+ * \addtogroup c64fs
+ * @{
+ */
+
+/**
+ * \file
+ * Header file for the C64 filesystem functions.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: c64-fs.h,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ *
+ */
+#ifndef __C64_FS_H__
+#define __C64_FS_H__
+
+#include "c64-dio.h"
+
+/**
+ * An opaque structure with no user visible elements that represents
+ * an open file.
+ */
+struct c64_fs_file {
+ unsigned char track, sect, ptr;
+};
+
+int c64_fs_open(const char *name, struct c64_fs_file *f);
+void c64_fs_close(struct c64_fs_file *f);
+int __fastcall__ c64_fs_read(struct c64_fs_file *f,
+ char *buf, int len);
+
+int __fastcall__ c64_fs_write(struct c64_fs_file *f,
+ char *buf, int len);
+
+/**
+ * An opaque structure with no user visible elements that represents a
+ * directory descriptor.
+ */
+struct c64_fs_dir {
+ unsigned char track, sect, ptr;
+};
+
+/**
+ * A C64 directory entry.
+ */
+struct c64_fs_dirent {
+ char name[17]; /**< The name of the directory entry. */
+ unsigned short size; /**< The size of the directory entry in 256 byte blocks. */
+ unsigned char track,
+ sect;
+};
+
+
+unsigned char c64_fs_opendir(struct c64_fs_dir *d);
+
+void c64_fs_readdir_dirent(struct c64_fs_dir *d,
+ struct c64_fs_dirent *f);
+unsigned char c64_fs_readdir_next(struct c64_fs_dir *d);
+
+void c64_fs_closedir(struct c64_fs_dir *d);
+
+/** @} */
+
+#endif /* __C64_FS_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c
new file mode 100644
index 0000000..66aaa2d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.c,v 1.1 2006/04/17 15:11:57 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "log.h"
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int s_open(const char *n, int f);
+static void s_close(int f);
+static int s_read(int f, char *b, unsigned int l);
+static int s_write(int f, char *b, unsigned int l);
+static int s_opendir(struct cfs_dir *p, const char *n);
+static int s_readdir(struct cfs_dir *p, struct cfs_dirent *e);
+static int s_closedir(struct cfs_dir *p);
+
+static const struct cfs_service_interface interface =
+ {
+ CFS_SERVICE_VERSION,
+ s_open,
+ s_close,
+ s_read,
+ s_write,
+ s_opendir,
+ s_readdir,
+ s_closedir
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": KERNAL", EK_PRIO_NORMAL,
+ eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cfs_cbm_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ log_message("Starting KERNAL CFS", "");
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, &interface);
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+ if(cbm_open(2, 8, f, n) == 0) {
+ return 2;
+ }
+ return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+ cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+ return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_write(int f, char *b, unsigned int l)
+{
+ return cbm_write(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_opendir(struct cfs_dir *p, const char *n)
+{
+ return cbm_opendir(4, 8);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_readdir(struct cfs_dir *p, struct cfs_dirent *e)
+{
+ struct cbm_dirent ce;
+ int ret;
+ ret = cbm_readdir(4, &ce);
+ strncpy(e->name, ce.name, sizeof(ce.name));
+ e->size = ce.size;
+ return ret;
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_closedir(struct cfs_dir *p)
+{
+ cbm_closedir(4);
+ return 1;
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h
new file mode 100644
index 0000000..774d855
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-cbm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-cbm.h,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#ifndef __CFS_CBM_H__
+#define __CFS_CBM_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_cbm_init, arg);
+
+#endif /* __CFS_CBM_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c
new file mode 100644
index 0000000..b4536f5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.c,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#include "contiki.h"
+
+#include "cfs.h"
+#include "cfs-service.h"
+
+#include <cbm.h>
+#include <string.h>
+
+static int s_open(const char *n, int f);
+static void s_close(int f);
+static int s_read(int f, char *b, unsigned int l);
+static int s_write(int f, char *b, unsigned int l) {return -1;}
+static int s_opendir(struct cfs_dir *p, const char *n) {return -1;}
+static int s_readdir(struct cfs_dir *p, struct cfs_dirent *e) {return -1;}
+static int s_closedir(struct cfs_dir *p) {return -1;}
+
+static const struct cfs_service_interface interface =
+ {
+ CFS_SERVICE_VERSION,
+ s_open,
+ s_close,
+ s_read,
+ s_write,
+ s_opendir,
+ s_readdir,
+ s_closedir
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(proc, CFS_SERVICE_NAME ": init", EK_PRIO_NORMAL,
+ eventhandler, NULL, (void *)&interface);
+
+/*---------------------------------------------------------------------------*/
+EK_PROCESS_INIT(cfs_init_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(CFS_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, &interface);
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_open(const char *n, int f)
+{
+ if(cbm_open(2, 8, CBM_READ, n) == 0) {
+ return 2;
+ }
+ return -1;
+}
+/*---------------------------------------------------------------------------*/
+static void
+s_close(int f)
+{
+ cbm_close(f);
+}
+/*---------------------------------------------------------------------------*/
+static int
+s_read(int f, char *b, unsigned int l)
+{
+ return cbm_read(f, b, l);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h
new file mode 100644
index 0000000..6289941
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/cfs-init.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs-init.h,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ */
+#ifndef __CFS_INIT_H__
+#define __CFS_INIT_H__
+
+#include "ek.h"
+
+EK_PROCESS_INIT(cfs_init_init, arg);
+
+#endif /* __CFS_INIT_H__ */
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h b/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h
new file mode 100644
index 0000000..9a2a22e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch-cpc.h
@@ -0,0 +1,19 @@
+int cpc_load(char *name, char *arg);
+void cpc_unload();
+struct dsc *cpc_load_dsc(char *name);
+void cpc_unload_dsc(struct dsc *dsc);
+
+#define LOADER_LOAD(name,arg) \
+ cpc_load(name, arg)
+
+#define LOADER_UNLOAD() \
+ cpc_unload()
+
+#define LOADER_LOAD_DSC(name) \
+ cpc_load_dsc(name)
+
+#define LOADER_UNLOAD_DSC(dsc) \
+ cpc_unload_dsc(dsc)
+
+
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c
new file mode 100644
index 0000000..0785ce0
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c
@@ -0,0 +1,185 @@
+/**
+ * \file
+ * File loader implementation.
+ * \author Adam Dunkels <adam@dunkels.com>
+ *
+ * This file implements dynamically loadable files for Contiki using
+ * the cc65 module loading system. The actual file operations are
+ * implemented in other files.
+ */
+
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include "modload.h"
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cfs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+static int __fastcall__
+do_read(int f, char *buf, unsigned int len)
+{
+ return cfs_read(f, buf, len);
+}
+
+static struct mod_ctrl ctrl = {
+ (void *)do_read /* Read from disk */
+};
+
+
+struct loader_arch_hdr {
+ char arch[8];
+ char version[8];
+
+ char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Load a program from disk and execute it.
+ *
+ * Code originally written by Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+ unsigned char res;
+
+ /* Now open the file */
+ ctrl.callerdata = cfs_open(name, 0);
+ if(ctrl.callerdata < 0) {
+ /* Could not open the file, display an error and return */
+ /* ### */
+ return LOADER_ERR_OPEN;
+ }
+
+ /* Load the module */
+ res = mod_load(&ctrl);
+
+ /* Close the input file */
+ cfs_close(ctrl.callerdata);
+
+ /* Check the return code */
+ if(res != MLOAD_OK) {
+ /* Wrong module, out of memory or whatever. Print an error
+ * message and return.
+ */
+ /* ### */
+ return res;
+ }
+
+ /* We've successfully loaded the module. */
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load and start a program.
+ *
+ * \param name The name of the program file.
+ * \param arg A pointer that will be passed to the new process.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+ unsigned char r;
+ struct loader_arch_hdr *hdr;
+
+ r = load(name);
+ if(r != MLOAD_OK) {
+ return r;
+ }
+ hdr = (struct loader_arch_hdr *)ctrl.module;
+
+ /* Check the program header and see that version and architecture
+ matches. */
+
+ /* Call the init function. */
+ ((void (*)(char *))hdr->initfunc)(arg);
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Load a DSC file into memory.
+ *
+ * The memory must be deallocated with the loader_arch_free() function
+ * after is has been used.
+ *
+ * \param name The name of the DSC file.
+ *
+ * \return A pointer to the struct dsc or NULL if the DSC file could
+ * not be loaded.
+ */
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+ unsigned char r;
+
+ r = load(name);
+ if(r == MLOAD_OK) {
+ return (struct dsc *)ctrl.module;
+ }
+ return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+/**
+ * Deallocate memory previously allocated by the loader.
+ *
+ * The loader allocates memory when it loads programs or DSC
+ * files. All such memory must be deallocated with this function. Memory for programs is automatically deallocated when calling the LOADER_UNLOAD() function, but memory for DSCs must be explicitly deallcated with this function.
+ *
+ * \param addr A pointer to memory allocated by the loader.
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+ mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old
new file mode 100644
index 0000000..d76c3cc
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/loader-arch.c.old
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c.old,v 1.1 2006/04/17 15:11:58 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+#include <modload.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+#include "cpc-fs.h"
+
+#include "loader.h"
+
+#include "loader-arch.h"
+
+struct loader_arch_hdr {
+ char arch[8];
+ char version[8];
+
+ char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+load(const char *name)
+{
+ unsigned char res;
+ int ret;
+
+ /* Now open the file */
+ ret = cpc_fs_open(name);
+ if(ret < 0) {
+ /* Could not open the file, display an error and return */
+ /* ### */
+ return LOADER_ERR_OPEN;
+ }
+/* ctrl.callerdata = (int)&file; */
+
+ /* Load the module */
+ res = cpc_fs_read();
+
+ /* Close the input file */
+ cpc_fs_close();
+
+ /* Check the return code */
+ if(res != MLOAD_OK) {
+ /* Wrong module, out of memory or whatever. Print an error
+ * message and return.
+ */
+ /* ### */
+ return res;
+ }
+
+ /* We've successfully loaded the module. */
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+ unsigned char r;
+ struct loader_arch_hdr *hdr;
+
+ r = load(name);
+ if(r != MLOAD_OK) {
+ return r;
+ }
+// hdr = (struct loader_arch_hdr *)ctrl.module;
+
+ /* Check the program header and see that version and architecture
+ matches. */
+
+ /* Call the init function. */
+
+ ((void (*)(char *))hdr->initfunc)(arg);
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+struct dsc *
+loader_arch_load_dsc(const char *name)
+{
+ unsigned char r;
+
+ r = load(name);
+ if(r == MLOAD_OK) {
+ return (struct dsc *)ctrl.module;
+ }
+ return NULL;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+loader_arch_free(void *addr)
+{
+ mod_free(addr);
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/modload.c b/contiki-cpc/contiki-cpc/loader/unused/modload.c
new file mode 100644
index 0000000..9c33b16
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/modload.c
@@ -0,0 +1,12 @@
+#include "modload.h"
+
+void mod_free(struct dsc *d)
+{
+
+
+}
+
+int mod_load(struct mod_ctrl *ctrl)
+{
+ return MLOAD_OK;
+}
diff --git a/contiki-cpc/contiki-cpc/loader/unused/modload.h b/contiki-cpc/contiki-cpc/loader/unused/modload.h
new file mode 100644
index 0000000..ff0dc41
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/modload.h
@@ -0,0 +1,13 @@
+void mod_free(struct dsc *);
+
+struct mod_ctrl
+{
+ void *read;
+ void *module;
+ int callerdata;
+};
+
+#define MLOAD_OK 0
+
+int mod_load(struct mod_ctrl *);
+
diff --git a/contiki-cpc/contiki-cpc/loader/unused/rel-old.s b/contiki-cpc/contiki-cpc/loader/unused/rel-old.s
new file mode 100644
index 0000000..8b03baa
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/loader/unused/rel-old.s
@@ -0,0 +1,167 @@
+ .area _CODE
+ .globl _get_file_length
+ .globl _load_file
+;;----------------------------------------------------------------------------
+;; get length of file on disc. Assumption file has a AMSDOS header
+;;
+;; int get_file_length(const char *filename);
+
+_get_file_length::
+ ld hl,#2
+ add hl,sp
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+
+ ;; HL = address of null terminated string
+ call count_string_length
+ ld de,#0x0c000 ;; points to unused 2k buffer
+ call 0x0bc77 ;; cas in open
+ push bc ;; BC = length of file
+ call 0x0bc7d ;; cas in abandon
+ pop hl
+ ret
+
+;;---------------------------------------------------------------------
+
+count_string_length:
+ push hl
+ ld b,#0
+csl: ld a,(hl)
+ or a
+ jr z,csl2
+ inc hl
+ inc b
+ jr csl
+csl2:
+ pop hl
+ ret
+
+;;---------------------------------------------------------------------------
+;; void load_file(const char *filename, void *addr)
+
+_load_file::
+ ld hl,#5
+ add hl,sp
+ ld d,(hl)
+ dec hl
+ ld e,(hl)
+ dec hl
+
+ push de
+ ld a,(hl)
+ dec hl
+ ld l,(hl)
+ ld h,a
+
+ call count_string_length
+ ld de,#0x0c000
+ call 0x0bc77 ;; cas in open
+ pop hl ;; load address
+ call 0x0bc83 ;; cas in direct
+ call 0x0bc7a ;; cas in close
+ ret
+
+;; void relocate(void *addr,void *base)
+
+;; IX = address of relocate data
+_relocate::
+ ld hl,#5
+ add hl,sp
+ push ix
+ ld b,(hl) ;; base address
+ dec hl
+ ld c,(hl)
+ dec hl
+ ld a,(hl)
+ .db #0x0dd
+ ld h,a
+ dec hl
+ ld a,(hl)
+ .db #0x0dd
+ ld l,a ;; IX is offset of table from start of loaded file
+ add ix,bc ;; relocate IX to give absolute address of table.
+ call relocate_16bit
+ ld e,c
+ call relocate_8bit ;; lower byte
+ ld e,b
+ call relocate_8bit ;; upper byte
+ pop ix
+ ret
+
+;;--------------------------------------------------------------------------
+;; Relocate 8-bit values (e.g. where low and high parts of an address
+;; are loaded seperatly into registers)
+;;
+;; IX = list of 16-bit addresses. Each address identifies an 8-bit
+;; value
+;;
+relocate_8bit:
+ ld a,0(ix)
+ or a
+ ret z
+ inc ix
+rel8bit: push af
+ ld l,0(ix)
+ inc ix
+ ld h,0(ix)
+inc ix
+add hl,bc
+ld a,(hl)
+add e
+ld (hl),a
+pop af
+dec a
+jr nz,rel8bit
+ret
+
+
+;;--------------------------------------------------------------------------
+;; Relocate 16-bit values
+;;
+;; Entry conditions:
+;;
+;; IX = list of 16-bit addresses. Each address identifies a 16-bit
+;; value to relocate.
+;;
+;; BC = base address
+;;
+;; NOTE:
+;; - Relocatable 16-bit values come from CALL and JP instructions and
+;; loading a 16-bit register.
+
+relocate_16bit:
+ld a,0(ix) ;; number of items to relocate
+or a
+ret z
+
+inc ix
+
+rel16bit:
+push af
+;; get offset (from start of file) of 16-bit value to relocate
+ld l,0(ix)
+inc ix
+ld h,0(ix)
+inc ix
+add hl,bc
+;; get the 16-bit value
+ld e,(hl)
+inc hl
+ld d,(hl)
+
+
+;; add base address; therefore relocating it.
+ex de,hl
+add hl,bc
+ex de,hl
+;; write relocated value
+ld (hl),d
+dec hl
+ld (hl),e
+pop af
+dec a
+jr nz,rel16bit
+ret
+
diff --git a/contiki-cpc/contiki-cpc/readme.txt b/contiki-cpc/contiki-cpc/readme.txt
new file mode 100644
index 0000000..2fc791a
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/readme.txt
@@ -0,0 +1,22 @@
+What I did to make contiki for CPC:
+
+1. I took the contiki sources and made it compile with gcc on linux.
+2. Next I made it compile with sdcc
+3. Next I added cpc version of some files.
+4. Then I prayed.
+
+About contiki:
+
+contiki is both the initial program to run to start the operating system
+AND contains a library of functions to use by the other programs.
+
+Compile contiki executable to generate the executable and to generate a
+list of symbols.
+
+These symbols are used to compile the other programs. When they are run
+they will automatically call the appropiate functions.
+
+This is not as good as referencing a fixed location jumptable, because
+each utility has to be recompiled if the contiki executable is recompiled
+:(
+
diff --git a/contiki-cpc/contiki-cpc/uip/cs8900a.c b/contiki-cpc/contiki-cpc/uip/cs8900a.c
new file mode 100644
index 0000000..ebb525c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/cs8900a.c
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+ written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+/*#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x00
+#define UIP_ETHADDR2 0x00
+#define UIP_ETHADDR3 0x64
+#define UIP_ETHADDR4 0x64
+#define UIP_ETHADDR5 0x64*/
+
+extern u8_t *cs8900a_rxtxreg,
+ *cs8900a_txcmd,
+ *cs8900a_txlen,
+ *cs8900a_packetpp,
+ *cs8900a_ppdata;
+
+static u16_t len;
+static u8_t r;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+ /* Turn on transmission and reception of frames. */
+ /* PACKETPP = 0x0112;
+ PPDATA = 0x00c0; */
+ asm("lda #$12");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda #$c0");
+ asm("sta %v", cs8900a_ppdata);
+ asm("lda #$00");
+ asm("sta %v+1", cs8900a_ppdata);
+
+ /* Accept valid unicast+broadcast frames. */
+ /* PACKETPP = 0x0104;
+ PPDATA = 0x0d05; */
+ asm("lda #$04");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda #$05");
+ asm("sta %v", cs8900a_ppdata);
+ asm("lda #$0d");
+ asm("sta %v+1", cs8900a_ppdata);
+
+ /* Set MAC address. */
+ /* PACKETPP = 0x0158;
+ PPDATA = (ETHADDR1 << 8) | (ETHADDR0); */
+ asm("lda #$58");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v", uip_ethaddr);
+ asm("sta %v", cs8900a_ppdata);
+ asm("lda %v+1", uip_ethaddr);
+ asm("sta %v+1", cs8900a_ppdata);
+
+ /* PACKETPP = 0x015a;
+ PPDATA = (ETHADDR3 << 8) | (ETHADDR2); */
+ asm("lda #$5a");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v+2", uip_ethaddr);
+ asm("sta %v", cs8900a_ppdata);
+ asm("lda %v+3", uip_ethaddr);
+ asm("sta %v+1", cs8900a_ppdata);
+
+ /* PACKETPP = 0x015c;
+ PPDATA = (ETHADDR5 << 8) | (ETHADDR4); */
+ asm("lda #$5c");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v+4", uip_ethaddr);
+ asm("sta %v", cs8900a_ppdata);
+ asm("lda %v+5", uip_ethaddr);
+ asm("sta %v+1", cs8900a_ppdata);
+
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+ if(uip_len > UIP_BUFSIZE) {
+ asm("inc $d020");
+ return;
+ }
+
+ /* Transmit command. */
+ asm("lda #$c0");
+ asm("sta %v", cs8900a_txcmd);
+ asm("lda #$00");
+ asm("sta %v+1", cs8900a_txcmd);
+ asm("lda _uip_len");
+ asm("sta %v", cs8900a_txlen);
+#if UIP_BUFSIZE > 255
+ asm("lda _uip_len+1");
+#else
+ asm("lda #0");
+#endif
+ asm("sta %v+1", cs8900a_txlen);
+
+ asm("ldx #8");
+ asm("tryagain:");
+ /* Check for avaliable buffer space. */
+ asm("lda #$38");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v+1", cs8900a_ppdata);
+ asm("and #1");
+ asm("bne send");
+
+ /* No space avaliable, skip a received frame and try again. */
+ asm("lda #$02");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v", cs8900a_ppdata);
+ asm("ora #$40");
+ asm("sta %v", cs8900a_ppdata);
+
+ asm("dex");
+ asm("bne tryagain");
+
+ asm("bailout:");
+ return;
+
+ /* Send the frame. */
+ asm("send:");
+
+
+ /* First, send 40+14=54 bytes of header. */
+
+ asm("ldx #54");
+ asm("ldy #0");
+ asm("sendloop1:");
+ asm("lda _uip_buf,y");
+ asm("sta %v", cs8900a_rxtxreg);
+ asm("lda _uip_buf+1,y");
+ asm("sta %v+1", cs8900a_rxtxreg);
+ asm("iny");
+ asm("iny");
+ asm("dex");
+ asm("dex");
+ asm("bne sendloop1");
+
+ if(uip_len <= 54) {
+ return;
+ }
+
+ /* Next, send rest of the packet. */
+
+ uip_len -= 54;
+
+
+ asm("lda ptr1");
+ asm("pha");
+ asm("lda ptr1+1");
+ asm("pha");
+
+ asm("lda _uip_appdata");
+ asm("sta ptr1");
+ asm("lda _uip_appdata+1");
+ asm("sta ptr1+1");
+
+ asm("sendloop2:");
+ asm("lda _uip_len");
+ asm("tax");
+ asm("and #1");
+ asm("beq noinc");
+ asm("inx");
+ asm("noinc:");
+#if UIP_BUFSIZE > 255
+ asm("lda _uip_len+1");
+#else
+ asm("lda #0");
+#endif
+ asm("beq nozero");
+ asm("ldx #0");
+ asm("nozero:");
+ asm("ldy #0");
+ asm("sendloop:");
+ asm("lda (ptr1),y");
+ asm("sta %v", cs8900a_rxtxreg);
+ asm("iny");
+ asm("lda (ptr1),y");
+ asm("sta %v+1", cs8900a_rxtxreg);
+ asm("iny");
+ asm("dex");
+ asm("dex");
+ asm("bne sendloop");
+ asm("inc ptr1+1");
+#if UIP_BUFSIZE > 255
+ asm("dec _uip_len+1");
+ asm("bpl sendloop2");
+#endif
+
+ asm("pla");
+ asm("sta ptr1+1");
+ asm("pla");
+ asm("sta ptr1");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+ /* PACKETPP = 0x0102;
+ PPDATA = PPDATA | 0x0040; */
+ asm("lda #$02");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v", cs8900a_ppdata);
+ asm("ora #$40");
+ asm("sta %v", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u8_t
+cs8900a_poll(void)
+{
+ /* Check receiver event register to see if there are any valid
+ unicast frames avaliable. */
+ /* PACKETPP = 0x0124;
+ if(PPDATA & 0x000d == 0x0000) {
+ return 0;
+ }
+ */
+ asm("lda #$24");
+ asm("sta %v", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1", cs8900a_packetpp);
+ asm("lda %v+1", cs8900a_ppdata);
+ asm("and #$0d");
+ asm("cmp #$00");
+ asm("bne noreturn");
+ /* No frame ready. */
+ return 0;
+
+ asm("noreturn:");
+ /* Process the incoming frame. */
+
+ /* Read receiver event and discard it. */
+ /* dummy = RXTXREG; */
+
+ asm("lda %v+1", cs8900a_rxtxreg);
+ asm("sta _len+1");
+ asm("lda %v", cs8900a_rxtxreg);
+ asm("sta _len");
+
+ /* Read frame length. */
+ /* len = uip_len = RXTXREG; */
+ asm("lda %v+1", cs8900a_rxtxreg);
+ asm("sta _len+1");
+ asm("sta _uip_len+1");
+ asm("lda %v", cs8900a_rxtxreg);
+ asm("sta _len");
+ asm("sta _uip_len");
+
+
+ if(len > UIP_BUFSIZE) {
+ skip_frame();
+ return 0;
+ }
+
+ /* Read bytes into uip_buf. */
+ asm("lda ptr1");
+ asm("pha");
+ asm("lda ptr1+1");
+ asm("pha");
+
+ asm("lda #<_uip_buf");
+ asm("sta ptr1");
+ asm("lda #>_uip_buf");
+ asm("sta ptr1+1");
+
+ asm("lda _len+1");
+ asm("beq read256");
+
+ /* Read first 256*n bytes. */
+ asm("ldy #0");
+ asm("read256loop:");
+ asm("lda %v", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("lda %v+1", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("bne read256loop");
+ asm("inc ptr1+1");
+
+ asm("dec _len+1");
+ asm("bne read256loop");
+
+ /* Read last 255 or less bytes. */
+ asm("read256:");
+ asm("lda _len");
+ asm("lsr");
+ asm("bcc noinc");
+ asm("inc _len");
+ asm("noinc:");
+ asm("ldy #$0");
+ asm("readloop:");
+ asm("lda %v", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("lda %v+1", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("cpy _len");
+ asm("bne readloop");
+
+ asm("pla");
+ asm("sta ptr1+1");
+ asm("pla");
+ asm("sta ptr1");
+ return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-cpc/contiki-cpc/uip/cs8900a.h b/contiki-cpc/contiki-cpc/uip/cs8900a.h
new file mode 100644
index 0000000..0112450
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u8_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-drv.c b/contiki-cpc/contiki-cpc/uip/eth64-drv.c
new file mode 100644
index 0000000..73b12bc
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-drv.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(eth64_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ uip_setethaddr(addr);
+ lan91c96_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = lan91c96_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ lan91c96_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-dsc.c b/contiki-cpc/contiki-cpc/uip/eth64-dsc.c
new file mode 100644
index 0000000..5504061
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: eth64-dsc.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lan91c96_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(lan91c96_dsc,
+ "IDE64/ETH64 driver",
+ "lan91c96.drv",
+ lan91c96_init,
+ &lan91c96_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lan91c96icon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lan91c96icon_textmap[9] = {
+ 'I', 'D', 'E',
+ ' ', '6', '4',
+ 'E', 'T', 'H'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon lan91c96_icon =
+ {CTK_ICON("ETH64 driver", lan91c96icon_bitmap, lan91c96icon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c b/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c
new file mode 100644
index 0000000..9adf3aa
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/eth64-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: eth64-dump-drv.c,v 1.1 2006/04/17 15:11:59 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x0d,0x60,0x80,0x3d,0xb9}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": ETH64", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+ {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+ memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+ tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+ CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ lan91c96_send();
+ dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+ CTK_WIDGET_ADD(&window, &dumplabel);
+ ctk_window_open(&window);
+ uip_setethaddr(addr);
+ lan91c96_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ctk_window_close(&window);
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ctk_window_close(&window);
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = lan91c96_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ dump_packet();
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ lan91c96_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/lan91c96.c b/contiki-cpc/contiki-cpc/uip/lan91c96.c
new file mode 100644
index 0000000..485b974
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/lan91c96.c
@@ -0,0 +1,486 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Ethernet card for Commodore 64, based on lan91c96 chip
+ * is a device created by IDE64 Project team.
+ * More information: http://ide64.come.to
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#define UIP_ETHADDR0 0x00
+#define UIP_ETHADDR1 0x0d
+#define UIP_ETHADDR2 0x60
+#define UIP_ETHADDR3 0x80
+#define UIP_ETHADDR4 0x3d
+#define UIP_ETHADDR5 0xb9
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+// #define DEBUG
+
+#define ETHBASE 0xde10
+
+#define ETHBSR ETHBASE+0x0e //Bank select register R/W (2B)
+
+/* Register bank 0 */
+
+#define ETHTCR ETHBASE //Transmition control register R/W (2B)
+#define ETHEPHSR ETHBASE+2 //EPH status register R/O (2B)
+#define ETHRCR ETHBASE+4 //Receive control register R/W (2B)
+#define ETHECR ETHBASE+6 //Counter register R/O (2B)
+#define ETHMIR (ETHBASE+8) //Memory information register R/O (2B)
+#define ETHMCR ETHBASE+0x0a //Memory Config. reg. +0 R/W +1 R/O (2B)
+
+/* Register bank 1 */
+
+#define ETHCR ETHBASE //Configuration register R/W (2B)
+#define ETHBAR ETHBASE+2 //Base address register R/W (2B)
+#define ETHIAR ETHBASE+4 //Individual address register R/W (6B)
+#define ETHGPR ETHBASE+0x0a //General address register R/W (2B)
+#define ETHCTR ETHBASE+0x0c //Control register R/W (2B)
+
+/* Register bank 2 */
+
+#define ETHMMUCR ETHBASE //MMU command register W/O (1B)
+#define ETHAUTOTX ETHBASE+1 //AUTO TX start register R/W (1B)
+#define ETHPNR ETHBASE+2 //Packet number register R/W (1B)
+#define ETHARR ETHBASE+3 //Allocation result register R/O (1B)
+#define ETHFIFO ETHBASE+4 //FIFO ports register R/O (2B)
+#define ETHPTR ETHBASE+6 //Pointer register R/W (2B)
+#define ETHDATA ETHBASE+8 //Data register R/W (4B)
+#define ETHIST (ETHBASE+0x0c) //Interrupt status register R/O (1B)
+#define ETHACK ETHBASE+0x0c //Interrupt acknowledge register W/O (1B)
+#define ETHMSK ETHBASE+0x0d //Interrupt mask register R/W (1B)
+
+/* Register bank 3 */
+
+#define ETHMT ETHBASE //Multicast table R/W (8B)
+#define ETHMGMT ETHBASE+8 //Management interface R/W (2B)
+#define ETHREV ETHBASE+0x0a //Revision register R/W (2B)
+#define ETHERCV ETHBASE+0x0c //Early RCV register R/W (2B)
+
+#define BANK(num) asm("lda #%b",num); asm("sta %w",ETHBSR);
+
+#ifdef DEBUG
+static void print_packet(u8_t *, u16_t);
+#endif
+
+static u8_t packet_status;
+static u16_t packet_length;
+
+extern u16_t uip_len;
+
+
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+ /* Check if high byte is 0x33 */
+ asm("lda %w", ETHBSR+1);
+ asm("cmp #$33");
+ asm("beq @L1");
+
+ asm("inc $d021"); // Error
+
+ asm("@L1:");
+
+ /* Reset ETH card */
+ BANK(0);
+ asm("lda #%%10000000"); //Software reset
+ asm("sta %w", ETHRCR+1);
+
+ asm("lda #0");
+ asm("sta %w", ETHRCR);
+ asm("sta %w", ETHRCR+1);
+
+ /* delay */
+ asm("ldx #0");
+ asm("@L2:");
+ asm("cmp ($ff,x)"); //6 cycles
+ asm("cmp ($ff,x)"); //6 cycles
+ asm("dex"); //2 cycles
+ asm("bne @L2"); //3 cycles
+ //17*256=4352 => 4,4 ms
+
+ /* Enable transmit and receive */
+ asm("lda #%%10000001"); //Enable transmit TXENA, PAD_EN
+ asm("sta %w", ETHTCR);
+ asm("lda #%%00000011"); //Enable receive, strip CRC ???
+ asm("sta %w", ETHRCR+1);
+
+ BANK(1);
+ asm("lda %w", ETHCR+1);
+ asm("ora #%%00010000"); //No wait (IOCHRDY)
+ asm("sta %w", ETHCR+1);
+
+ asm("lda #%%00001001"); //Auto release
+ asm("sta %w", ETHCTR+1);
+
+ /* Set MAC address */
+ asm("lda #%b", (unsigned)UIP_ETHADDR0);
+ asm("sta %w", ETHIAR);
+ asm("lda #%b", (unsigned)UIP_ETHADDR1);
+ asm("sta %w", ETHIAR+1);
+ asm("lda #%b", (unsigned)UIP_ETHADDR2);
+ asm("sta %w", ETHIAR+2);
+ asm("lda #%b", (unsigned)UIP_ETHADDR3);
+ asm("sta %w", ETHIAR+3);
+ asm("lda #%b", (unsigned)UIP_ETHADDR4);
+ asm("sta %w", ETHIAR+4);
+ asm("lda #%b", (unsigned)UIP_ETHADDR5);
+ asm("sta %w", ETHIAR+5);
+
+ BANK(2);
+ asm("lda #%%00001111"); //RCV INT, ALLOC INT, TX INT, TX EMPTY
+ asm("sta %w", ETHMSK);
+}
+#pragma optimize(pop)
+
+
+#pragma optimize(push, off)
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void)
+#else
+u8_t lan91c96_poll(void)
+#endif
+{
+ // #######
+// BANK(0);
+// printf("RAM: %d ", ((*(unsigned int *)ETHMIR) & 0xff00));
+// BANK(2);
+ // #######
+
+ asm("lda %w", ETHIST);
+ asm("and #%%00000001"); //RCV INT
+ asm("bne @L1");
+
+ /* No packet available */
+ return 0;
+
+ asm("@L1:");
+
+ #ifdef DEBUG
+ printf("RCV: IRQ\n");
+ #endif
+
+ asm("lda #0");
+ asm("sta %w", ETHPTR);
+ asm("lda #%%11100000"); //RCV,AUTO INCR.,READ
+ asm("sta %w", ETHPTR+1);
+
+ asm("lda %w", ETHDATA); //Status word
+ asm("lda %w", ETHDATA);
+ asm("sta _packet_status"); //High byte only
+
+ asm("lda %w", ETHDATA); //Total number of bytes
+ asm("sta _packet_length");
+ asm("lda %w", ETHDATA);
+ asm("sta _packet_length+1");
+
+ /* Last word contain 'last data byte' and 0x60 */
+ /* or 'fill byte' and 0x40 */
+
+ packet_length -= 6; //The packet contains 3 extra words
+
+ asm("lda _packet_status");
+ asm("and #$10");
+ asm("beq @L2");
+
+ packet_length++;
+
+ #ifdef DEBUG
+ printf("RCV: odd number of bytes\n");
+ #endif
+
+ asm("@L2:");
+
+ #ifdef DEBUG
+ printf("RCV: L:%d ST-HIGH:0x%02x ",packet_length,packet_status);
+ #endif
+
+ if (packet_length > UIP_BUFSIZE)
+ {
+ /* Remove and release RX packet from FIFO*/
+ asm("lda #%%10000000");
+ asm("sta %w", ETHMMUCR);
+
+ #ifdef DEBUG
+ printf("RCV: UIP_BUFSIZE exceeded - packet dropped!\n");
+ #endif
+
+ return 0;
+ }
+
+ asm("lda #<_uip_buf");
+ asm("sta ptr1");
+ asm("lda #>_uip_buf");
+ asm("sta ptr1+1");
+
+ asm("ldy #0");
+ asm("ldx _packet_length+1");
+ asm("beq @RE1"); //packet_length < 256
+
+ asm("@RL1:");
+ asm("lda %w", ETHDATA);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("bne @RL1");
+ asm("inc ptr1+1");
+ asm("dex");
+ asm("bne @RL1");
+
+ asm("@RE1:");
+ asm("lda %w", ETHDATA);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("cpy _packet_length");
+ asm("bne @RE1");
+
+ /* Remove and release RX packet from FIFO*/
+ asm("lda #%%10000000");
+ asm("sta %w", ETHMMUCR);
+
+ #ifdef DEBUG
+// print_packet(uip_buf, packet_length);
+ #endif
+
+ return packet_length;
+}
+#pragma optimize(pop)
+
+/* First 40+14 (IP nad TCP header) is send from uip_buf */
+/* than data from uip_appdata */
+
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+ #ifdef DEBUG
+ printf("SND: send packet\n");
+ #endif
+
+ #if UIP_BUFSIZE > 255
+ asm("lda _uip_len+1");
+ #else
+ asm("lda #0");
+ #endif
+ asm("ora #%%00100000"); //Allocate memory for TX
+ asm("sta %w", ETHMMUCR);
+
+ asm("ldx #8"); //Wait...
+ asm("@L1:"); //Wait for allocation ready
+ asm("lda %w", ETHIST);
+ asm("and #%%00001000"); //ALLOC INT
+ asm("bne @X1");
+ asm("dex");
+ asm("bne @L1");
+
+ #ifdef DEBUG
+ printf("SND: ERR: memory alloc timeout\n");
+ #endif
+
+ return;
+
+ asm("@X1:");
+ #ifdef DEBUG
+ printf("SND: packet memory allocated\n");
+ #endif
+
+ asm("lda #%%00001000"); //Acknowledge int, is it necessary ???
+ asm("sta %w", ETHACK);
+
+ asm("lda %w", ETHARR);
+ asm("sta %w", ETHPNR); //Set packet address
+
+ asm("lda #0");
+ asm("sta %w", ETHPTR);
+ asm("lda #%%01000000"); //AUTO INCR.
+ asm("sta %w", ETHPTR+1);
+
+ #ifdef DEBUG
+ printf("SND: L:%d ", uip_len);
+ #endif
+
+ asm("lda #0"); //Status written by CSMA
+ asm("sta %w", ETHDATA);
+ asm("sta %w", ETHDATA);
+
+ asm("lda _uip_len");
+ asm("and #$01");
+ asm("beq @SD1");
+
+ packet_length=uip_len+5;
+ asm("jmp @LC1");
+
+ asm("@SD1:");
+
+ packet_length=uip_len+6; //+6 for status word, length and ctl byte
+
+ asm("@LC1:");
+
+// printf("SND: L:%d ", packet_length);
+
+ asm("lda _packet_length");
+ asm("sta %w", ETHDATA);
+ asm("lda _packet_length+1");
+ asm("sta %w", ETHDATA);
+
+ #ifdef DEBUG
+// print_packet(uip_buf, uip_len);
+ #endif
+
+ /* Send 40+14=54 bytes of header */
+
+ if(uip_len <= 54) {
+
+ #ifdef DEBUG
+ printf("SND: short packet sent.\n");
+ #endif
+
+ asm("ldx _uip_len");
+ asm("ldy #0");
+ asm("@WL1:");
+ asm("lda _uip_buf,y");
+ asm("sta %w", ETHDATA);
+ asm("iny");
+ asm("dex");
+ asm("bne @WL1");
+
+ } else {
+
+ asm("ldx #54");
+ asm("ldy #0");
+ asm("@WL2:");
+ asm("lda _uip_buf,y");
+ asm("sta %w", ETHDATA);
+ asm("iny");
+ asm("dex");
+ asm("bne @WL2");
+
+ uip_len -= 54;
+
+ asm("lda _uip_appdata"); //uip_appdata is pointer
+ asm("sta ptr1");
+ asm("lda _uip_appdata+1");
+ asm("sta ptr1+1");
+
+ asm("ldy #0");
+ #if UIP_BUFSIZE > 255
+ asm("ldx _uip_len+1");
+ #else
+ asm("ldx #0");
+ #endif
+ asm("beq @RE1"); //packet_length < 256
+
+ asm("@RL1:");
+ asm("lda (ptr1),y");
+ asm("sta %w", ETHDATA);
+ asm("iny");
+ asm("bne @RL1");
+ asm("inc ptr1+1");
+ asm("dex");
+ asm("bne @RL1");
+
+ asm("@RE1:");
+ asm("lda (ptr1),y");
+ asm("sta %w", ETHDATA);
+ asm("iny");
+ asm("cpy _uip_len");
+ asm("bne @RE1");
+
+ }
+
+ asm("lda _uip_len");
+ asm("and #$01");
+ asm("beq @R3");
+
+ asm("lda #%%00100000");
+ asm("sta %w", ETHDATA); //Control byte
+
+ asm("lda #%%11000000"); //ENQUEUE PACKET - transmit packet
+ asm("sta %w", ETHMMUCR);
+
+// printf("\n## %02x", *(unsigned char *)ETHIST);
+
+ return;
+
+ asm("@R3:");
+
+ asm("lda #0");
+ asm("sta %w", ETHDATA); //Fill byte
+ asm("sta %w", ETHDATA); //Control byte
+
+ asm("lda #%%11000000"); //ENQUEUE PACKET - transmit packet
+ asm("sta %w", ETHMMUCR);
+
+// printf("\n## %02x\n", *(unsigned char *)ETHIST);
+ return;
+}
+#pragma optimize(pop)
+
+#ifdef DEBUG
+static void print_packet(u8_t *buf, u16_t length)
+{
+ int i;
+ int remainder;
+ int lines;
+ u8_t a;
+ int cur;
+ int address=0;
+
+ printf("\nPacket of length %d \n", length );
+
+ lines = length / 8;
+ remainder = length % 8;
+
+ for ( i = 0; i < lines ; i ++ ) {
+ printf(":%04x ", address=i*8);
+
+ for ( cur = 0; cur < 8; cur ++ ) {
+ a = *(buf ++ );
+ printf("%02x ", a);
+ }
+ printf("\n");
+ }
+
+ printf(":%04x ", address+8);
+
+ for ( i = 0; i < remainder ; i++ ) {
+ a = *(buf ++ );
+ printf("%02x ", a);
+ }
+ printf("\n");
+}
+#endif /* DEBUG */
+
diff --git a/contiki-cpc/contiki-cpc/uip/lan91c96.h b/contiki-cpc/contiki-cpc/uip/lan91c96.h
new file mode 100644
index 0000000..762a1e4
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/lan91c96.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ */
+
+#ifndef _LAN91C96_H
+#define _LAN91C96_H
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_done(void);
+void lan91c96_send(void);
+#if UIP_BUFSIZE > 255
+u16_t lan91c96_poll(void);
+#else
+u8_t lan91c96_poll(void);
+#endif
+
+/* End of lan91c96.h */
+#endif
+
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S b/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S
new file mode 100644
index 0000000..595c00c
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------
+ .export _cs8900a_rxtxreg
+ .export _cs8900a_txcmd
+ .export _cs8900a_txlen
+ .export _cs8900a_packetpp
+ .export _cs8900a_ppdata
+
+
+;---------------------------------------------------------------------
+
+ _cs8900a_rxtxreg = $de08
+ _cs8900a_txcmd = $de0c
+ _cs8900a_txlen = $de0e
+ _cs8900a_packetpp = $de02
+ _cs8900a_ppdata = $de04
+
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-drv.c b/contiki-cpc/contiki-cpc/uip/rrnet-drv.c
new file mode 100644
index 0000000..0e3b4b5
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-drv.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-drv.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ uip_setethaddr(addr);
+ asm("lda #1");
+ asm("ora $de01");
+ asm("sta $de01");
+ cs8900a_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = cs8900a_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ cs8900a_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c b/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c
new file mode 100644
index 0000000..b19135e
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: rrnet-dsc.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon rrnet_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(rrnet_dsc,
+ "RR-Net driver",
+ "rrnet.drv",
+ rrnet_init,
+ &rrnet_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char rrneticon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char rrneticon_textmap[9] = {
+ 'R', 'R', '-',
+ 'N', 'e', 't',
+ 'D', 'R', 'V'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon rrnet_icon =
+ {CTK_ICON("RR-Net driver", rrneticon_bitmap, rrneticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c b/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c
new file mode 100644
index 0000000..2863457
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rrnet-dump-drv.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rrnet-dump-drv.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": RR-net", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+ {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+ memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+ tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+ CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(rrnet_dump_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ cs8900a_send();
+ dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "RR-Net dump");
+ CTK_WIDGET_ADD(&window, &dumplabel);
+ ctk_window_open(&window);
+ uip_setethaddr(addr);
+ asm("lda #1");
+ asm("ora $de01");
+ asm("sta $de01");
+ cs8900a_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ctk_window_close(&window);
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ctk_window_close(&window);
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+#pragma optimize(pop)
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = cs8900a_poll();
+ if(uip_len > 0) {
+ dump_packet();
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ cs8900a_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c b/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c
new file mode 100644
index 0000000..f9e900b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev-ss.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev-ss.c,v 1.1 2006/04/17 15:12:00 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include "rs232silversurfer.h"
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+# include <cbm.h>
+#elif defined(__ATARI__)
+# include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END 0300
+#define SLIP_ESC 0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c) while(rs232_get(&c) == RS_ERR_NO_DATA)
+#define SIO_POLL(c) (rs232_get(&c) != RS_ERR_NO_DATA)
+#define SIO_SEND(c) while(rs232_put(c) == RS_ERR_OVERFLOW)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+#if MAX_SIZE > 255
+static u16_t len, tmplen;
+#else
+static u8_t len, tmplen;
+#endif /* MAX_SIZE > 255 */
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+rs232_err(char err)
+{
+ switch(err) {
+ case RS_ERR_OK:
+ printf("RS232 OK\n");
+ break;
+ case RS_ERR_NOT_INITIALIZED:
+ printf("RS232 not initialized\n");
+ break;
+ case RS_ERR_BAUD_TOO_FAST:
+ printf("RS232 baud too fast\n");
+ break;
+ case RS_ERR_BAUD_NOT_AVAIL:
+ printf("RS232 baud rate not available\n");
+ break;
+ case RS_ERR_NO_DATA:
+ printf("RS232 nothing to read\n");
+ break;
+ case RS_ERR_OVERFLOW:
+ printf("RS232 overflow\n");
+ break;
+ }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+#if MAX_SIZE > 255
+ u16_t i;
+#else
+ u8_t i;
+#endif /* MAX_SIZE > 255 */
+ u8_t *ptr;
+ u8_t c;
+
+ SIO_SEND(SLIP_END);
+
+ ptr = &uip_buf[UIP_LLH_LEN];
+ for(i = 0; i < uip_len; ++i) {
+ if(i == 40) {
+ ptr = uip_appdata;
+ }
+ c = *ptr++;
+ switch(c) {
+ case SLIP_END:
+ SIO_SEND(SLIP_ESC);
+ SIO_SEND(SLIP_ESC_END);
+ break;
+ case SLIP_ESC:
+ SIO_SEND(SLIP_ESC);
+ SIO_SEND(SLIP_ESC_ESC);
+ break;
+ default:
+ SIO_SEND(c);
+ break;
+ }
+ }
+ SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+#if MAX_SIZE > 255
+u16_t
+#else
+u8_t
+#endif /* MAX_SIZE > 255 */
+rs232dev_poll(void)
+{
+ u8_t c;
+ static u8_t lastc;
+
+ while(SIO_POLL(c)) {
+ /* printf("c %x\n", c);*/
+ switch(c) {
+ case SLIP_ESC:
+ lastc = c;
+ break;
+
+ case SLIP_END:
+ lastc = c;
+ /* End marker found, we copy our input buffer to the uip_buf
+ buffer and return the size of the packet we copied. */
+ memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+ tmplen = len;
+ len = 0;
+ return tmplen;
+
+ default:
+ if(lastc == SLIP_ESC) {
+ lastc = c;
+ /* Previous read byte was an escape byte, so this byte will be
+ interpreted differently from others. */
+ switch(c) {
+ case SLIP_ESC_END:
+ c = SLIP_END;
+ break;
+ case SLIP_ESC_ESC:
+ c = SLIP_ESC;
+ break;
+ }
+ } else {
+ lastc = c;
+ }
+
+
+ slip_buf[len] = c;
+ ++len;
+
+ if(len > MAX_SIZE) {
+ len = 0;
+ }
+
+ break;
+ }
+ }
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+ char err;
+
+ err = rs232_init(0);
+ rs232_err(err);
+ err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);
+ rs232_err(err);
+
+ len = 0;
+
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev.c b/contiki-cpc/contiki-cpc/uip/rs232dev.c
new file mode 100644
index 0000000..cc89d52
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.c,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+/*
+ * This is a generic implementation of the SLIP protocol over an RS232
+ * (serial) device. While initially intented for the C64, the code can
+ * easily be ported to other platforms as well.
+ *
+ * Huge thanks to Ullrich von Bassewitz <uz@cc65.org> of cc65 fame for
+ * and endless supply of bugfixes, insightsful comments and
+ * suggestions, and improvements to this code!
+ */
+
+#include <serial.h>
+#include <time.h>
+#include <string.h>
+
+ /* This will include the system specific header files as well */
+#if defined(__CBM__)
+# include <cbm.h>
+#elif defined(__ATARI__)
+# include <atari.h>
+#endif
+
+#include "uip.h"
+
+#define SLIP_END 0300
+#define SLIP_ESC 0333
+#define SLIP_ESC_END 0334
+#define SLIP_ESC_ESC 0335
+
+
+#define SIO_RECV(c) while(ser_get(&c) == SER_ERR_NO_DATA)
+#define SIO_POLL(c) (ser_get(&c) != SER_ERR_NO_DATA)
+#define SIO_SEND(c) ser_put(c)
+
+#define MAX_SIZE (UIP_BUFSIZE - UIP_LLH_LEN)
+
+static u8_t slip_buf[MAX_SIZE + 2];
+
+static u16_t len, tmplen;
+
+static char loaded = 0;
+
+#if 1
+#define printf(x)
+#else
+#include <stdio.h>
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+/*static void
+rs232_err(char err)
+{
+ switch(err) {
+ case RS_ERR_OK:
+ printf("RS232 OK\n");
+ break;
+ case RS_ERR_NOT_INITIALIZED:
+ printf("RS232 not initialized\n");
+ break;
+ case RS_ERR_BAUD_TOO_FAST:
+ printf("RS232 baud too fast\n");
+ break;
+ case RS_ERR_BAUD_NOT_AVAIL:
+ printf("RS232 baud rate not available\n");
+ break;
+ case RS_ERR_NO_DATA:
+ printf("RS232 nothing to read\n");
+ break;
+ case RS_ERR_OVERFLOW:
+ printf("RS232 overflow\n");
+ break;
+ }
+}*/
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_send():
+ *
+ * Sends the packet in the uip_buf and uip_appdata buffers. The first
+ * 40 bytes of the packet (the IP and TCP headers) are read from the
+ * uip_buf buffer, and the following bytes (the application data) are
+ * read from the uip_appdata buffer.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_send(void)
+{
+ u16_t i;
+ u8_t *ptr;
+ u8_t c;
+
+ SIO_SEND(SLIP_END);
+
+ ptr = &uip_buf[UIP_LLH_LEN];
+ for(i = 0; i < uip_len; ++i) {
+ if(i == 40) {
+ ptr = uip_appdata;
+ }
+ c = *ptr++;
+ switch(c) {
+ case SLIP_END:
+ SIO_SEND(SLIP_ESC);
+ SIO_SEND(SLIP_ESC_END);
+ break;
+ case SLIP_ESC:
+ SIO_SEND(SLIP_ESC);
+ SIO_SEND(SLIP_ESC_ESC);
+ break;
+ default:
+ SIO_SEND(c);
+ break;
+ }
+ }
+ SIO_SEND(SLIP_END);
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_poll():
+ *
+ * Read all avaliable bytes from the RS232 interface into the slip_buf
+ * buffer. If no more bytes are avaliable, it returns with 0 to
+ * indicate that no packet was immediately ready. When a full packet
+ * has been read into the buffer, the packet is copied into the
+ * uip_buf buffer and the length of the packet is returned.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+u16_t
+rs232dev_poll(void)
+{
+ u8_t c;
+ static u8_t lastc;
+
+ if(loaded == 0) {
+ return 0;
+ }
+
+ while(SIO_POLL(c)) {
+
+ switch(c) {
+ case SLIP_ESC:
+ lastc = c;
+ break;
+
+ case SLIP_END:
+ lastc = c;
+ /* End marker found, we copy our input buffer to the uip_buf
+ buffer and return the size of the packet we copied. */
+ memcpy(&uip_buf[UIP_LLH_LEN], slip_buf, len);
+ tmplen = len;
+ len = 0;
+ return tmplen;
+
+ default:
+ if(lastc == SLIP_ESC) {
+ lastc = c;
+ /* Previous read byte was an escape byte, so this byte will be
+ interpreted differently from others. */
+ switch(c) {
+ case SLIP_ESC_END:
+ c = SLIP_END;
+ break;
+ case SLIP_ESC_ESC:
+ c = SLIP_ESC;
+ break;
+ }
+ } else {
+ lastc = c;
+ }
+
+ slip_buf[len] = c;
+ ++len;
+
+ if(len > MAX_SIZE) {
+ len = 0;
+ }
+
+ break;
+ }
+ }
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/*
+ * rs232dev_init():
+ *
+ * Initializes the RS232 device and sets the parameters of the device.
+ *
+ */
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_init(void)
+{
+ char err;
+ struct ser_params p;
+
+ err = ser_load_driver("c64-swlink.ser");
+
+ if(err != SER_ERR_OK) {
+ asm("inc $d020");
+ return;
+ }
+
+ p.baudrate = SER_BAUD_9600;
+ p.databits = SER_BITS_8;
+ p.stopbits = SER_STOP_1;
+ p.parity = SER_PAR_NONE;
+ p.handshake = SER_HS_HW;
+
+ err = ser_open(&p);
+
+ if(err != SER_ERR_OK) {
+ asm("inc $d020");
+ return;
+ }
+
+
+ loaded = 1;
+
+ /* err = rs232_init(0); */
+ /* rs232_err(err);*/
+ /* err = rs232_params(RS_BAUD_9600 | RS_BITS_8 | RS_STOP_1, RS_PAR_NONE);*/
+ /* rs232_err(err);*/
+
+ len = 0;
+
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+rs232dev_unload(void)
+{
+ if(loaded){
+ ser_unload();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/contiki-cpc/uip/rs232dev.h b/contiki-cpc/contiki-cpc/uip/rs232dev.h
new file mode 100644
index 0000000..ddce6ef
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232dev.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: rs232dev.h,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+#ifndef __RS232DEV_H__
+#define __RS232DEV_H__
+
+#include "uip.h"
+
+void rs232dev_init(void);
+u8_t rs232dev_read(void);
+void rs232dev_send(void);
+
+u16_t rs232dev_poll(void);
+
+void rs232dev_unload(void);
+
+#endif /* __RS232DEV_H__ */
diff --git a/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S
new file mode 100644
index 0000000..89bbf9d
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.S
@@ -0,0 +1,329 @@
+ ;; The following code is written and is copyrighted by
+ ;; Groepaz/Hitmen
+
+ ;; Small changes by Adam Dunkels (renamed ss232 -> rs232)
+
+;----------------------------------------------------------------------------------------------
+; silver surfer polling mode driver for cc65
+; - work from here to create a full featured driver with interupts.
+; gpz fixed 20020828: fatal bug fixed in _rs232_params
+;----------------------------------------------------------------------------------------------
+
+rs16550base = $de08
+
+fifo_rxd = rs16550base+$00 ;8 (r)
+fifo_txd = rs16550base+$00 ;8 (w)
+
+fifo_dll = rs16550base+$00 ;8 (r/w)
+fifo_dlm = rs16550base+$01 ;9 (r/w)
+
+fifo_ier = rs16550base+$01 ;9
+
+fifo_fcr = rs16550base+$02 ;a (w)
+fifo_iir = rs16550base+$02 ;a (r)
+fifo_lcr = rs16550base+$03 ;b
+fifo_mcr = rs16550base+$04 ;c
+fifo_lsr = rs16550base+$05 ;d
+fifo_msr = rs16550base+$06 ;e (r)
+fifo_scratch = rs16550base+$07 ;f (r/w)
+
+
+
+ .export _rs232_init
+ .export _rs232_done
+ .export _rs232_params
+ .export _rs232_put
+ .export _rs232_get
+
+ .importzp ptr1, ptr2
+ .import popa, popax
+
+;----------------------------------------------------------------------------------------------
+; Error codes. Beware: The codes must match the codes in the C header file
+
+ErrNotInitialized = $01
+ErrBaudTooFast = $02
+ErrBaudNotAvail = $03
+ErrNoData = $04
+ErrOverflow = $05
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_init (char hacked);
+;/* Initialize the serial port, install the interrupt handler. The parameter
+; * has no effect for now and should be set to 0.
+; */
+;----------------------------------------------------------------------------------------------
+
+ .code
+
+_rs232_init:
+ ; enable ssurfer-port
+ lda $de01
+ ora #$01
+ sta $de01
+
+ ; disable nmi's from ssurfer
+ lda #%00000000
+ sta fifo_ier
+
+ ; activate dtr
+ lda #%00000001
+ sta fifo_mcr
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_done (void);
+;/* Close the port, deinstall the interrupt hander. You MUST call this function
+; * before terminating the program, otherwise the machine may crash later. If
+; * in doubt, install an exit handler using atexit(). The function will do
+; * nothing, if it was already called.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_done:
+ ; disable nmi's from ssurfer
+ lda #%00000000
+ sta fifo_ier
+
+ ; deactivate dtr
+ sta fifo_mcr
+
+ ; disable ssurfer-port
+ lda $de01
+ and #$fe
+ sta $de01
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+;/* Set the port parameters. Use a combination of the #defined values above. */
+;----------------------------------------------------------------------------------------------
+
+ .data
+
+_rs232_baudrates:
+
+ .word (7372800 / ( 50 * 16))
+ .word (7372800 / ( 110 * 16))
+ .word (7372800 / ( 269 * 8))
+ .word (7372800 / ( 300 * 16))
+ .word (7372800 / ( 600 * 16))
+ .word (7372800 / ( 1200 * 16))
+ .word (7372800 / ( 2400 * 16))
+ .word (7372800 / ( 4800 * 16))
+ .word (7372800 / ( 9600 * 16))
+ .word (7372800 / ( 19200 * 16))
+ .word (7372800 / ( 38400 * 16))
+ .word (7372800 / ( 57600 * 16))
+ .word (7372800 / ( 115200 * 16))
+ .word (7372800 / ( 230400 * 16))
+
+ .bss
+
+_rs232_tmp1:
+ .res 1
+
+ .code
+
+_rs232_params:
+
+ sta _rs232_tmp1 ; save parity
+
+ ; reset fifo
+ lda #%10000111
+ sta fifo_fcr
+
+ ; that delay thing really needed ?!
+ ; (original datasheet mentions a delay here)
+ ; ldy #$00
+ ; dey
+ ; bny *-1
+
+ ; set dlab
+ lda #%10000011 ; we assmume 8n1
+ sta fifo_lcr
+
+ jsr popa
+ tay ; save param
+
+ ; set baudrate
+ clc
+ lsr a
+ lsr a
+ lsr a
+ lsr a
+ asl a
+ tax
+ lda _rs232_baudrates,x
+ sta fifo_dll
+ lda _rs232_baudrates+1,x
+ sta fifo_dlm
+
+ tya ; param
+ and #$0f
+ ora _rs232_tmp1 ; parity
+
+ ; reset dlab
+ sta fifo_lcr
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+; check if byte available, returns AKKU=0 if none
+
+ss_getlsr:
+ lda fifo_lsr
+ and #$01
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_get (char* b);
+;/* Get a character from the serial port. If no characters are available, the
+; * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+; */
+;----------------------------------------------------------------------------------------------
+; get byte (non blocking, returns byte in A or CARRY=1 - error)
+
+_rs232_get:
+ sta ptr1
+ stx ptr1+1
+
+ jsr ss_getlsr ; check if byte available
+; bne sk32 ; yes
+ bne sk33 ; yes
+
+ ; activate rts
+ lda #%00000011
+ sta fifo_mcr
+sk32:
+
+ ; deactivate rts
+; lda #%00000001
+; sta fifo_mcr
+
+ jsr ss_getlsr ; check if byte available
+ bne sk33 ; yes
+
+ ; deactivate rts
+ lda #%00000001
+ sta fifo_mcr
+
+ lda #ErrNoData ; no data
+ ldx #0
+ rts
+sk33:
+ ; deactivate rts
+ lda #%00000001
+ sta fifo_mcr
+
+ ; get byte
+ ldy #$00
+ lda fifo_rxd
+ sta (ptr1),y
+
+ lda #0 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_put (char b);
+;/* Send a character via the serial port. There is a transmit buffer, but
+; * transmitting is not done via interrupt. The function returns
+; * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+; */
+;----------------------------------------------------------------------------------------------
+
+_rs232_put:
+ tax
+ ; transmit buf ready?
+ lda fifo_lsr
+ and #%00100000
+ bne @sk1
+@sk2:
+ lda #ErrOverflow ; overflow
+ ldx #$00
+ rts
+@sk1:
+ ; reciever ready?
+ lda fifo_msr
+ and #%00010000
+ beq @sk2
+
+ stx fifo_txd
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_pause (void);
+;/* Assert flow control and disable interrupts. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_pause:
+ ; activate rts
+ lda #%00000011
+ sta fifo_mcr
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_unpause (void);
+;/* Re-enable interrupts and release flow control */
+;----------------------------------------------------------------------------------------------
+
+_rs232_unpause:
+ ; deactivate rts
+ lda #%00000001
+ sta fifo_mcr
+
+ lda #$00 ; ok
+ tax
+ rts
+
+;----------------------------------------------------------------------------------------------
+;unsigned char __fastcall__ rs232_status (unsigned char* status,
+; unsigned char* errors);
+;/* Return the serial port status. */
+;----------------------------------------------------------------------------------------------
+
+_rs232_status:
+ sta ptr2
+ stx ptr2+1
+ jsr popax
+ sta ptr1
+ stx ptr1+1
+
+ ldy #$00
+
+ ; Get status
+ lda fifo_iir
+ and #%00000001
+ sta _rs232_tmp1
+ lda fifo_msr
+ lsr a
+ and #%01010000
+ ora _rs232_tmp1
+ sta _rs232_tmp1
+ lda fifo_lsr
+ and #%00101110
+ ora _rs232_tmp1
+ sta (ptr1),y
+
+ ; Get errors
+ lda #$00 ; ok
+ sta (ptr2),y
+
+ lda #$00 ; ok
+ tax
+ rts
diff --git a/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h
new file mode 100644
index 0000000..9e9a49f
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/rs232silversurfer.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2003, Groepaz/Hitmen.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * rs232silversurfer.h
+ *
+ * Groepaz/Hitmen, 16.12.2001
+ *
+ * This defines for the SilverSurver (16c550 UART) what Ullrichs rs232 module
+ * defines for the Swithlink/Turbo232
+ *
+ * this driver operates in polling mode only atm !
+ *
+ */
+
+#ifndef _RS232silversurfer_H
+#define _RS232silversurfer_H
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+/* Baudrate settings */
+#define RS_BAUD_50 0x00
+#define RS_BAUD_110 0x10
+#define RS_BAUD_134_5 0x20
+#define RS_BAUD_300 0x30
+#define RS_BAUD_600 0x40
+#define RS_BAUD_1200 0x50
+#define RS_BAUD_2400 0x60
+#define RS_BAUD_4800 0x70
+#define RS_BAUD_9600 0x80
+#define RS_BAUD_19200 0x90
+#define RS_BAUD_38400 0xa0
+#define RS_BAUD_57600 0xb0
+#define RS_BAUD_115200 0xc0
+#define RS_BAUD_230400 0xd0
+
+/* Stop bit settings */
+#define RS_STOP_1 0x00
+#define RS_STOP_2 0x04
+
+/* Data bit settings */
+#define RS_BITS_5 0x00
+#define RS_BITS_6 0x01
+#define RS_BITS_7 0x02
+#define RS_BITS_8 0x03
+
+/* Parity settings */
+#define RS_PAR_NONE 0x00
+#define RS_PAR_ODD 0x28
+#define RS_PAR_EVEN 0x38
+#define RS_PAR_MARK 0x48
+#define RS_PAR_SPACE 0x48
+
+/* Bit masks to mask out things from the status returned by rs232_status */
+#define RS_STATUS_IRQ 0x01 /* (iir) IRQ condition */
+#define RS_STATUS_OVERRUN 0x02 /* (lsr) Overrun error */
+#define RS_STATUS_PE 0x04 /* (lsr) Parity error */
+#define RS_STATUS_FE 0x08 /* (lsr) Framing error */
+#define RS_STATUS_DSR 0x10 /* (msr>>1) NOT data set ready */
+#define RS_STATUS_THRE 0x20 /* (lsr) Transmit holding reg. empty */
+#define RS_STATUS_DCD 0x40 /* (msr>>1) NOT data carrier detect */
+#define RS_STATUS_RDRF 0x80 /* Receiver data register full */
+
+/* Error codes returned by all functions */
+#define RS_ERR_OK 0x00 /* Not an error - relax */
+#define RS_ERR_NOT_INITIALIZED 0x01 /* Module not initialized */
+#define RS_ERR_BAUD_TOO_FAST 0x02 /* Cannot handle baud rate */
+#define RS_ERR_BAUD_NOT_AVAIL 0x03 /* Baud rate not available */
+#define RS_ERR_NO_DATA 0x04 /* Nothing to read */
+#define RS_ERR_OVERFLOW 0x05 /* No room in send buffer */
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+unsigned char __fastcall__ rs232_init (char hacked);
+/* Initialize the serial port, install the interrupt handler. The parameter
+ * has no effect for now and should be set to 0.
+ */
+
+unsigned char __fastcall__ rs232_params (unsigned char params, unsigned char parity);
+/* Set the port parameters. Use a combination of the #defined values above. */
+
+unsigned char __fastcall__ rs232_done (void);
+/* Close the port, deinstall the interrupt hander. You MUST call this function
+ * before terminating the program, otherwise the machine may crash later. If
+ * in doubt, install an exit handler using atexit(). The function will do
+ * nothing, if it was already called.
+ */
+
+unsigned char __fastcall__ rs232_get (char* b);
+/* Get a character from the serial port. If no characters are available, the
+ * function will return RS_ERR_NO_DATA, so this is not a fatal error.
+ */
+
+unsigned char __fastcall__ rs232_put (char b);
+/* Send a character via the serial port. There is a transmit buffer, but
+ * transmitting is not done via interrupt. The function returns
+ * RS_ERR_OVERFLOW if there is no space left in the transmit buffer.
+ */
+
+unsigned char __fastcall__ rs232_pause (void);
+/* Assert flow control and disable interrupts. */
+
+unsigned char __fastcall__ rs232_unpause (void);
+/* Re-enable interrupts and release flow control */
+
+unsigned char __fastcall__ rs232_status (unsigned char* status,
+ unsigned char* errors);
+/* Return the serial port status. */
+
+/* End of rs232silversurfer.h */
+#endif
+
+
+
diff --git a/contiki-cpc/contiki-cpc/uip/slip-drv.c b/contiki-cpc/contiki-cpc/uip/slip-drv.c
new file mode 100644
index 0000000..dc37f1b
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-drv.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-drv.c,v 1.1 2006/04/17 15:12:01 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tapdev_service_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ rs232dev_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ rs232dev_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ rs232dev_unload();
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ rs232dev_unload();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+ uip_len = rs232dev_poll();
+ if(uip_len > 0) {
+ tcpip_input();
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/slip-dsc.c b/contiki-cpc/contiki-cpc/uip/slip-dsc.c
new file mode 100644
index 0000000..2cf7720
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: slip-dsc.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon slip_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(slip_dsc,
+ "SLIP driver",
+ "slip.drv",
+ slip_init,
+ &slip_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char slipicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char slipicon_textmap[9] = {
+ 'R', 'S', ' ',
+ '2', '3', '2',
+ '/', 'I', 'P'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon slip_icon =
+ {CTK_ICON("SLIP driver", slipicon_bitmap, slipicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c b/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c
new file mode 100644
index 0000000..4741e74
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/slip-dump-drv.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki OS
+ *
+ * $Id: slip-dump-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include "rs232dev.h"
+
+#include "packet-service.h"
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": SLIP", EK_PRIO_HIGH,
+ eventhandler, pollhandler, (void *)&state);
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+ {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+ memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+ tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+ CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(slip_service_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ rs232dev_send();
+ dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "SLIP dump");
+ CTK_WIDGET_ADD(&window, &dumplabel);
+ ctk_window_open(&window);
+ rs232dev_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ctk_window_close(&window);
+ ek_replace((struct ek_proc *)data, NULL);
+ rs232dev_unload();
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ctk_window_close(&window);
+ ek_exit();
+ rs232dev_unload();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+ uip_len = rs232dev_poll();
+ if(uip_len > 0) {
+ dump_packet();
+ tcpip_input();
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S b/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S
new file mode 100644
index 0000000..d31c320
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-drv-asm.S
@@ -0,0 +1,17 @@
+
+;---------------------------------------------------------------------
+ .export _cs8900a_rxtxreg
+ .export _cs8900a_txcmd
+ .export _cs8900a_txlen
+ .export _cs8900a_packetpp
+ .export _cs8900a_ppdata
+
+
+;---------------------------------------------------------------------
+
+ _cs8900a_rxtxreg = $de00
+ _cs8900a_txcmd = $de04
+ _cs8900a_txlen = $de06
+ _cs8900a_packetpp = $de0a
+ _cs8900a_ppdata = $de0c
+
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-drv.c b/contiki-cpc/contiki-cpc/uip/tfe-drv.c
new file mode 100644
index 0000000..ea807ac
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-drv.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x0d,0x60,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ uip_setethaddr(addr);
+ cs8900a_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = cs8900a_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ cs8900a_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-dsc.c b/contiki-cpc/contiki-cpc/uip/tfe-dsc.c
new file mode 100644
index 0000000..24d9314
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: tfe-dsc.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon tfe_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+ "The Final Ethernet driver",
+ "tfe.drv",
+ tfe_init,
+ &tfe_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tfeicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tfeicon_textmap[9] = {
+ 'T', 'C', 'P',
+ '/', 'I', 'P',
+ 'T', 'F', 'E'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon tfe_icon =
+ {CTK_ICON("TFE driver", tfeicon_bitmap, tfeicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c b/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c
new file mode 100644
index 0000000..e572909
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/tfe-dump-drv.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: tfe-dump-drv.c,v 1.1 2006/04/17 15:12:02 kthacker Exp $
+ *
+ */
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+static const struct uip_eth_addr addr =
+ {{0x00,0x00,0x00,0x64,0x64,0x64}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": TFE", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+#include "tcpdump.h"
+#include <string.h>
+#include "ctk.h"
+
+#define DUMP_WIDTH 38
+#define DUMP_HEIGHT 20
+static struct ctk_window window;
+static char dump[DUMP_WIDTH * DUMP_HEIGHT];
+static struct ctk_label dumplabel =
+ {CTK_LABEL(0, 0, DUMP_WIDTH, DUMP_HEIGHT, dump)};
+static void
+dump_packet(void)
+{
+ memcpy(dump, &dump[DUMP_WIDTH], DUMP_WIDTH * (DUMP_HEIGHT - 1));
+ tcpdump_print(&dump[DUMP_WIDTH * (DUMP_HEIGHT - 1)], DUMP_WIDTH);
+ CTK_WIDGET_REDRAW(&dumplabel);
+}
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(tfe_dump_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ cs8900a_send();
+ dump_packet();
+}
+/*---------------------------------------------------------------------------*/
+
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ ctk_window_new(&window, DUMP_WIDTH, DUMP_HEIGHT, "TFE dump");
+ CTK_WIDGET_ADD(&window, &dumplabel);
+ ctk_window_open(&window);
+ uip_setethaddr(addr);
+ cs8900a_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ctk_window_close(&window);
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ctk_window_close(&window);
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = cs8900a_poll();
+ if(uip_len > 0) {
+ dump_packet();
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ cs8900a_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/uip_arch.c b/contiki-cpc/contiki-cpc/uip/uip_arch.c
new file mode 100644
index 0000000..3e07ef1
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/uip_arch.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.c,v 1.1 2006/04/17 15:12:03 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+#include "uip_arch.h"
+
+#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define IP_PROTO_TCP 6
+#define IP_PROTO_UDP 17
+
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+void
+uip_add32(u8_t *op32, u16_t op16)
+{
+#if 0
+ asm("ldy #3");
+ asm("jsr ldaxysp");
+ asm("sta ptr1");
+ asm("stx ptr1+1");
+ asm("ldy #0");
+ asm("lda (sp),y");
+ asm("ldy #3");
+ asm("clc");
+ asm("adc (ptr1),y");
+ asm("sta _uip_acc32+3");
+ asm("dey");
+ asm("lda (ptr1),y");
+ asm("ldy #1");
+ asm("adc (sp),y");
+ asm("sta _uip_acc32+2");
+ asm("ldy #1");
+ asm("lda (ptr1),y");
+ asm("adc #0");
+ asm("sta _uip_acc32+1");
+ asm("dey");
+ asm("lda (ptr1),y");
+ asm("adc #0");
+ asm("sta _uip_acc32+0");
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+static u16_t chksum_ptr, chksum_len, chksum_tmp;
+static u8_t chksum_protocol;
+static u16_t chksum(void);
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+u16_t
+chksum(void) {
+
+#if 0
+ asm("lda #0");
+ asm("sta tmp1");
+ asm("sta tmp1+1");
+ asm("lda _chksum_ptr");
+ asm("sta ptr1");
+ asm("lda _chksum_ptr+1");
+ asm("sta ptr1+1");
+
+
+ asm("lda _chksum_len+1");
+ asm("beq chksumlast");
+
+
+ /* If checksum is > 256, do the first runs. */
+ asm("ldy #0");
+ asm("clc");
+ asm("chksumloop_256:");
+ asm("lda (ptr1),y");
+ asm("adc tmp1");
+ asm("sta tmp1");
+ asm("iny");
+ asm("lda (ptr1),y");
+ asm("adc tmp1+1");
+ asm("sta tmp1+1");
+ asm("iny");
+ asm("bne chksumloop_256");
+ asm("inc ptr1+1");
+ asm("dec _chksum_len+1");
+ asm("bne chksumloop_256");
+
+ asm("chksum_endloop_256:");
+ asm("lda tmp1");
+ asm("adc #0");
+ asm("sta tmp1");
+ asm("lda tmp1+1");
+ asm("adc #0");
+ asm("sta tmp1+1");
+ asm("bcs chksum_endloop_256");
+
+ asm("chksumlast:");
+ asm("lda _chksum_len");
+ asm("lsr");
+ asm("bcc chksum_noodd");
+ asm("ldy _chksum_len");
+ asm("dey");
+ asm("lda (ptr1),y");
+ asm("clc");
+ asm("adc tmp1");
+ asm("sta tmp1");
+ asm("bcc noinc1");
+ asm("inc tmp1+1");
+ asm("bne noinc1");
+ asm("inc tmp1");
+ asm("noinc1:");
+ asm("dec _chksum_len");
+
+ asm("chksum_noodd:");
+ asm("clc");
+ asm("php");
+ asm("ldy _chksum_len");
+ asm("chksum_loop1:");
+ asm("cpy #0");
+ asm("beq chksum_loop1_end");
+ asm("plp");
+ asm("dey");
+ asm("dey");
+ asm("lda (ptr1),y");
+ asm("adc tmp1");
+ asm("sta tmp1");
+ asm("iny");
+ asm("lda (ptr1),y");
+ asm("adc tmp1+1");
+ asm("sta tmp1+1");
+ asm("dey");
+ asm("php");
+ asm("jmp chksum_loop1");
+ asm("chksum_loop1_end:");
+ asm("plp");
+
+ asm("chksum_endloop:");
+ asm("lda tmp1");
+ asm("adc #0");
+ asm("sta tmp1");
+ asm("lda tmp1+1");
+ asm("adc #0");
+ asm("sta tmp1+1");
+ asm("bcs chksum_endloop");
+
+ asm("lda tmp1");
+ asm("ldx tmp1+1");
+#endif
+}
+/*#pragma optimize(pop)*/
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_chksum(u16_t *buf, u16_t len)
+{
+ /* unsigned long sum;
+
+ sum = 0;
+
+ chksum_ptr = (u16_t)buf;
+ while(len >= 256) {
+ chksum_len = 256;
+ sum += chksum();
+ len -= 256;
+ chksum_ptr += 256;
+ }
+
+ if(len < 256) {
+ chksum_len = len;
+ sum += chksum();
+ }
+
+ while((sum >> 16) != 0) {
+ sum = (sum >> 16) + (sum & 0xffff);
+ }
+
+ return sum;*/
+
+ chksum_len = len;
+ chksum_ptr = (u16_t)buf;
+ return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_ipchksum(void)
+{
+ chksum_ptr = (u16_t)uip_buf + UIP_LLH_LEN;
+ chksum_len = 20;
+ return chksum();
+}
+/*-----------------------------------------------------------------------------------*/
+/*#pragma optimize(push, off) */
+static u16_t
+transport_chksum(u8_t protocol)
+{
+ chksum_protocol = protocol;
+ chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+ chksum_len = 20;
+ chksum_tmp = chksum();
+
+ chksum_ptr = (u16_t)uip_appdata;
+
+#if 0
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #40");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+ asm("jsr %v", chksum);
+
+ asm("clc");
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("txa");
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+
+ /* Fold carry */
+ /* asm("bcc noinc");
+ asm("inc _chksum_tmp");
+ asm("noinc:");*/
+
+ asm("tcpchksum_loop1:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop1");
+
+
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #20");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+
+ asm("ldy #$0c");
+ asm("clc");
+ asm("php");
+ asm("tcpchksum_loop2:");
+ asm("plp");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("iny");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+ asm("iny");
+ asm("php");
+ asm("cpy #$14");
+ asm("bne tcpchksum_loop2");
+
+ asm("plp");
+
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc %v", chksum_protocol);
+ asm("sta _chksum_tmp+1");
+
+
+ asm("lda _chksum_tmp");
+ asm("adc _chksum_len+1");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc _chksum_len");
+ asm("sta _chksum_tmp+1");
+
+
+
+ asm("tcpchksum_loop3:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop3");
+#endif
+
+ return chksum_tmp;
+}
+/*#pragma optimize(pop)*/
+
+/*-----------------------------------------------------------------------------------*/
+u16_t
+uip_tcpchksum(void)
+{
+ return transport_chksum(IP_PROTO_TCP);
+#if 0
+ chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+ chksum_len = 20;
+ chksum_tmp = chksum();
+
+ chksum_ptr = (u16_t)uip_appdata;
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #40");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+ asm("jsr %v", chksum);
+
+ asm("clc");
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("txa");
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+
+ /* Fold carry */
+ /* asm("bcc noinc");
+ asm("inc _chksum_tmp");
+ asm("noinc:");*/
+
+ asm("tcpchksum_loop1:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop1");
+
+
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #20");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+
+ asm("ldy #$0c");
+ asm("clc");
+ asm("php");
+ asm("tcpchksum_loop2:");
+ asm("plp");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("iny");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+ asm("iny");
+ asm("php");
+ asm("cpy #$14");
+ asm("bne tcpchksum_loop2");
+
+ asm("plp");
+
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #6"); /* IP_PROTO_TCP */
+ asm("sta _chksum_tmp+1");
+
+
+ asm("lda _chksum_tmp");
+ asm("adc _chksum_len+1");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc _chksum_len");
+ asm("sta _chksum_tmp+1");
+
+
+
+ asm("tcpchksum_loop3:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop3");
+
+
+ return chksum_tmp;
+#endif
+}
+
+/*-----------------------------------------------------------------------------------*/
+#if UIP_UDP_CHECKSUMS
+u16_t
+uip_udpchksum(void)
+{
+ return transport_chksum(IP_PROTO_UDP);
+#if 0
+ chksum_ptr = (u16_t)&uip_buf[20 + UIP_LLH_LEN];
+ chksum_len = 20;
+ chksum_tmp = chksum();
+
+ chksum_ptr = (u16_t)uip_appdata;
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #40");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+ asm("jsr %v", chksum);
+
+ asm("clc");
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("txa");
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+
+ /* Fold carry */
+ /* asm("bcc noinc");
+ asm("inc _chksum_tmp");
+ asm("noinc:");*/
+
+ asm("tcpchksum_loop1:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop1");
+
+
+ asm("lda _uip_buf+3+%b", UIP_LLH_LEN);
+ asm("sec");
+ asm("sbc #20");
+ asm("sta _chksum_len");
+ asm("lda _uip_buf+2+%b", UIP_LLH_LEN);
+ asm("sbc #0");
+ asm("sta _chksum_len+1");
+
+
+ asm("ldy #$0c");
+ asm("clc");
+ asm("php");
+ asm("tcpchksum_loop2:");
+ asm("plp");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp");
+ asm("sta _chksum_tmp");
+ asm("iny");
+ asm("lda _uip_buf+%b,y", UIP_LLH_LEN);
+ asm("adc _chksum_tmp+1");
+ asm("sta _chksum_tmp+1");
+ asm("iny");
+ asm("php");
+ asm("cpy #$14");
+ asm("bne tcpchksum_loop2");
+
+ asm("plp");
+
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #17"); /* IP_PROTO_UDP */
+ asm("sta _chksum_tmp+1");
+
+
+ asm("lda _chksum_tmp");
+ asm("adc _chksum_len+1");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc _chksum_len");
+ asm("sta _chksum_tmp+1");
+
+
+
+ asm("tcpchksum_loop3:");
+ asm("lda _chksum_tmp");
+ asm("adc #0");
+ asm("sta _chksum_tmp");
+ asm("lda _chksum_tmp+1");
+ asm("adc #0");
+ asm("sta _chksum_tmp+1");
+ asm("bcs tcpchksum_loop3");
+
+
+ return chksum_tmp;
+#endif
+}
+#endif /* UIP_UDP_CHECKSUMS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/contiki-cpc/uip/uip_arch.h b/contiki-cpc/contiki-cpc/uip/uip_arch.h
new file mode 100644
index 0000000..b850435
--- /dev/null
+++ b/contiki-cpc/contiki-cpc/uip/uip_arch.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uip_arch.h,v 1.1 2006/04/17 15:12:03 kthacker Exp $
+ *
+ */
+
+#ifndef __UIP_ARCH_H__
+#define __UIP_ARCH_H__
+
+#include "uip.h"
+
+void uip_add_rcv_nxt(u16_t n);
+void uip_add32(u8_t *op32, u16_t op16);
+
+u16_t uip_chksum(u16_t *data, u16_t len);
+u16_t uip_ipchksum(void);
+u16_t uip_tcpchksum(void);
+
+#endif /* __UIP_ARCH_H__ */