Merge remote-tracking branch 'contiki-apple2/master'
diff --git a/contiki-apple2/Makefile b/contiki-apple2/Makefile
new file mode 100644
index 0000000..18d56b4
--- /dev/null
+++ b/contiki-apple2/Makefile
@@ -0,0 +1,67 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile,v 1.6 2005/04/18 21:49:36 oliverschmidt Exp $
+#
+
+CONTIKI=../contiki
+CONTIKICC65=../contiki-cc65
+
+usage:
+ @echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
+ @echo 'To compile Contiki, use "'$(MAKE)' target" where target'
+ @echo 'is one of the following:'
+ @echo all
+ @echo apple2
+ @echo apple2enh
+ @echo programs
+ @echo programsenh
+ @echo '(Also check the Makefile for more targets to try...)'
+
+all: clean apple2enh programsenh
+
+apple2:
+ $(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.apple2 SYS=apple2
+
+apple2enh:
+ $(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.apple2 SYS=apple2enh
+
+programs:
+ $(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs SYS=apple2
+
+programsenh:
+ $(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs SYS=apple2enh
+
+CCDEPFLAGS=
+
+include $(CONTIKICC65)/Makefile.cc65
+
diff --git a/contiki-apple2/Makefile.apple2 b/contiki-apple2/Makefile.apple2
new file mode 100644
index 0000000..293f4d2
--- /dev/null
+++ b/contiki-apple2/Makefile.apple2
@@ -0,0 +1,65 @@
+# Copyright (c) 2002, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Adam Dunkels.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.apple2,v 1.20 2006/05/30 20:51:01 oliverschmidt Exp $
+#
+
+all: contiki
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+AFLAGS:=-t $(SYS) -I lib -I $(CC65_INC)/../asminc
+
+CFLAGS:=$(CFLAGSCC65) --code-name CONTIKI \
+ -DWITH_ASCII -DWITH_UIP -DWITH_LOADER_ARCH -DWITH_ETHERNET
+
+ifeq ($(SYS),apple2)
+
+CTK=ctk.o ctk-conio.o
+
+else # apple2
+
+CTK=ctk.o ctk-mousetext.o ctk-mouse.o
+
+uip.s uip_arch.s uiplib.s tcpip.s: %.s: %.c
+ $(CC) $(CFLAGS) $(OPT) -DUIP_CODE -o $(notdir $@) $<
+
+endif # apple2
+
+contiki:crt0.o main.o ek.o ek-service.o timer.o program-handler.o arg.o \
+ loader-arch.o clock-arch.o bank.o kfs.o import.o $(CTK) $(UIP) \
+ www-dsc.o \
+ email-dsc.o \
+ ftp-dsc.o \
+ directory-dsc.o
+ $(LD) -C $(SYS).cfg -Ln contiki-labels -m contiki.map $^ $(SYS).lib
diff --git a/contiki-apple2/Makefile.programs b/contiki-apple2/Makefile.programs
new file mode 100644
index 0000000..b3df70e
--- /dev/null
+++ b/contiki-apple2/Makefile.programs
@@ -0,0 +1,94 @@
+# Copyright (c) 2003, Adam Dunkels.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is part of the Contiki desktop environment
+#
+# $Id: Makefile.programs,v 1.20 2006/05/30 20:51:01 oliverschmidt Exp $
+#
+
+all: loader-arch-module.o loader-arch-module-dsc.o contiki-labels.o \
+ about.prg about.dsc \
+ calc.prg calc.dsc \
+ config.prg \
+ configedit.prg configedit.dsc \
+ dhcp.prg dhcp.dsc \
+ directory.prg directory.dsc \
+ email.prg email.dsc \
+ ftp.prg ftp.dsc \
+ irc.prg irc.dsc \
+ memstat.prg memstat.dsc \
+ processes.prg processes.dsc \
+ shell.prg shell.dsc \
+ telnet.prg telnet.dsc \
+ welcome.prg \
+ wget.prg wget.dsc \
+ www.prg www.dsc \
+ lancegs.drv lancegs.dsc \
+ uther.drv uther.dsc \
+ plasma.sav plasma.dsc \
+ ssfire.sav ssfire.dsc
+
+ifeq ($(SYS),apple2enh)
+
+all: webserver.prg webserver.dsc \
+ bounce.sav bounce.dsc
+
+endif # apple2enh
+
+include $(CONTIKI)/Makefile.common
+include $(CONTIKICC65)/Makefile.cc65
+
+AFLAGS:=-t $(SYS)
+
+CFLAGS:=$(CFLAGSCC65) \
+ -DWITH_ASCII -DWITH_UIP -DWITH_LOADER_ARCH -DWITH_ETHERNET
+
+configedit.prg: configedit.o ctk-textentry-checkbox.o
+
+dhcp.prg: $(DHCP) lc-asm.o
+
+directory.prg: $(DIRECTORY) cfs.o
+
+email.prg: $(EMAIL) lc-asm.o
+
+ftp.prg: $(FTP) cfs.o
+
+irc.prg: $(IRC) lc-asm.o
+
+shell.prg: $(SHELL_) cfs.o
+
+telnet.prg: $(TELNET)
+
+webserver.prg: $(WEBSERVER) lc-asm.o
+
+wget.prg: $(WGET)
+
+www.prg: $(WWW)
+
+lancegs.drv: lancegs-drv.o lan91c96.o uip_arp.o
+
+uther.drv: uther-drv.o cs8900a.o uther-drv-asm.o uip_arp.o
diff --git a/contiki-apple2/apple2.cfg b/contiki-apple2/apple2.cfg
new file mode 100644
index 0000000..2e8c07d
--- /dev/null
+++ b/contiki-apple2/apple2.cfg
@@ -0,0 +1,36 @@
+MEMORY {
+ ZP: start = $0080, size = $001A, file = "", define = yes;
+ BUFFER: start = $0800, size = $0400, file = "";
+ HEADER: start = $0000, size = $0004, file = "contiki";
+ RAM: start = $0C00, size = $8A00, file = "contiki";
+ PIC: start = $0000, size = $FFFF, file = "contiki";
+ TMP: start = $0000, size = $FFFF, file = "contiki";
+ LC: start = $D400, size = $0C00, file = "contiki";
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ UIPBUF: load = BUFFER, type = bss;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = RAM, type = ro, define = yes;
+ CONTIKI: load = RAM, type = ro;
+ RODATA: load = RAM, type = ro;
+ DATA: load = RAM, type = rw;
+ BSS: load = RAM, type = bss, define = yes;
+ BOOT: load = PIC, type = ro, define = yes;
+ INIT: load = TMP, run = RAM, type = ro, define = yes;
+ CODE: load = LC, type = ro, define = yes;
+}
+FEATURES {
+ CONDES: segment = INIT,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+ type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__;
+}
+SYMBOLS {
+ __STACKSIZE__ = $0100;
+ __UIP_SIZE__ = $0000;
+}
diff --git a/contiki-apple2/apple2enh.cfg b/contiki-apple2/apple2enh.cfg
new file mode 100644
index 0000000..68fdc20
--- /dev/null
+++ b/contiki-apple2/apple2enh.cfg
@@ -0,0 +1,41 @@
+MEMORY {
+ ZP: start = $0080, size = $001A, file = "", define = yes;
+ BUFFER: start = $0800, size = $0400, file = "";
+ HEADER: start = $0000, size = $0004, file = "contiki";
+ RAM: start = $0C00, size = $8A00, file = "contiki";
+ PIC: start = $0000, size = $FFFF, file = "contiki";
+ TMP: start = $0000, size = $FFFF, file = "contiki";
+ LC: start = $D000, size = $1000, file = "contiki";
+ AUX: start = $2000, size = $2000, file = "contiki";
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ UIPBUF: load = BUFFER, type = bss;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = RAM, type = ro, define = yes;
+ CONTIKI: load = RAM, type = ro;
+ RODATA: load = RAM, type = ro;
+ DATA: load = RAM, type = rw;
+ BSS: load = RAM, type = bss, define = yes;
+ BOOT: load = PIC, type = ro, define = yes;
+ INIT: load = TMP, run = RAM, type = ro, define = yes;
+ CODE: load = LC, type = ro, define = yes;
+ UIP: load = AUX, type = ro, define = yes;
+}
+FEATURES {
+ CONDES: segment = INIT,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+ type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+ type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__;
+}
+SYMBOLS {
+ __STACKSIZE__ = $0100;
+}
diff --git a/contiki-apple2/apps/bounce-dsc.c b/contiki-apple2/apps/bounce-dsc.c
new file mode 100644
index 0000000..abc2251
--- /dev/null
+++ b/contiki-apple2/apps/bounce-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: bounce-dsc.c,v 1.1 2006/05/30 20:50:26 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon bounce_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+ "Screensaver with a bouncing box",
+ "bounce.sav",
+ bounce_init,
+ &bounce_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char bounceicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char bounceicon_textmap[9] = {
+ '-', '|', '-',
+ '|', '|', '|',
+ '|', '-', '|'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon bounce_icon =
+ {CTK_ICON("Bounce", bounceicon_bitmap, bounceicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/bounce.c b/contiki-apple2/apps/bounce.c
new file mode 100644
index 0000000..b56d1d1
--- /dev/null
+++ b/contiki-apple2/apps/bounce.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: bounce.c,v 1.1 2006/05/30 20:50:26 oliverschmidt Exp $
+ *
+ */
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+EK_EVENTHANDLER(bounce_eventhandler, ev, data);
+EK_POLLHANDLER(bounce_pollhandler);
+EK_PROCESS(p, "Bounce screensaver", EK_PRIO_LOWEST,
+ bounce_eventhandler, bounce_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static char pos[4] = {3, 17, 7, 13};
+static char vec[4] = {-1, 1, -1, 1};
+static char max[4];
+static char rev[2];
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+ arg_free(arg);
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(bounce_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_mode_set(CTK_MODE_SCREENSAVER);
+ ctk_mouse_hide();
+ max[0] = max[1] = ctk_draw_width();
+ max[2] = max[3] = ctk_draw_height();
+ } else if(ev == ctk_signal_screensaver_stop ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(bounce_pollhandler)
+{
+ static unsigned char i;
+
+ if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+ for(i = 0; i < 4; ++i) {
+ pos[i] += vec[i];
+ if(pos[i] <= 0 || pos[i] >= max[i]) {
+ vec[i] = -vec[i];
+ }
+ }
+ if(pos[0] == pos[1] || pos[2] == pos[3]) {
+ return;
+ }
+ for(i = 0; i < 2; ++i) {
+ rev[i] = pos[i * 2] > pos[i * 2 + 1];
+ }
+ _textframexy(pos[0 + rev[0]],
+ pos[2 + rev[1]],
+ pos[1 - rev[0]] - pos[0 + rev[0]],
+ pos[3 - rev[1]] - pos[2 + rev[1]], _TEXTFRAME_TALL);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/config.c b/contiki-apple2/apps/config.c
new file mode 100644
index 0000000..409da35
--- /dev/null
+++ b/contiki-apple2/apps/config.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: config.c,v 1.13 2006/06/28 23:10:44 oliverschmidt Exp $
+ *
+ */
+
+
+#include <string.h>
+#include <unistd.h>
+
+#include "uiplib.h"
+#include "resolv.h"
+#include "uip_arp.h"
+
+#include "program-handler.h"
+#include "kfs.h"
+
+#include "config.h"
+
+
+static config_t config = {0,
+#ifdef __APPLE2__
+ "SSFire.sav", 5,
+#else /* __APPLE2__ */
+ "Bounce.sav", 5,
+#endif /* __APPLE2__ */
+ "Uther.drv", 0,
+ "",
+ {0xA8C0, 0x8000}, {0xFFFF, 0x00FF},
+ {0xA8C0, 0x0100}, {0xA8C0, 0x0100},
+ 0xA2};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+config_load(void)
+{
+ int fd;
+
+ fd = kfs_open("contiki.cfg");
+ if(fd == -1) {
+ return;
+ }
+ kfs_read(fd, &config, sizeof(config));
+ kfs_close(fd);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+config_apply(void)
+{
+#ifdef __APPLE2ENH__
+
+ ctk_draw_setbackground(config.bkgnd);
+
+#endif /* __APPLE2ENH__ */
+
+ program_handler_setscreensaver(config.screensaver);
+
+ CTK_SCREENSAVER_SET_TIMEOUT(config.timeout * 60);
+
+ config_setlanslot(config.slot);
+
+ if(*config.driver) {
+ program_handler_load(config.driver, NULL);
+ }
+
+ if(*config.prefix == '/') {
+ config_setprefixok(chdir(config.prefix) == 0);
+ }
+
+#ifdef WITH_UIP
+
+ uip_sethostaddr(config.ipaddr);
+
+#ifdef WITH_ETHERNET
+
+ uip_setnetmask(config.netmask);
+ uip_setdraddr(config.gateway);
+ uip_ethaddr.addr[5] = config.maclsb;
+
+#endif /* WITH_ETHERNET */
+
+ resolv_conf(config.dnsserver);
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+ arg_free(arg);
+ config_load();
+ config_apply();
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/config.h b/contiki-apple2/apps/config.h
new file mode 100644
index 0000000..ea7e1b3
--- /dev/null
+++ b/contiki-apple2/apps/config.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: config.h,v 1.8 2006/06/28 23:10:44 oliverschmidt Exp $
+ *
+ */
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+typedef struct {
+ unsigned char bkgnd;
+ char screensaver[16];
+ unsigned char timeout;
+ char driver[16];
+ unsigned char slot;
+ char prefix[65];
+ u16_t ipaddr[2];
+ u16_t netmask[2];
+ u16_t gateway[2];
+ u16_t dnsserver[2];
+ unsigned char maclsb;
+} config_t;
+
+extern unsigned char lanslot;
+extern unsigned char prefixok;
+
+#define config_getlanslot() lanslot
+#define config_setlanslot(slot) lanslot = (slot)
+
+#define config_getprefixok() prefixok
+#define config_setprefixok(ok) prefixok = (ok)
+
+#endif /* __CONFIG_H__ */
diff --git a/contiki-apple2/apps/configedit-dsc.c b/contiki-apple2/apps/configedit-dsc.c
new file mode 100644
index 0000000..cfe7564
--- /dev/null
+++ b/contiki-apple2/apps/configedit-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.3 2005/05/06 22:33:51 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+ "Edit Contiki configuration",
+ "configedit.prg",
+ configedit_init,
+ &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char tcpipconficon_bitmap[3*3*8] = {
+ 0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+ 0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+ 0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+ 0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+ 0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+ 0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char tcpipconficon_textmap[9] = {
+ '-', '-', '-',
+ 'C', 'F', 'G',
+ 'E', 'D', 'T'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon configedit_icon =
+ {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/configedit-dsc.h b/contiki-apple2/apps/configedit-dsc.h
new file mode 100644
index 0000000..0b33f4a
--- /dev/null
+++ b/contiki-apple2/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2004/12/26 14:13:34 oliverschmidt Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-apple2/apps/configedit.c b/contiki-apple2/apps/configedit.c
new file mode 100644
index 0000000..e3aa78b
--- /dev/null
+++ b/contiki-apple2/apps/configedit.c
@@ -0,0 +1,508 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.12 2006/06/28 23:10:45 oliverschmidt Exp $
+ *
+ */
+
+
+#include <string.h>
+
+#include "uiplib.h"
+#include "resolv.h"
+#include "uip_arp.h"
+#include "ctk.h"
+
+#include "program-handler.h"
+#include "packet-service.h"
+#include "kfs.h"
+#include "cfs.h"
+
+#include "ctk-textentry-checkbox.h"
+
+#include "config.h"
+
+
+static config_t config;
+static struct ctk_window window;
+
+#ifdef __APPLE2ENH__
+
+static struct ctk_label backgroundlabel =
+ {CTK_LABEL(0, 1, 11, 1, "Background")};
+static char bkgnd[2];
+static struct ctk_textentry backgroundtextentry =
+ {CTK_TEXTENTRY_INPUT(12, 1, 1, 1, bkgnd, 1, ctk_textentry_checkbox_input)};
+static struct ctk_label backgrounddescr =
+ {CTK_LABEL(16, 1, 12, 1, "('x' or ' ')")};
+
+#endif /* __APPLE2ENH__ */
+
+static struct ctk_label screensaverlabel =
+ {CTK_LABEL(0, 3, 11, 1, "Screensaver")};
+static char screensaver[16];
+static struct ctk_textentry screensavertextentry =
+ {CTK_TEXTENTRY(12, 3, 15, 1, screensaver, 15)};
+
+static struct ctk_label timeoutlabel =
+ {CTK_LABEL(0, 4, 11, 1, "Timeout")};
+static char timeout[2];
+static struct ctk_textentry timeouttextentry =
+ {CTK_TEXTENTRY(12, 4, 1, 1, timeout, 1)};
+static struct ctk_label timeoutdescr =
+ {CTK_LABEL(16, 4, 12, 1, "(in Minutes)")};
+
+static struct ctk_label driverlabel =
+ {CTK_LABEL(0, 6, 11, 1, "LAN driver")};
+static char driver[16];
+static struct ctk_textentry drivertextentry =
+ {CTK_TEXTENTRY(12, 6, 15, 1, driver, 15)};
+
+static struct ctk_label slotlabel =
+ {CTK_LABEL(0, 7, 11, 1, "LAN slot")};
+static char slot[2];
+static struct ctk_textentry slottextentry =
+ {CTK_TEXTENTRY(12, 7, 1, 1, slot, 1)};
+static struct ctk_label slotdescr =
+ {CTK_LABEL(16, 7, 12, 1, "('1' to '7')")};
+
+static struct ctk_label prefixlabel =
+ {CTK_LABEL(0, 9, 11, 1, "DOS Prefix")};
+static char prefix[65];
+static struct ctk_textentry prefixtextentry =
+ {CTK_TEXTENTRY(12, 9, 15, 1, prefix, 65)};
+
+static struct ctk_label ipaddrlabel =
+ {CTK_LABEL(0, 11, 10, 1, "IP address")};
+static char ipaddr[16];
+static struct ctk_textentry ipaddrtextentry =
+ {CTK_TEXTENTRY(12, 11, 15, 1, ipaddr, 15)};
+
+#ifdef WITH_ETHERNET
+
+static struct ctk_label netmasklabel =
+ {CTK_LABEL(0, 12, 11, 1, "Netmask")};
+static char netmask[16];
+static struct ctk_textentry netmasktextentry =
+ {CTK_TEXTENTRY(12, 12, 15, 1, netmask, 15)};
+
+static struct ctk_label gatewaylabel =
+ {CTK_LABEL(0, 13, 11, 1, "Gateway")};
+static char gateway[16];
+static struct ctk_textentry gatewaytextentry =
+ {CTK_TEXTENTRY(12, 13, 15, 1, gateway, 15)};
+
+static struct ctk_label dnsserverlabel =
+ {CTK_LABEL(0, 14, 11, 1, "DNS server")};
+static char dnsserver[16];
+static struct ctk_textentry dnsservertextentry =
+ {CTK_TEXTENTRY(12, 14, 15, 1, dnsserver, 15)};
+
+static struct ctk_label maclsblabel =
+ {CTK_LABEL(0, 16, 11, 1, "MAC address")};
+static char maclsb[4];
+static struct ctk_textentry maclsbtextentry =
+ {CTK_TEXTENTRY(12, 16, 3, 1, maclsb, 3)};
+static struct ctk_label maclsbdescr =
+ {CTK_LABEL(18, 16, 10, 1, "(LSB only)")};
+
+#else /* WITH_ETHERNET */
+
+static struct ctk_label dnsserverlabel =
+ {CTK_LABEL(0, 12, 11, 1, "DNS server")};
+static char dnsserver[16];
+static struct ctk_textentry dnsservertextentry =
+ {CTK_TEXTENTRY(12, 12, 15, 1, dnsserver, 15)};
+
+#endif /* WITH_ETHERNET */
+
+static struct ctk_button okbutton =
+ {CTK_BUTTON(0, 18, 12, "Save & close")};
+static struct ctk_button cancelbutton =
+ {CTK_BUTTON(22, 18, 6, "Cancel")};
+
+
+static struct ctk_window errordialog;
+
+static struct ctk_label errormsg =
+ {CTK_LABEL(0, 1, 19, 1, "Error saving config")};
+static struct ctk_button errorokbutton =
+ {CTK_BUTTON(7, 3, 2, "Ok")};
+
+
+EK_EVENTHANDLER(config_eventhandler, ev, data);
+EK_PROCESS(p, "Configuration", EK_PRIO_NORMAL,
+ config_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+static ek_id_t driverid = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+makebyte(u8_t byte, char *str)
+{
+ if(byte >= 100) {
+ *str++ = (byte / 100 ) % 10 + '0';
+ }
+ if(byte >= 10) {
+ *str++ = (byte / 10) % 10 + '0';
+ }
+ *str++ = (byte % 10) + '0';
+
+ return str;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makeaddr(u16_t *addr, char *str)
+{
+ str = makebyte(HTONS(addr[0]) >> 8, str);
+ *str++ = '.';
+ str = makebyte(HTONS(addr[0]) & 0xff, str);
+ *str++ = '.';
+ str = makebyte(HTONS(addr[1]) >> 8, str);
+ *str++ = '.';
+ str = makebyte(HTONS(addr[1]) & 0xff, str);
+ *str++ = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static int
+makedriver(const char *name, char *str)
+{
+ char *pattern = PACKET_SERVICE_NAME ": ";
+
+ while(*pattern) {
+ if(*name++ != *pattern++) {
+ return 0;
+ }
+ }
+
+ while(*name) {
+ *str++ = *name++;
+ }
+ strcpy(str, ".drv");
+
+ return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makestrings(void)
+{
+ u16_t addr[2], *addrptr;
+ struct ek_proc *p;
+
+#ifdef __APPLE2ENH__
+
+ if(ctk_draw_getbackground()) {
+ *bkgnd = 'x';
+ }
+
+#endif /* __APPLE2ENH__ */
+
+ strncpy(screensaver, program_handler_getscreensaver(), sizeof(screensaver));
+
+ *timeout = (CTK_SCREENSAVER_TIMEOUT() / 60) % 10 + '0';
+
+ for(p = EK_PROCS(); p != NULL; p = p->next) {
+ if(makedriver(p->name, driver)) {
+ driverid = p->id;
+ break;
+ }
+ }
+
+ if(config_getlanslot() != 0) {
+ *slot = config_getlanslot() + '0';
+ }
+
+ if(config_getprefixok()) {
+ getcwd(prefix, sizeof(prefix));
+ }
+
+#ifdef WITH_UIP
+
+ uip_gethostaddr(addr);
+ makeaddr(addr, ipaddr);
+
+#ifdef WITH_ETHERNET
+
+ uip_getnetmask(addr);
+ makeaddr(addr, netmask);
+
+ uip_getdraddr(addr);
+ makeaddr(addr, gateway);
+
+ makebyte(uip_ethaddr.addr[5], maclsb);
+
+#endif /* WITH_ETHERNET */
+
+ addrptr = resolv_getserver();
+ if(addrptr != NULL) {
+ makeaddr(addrptr, dnsserver);
+ }
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+nullterminate(char *cptr)
+{
+ /* Find the first space character in the ipaddr and put a zero there
+ to end the string. */
+ for(; *cptr != ' ' && *cptr != 0; ++cptr);
+ *cptr = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makeconfig(void)
+{
+ u16_t addr[2];
+ char *cptr;
+ u8_t tmp;
+
+#ifdef __APPLE2ENH__
+
+ config.bkgnd = (*bkgnd == 'x');
+
+#endif /* __APPLE2ENH__ */
+
+ nullterminate(screensaver);
+ strcpy(config.screensaver, screensaver);
+
+ if(*timeout >= '1' && *timeout <= '9') {
+ config.timeout = *timeout - '0';
+ }
+
+ nullterminate(driver);
+ strcpy(config.driver, driver);
+
+ if(*slot >= '1' && *slot <= '7') {
+ config.slot = *slot - '0';
+ } else {
+ config.slot = 0;
+ }
+
+ nullterminate(prefix);
+ strcpy(config.prefix, prefix);
+
+#ifdef WITH_UIP
+
+ nullterminate(ipaddr);
+ if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) {
+ config.ipaddr[0] = addr[0];
+ config.ipaddr[1] = addr[1];
+ }
+
+#ifdef WITH_ETHERNET
+
+ nullterminate(netmask);
+ if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) {
+ config.netmask[0] = addr[0];
+ config.netmask[1] = addr[1];
+ }
+
+ nullterminate(gateway);
+ if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) {
+ config.gateway[0] = addr[0];
+ config.gateway[1] = addr[1];
+ }
+
+ tmp = 0;
+ for(cptr = maclsb; *cptr >= '0' && *cptr <= '9'; ++cptr) {
+ tmp = (tmp * 10) + (*cptr - '0');
+ }
+ if(tmp != 0) {
+ config.maclsb = tmp;
+ }
+
+#endif /* WITH_ETHERNET */
+
+ nullterminate(dnsserver);
+ if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) {
+ config.dnsserver[0] = addr[0];
+ config.dnsserver[1] = addr[1];
+ }
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+config_apply(void)
+{
+#ifdef __APPLE2ENH__
+
+ ctk_draw_setbackground(config.bkgnd);
+
+#endif /* __APPLE2ENH__ */
+
+ program_handler_setscreensaver(config.screensaver);
+
+ CTK_SCREENSAVER_SET_TIMEOUT(config.timeout * 60);
+
+ if(driverid != EK_ID_NONE) {
+ ek_post(driverid, EK_EVENT_REQUEST_EXIT, NULL);
+ }
+
+ config_setlanslot(config.slot);
+
+ if(*config.driver) {
+ program_handler_load(config.driver, NULL);
+ }
+
+ if(*config.prefix == '/') {
+ config_setprefixok(chdir(config.prefix) == 0);
+ }
+
+#ifdef WITH_UIP
+
+ uip_sethostaddr(config.ipaddr);
+
+#ifdef WITH_ETHERNET
+
+ uip_setnetmask(config.netmask);
+ uip_setdraddr(config.gateway);
+ uip_ethaddr.addr[5] = config.maclsb;
+
+#endif /* WITH_ETHERNET */
+
+ resolv_conf(config.dnsserver);
+
+#endif /* WITH_UIP */
+}
+/*-----------------------------------------------------------------------------------*/
+static int
+config_save(void)
+{
+ int fd, written = 0;
+
+ fd = cfs_open(strcat(kfs_getdir(), "contiki.cfg"), CFS_WRITE);
+ if(fd != -1) {
+ written = cfs_write(fd, &config, sizeof(config));
+ cfs_close(fd);
+ }
+ return written == sizeof(config);
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(config_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_window_new(&window, 30, 19, "Config editor");
+#ifdef __APPLE2ENH__
+ CTK_WIDGET_ADD(&window, &backgroundlabel);
+ CTK_WIDGET_ADD(&window, &backgroundtextentry);
+ CTK_WIDGET_ADD(&window, &backgrounddescr);
+#endif /* __APPLE2ENH__ */
+ CTK_WIDGET_ADD(&window, &screensaverlabel);
+ CTK_WIDGET_ADD(&window, &screensavertextentry);
+ CTK_WIDGET_ADD(&window, &timeoutlabel);
+ CTK_WIDGET_ADD(&window, &timeouttextentry);
+ CTK_WIDGET_ADD(&window, &timeoutdescr);
+ CTK_WIDGET_ADD(&window, &driverlabel);
+ CTK_WIDGET_ADD(&window, &drivertextentry);
+ CTK_WIDGET_ADD(&window, &slotlabel);
+ CTK_WIDGET_ADD(&window, &slottextentry);
+ CTK_WIDGET_ADD(&window, &slotdescr);
+ CTK_WIDGET_ADD(&window, &prefixlabel);
+ CTK_WIDGET_ADD(&window, &prefixtextentry);
+ CTK_WIDGET_ADD(&window, &ipaddrlabel);
+ CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+#ifdef WITH_ETHERNET
+ CTK_WIDGET_ADD(&window, &netmasklabel);
+ CTK_WIDGET_ADD(&window, &netmasktextentry);
+ CTK_WIDGET_ADD(&window, &gatewaylabel);
+ CTK_WIDGET_ADD(&window, &gatewaytextentry);
+#endif /* WITH_ETHERNET */
+ CTK_WIDGET_ADD(&window, &dnsserverlabel);
+ CTK_WIDGET_ADD(&window, &dnsservertextentry);
+#ifdef WITH_ETHERNET
+ CTK_WIDGET_ADD(&window, &maclsblabel);
+ CTK_WIDGET_ADD(&window, &maclsbtextentry);
+ CTK_WIDGET_ADD(&window, &maclsbdescr);
+#endif /* WITH_ETHERNET */
+ CTK_WIDGET_ADD(&window, &okbutton);
+ CTK_WIDGET_ADD(&window, &cancelbutton);
+#ifdef __APPLE2ENH__
+ CTK_WIDGET_FOCUS(&window, &backgroundtextentry);
+#else /* __APPLE2ENH__ */
+ CTK_WIDGET_FOCUS(&window, &screensavertextentry);
+#endif /* __APPLE2ENH__ */
+
+ ctk_dialog_new(&errordialog, 19, 5);
+ CTK_WIDGET_ADD(&errordialog, &errormsg);
+ CTK_WIDGET_ADD(&errordialog, &errorokbutton);
+ CTK_WIDGET_FOCUS(&errordialog, &errorokbutton);
+
+ /* Fill the configuration strings with values from the current
+ configuration */
+ makestrings();
+ ctk_window_open(&window);
+ } else if(ev == ctk_signal_button_activate) {
+ if(data == (ek_data_t)&okbutton) {
+
+ /* Fill the configuration with values from the current
+ configuration strings */
+ makeconfig();
+ config_apply();
+ if(config_save()) {
+ goto quit;
+ }
+ ctk_dialog_open(&errordialog);
+ } else if(data == (ek_data_t)&errorokbutton) {
+ ctk_dialog_close();
+ goto quit;
+ } else if(data == (ek_data_t)&cancelbutton) {
+ goto quit;
+ }
+
+ } else if(ev == ctk_signal_window_close ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ goto quit;
+ }
+ return;
+
+quit:
+ ctk_window_close(&window);
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/plasma-dsc.c b/contiki-apple2/apps/plasma-dsc.c
new file mode 100644
index 0000000..bd8940b
--- /dev/null
+++ b/contiki-apple2/apps/plasma-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+ "Screensaver with a plasma",
+ "plasma.sav",
+ plasma_init,
+ &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+ '.', ' ', '.',
+ ' ', 'O', ' ',
+ '.', ' ', '.'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon plasma_icon =
+ {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/plasma.c b/contiki-apple2/apps/plasma.c
new file mode 100644
index 0000000..1936363
--- /dev/null
+++ b/contiki-apple2/apps/plasma.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+ 128, 131, 134, 137, 140, 143, 146, 149,
+ 152, 156, 159, 162, 165, 168, 171, 174,
+ 176, 179, 182, 185, 188, 191, 193, 196,
+ 199, 201, 204, 206, 209, 211, 213, 216,
+ 218, 220, 222, 224, 226, 228, 230, 232,
+ 234, 236, 237, 239, 240, 242, 243, 245,
+ 246, 247, 248, 249, 250, 251, 252, 252,
+ 253, 254, 254, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 254, 254,
+ 253, 252, 252, 251, 250, 249, 248, 247,
+ 246, 245, 243, 242, 240, 239, 237, 236,
+ 234, 232, 230, 228, 226, 224, 222, 220,
+ 218, 216, 213, 211, 209, 206, 204, 201,
+ 199, 196, 193, 191, 188, 185, 182, 179,
+ 176, 174, 171, 168, 165, 162, 159, 156,
+ 152, 149, 146, 143, 140, 137, 134, 131,
+ 128, 124, 121, 118, 115, 112, 109, 106,
+ 103, 99, 96, 93, 90, 87, 84, 81,
+ 79, 76, 73, 70, 67, 64, 62, 59,
+ 56, 54, 51, 49, 46, 44, 42, 39,
+ 37, 35, 33, 31, 29, 27, 25, 23,
+ 21, 19, 18, 16, 15, 13, 12, 10,
+ 9, 8, 7, 6, 5, 4, 3, 3,
+ 2, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 1, 1,
+ 2, 3, 3, 4, 5, 6, 7, 8,
+ 9, 10, 12, 13, 15, 16, 18, 19,
+ 21, 23, 25, 27, 29, 31, 33, 35,
+ 37, 39, 42, 44, 46, 49, 51, 54,
+ 56, 59, 62, 64, 67, 70, 73, 76,
+ 78, 81, 84, 87, 90, 93, 96, 99,
+ 103, 106, 109, 112, 115, 118, 121, 124,
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+ {
+ 0x00, 0x22, 0x55, 0x33,
+ 0xBB, 0xAA, 0xDD, 0xFF,
+ 0xDD, 0xAA, 0xBB, 0x99,
+ 0x11, 0x88, 0x00, 0x00
+ };
+
+#define XSIZE 25
+#define YSIZE 24
+
+#define XADD01 0xfe
+#define YADD01 0x05
+
+#define XADD1 0x04
+#define YADD1 0x02
+#define XADD2 0xfc
+#define YADD2 0xf9
+
+#define XADD 0x03
+#define YADD 0xfe
+
+#define MOVADD 0xfb
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char movcnt;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Plasma screensaver", idle,
+ sighandler,
+ NULL)};
+ static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+ eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+ *(char *)0xC051 = 0;
+
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+ static int i;
+
+ /* Make sine tables */
+ for(i = 0; i < 256; ++i) {
+ sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+ sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;
+ }
+
+ /* Make color table */
+ for(i = 0; i < 256; ++i) {
+ colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+ }
+
+ *(char *)0xC056 = 0;
+ *(char *)0xC054 = 0;
+ *(char *)0xC052 = 0;
+ *(char *)0xC050 = 0;
+
+ for(ycnt = 0; ycnt < 24; ++ycnt) {
+ gotoy(ycnt);
+ for(xcnt = 0; xcnt < 40; ++xcnt) {
+ (*(unsigned char **)0x28)[xcnt] = 0x00;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+ static unsigned char i, x, y, xofs;
+
+ if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+ xcnt1 = xcnt01;
+ xcnt2 = xcnt02;
+
+ for(i = 0; i < XSIZE; ++i) {
+ xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+ xcnt1 += XADD1;
+ xcnt2 += XADD2;
+ }
+
+ ycnt1 = ycnt01;
+ ycnt2 = ycnt02;
+
+ for(i = 0; i < YSIZE; ++i) {
+ yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+ ycnt1 += YADD1;
+ ycnt2 += YADD2;
+ }
+
+ xcnt01 += XADD01;
+ xcnt02 += xadd02;
+ ycnt01 += YADD01;
+ ycnt02 += yadd02;
+
+
+ yadd02 = sinetab3[ycnt] / 4;
+ xadd02 = sinetab3[xcnt] / 4;
+
+ ycnt += YADD;
+ xcnt += XADD;
+
+ movcnt += MOVADD;
+ xofs = sinetab1[movcnt]/16;
+
+ for(y = 0; y < YSIZE; ++y) {
+ gotoy(y);
+ for(x = 0; x < XSIZE; ++x) {
+ (*(unsigned char **)0x28)[x + xofs] = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+ }
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+ DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_mode_set(CTK_MODE_SCREENSAVER);
+ ctk_mouse_hide();
+
+ scrninit();
+
+ } else if(ev == ctk_signal_screensaver_stop ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+ /* ctk_mode_set(CTK_MODE_NORMAL);*/
+ quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-apple2/apps/ssfire-dsc.c b/contiki-apple2/apps/ssfire-dsc.c
new file mode 100644
index 0000000..0fe625d
--- /dev/null
+++ b/contiki-apple2/apps/ssfire-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+ "Screensaver with two fires",
+ "ssfire.sav",
+ ssfire_init,
+ &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+ '.', ' ', '.',
+ 'o', ' ', 'o',
+ 'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon ssfire_icon =
+ {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/ssfire.c b/contiki-apple2/apps/ssfire.c
new file mode 100644
index 0000000..574a652
--- /dev/null
+++ b/contiki-apple2/apps/ssfire.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.1 2005/05/12 21:12:43 oliverschmidt Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+ {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+ ssfire_sighandler,
+ NULL)};
+ static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+ ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+static const unsigned char flamecolors[16] =
+ {0x00, 0x00, 0x00, 0x11, 0x99, 0xDD, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+
+static unsigned char *flameptr;
+static unsigned char x, y;
+
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+ *(char *)0xC051 = 0;
+
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+ *(char *)0xC056 = 0;
+ *(char *)0xC054 = 0;
+ *(char *)0xC052 = 0;
+ *(char *)0xC050 = 0;
+
+ for(y = 0; y < 24; ++y) {
+ gotoy(y);
+ for(x = 0; x < 40; ++x) {
+ (*(unsigned char **)0x28)[x] = 0x00;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ ctk_mode_set(CTK_MODE_SCREENSAVER);
+ ctk_mouse_hide();
+ fire_init();
+ } else if(ev == ctk_signal_screensaver_stop ||
+ ev == EK_EVENT_REQUEST_EXIT) {
+ fire_quit();
+ ctk_draw_init();
+ ctk_desktop_redraw(NULL);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+fire_burn(void)
+{
+ /* Calculate new flames. */
+ asm("ldy #$00");
+loop1:
+ asm("lda %v+7,y", flames);
+ asm("clc");
+ asm("adc %v+8,y", flames);
+ asm("adc %v+9,y", flames);
+ asm("adc %v+16,y", flames);
+ asm("lsr");
+ asm("lsr");
+ asm("sta %v,y", flames);
+ asm("iny");
+ asm("cpy #(8*15)");
+ asm("bne %g", loop1);
+
+ /* Fill last line with pseudo-random data. */
+ asm("ldy #$05");
+loop2:
+ asm("jsr %v", rand);
+ asm("and #$0F");
+ asm("sta %v+8*15+1,y", flames);
+ asm("dey");
+ asm("bpl %g", loop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+ if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+ fire_burn();
+
+ /* Display flames on screen. */
+ flameptr = flames;
+ for(y = 9; y < 24; ++y) {
+ gotoy(y);
+ for(x = 0; x < 8; ++x) {
+ (*(unsigned char **)0x28)[x ] =
+ (*(unsigned char **)0x28)[x+32] = flamecolors[flameptr[x]];
+ }
+ flameptr += 8;
+ }
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-apple2/apps/welcome.c b/contiki-apple2/apps/welcome.c
new file mode 100644
index 0000000..10acca3
--- /dev/null
+++ b/contiki-apple2/apps/welcome.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.3 2006/05/30 21:02:32 oliverschmidt Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+static struct ctk_label welcomelabel1 =
+ {CTK_LABEL(2, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING " !")};
+static struct ctk_label welcomelabel2 =
+ {CTK_LABEL(2, 4, 30, 1, "Esc - open menus")};
+static struct ctk_label welcomelabel3 =
+ {CTK_LABEL(2, 6, 30, 1, "Ctrl-W - cycle windows")};
+static struct ctk_label welcomelabel4 =
+ {CTK_LABEL(2, 8, 30, 1, "Ctrl-A - select up")};
+static struct ctk_label welcomelabel5 =
+ {CTK_LABEL(2, 10, 30, 1, "Tab - select down")};
+static struct ctk_label welcomelabel6 =
+ {CTK_LABEL(2, 12, 30, 1, "Return - activate selected")};
+#ifdef __APPLE2__
+static struct ctk_label welcomelabel7 =
+ {CTK_LABEL(2, 14, 30, 1, "Ctrl-D - delete character")};
+static struct ctk_label welcomelabel8 =
+ {CTK_LABEL(2, 16, 30, 1, "Ctrl-Reset - quit Contiki")};
+static struct ctk_label welcomeclose =
+ {CTK_BUTTON(13, 19, 5, "Close")};
+#else /* __APPLE2__ */
+static struct ctk_label welcomelabel7 =
+ {CTK_LABEL(2, 14, 30, 1, "Ctrl-Reset - quit Contiki")};
+static struct ctk_label welcomeclose =
+ {CTK_BUTTON(13, 17, 5, "Close")};
+#endif /* __APPLE2__ */
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+ ctk_dialog_close();
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+#ifdef __APPLE2__
+ ctk_dialog_new(&welcomedialog, 34, 21);
+#else /* __APPLE2__ */
+ ctk_dialog_new(&welcomedialog, 34, 19);
+#endif /* __APPLE2__ */
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);
+#ifdef __APPLE2__
+ CTK_WIDGET_ADD(&welcomedialog, &welcomelabel8);
+#endif /* __APPLE2__ */
+ CTK_WIDGET_ADD(&welcomedialog, &welcomeclose);
+ CTK_WIDGET_FOCUS(&welcomedialog, &welcomeclose);
+
+ ctk_dialog_open(&welcomedialog);
+
+ } else if(ev == EK_EVENT_REQUEST_EXIT ||
+ ev == ctk_signal_button_activate) {
+ welcome_quit();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/wget-dsc.c b/contiki-apple2/apps/wget-dsc.c
new file mode 100644
index 0000000..59f58cb
--- /dev/null
+++ b/contiki-apple2/apps/wget-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.2 2005/04/19 22:01:22 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon wget_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+ "Downloads files or disks from the web",
+ "wget.prg",
+ wget_init,
+ &wget_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char wgeticon_bitmap[3*3*8] = {
+ 0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+ 0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+ 0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+ 0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+ 0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+ 0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+ 0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+ 0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+ 0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char wgeticon_textmap[9] = {
+ 'w', 'e', 'b',
+ 'p', 'r', 'g',
+ 'd', 's', 'k'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon wget_icon =
+ {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/apps/wget-dsc.h b/contiki-apple2/apps/wget-dsc.h
new file mode 100644
index 0000000..1d217b8
--- /dev/null
+++ b/contiki-apple2/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2005/03/29 23:12:31 oliverschmidt Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-apple2/apps/wget.c b/contiki-apple2/apps/wget.c
new file mode 100644
index 0000000..ec74e8a
--- /dev/null
+++ b/contiki-apple2/apps/wget.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.3 2005/04/24 13:37:06 oliverschmidt Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "uiplib.h"
+#include "loader.h"
+#include "cfs.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <dio.h>
+
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+ {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+ {CTK_TEXTENTRY(5, 1, 30, 1, urledit, 78)};
+
+static struct ctk_label savefilenamelabel =
+ {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+ {CTK_TEXTENTRY(15, 3, 20, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+ {CTK_BUTTON(0, 5, 16, "Download to file")};
+
+static struct ctk_button dskbutton =
+ {CTK_BUTTON(19, 5, 16, "Download to disk")};
+
+static struct ctk_label statustext =
+ {CTK_LABEL(0, 7, 37, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window dskdialog;
+static struct ctk_label overwritelabel =
+ {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+ {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+ {CTK_LABEL(4, 4, 28, 1, "right disk in slot 6 drive 1")};
+static struct ctk_button overwritebutton =
+ {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+ {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+ wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_DSK 2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+static int savefile;
+static void* savedsk;
+
+static char buffer[16][256];
+static u16_t bufferptr;
+static u8_t relsector;
+static u16_t absblock;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+ if(arg != NULL) {
+ strncpy(url, arg, sizeof(url));
+ strncpy(urledit, arg, sizeof(urledit));
+ } else {
+#ifdef WGET_CONF_URL
+ strncpy(url, WGET_CONF_URL, sizeof(url));
+ strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL */
+ }
+ arg_free(arg);
+
+ if(id == EK_ID_NONE) {
+ id = ek_start(&p);
+
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+ ctk_label_set_text(&statustext, text);
+ CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+dload_close(char *text)
+{
+ show_statustext(text);
+ if(dload_state == DLOAD_FILE) {
+ cfs_close(savefile);
+ } else if(dload_state == DLOAD_DSK) {
+ dio_close(savedsk);
+ }
+ dload_state = DLOAD_NONE;
+ webclient_close();
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+ u16_t addr[2];
+ unsigned char i;
+ static char host[32];
+ char *file;
+ register char *urlptr;
+
+ /* Trim off any spaces in the end of the url. */
+ urlptr = url + strlen(url) - 1;
+ while(*urlptr == ' ' && urlptr > url) {
+ *urlptr = 0;
+ --urlptr;
+ }
+
+ /* Don't even try to go further if the URL is empty. */
+ if(urlptr == url) {
+ return;
+ }
+
+ /* See if the URL starts with http://, otherwise prepend it. */
+ if(strncmp(url, http_http, 7) != 0) {
+ while(urlptr >= url) {
+ *(urlptr + 7) = *urlptr;
+ --urlptr;
+ }
+ strncpy(url, http_http, 7);
+ }
+
+ /* Find host part of the URL. */
+ urlptr = &url[7];
+ for(i = 0; i < sizeof(host); ++i) {
+ if(*urlptr == 0 ||
+ *urlptr == '/' ||
+ *urlptr == ' ' ||
+ *urlptr == ':') {
+ host[i] = 0;
+ break;
+ }
+ host[i] = *urlptr;
+ ++urlptr;
+ }
+
+ /* XXX: Here we should find the port part of the URL, but this isn't
+ currently done because of laziness from the programmer's side
+ :-) */
+
+ /* Find file part of the URL. */
+ while(*urlptr != '/' && *urlptr != 0) {
+ ++urlptr;
+ }
+ if(*urlptr == '/') {
+ file = urlptr;
+ } else {
+ file = "/";
+ }
+
+ /* First check if the host is an IP address. */
+ if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
+
+ /* Try to lookup the hostname. If it fails, we initiate a hostname
+ lookup and print out an informative message on the
+ statusbar. */
+ if(resolv_lookup(host) == NULL) {
+ resolv_query(host);
+ show_statustext("Resolving host...");
+ return;
+ }
+ }
+
+ /* The hostname we present in the hostname table, so we send out the
+ initial GET request. */
+ if(webclient_get(host, 80, file) == 0) {
+ show_statustext("Out of memory error.");
+ } else {
+ show_statustext("Connecting...");
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+ EK_EVENTHANDLER_ARGS(ev, data);
+
+ if(ev == EK_EVENT_INIT) {
+ /* Create the main window. */
+ ctk_window_new(&window, 37, 8, "Web downloader");
+
+ CTK_WIDGET_ADD(&window, &urllabel);
+ CTK_WIDGET_ADD(&window, &urltextentry);
+ CTK_WIDGET_ADD(&window, &savefilenamelabel);
+ CTK_WIDGET_ADD(&window, &savefilenametextentry);
+ CTK_WIDGET_ADD(&window, &filebutton);
+ CTK_WIDGET_ADD(&window, &dskbutton);
+ CTK_WIDGET_ADD(&window, &statustext);
+
+ CTK_WIDGET_FOCUS(&window, &urltextentry);
+
+ dload_state = DLOAD_NONE;
+
+ memset(savefilename, 0, sizeof(savefilename));
+ memset(url, 0, sizeof(url));
+
+ ctk_dialog_new(&dskdialog, 36, 8);
+ CTK_WIDGET_ADD(&dskdialog, &overwritelabel);
+ CTK_WIDGET_ADD(&dskdialog, &makesurelabel1);
+ CTK_WIDGET_ADD(&dskdialog, &makesurelabel2);
+ CTK_WIDGET_ADD(&dskdialog, &overwritebutton);
+ CTK_WIDGET_ADD(&dskdialog, &cancelbutton);
+
+ CTK_WIDGET_FOCUS(&dskdialog, &cancelbutton);
+
+ ctk_window_open(&window);
+ } else if(ev == tcpip_event) {
+ webclient_appcall(data);
+ } else if(ev == ctk_signal_button_activate) {
+ if(data == (void *)&filebutton) {
+ dload_close("");
+ savefile = cfs_open(savefilename, CFS_WRITE);
+ if(savefile == -1) {
+ sprintf(statusmsg, "Open error with '%s'", savefilename);
+ show_statustext(statusmsg);
+ } else {
+ strncpy(url, urledit, sizeof(url));
+ start_get();
+ dload_bytes = 0;
+ dload_state = DLOAD_FILE;
+ }
+ } else if(data == (void *)&dskbutton) {
+ ctk_dialog_open(&dskdialog);
+ } else if(data == (void *)&cancelbutton) {
+ ctk_dialog_close();
+ } else if(data == (void *)&overwritebutton) {
+ ctk_dialog_close();
+ dload_close("");
+ savedsk = dio_open(/*slot*/6 * 2 + /*drive*/1 - 1);
+ if(savedsk == NULL) {
+ sprintf(statusmsg, "Access error with slot 6 drive 1");
+ show_statustext(statusmsg);
+ } else {
+ strncpy(url, urledit, sizeof(url));
+ start_get();
+ dload_bytes = 0;
+ dload_state = DLOAD_DSK;
+ bufferptr = 0;
+ relsector = 0;
+ absblock = 0;
+ }
+ }
+ } else if(ev == ctk_signal_hyperlink_activate) {
+ if(dload_state == DLOAD_NONE) {
+ /* open_link(w->widget.hyperlink.url);*/
+ strncpy(urledit,
+ ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+ CTK_WIDGET_REDRAW(&urltextentry);
+ CTK_WIDGET_FOCUS(&window, &urltextentry);
+ }
+ } else if(ev == resolv_event_found) {
+ /* Either found a hostname, or not. */
+ if((char *)data != NULL &&
+ resolv_lookup((char *)data) != NULL) {
+ start_get();
+ } else {
+ show_statustext("Host not found.");
+ }
+ } else if(ev == ctk_signal_window_close) {
+ dload_close("");
+ ek_exit();
+ id = EK_ID_NONE;
+ LOADER_UNLOAD();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+ show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+ dload_close("Connection timed out");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{
+ if(dload_state == DLOAD_NONE) {
+ return;
+ }
+ show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{
+ show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+write_buffer(void)
+{
+ u8_t sector;
+
+ for(sector = 0; sector < 16; sector += 2) {
+ if(dio_write(savedsk, absblock++, buffer[sector]) != 0) {
+ return 0;
+ }
+ }
+ return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char
+handle_dsk_data(char *data, u16_t len)
+{
+ static u8_t skew[16] = {0x0, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8,
+ 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0xF};
+ u16_t bufferlen;
+
+ while(len > 0) {
+ bufferlen = sizeof(buffer[0]) - bufferptr;
+ if(len < bufferlen) {
+ bufferlen = len;
+ }
+
+ memcpy(&buffer[skew[relsector]][bufferptr], data, bufferlen);
+
+ data += bufferlen;
+ bufferptr += bufferlen;
+ len -= bufferlen;
+
+ if(bufferptr == sizeof(buffer[0])) {
+ bufferptr = 0;
+ if(++relsector == 16) {
+ relsector = 0;
+ if(write_buffer() == 0) {
+ return 0;
+ }
+ }
+ }
+ }
+ return 1;
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+ int ret;
+
+ if(len > 0) {
+ dload_bytes += len;
+ sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+ show_statustext(statusmsg);
+ if(dload_state == DLOAD_DSK) {
+ if(handle_dsk_data(data, len) == 0) {
+ dload_close("Write error with slot 6 drive 1");
+ }
+ } else if(dload_state == DLOAD_FILE) {
+ ret = cfs_write(savefile, data, len);
+ if(ret != len) {
+ sprintf(statusmsg, "Wrote only %d bytes", ret);
+ dload_close(statusmsg);
+ }
+ }
+ }
+
+ if(data == NULL) {
+ sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+ dload_close(statusmsg);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/conf/cc-conf.h b/contiki-apple2/conf/cc-conf.h
new file mode 100644
index 0000000..a358a3f
--- /dev/null
+++ b/contiki-apple2/conf/cc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: cc-conf.h,v 1.1 2003/04/10 07:25:27 adamdunkels Exp $
+ *
+ */
+#ifndef __CC_CONF_H__
+#define __CC_CONF_H__
+
+#define CC_CONF_REGISTER_ARGS 1
+#define CC_CONF_FUNCTION_POINTER_ARGS 1
+
+#define CC_CONF_FASTCALL fastcall
+
+#endif /* __CC_CONF_H__ */
+
diff --git a/contiki-apple2/conf/clock-conf.h b/contiki-apple2/conf/clock-conf.h
new file mode 100644
index 0000000..8417343
--- /dev/null
+++ b/contiki-apple2/conf/clock-conf.h
@@ -0,0 +1,8 @@
+#ifndef __CLOCK_CONF_H__
+#define __CLOCK_CONF_H__
+
+typedef unsigned short clock_time_t;
+
+#define CLOCK_CONF_SECOND 2
+
+#endif /* __CLOCK_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-conf.h b/contiki-apple2/conf/ctk-conf.h
new file mode 100644
index 0000000..8c304f0
--- /dev/null
+++ b/contiki-apple2/conf/ctk-conf.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conf.h,v 1.13 2006/05/07 23:08:42 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONF_H__
+#define __CTK_CONF_H__
+
+/*
+ * This file is used for setting various compile time settings for the
+ * CTK GUI toolkit.
+*/
+
+/* Defines which key that is to be used for activating the menus */
+#define CTK_CONF_MENU_KEY CH_ESC
+
+/* Defines which key that is to be used for switching the frontmost
+ window. */
+#define CTK_CONF_WINDOWSWITCH_KEY 0x17 /* Ctrl-W */
+
+/* Defines which key that is to be used for switching to the prevoius
+ widget. */
+#define CTK_CONF_WIDGETUP_KEY 0x01 /* Ctrl-A */
+
+/* Defines which key that is to be used for switching to the next
+ widget. */
+#define CTK_CONF_WIDGETDOWN_KEY '\t' /* Tab or Ctrl-I */
+
+/* Toggles mouse support (must have support functions in the
+architecture specific files to work). */
+#ifdef __APPLE2__
+#define CTK_CONF_MOUSE_SUPPORT 0 /* 1342 bytes */
+#else /* __APPLE2__ */
+#define CTK_CONF_MOUSE_SUPPORT 1 /* 1342 bytes */
+#endif /* __APPLE2__ */
+
+/* Toggles support for icons. */
+#define CTK_CONF_ICONS 1 /* 107 bytes */
+
+/* Toggles support for icon bitmaps. */
+#define CTK_CONF_ICON_BITMAPS 0
+
+/* Toggles support for icon textmaps. */
+#define CTK_CONF_ICON_TEXTMAPS 1
+
+/* Toggles support for movable windows. */
+#ifdef __APPLE2__
+#define CTK_CONF_WINDOWMOVE 0 /* 333 bytes */
+#else /* __APPLE2__ */
+#define CTK_CONF_WINDOWMOVE 1 /* 333 bytes */
+#endif /* __APPLE2__ */
+
+/* Toggles support for closable windows. */
+#define CTK_CONF_WINDOWCLOSE 1 /* 14 bytes */
+
+/* Toggles support for menus. */
+#define CTK_CONF_MENUS 1 /* 1384 bytes */
+
+/* Defines the default width of a menu. */
+#define CTK_CONF_MENUWIDTH 16
+/* The maximum number of menu items in each menu. */
+#ifdef __APPLE2__
+#define CTK_CONF_MAXMENUITEMS 5
+#else /* __APPLE2__ */
+#define CTK_CONF_MAXMENUITEMS 6
+#endif /* __APPLE2__ */
+
+/* Toggles support for screen savers. */
+#define CTK_CONF_SCREENSAVER 1
+
+#endif /* __CTK_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-conio-conf.h b/contiki-apple2/conf/ctk-conio-conf.h
new file mode 100644
index 0000000..3a646d5
--- /dev/null
+++ b/contiki-apple2/conf/ctk-conio-conf.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-conio-conf.h,v 1.1 2005/02/17 22:36:19 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_CONIO_CONF_H__
+#define __CTK_CONIO_CONF_H__
+
+#if 0
+/* Light gray inverted color scheme: */
+#define BORDERCOLOR COLOR_WHITE
+#define SCREENCOLOR COLOR_WHITE
+#define BACKGROUNDCOLOR COLOR_WHITE
+
+#define WINDOWCOLOR_FOCUS COLOR_BLACK
+#define WINDOWCOLOR COLOR_GRAY2
+
+#define DIALOGCOLOR COLOR_RED
+
+#define WIDGETCOLOR_HLINK COLOR_BLUE
+#define WIDGETCOLOR_FWIN COLOR_BLACK
+#define WIDGETCOLOR COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG COLOR_RED
+#define WIDGETCOLOR_FOCUS COLOR_BLACK
+
+#define MENUCOLOR COLOR_BLACK
+#define OPENMENUCOLOR COLOR_BLACK
+#define ACTIVEMENUITEMCOLOR COLOR_BLACK
+#endif /* 0 */
+
+#if 0
+/* Blue color scheme: */
+#define BORDERCOLOR COLOR_LIGHTBLUE
+#define SCREENCOLOR COLOR_BLUE
+#define BACKGROUNDCOLOR COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS COLOR_LIGHTBLUE
+#define WINDOWCOLOR COLOR_GRAY1
+
+#define DIALOGCOLOR COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK COLOR_CYAN
+#define WIDGETCOLOR_FWIN COLOR_LIGHTBLUE
+#define WIDGETCOLOR COLOR_GRAY1
+#define WIDGETCOLOR_DIALOG COLOR_WHITE
+#define WIDGETCOLOR_FOCUS COLOR_YELLOW
+
+#define MENUCOLOR COLOR_WHITE
+#define OPENMENUCOLOR COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 1
+/* Black and white monocrome color scheme: */
+#define BORDERCOLOR COLOR_BLACK
+#define SCREENCOLOR COLOR_BLACK
+#define BACKGROUNDCOLOR COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS COLOR_WHITE
+#define WINDOWCOLOR COLOR_WHITE
+
+#define DIALOGCOLOR COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK COLOR_WHITE
+#define WIDGETCOLOR_FWIN COLOR_WHITE
+#define WIDGETCOLOR COLOR_WHITE
+#define WIDGETCOLOR_DIALOG COLOR_WHITE
+#define WIDGETCOLOR_FOCUS COLOR_WHITE
+
+#define MENUCOLOR COLOR_WHITE
+#define OPENMENUCOLOR COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_WHITE
+#endif /* 0 */
+
+#if 0
+/* Blue monocrome color scheme: */
+#define BORDERCOLOR COLOR_BLUE
+#define SCREENCOLOR COLOR_BLUE
+#define BACKGROUNDCOLOR COLOR_BLUE
+
+#define WINDOWCOLOR_FOCUS COLOR_LIGHTBLUE
+#define WINDOWCOLOR COLOR_LIGHTBLUE
+
+#define DIALOGCOLOR COLOR_LIGHTBLUE
+
+#define WIDGETCOLOR_HLINK COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN COLOR_LIGHTBLUE
+#define WIDGETCOLOR COLOR_LIGHTBLUE
+#define WIDGETCOLOR_DIALOG COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FOCUS COLOR_LIGHTBLUE
+
+#define MENUCOLOR COLOR_LIGHTBLUE
+#define OPENMENUCOLOR COLOR_LIGHTBLUE
+#define ACTIVEMENUITEMCOLOR COLOR_LIGHTBLUE
+#endif /* 0 */
+
+#if 0
+/* Gray color scheme: */
+#define BORDERCOLOR COLOR_GRAY1
+#define SCREENCOLOR COLOR_GRAY1
+#define BACKGROUNDCOLOR COLOR_GRAY1
+
+#define WINDOWCOLOR_FOCUS COLOR_GRAY3
+#define WINDOWCOLOR COLOR_GRAY2
+
+#define DIALOGCOLOR COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN COLOR_GRAY3
+#define WIDGETCOLOR COLOR_GRAY2
+#define WIDGETCOLOR_DIALOG COLOR_WHITE
+#define WIDGETCOLOR_FOCUS COLOR_YELLOW
+
+#define MENUCOLOR COLOR_GRAY3
+#define OPENMENUCOLOR COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+#if 0
+/* Red color scheme: */
+#define BORDERCOLOR COLOR_BLACK
+#define SCREENCOLOR COLOR_BLACK
+#define BACKGROUNDCOLOR COLOR_BLACK
+
+#define WINDOWCOLOR_FOCUS COLOR_LIGHTRED
+#define WINDOWCOLOR COLOR_RED
+
+#define DIALOGCOLOR COLOR_WHITE
+
+#define WIDGETCOLOR_HLINK COLOR_LIGHTBLUE
+#define WIDGETCOLOR_FWIN COLOR_YELLOW
+#define WIDGETCOLOR COLOR_LIGHTRED
+#define WIDGETCOLOR_DIALOG COLOR_WHITE
+#define WIDGETCOLOR_FOCUS COLOR_YELLOW
+
+#define MENUCOLOR COLOR_LIGHTRED
+#define OPENMENUCOLOR COLOR_WHITE
+#define ACTIVEMENUITEMCOLOR COLOR_YELLOW
+#endif /* 0 */
+
+
+#endif /* __CTK_CONIO_CONF_H__ */
diff --git a/contiki-apple2/conf/ctk-mouse-conf.h b/contiki-apple2/conf/ctk-mouse-conf.h
new file mode 100644
index 0000000..f9a3285
--- /dev/null
+++ b/contiki-apple2/conf/ctk-mouse-conf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" GUI toolkit for cc65
+ *
+ * $Id: ctk-mouse-conf.h,v 1.1 2006/04/09 16:13:31 oliverschmidt Exp $
+ *
+ */
+
+#ifndef __CTK_MOUSE_CONF_H__
+#define __CTK_MOUSE_CONF_H__
+
+#define MOUSE_CONF_DRIVER "a2e.stdmou.mou"
+#define MOUSE_CONF_XTOC(x) ((x) * 2 / 7)
+#define MOUSE_CONF_YTOC(y) ((y) / 8)
+
+#endif /* __CTK_MOUSE_CONF_H__ */
diff --git a/contiki-apple2/conf/ek-conf.h b/contiki-apple2/conf/ek-conf.h
new file mode 100644
index 0000000..354d7d9
--- /dev/null
+++ b/contiki-apple2/conf/ek-conf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ek" event kernel.
+ *
+ * $Id: ek-conf.h,v 1.5 2005/04/16 14:10:31 oliverschmidt Exp $
+ *
+ */
+
+
+#ifndef __EK_CONF_H__
+#define __EK_CONF_H__
+
+#include <time.h>
+
+typedef void *ek_data_t;
+
+typedef unsigned char ek_event_t;
+typedef unsigned char ek_num_events_t;
+typedef unsigned char ek_id_t;
+
+#define EK_CONF_MAXPROCS 32
+#define EK_CONF_NUMEVENTS 16
+
+#endif /* __EK_CONF_H__ */
diff --git a/contiki-apple2/conf/email-conf.h b/contiki-apple2/conf/email-conf.h
new file mode 100644
index 0000000..e2d2d2c
--- /dev/null
+++ b/contiki-apple2/conf/email-conf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: email-conf.h,v 1.2 2005/05/04 23:49:37 oliverschmidt Exp $
+ */
+#ifndef __EMAIL_CONF_H__
+#define __EMAIL_CONF_H__
+
+#ifdef __APPLE2__
+#define EMAIL_CONF_WIDTH 37
+#else /* __APPLE2__ */
+#define EMAIL_CONF_WIDTH 48
+#endif /* __APPLE2__ */
+#define EMAIL_CONF_HEIGHT 16
+
+#endif /* __EMAIL_CONF_H__ */
diff --git a/contiki-apple2/conf/irc-conf.h b/contiki-apple2/conf/irc-conf.h
new file mode 100644
index 0000000..d050bbc
--- /dev/null
+++ b/contiki-apple2/conf/irc-conf.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: irc-conf.h,v 1.1 2004/12/26 14:13:34 oliverschmidt Exp $
+ */
+#ifndef __IRC_CONF_H__
+#define __IRC_CONF_H__
+
+#ifdef __APPLE2__
+#define IRC_CONF_WIDTH 38
+#else /* __APPLE2__ */
+#define IRC_CONF_WIDTH 78
+#endif /* __APPLE2__ */
+#define IRC_CONF_HEIGHT 20
+
+#define IRC_CONF_SYSTEM_STRING "apple2"
+
+#endif /* __IRC_CONF_H__ */
diff --git a/contiki-apple2/conf/log-conf.h b/contiki-apple2/conf/log-conf.h
new file mode 100644
index 0000000..9ff4810
--- /dev/null
+++ b/contiki-apple2/conf/log-conf.h
@@ -0,0 +1,6 @@
+#ifndef __LOG_CONF_H__
+#define __LOG_CONF_H__
+
+#define LOG_CONF_ENABLED 0
+
+#endif /* __LOG_CONF__H__ */
diff --git a/contiki-apple2/conf/program-handler-conf.h b/contiki-apple2/conf/program-handler-conf.h
new file mode 100644
index 0000000..e2bc71d
--- /dev/null
+++ b/contiki-apple2/conf/program-handler-conf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: program-handler-conf.h,v 1.6 2006/05/14 23:34:13 oliverschmidt Exp $
+ */
+#ifndef __PROGRAM_HANDLER_CONF_H__
+#define __PROGRAM_HANDLER_CONF_H__
+
+#ifdef __APPLE2__
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 5
+#define PROGRAM_HANDLER_CONF_QUIT_MENU 0
+#else /* __APPLE2__ */
+#define PROGRAM_HANDLER_CONF_MAX_NUMDSCS 6
+#define PROGRAM_HANDLER_CONF_QUIT_MENU 1
+#endif /* __APPLE2__ */
+
+#endif /* __PROGRAM_HANDLER_CONF_H__ */
diff --git a/contiki-apple2/conf/shell-gui-conf.h b/contiki-apple2/conf/shell-gui-conf.h
new file mode 100644
index 0000000..eaf02e6
--- /dev/null
+++ b/contiki-apple2/conf/shell-gui-conf.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: shell-gui-conf.h,v 1.1 2005/05/04 22:12:05 oliverschmidt Exp $
+ */
+#ifndef __SHELL_GUI_CONF_H__
+#define __SHELL_GUI_CONF_H__
+
+#define SHELL_GUI_CONF_XSIZE 38
+#define SHELL_GUI_CONF_YSIZE 12
+
+#endif /* __SHELL_GUI_CONF_H__ */
diff --git a/contiki-apple2/conf/uip-conf.h b/contiki-apple2/conf/uip-conf.h
new file mode 100644
index 0000000..b4e379b
--- /dev/null
+++ b/contiki-apple2/conf/uip-conf.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki Destop OS
+ *
+ * $Id: uip-conf.h,v 1.4 2006/05/17 15:55:29 oliverschmidt Exp $
+ *
+ */
+#ifndef __UIP_CONF_H__
+
+#define UIP_CONF_MAX_CONNECTIONS 10
+#define UIP_CONF_MAX_LISTENPORTS 10
+#define UIP_CONF_BUFFER_SIZE 1024 - 2
+#define UIP_CONF_RECEIVE_WINDOW UIP_TCP_MSS
+#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
+#define UIP_CONF_EXTERNAL_BUFFER
+
+#ifdef UIP_CODE
+
+#pragma codeseg("UIP");
+
+#include "ek-conf.h"
+
+#undef EK_PROCESS_INIT
+#define EK_PROCESS_INIT(name, arg) \
+ void _tcpip_init(void *arg)
+
+#undef EK_EVENTHANDLER
+#define EK_EVENTHANDLER(name, ev, data) \
+ void _tcpip_eventhandler(ek_event_t ev, ek_data_t data)
+
+#undef EK_POLLHANDLER
+#define EK_POLLHANDLER(name) \
+ void _tcpip_pollhandler(void)
+
+#undef EK_PROCESS
+#define EK_PROCESS(name, strname, prio, eventh, pollh, stateptr) \
+ void tcpip_eventhandler(ek_event_t ev, ek_data_t data); \
+ void tcpip_pollhandler(void); \
+ static struct ek_proc name = {NULL, EK_ID_NONE, strname, prio, tcpip_eventhandler, tcpip_pollhandler, stateptr}
+
+#define htons _htons
+#define uiplib_ipaddrconv _uiplib_ipaddrconv
+#define tcp_markconn _tcp_markconn
+#define tcp_listen _tcp_listen
+#define tcp_unlisten _tcp_unlisten
+#define tcp_connect _tcp_connect
+#define udp_new _udp_new
+#define tcpip_set_forwarding _tcpip_set_forwarding
+#define tcpip_input _tcpip_input
+#define tcpip_output _tcpip_output
+#define tcpip_poll_tcp _tcpip_poll_tcp
+#define tcpip_poll_udp _tcpip_poll_udp
+
+#define ek_post_synch _ek_post_synch
+void _ek_post_synch(ek_id_t id, ek_event_t ev, ek_data_t data);
+
+#endif /* UIP_CODE */
+
+#endif /* __UIP_CONF_H__ */
diff --git a/contiki-apple2/conf/www-conf.h b/contiki-apple2/conf/www-conf.h
new file mode 100644
index 0000000..1c3a761
--- /dev/null
+++ b/contiki-apple2/conf/www-conf.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: www-conf.h,v 1.8 2005/05/23 22:39:56 oliverschmidt Exp $
+ *
+ */
+#ifndef __WWW_CONF_H__
+#define __WWW_CONF_H__
+
+#define WWW_CONF_HOMEPAGE "http://www.sics.se/~adam/contiki/"
+
+/* The size of the HTML viewing area. */
+#ifdef __APPLE2__
+#define WWW_CONF_WEBPAGE_WIDTH 38
+#else /* __APPLE2__ */
+#define WWW_CONF_WEBPAGE_WIDTH 78
+#endif /* __APPLE2__ */
+#define WWW_CONF_WEBPAGE_HEIGHT 16
+
+/* The size of the "Back" history. */
+#define WWW_CONF_HISTORY_SIZE 4
+
+/* Defines the maximum length of an URL */
+#define WWW_CONF_MAX_URLLEN 78
+
+/* The maxiumum number of widgets (i.e., hyperlinks, form elements) on
+ a page. */
+#define WWW_CONF_MAX_NUMPAGEWIDGETS 26
+
+/* Turns <center> support on or off; must be on for forms to work. */
+#define WWW_CONF_RENDERSTATE 1
+
+/* Toggles support for HTML forms. */
+#define WWW_CONF_FORMS 1
+
+/* Maximum lengths for various HTML form parameters. */
+#define WWW_CONF_MAX_FORMACTIONLEN 30
+#define WWW_CONF_MAX_FORMNAMELEN 20
+#define WWW_CONF_MAX_INPUTNAMELEN 20
+
+#define WWW_CONF_MAX_INPUTVALUELEN (WWW_CONF_WEBPAGE_WIDTH - 1)
+
+#endif /* __WWW_CONF_H__ */
diff --git a/contiki-apple2/contiki.icon b/contiki-apple2/contiki.icon
new file mode 100644
index 0000000..56a5c8e
--- /dev/null
+++ b/contiki-apple2/contiki.icon
Binary files differ
diff --git a/contiki-apple2/ctk/ctk-arch.h b/contiki-apple2/ctk/ctk-arch.h
new file mode 100644
index 0000000..02d08e7
--- /dev/null
+++ b/contiki-apple2/ctk/ctk-arch.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-arch.h,v 1.9 2005/04/17 22:40:11 oliverschmidt Exp $
+ *
+ */
+#ifndef __CTK_ARCH_H__
+#define __CTK_ARCH_H__
+
+#include "ctk-conio.h"
+
+#ifndef CH_CURS_UP
+#define CH_CURS_UP 0x0B /* Ctrl-K */
+#endif /* CH_CURS_UP */
+
+#ifndef CH_CURS_DOWN
+#define CH_CURS_DOWN 0x0A /* Ctrl-J */
+#endif /* CH_CURS_DOWN */
+
+#ifndef CH_DEL
+#define CH_DEL 0x04 /* Ctrl-D */
+#endif /* CH_DEL */
+
+#ifdef __APPLE2ENH__
+
+extern unsigned char ctk_draw_background;
+
+#define ctk_draw_getbackground() ctk_draw_background
+#define ctk_draw_setbackground(bkgnd) ctk_draw_background = (bkgnd)
+
+#endif /* __APPLE2ENH__ */
+
+#endif /* __CTK_ARCH_H__ */
diff --git a/contiki-apple2/ctk/ctk-mousetext.c b/contiki-apple2/ctk/ctk-mousetext.c
new file mode 100644
index 0000000..0a3a925
--- /dev/null
+++ b/contiki-apple2/ctk/ctk-mousetext.c
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the "ctk" console GUI toolkit for cc65
+ *
+ * $Id: ctk-mousetext.c,v 1.22 2006/05/29 20:57:32 oliverschmidt Exp $
+ *
+ */
+
+#include <conio.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "uip.h"
+#include "config.h"
+
+#include "ctk-conio-conf.h"
+#include <string.h>
+#include <ctype.h>
+
+#ifndef NULL
+#define NULL (void *)0
+#endif /* NULL */
+
+unsigned char ctk_draw_windowborder_height = 1;
+unsigned char ctk_draw_windowborder_width = 1;
+unsigned char ctk_draw_windowtitle_height = 1;
+
+unsigned char ctk_draw_background;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+cputsn(char *str, unsigned char len)
+{
+ char c;
+
+ while(len > 0) {
+ --len;
+ c = *str;
+ if(c == 0) {
+ break;
+ }
+ cputc(c);
+ ++str;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_init(void)
+{
+ ctk_draw_clear(0, 24);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_widget(struct ctk_widget *w,
+ unsigned char x, unsigned char y,
+ unsigned char clipx,
+ unsigned char clipy,
+ unsigned char focus)
+{
+ unsigned char xpos, ypos, xscroll;
+ unsigned char i, j;
+ char c, *text;
+ unsigned char len, wfocus;
+
+ wfocus = 0;
+ if(focus & CTK_FOCUS_WINDOW) {
+ if(focus & CTK_FOCUS_WIDGET) {
+ wfocus = 1;
+ }
+ } else if(focus & CTK_FOCUS_DIALOG) {
+ if(focus & CTK_FOCUS_WIDGET) {
+ wfocus = 1;
+ }
+ }
+
+ xpos = x + w->x;
+ ypos = y + w->y;
+
+ switch(w->type) {
+ case CTK_WIDGET_SEPARATOR:
+ chlinexy(xpos, ypos, w->w);
+ break;
+ case CTK_WIDGET_LABEL:
+ text = w->widget.label.text;
+ for(i = 0; i < w->h; ++i) {
+ gotoxy(xpos, ypos);
+ cputsn(text, w->w);
+ if(w->w - (wherex() - xpos) > 0) {
+ cclear(w->w - (wherex() - xpos));
+ }
+ ++ypos;
+ text += w->w;
+ }
+ break;
+ case CTK_WIDGET_BUTTON:
+ revers(wfocus != 0);
+ cputcxy(xpos, ypos, '[');
+ cputsn(w->widget.button.text, w->w);
+ cputc(']');
+ revers(0);
+ break;
+ case CTK_WIDGET_HYPERLINK:
+ revers(wfocus == 0);
+ gotoxy(xpos, ypos);
+ cputsn(w->widget.button.text, w->w);
+ revers(0);
+ break;
+ case CTK_WIDGET_TEXTENTRY:
+ text = w->widget.textentry.text;
+ xscroll = 0;
+ if(w->widget.textentry.xpos >= w->w - 1) {
+ xscroll = w->widget.textentry.xpos - w->w + 1;
+ }
+ for(j = 0; j < w->h; ++j) {
+ if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
+ w->widget.textentry.ypos == j) {
+ revers(0);
+ cputcxy(xpos, ypos, '>');
+ c = 1;
+ for(i = 0; i < w->w; ++i) {
+ if(c != 0) {
+ c = text[i + xscroll];
+ }
+ revers(i == w->widget.textentry.xpos - xscroll);
+ if(c == 0) {
+ cputc(' ');
+ } else {
+ cputc(c);
+ }
+ }
+ revers(0);
+ cputc('<');
+ } else {
+ revers(wfocus != 0 && j == w->widget.textentry.ypos);
+ cvlinexy(xpos, ypos, 1);
+ gotoxy(xpos + 1, ypos);
+ cputsn(text, w->w);
+ i = wherex();
+ if(i - xpos - 1 < w->w) {
+ cclear(w->w - (i - xpos) + 1);
+ }
+ cvline(1);
+ }
+ ++ypos;
+ text += w->widget.textentry.len + 1;
+ }
+ revers(0);
+ break;
+#if CTK_CONF_ICONS
+ case CTK_WIDGET_ICON:
+ revers(wfocus != 0);
+#if CTK_CONF_ICON_TEXTMAPS
+ if(w->widget.icon.textmap != NULL) {
+ for(i = 0; i < 3; ++i) {
+ gotoxy(xpos, ypos);
+ cputc(w->widget.icon.textmap[0 + 3 * i]);
+ cputc(w->widget.icon.textmap[1 + 3 * i]);
+ cputc(w->widget.icon.textmap[2 + 3 * i]);
+ ++ypos;
+ }
+ }
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+ len = strlen(w->widget.icon.title);
+ if(xpos + len >= 80) {
+ xpos = 80 - len;
+ }
+
+ gotoxy(xpos, ypos);
+ cputs(w->widget.icon.title);
+ revers(0);
+ break;
+#endif /* CTK_CONF_ICONS */
+
+ default:
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_widget(struct ctk_widget *w,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ struct ctk_window *win = w->window;
+ unsigned char posx, posy;
+
+ posx = win->x + 1;
+ posy = win->y + 2;
+
+ if(w == win->focused) {
+ focus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, posx, posy, posx + win->w, posy + win->h, focus);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear_window(struct ctk_window *window,
+ unsigned char focus,
+ unsigned char clipy1,
+ unsigned char clipy2)
+{
+ unsigned char i;
+ unsigned char h;
+
+ h = window->y + 2 + window->h;
+
+ /* Clear window contents. */
+ for(i = window->y + 2; i < h; ++i) {
+ cclearxy(window->x + 1, i, window->w);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_window_contents(struct ctk_window *window, unsigned char focus,
+ unsigned char x1, unsigned char x2,
+ unsigned char y1, unsigned char y2)
+{
+ struct ctk_widget *w;
+ unsigned char wfocus;
+
+ /* Draw inactive widgets. */
+ for(w = window->inactive; w != NULL; w = w->next) {
+ draw_widget(w, x1, y1, x2, y2, focus);
+ }
+
+ /* Draw active widgets. */
+ for(w = window->active; w != NULL; w = w->next) {
+ wfocus = focus;
+ if(w == window->focused) {
+ wfocus |= CTK_FOCUS_WIDGET;
+ }
+
+ draw_widget(w, x1, y1, x2, y2, wfocus);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma codeseg(push, "CODE");
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_window(struct ctk_window *window, unsigned char focus,
+ unsigned char clipy1, unsigned char clipy2,
+ unsigned char draw_borders)
+{
+ unsigned char x, y;
+ unsigned char x1, y1, x2, y2;
+
+ x = window->x;
+ y = window->y + 1;
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + window->w;
+ y2 = y1 + window->h;
+
+ if(draw_borders) {
+
+ /* Draw window frame. */
+ _textframexy(x, y, window->w + 2, window->h + 2, _TEXTFRAME_TALL);
+ }
+
+ draw_window_contents(window, focus, x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_dialog(struct ctk_window *dialog)
+{
+ unsigned char x, y;
+ unsigned char i;
+ unsigned char x1, y1, x2, y2;
+
+ x = dialog->x;
+ y = dialog->y + 1;
+ x1 = x + 1;
+ y1 = y + 1;
+ x2 = x1 + dialog->w;
+ y2 = y1 + dialog->h;
+
+ /* Draw dialog frame. */
+ _textframexy(x, y, dialog->w + 2, dialog->h + 2, _TEXTFRAME_WIDE);
+
+ /* Clear dialog contents. */
+ for(i = y1; i < y2; ++i) {
+ cclearxy(x1, i, dialog->w);
+ }
+
+ draw_window_contents(dialog, CTK_FOCUS_DIALOG, x1, x2, y1, y2);
+}
+/*-----------------------------------------------------------------------------------*/
+#pragma codeseg(pop);
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_clear(unsigned char y1, unsigned char y2)
+{
+ char c1, c2;
+ unsigned char i;
+
+ if(ctk_draw_background) {
+ c1 = 'V';
+ c2 = 'W';
+ } else {
+ c1 = ' ' | 0x80;
+ c2 = ' ' | 0x80;
+ }
+
+ for(i = 1; i < 24; ++i) {
+ gotoy(i);
+ *(char *)0xC055 = 0;
+ memset(*(char **)0x28, c1, 40);
+ *(char *)0xC054 = 0;
+ memset(*(char **)0x28, c2, 40);
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+draw_menu(struct ctk_menu *m, unsigned char open)
+{
+ unsigned char x, x2, y;
+
+ if(open) {
+ x = x2 = wherex();
+ if(x2 + CTK_CONF_MENUWIDTH > 80) {
+ x2 = 80 - CTK_CONF_MENUWIDTH;
+ }
+
+ for(y = 0; y < m->nitems; ++y) {
+ if(y == m->active) {
+ revers(0);
+ } else {
+ revers(1);
+ }
+ gotoxy(x2, y + 1);
+ if(m->items[y].title[0] == '-') {
+ chline(CTK_CONF_MENUWIDTH);
+ } else {
+ cputs(m->items[y].title);
+ }
+ if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
+ cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
+ }
+ }
+
+ gotoxy(x, 0);
+ revers(0);
+ }
+
+ cputs(m->title);
+ cputc(' ');
+ revers(1);
+}
+/*-----------------------------------------------------------------------------------*/
+void
+ctk_draw_menus(struct ctk_menus *menus)
+{
+ struct ctk_menu *m;
+
+ /* Draw menus */
+ gotoxy(0, 0);
+ revers(1);
+ cputc(' ');
+ for(m = menus->menus->next; m != NULL; m = m->next) {
+ draw_menu(m, m == menus->open);
+ }
+
+ /* Draw desktopmenu */
+ if(wherex() + strlen(menus->desktopmenu->title) + 1 >= 80) {
+ gotoxy(80 - strlen(menus->desktopmenu->title) - 1, 0);
+ } else {
+ cclear(80 - wherex() -
+ strlen(menus->desktopmenu->title) - 1);
+ }
+ draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
+
+ revers(0);
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_height(void)
+{
+ return 24;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+ctk_draw_width(void)
+{
+ return 80;
+}
+/*-----------------------------------------------------------------------------------*/
+int
+ctk_arch_isprint(char c)
+{
+ return isprint(c);
+}
diff --git a/contiki-apple2/lib/bank.S b/contiki-apple2/lib/bank.S
new file mode 100644
index 0000000..9d3d866
--- /dev/null
+++ b/contiki-apple2/lib/bank.S
@@ -0,0 +1,138 @@
+;
+; Bank switching code for Contiki (Apple2 version)
+;
+
+ .segment "CONTIKI"
+
+ .export VTABZ
+
+VTABZ:
+ ; Switch in ROM and call VTABZ
+ bit $C082
+ jsr $FC24
+
+ ; Switch in LC bank 2 for R/O and return
+ bit $C080
+ rts
+
+.ifdef __APPLE2ENH__
+
+ .code
+
+main2aux:
+ ; Switch in $2000-$3FFF from aux memory
+ bit $C055 ; Page2
+ bit $C057 ; HiRes
+ rts
+
+aux2main:
+ ; Switch in $2000-$3FFF from main memory
+ bit $C056 ; LoRes
+ bit $C054 ; Page1
+ rts
+
+ .export _tcpip_init
+ .import __tcpip_init
+
+_tcpip_init:
+ jsr main2aux
+ jsr __tcpip_init
+ jmp aux2main
+
+ .export _tcpip_eventhandler
+ .import __tcpip_eventhandler
+
+_tcpip_eventhandler:
+ jsr main2aux
+ jsr __tcpip_eventhandler
+ jmp aux2main
+
+ .export _tcpip_pollhandler
+ .import __tcpip_pollhandler
+
+_tcpip_pollhandler:
+ jsr main2aux
+ jsr __tcpip_pollhandler
+ jmp aux2main
+
+ .export _htons
+ .import __htons
+
+_htons:
+ jsr main2aux
+ jsr __htons
+ jmp aux2main
+
+ .export _uiplib_ipaddrconv
+ .import __uiplib_ipaddrconv
+
+_uiplib_ipaddrconv:
+ jsr main2aux
+ jsr __uiplib_ipaddrconv
+ jmp aux2main
+
+ .export _tcp_markconn
+ .import __tcp_markconn
+
+_tcp_markconn:
+ jsr main2aux
+ jsr __tcp_markconn
+ jmp aux2main
+
+ .export _tcp_listen
+ .import __tcp_listen
+
+_tcp_listen:
+ jsr main2aux
+ jsr __tcp_listen
+ jmp aux2main
+
+ .export _tcp_unlisten
+ .import __tcp_unlisten
+
+_tcp_unlisten:
+ jsr main2aux
+ jsr __tcp_unlisten
+ jmp aux2main
+
+ .export _tcp_connect
+ .import __tcp_connect
+
+_tcp_connect:
+ jsr main2aux
+ jsr __tcp_connect
+ jmp aux2main
+
+ .export _udp_new
+ .import __udp_new
+
+_udp_new:
+ jsr main2aux
+ jsr __udp_new
+ jmp aux2main
+
+ .export _tcpip_input
+ .import __tcpip_input
+
+_tcpip_input:
+ jsr main2aux
+ jsr __tcpip_input
+ jmp aux2main
+
+ .export _tcpip_poll_udp
+ .import __tcpip_poll_udp
+
+_tcpip_poll_udp:
+ jsr main2aux
+ jsr __tcpip_poll_udp
+ jmp aux2main
+
+ .export __ek_post_synch
+ .import _ek_post_synch
+
+__ek_post_synch:
+ jsr aux2main
+ jsr _ek_post_synch
+ jmp main2aux
+
+.endif
diff --git a/contiki-apple2/lib/cfs.c b/contiki-apple2/lib/cfs.c
new file mode 100644
index 0000000..be57120
--- /dev/null
+++ b/contiki-apple2/lib/cfs.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.c,v 1.4 2006/04/09 23:28:10 oliverschmidt Exp $
+ */
+
+
+#include <string.h>
+
+#include "contiki.h"
+#include "kfs.h"
+
+#include "cfs.h"
+
+
+/*---------------------------------------------------------------------------*/
+int
+cfs_opendir(struct cfs_dir *dirp, const char *name)
+{
+ if(strcmp(name, "/") == 0) {
+ name = kfs_getdir();
+ }
+
+ dirp->dir = opendir(name);
+ if(dirp->dir == NULL) {
+ return -1;
+ }
+ return 0;
+}
+/*---------------------------------------------------------------------------*/
+int
+cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *direntp)
+{
+ struct dirent *dirent = readdir(dirp->dir);
+ if(dirent == NULL) {
+ return -1;
+ }
+
+ strcpy(direntp->name, dirent->d_name);
+ direntp->size = 0;
+ return 0;
+}
+/*---------------------------------------------------------------------------*/
+int
+cfs_closedir(struct cfs_dir *dirp)
+{
+ return closedir(dirp->dir);
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/lib/cfs.h b/contiki-apple2/lib/cfs.h
new file mode 100644
index 0000000..bae94c5
--- /dev/null
+++ b/contiki-apple2/lib/cfs.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cfs.h,v 1.4 2006/04/09 23:28:10 oliverschmidt Exp $
+ */
+#ifndef __CFS_H__
+#define __CFS_H__
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#define CFS_READ (O_RDONLY)
+#define CFS_WRITE (O_WRONLY | O_CREAT | O_TRUNC)
+
+#define cfs_open open
+#define cfs_close close
+#define cfs_read read
+#define cfs_write write
+
+struct cfs_dir {
+ DIR *dir;
+};
+
+struct cfs_dirent {
+ char name[16];
+ unsigned int size;
+};
+
+int cfs_opendir(struct cfs_dir *dirp, const char *name);
+int cfs_readdir(struct cfs_dir *dirp, struct cfs_dirent *direntp);
+int cfs_closedir(struct cfs_dir *dirp);
+
+#endif /* __CFS_H__ */
diff --git a/contiki-apple2/lib/clock-arch.S b/contiki-apple2/lib/clock-arch.S
new file mode 100644
index 0000000..5d9c39d
--- /dev/null
+++ b/contiki-apple2/lib/clock-arch.S
@@ -0,0 +1,34 @@
+;
+; Clock tick code for Contiki (Apple2 version)
+;
+
+ .constructor inittick
+ .export _tick
+
+ .segment "INIT"
+
+inittick:
+ ; Switch in ROM
+ bit $C082
+
+ ; Check for IIgs
+ sec
+ jsr $FE1F
+ bcs done
+
+ ; Check for fast speed
+ bit $C036
+ bpl done
+
+ ; Adjust tick (5/14 = 1.0MHz/2.8MHz)
+ lda #5
+ sta _tick
+
+ ; Switch in LC bank 2 for R/O
+done: bit $C080
+
+ rts
+
+ .data
+
+_tick: .byte 14
diff --git a/contiki-apple2/lib/clock-arch.h b/contiki-apple2/lib/clock-arch.h
new file mode 100644
index 0000000..78a9270
--- /dev/null
+++ b/contiki-apple2/lib/clock-arch.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: clock-arch.h,v 1.1 2005/05/16 21:20:53 oliverschmidt Exp $
+ */
+#ifndef __CLOCK_ARCH_H__
+#define __CLOCK_ARCH_H__
+
+extern unsigned char tick;
+
+#endif /* __CLOCK_ARCH_H__ */
diff --git a/contiki-apple2/lib/crt0.S b/contiki-apple2/lib/crt0.S
new file mode 100644
index 0000000..acf5533
--- /dev/null
+++ b/contiki-apple2/lib/crt0.S
@@ -0,0 +1,559 @@
+;
+; Startup code for Contiki (Apple2 version)
+;
+; This must be the *first* file on the linker command line
+;
+
+ .export _exit
+ .import zerobss, initlib, callmain, donelib
+.ifdef __APPLE2ENH__
+ .import _uip_buf, callirq
+.endif
+ .import __STARTUP_RUN__ ; Linker generated
+ .import __BSS_RUN__, __BSS_SIZE__ ; Linker generated
+ .import __INIT_RUN__, __INIT_SIZE__ ; Linker generated
+ .import __CODE_RUN__, __CODE_SIZE__ ; Linker generated
+ .import __BOOT_SIZE__, __UIP_SIZE__ ; Linker generated
+ .importzp sp
+ .linecont +
+
+; ------------------------------------------------------------------------
+; The executable header
+
+.segment "EXEHDR"
+
+ .word __STARTUP_RUN__ ; Start address
+ .word __BSS_RUN__ + __BOOT_SIZE__ + \
+ __INIT_SIZE__ + __CODE_SIZE__ + \
+ __UIP_SIZE__ - __STARTUP_RUN__ ; Size
+
+; ------------------------------------------------------------------------
+; Place the startup code in a special segment
+
+.segment "STARTUP"
+
+; Forward control to the code in the "BOOT" segment
+
+ jmp __BSS_RUN__
+
+.ifdef __APPLE2ENH__
+
+; ProDOS TechRefMan, chapter 6.2:
+; "Each installed routine must begin with a CLD instruction."
+
+irq: cld
+
+; Switch in LC bank 2 for R/O
+
+ bit $C080
+
+; Call interruptors
+
+ jsr callirq
+
+; Switch in LC bank 1 for R/W
+
+ bit $C08B
+ bit $C08B
+
+; Check for success
+
+ bcc :+
+
+; ProDOS TechRefMan, chapter 6.2:
+; "When the routine that can process the interrupt is called, it
+; should ... return (via an RTS) with the carry flag clear."
+
+ clc
+ rts
+
+; ProDOS TechRefMan, chapter 6.2:
+; "When a routine that cannot process the interrupt is called,
+; it should return (via an RTS) with the cary flag set ..."
+
+: sec
+ rts
+
+.endif
+
+; Avoid re-entrance of donelib. This is also the _exit entry
+
+_exit: ldx #$02
+: lda rvsave,x
+ sta $03F2,x
+ dex
+ bpl :-
+
+; Switch in LC bank 2 for R/O
+
+ bit $C080
+
+; Call module destructors
+
+ jsr donelib
+
+.ifdef __APPLE2ENH__
+
+; Switch in $2000-$3FFF from aux memory
+
+ lda $C018 ; 80Store ?
+ pha
+ sta $C001 ; 80Store On
+
+ bit $C055 ; Page2
+ bit $C057 ; HiRes
+
+; Call the cleanup code in the "UIP" segment
+
+ jsr cleanup
+
+; Switch in $2000-$3FFF from main memory
+
+ bit $C056 ; LoRes
+ bit $C054 ; Page1
+
+ pla
+ bmi :+
+ sta $C000 ; 80Store Off
+
+.endif
+
+; Switch in ROM
+
+: bit $C082
+
+; Back to DOS
+
+ jmp $03D0
+
+.ifdef __APPLE2ENH__
+; ------------------------------------------------------------------------
+; There's space left in the "UIP" segment so we move all cleanup code here
+
+.segment "UIP"
+
+.proc cleanup
+
+; Deallocate interrupt vector table entry
+
+ dec intrpt ; Adjust parameter count
+ jsr $BF00
+ .byte $41 ; Dealloc interrupt
+ .addr intrpt
+
+; Save last used device number
+
+ lda $BF30 ; DEVNUM
+ sta devnum
+
+; Read ProDOS dispatcher from /RAM
+
+ jsr $BF00
+ .byte $C8 ; Open file
+ .addr open
+
+ lda o_ref
+ sta r_ref
+ sta c_ref
+
+ jsr $BF00
+ .byte $CA ; Read file
+ .addr read
+
+ jsr $BF00
+ .byte $CC ; Close file
+ .addr close
+
+; Destroy /RAM files
+
+ jsr $BF00
+ .byte $C1 ; Destroy file
+ .addr destr
+
+ dec n_ext ; CONTIKI.2 -> CONTIKI.1
+
+ jsr $BF00
+ .byte $C1 ; Destroy file
+ .addr destr
+
+; Restore last used device number
+
+ lda devnum
+ sta $BF30 ; DEVNUM
+
+; Switch in LC bank 2 for W/O
+
+ bit $C081
+ bit $C081
+
+; Set source start
+
+ lda #<__BSS_RUN__
+ ldx #>__BSS_RUN__
+ sta $3C
+ stx $3D
+
+; Set source end
+
+ lda #<(__BSS_RUN__ + $0300)
+ ldx #>(__BSS_RUN__ + $0300)
+ sta $3E
+ stx $3F
+
+; Set destination
+
+ lda #<$D100
+ ldx #>$D100
+ sta $42
+ stx $43
+
+; Reset index and call MOVE to copy ProDOS dispatcher into LC
+
+ ldy #$00
+ jmp $FE2C
+
+open: .byte $03 ; Parameter count
+ .addr name ; Pathname
+ .addr _uip_buf ; IO buffer
+o_ref: .byte $00 ; Reference number
+
+read: .byte $04 ; Parameter count
+r_ref: .byte $00 ; Reference number
+ .addr __BSS_RUN__ ; Data buffer
+ .word $0300 ; Requested count
+ .word $0000 ; Transfered count
+
+close: .byte $01 ; Parameter count
+c_ref: .byte $00 ; Reference number
+
+destr: .byte $01 ; Parameter count
+ .addr name ; Pathname
+
+name: .byte .strlen("/RAM/CONTIKI.2")
+ .byte "/RAM/CONTIKI."
+n_ext: .byte '2'
+
+devnum: .res 1
+
+.endproc
+.endif
+
+; ------------------------------------------------------------------------
+; The linker doesn't understand that the "BOOT" segment overlays the "BSS"
+; segment so the automatic fixup of references to the "BOOT" segment does
+; not work. Therefore references to this segment have to be expressed as
+; offsets to __BSS_RUN__.
+
+.segment "BOOT"
+
+.ifdef __APPLE2ENH__
+
+; Save potential command line arguments from being overwritten by
+; a slot-based realtime clock being called by ProDOS on file I/O
+
+ ldx #$7F
+: lda $0200,x
+ sta $0100,x
+ dex
+ bpl :-
+
+; ProDOS TechRefMan, chapter 5.2.2.1:
+; "... you may protect those areas of auxiliary memory. If you save a
+; dummy 8K file as the first entry in /RAM, it will always be saved
+; at $2000 to $3FFF."
+;
+; Read /RAM directory
+
+ jsr $BF00
+ .byte $C8 ; Open file
+ .addr open
+
+ lda o_ref
+ sta r_ref
+ sta c_ref
+
+ jsr $BF00
+ .byte $CA ; Read file
+ .addr read
+
+ jsr $BF00
+ .byte $CC ; Close file
+ .addr close
+
+; ProDOS TechRefMan, chapter B.2.5:
+; "FileCount := ThisBlock[$25] + (256 * ThisBlock[$26]);"
+;
+; Make sure /RAM is empty
+
+ lda END + $25
+ ora END + $26
+ beq :++
+
+ ldx #.strlen("Fatal error: /RAM not empty !")
+: lda error,x
+ jsr $FDED ; COUT
+ dex
+ bpl :-
+
+ jsr $FD0C ; RDKEY
+ jmp $03D0 ; DOSWARM
+
+; Switch to 80 column mode here to show some progress
+
+: lda #$0D
+ jsr $C300
+
+; Relocate the "UIP" segment by writing it to /RAM as the first file
+
+ lda #.strlen("/RAM/CONTIKI.1")
+ sta name
+ jsr ramfile
+
+; Switch in LC bank 2 for R/O
+
+ bit $C080
+
+; Copy ProDOS dispatcher out of LC
+
+ ldx #$00
+l_mod = __BSS_RUN__ + *
+: lda $D100,x
+s_mod = __BSS_RUN__ + *
+ sta UIP,x
+ inx
+ bne :-
+ inc l_mod+2
+ inc s_mod+2
+ lda l_mod+2
+ cmp #>$D400
+ bne :-
+
+; Write ProDOS dispatcher to /RAM
+
+ lda #>$0300
+ sta w_cnt+1
+ inc n_ext ; CONTIKI.1 -> CONTIKI.2
+ jsr ramfile
+
+; Restore potential command line arguments
+
+ ldx #$7F
+: lda $0100,x
+ sta $0200,x
+ dex
+ bpl :-
+
+; Allocate interrupt vector table entry
+
+ jsr $BF00
+ .byte $40 ; Alloc interrupt
+ .addr intrpt
+
+.endif
+
+; Setup the stack at HIMEM
+
+ lda $73
+ ldx $73+1
+ sta sp
+ stx sp+1
+
+; Save the original RESET vector
+
+ ldx #$02
+: lda $03F2,x
+ sta rvsave,x
+ dex
+ bpl :-
+
+; ProDOS TechRefMan, chapter 5.3.5:
+; "Your system program should place in the RESET vector the address of a
+; routine that ... closes the files."
+
+ lda #<_exit
+ sta $03F2
+ lda #>_exit
+ sta $03F3
+ eor #$A5
+ sta $03F4
+
+; Switch in LC bank 2 for W/O
+
+ bit $C081
+ bit $C081
+
+; Set source start
+
+ lda #<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+ ldx #>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+ sta $3C
+ stx $3D
+
+; Set source end
+
+ lda #<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__)
+ ldx #>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__)
+ sta $3E
+ stx $3F
+
+; Set destination
+
+ lda #<__CODE_RUN__
+ ldx #>__CODE_RUN__
+ sta $42
+ stx $43
+
+; Reset index and call MOVE to relocate the "CODE" segment
+
+ ldy #$00
+ jsr $FE2C
+
+; Set source start
+
+ lda #<(__BSS_RUN__ + __BOOT_SIZE__)
+ ldx #>(__BSS_RUN__ + __BOOT_SIZE__)
+ sta $3C
+ stx $3D
+
+; Set source end
+
+ lda #<(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+ ldx #>(__BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__)
+ sta $3E
+ stx $3F
+
+; Set destination
+
+ lda #<__INIT_RUN__
+ ldx #>__INIT_RUN__
+ sta $42
+ stx $43
+
+; Reset index and call MOVE to relocate the "INIT" segment
+
+ ldy #$00
+ jsr $FE2C
+
+; Switch in LC bank 2 for R/O
+
+ bit $C080
+
+; Forward control to code in the "INIT" segment
+
+ jmp init
+
+.ifdef __APPLE2ENH__
+
+; Create a temporary file in /RAM
+
+ramfile = __BSS_RUN__ + *
+ jsr $BF00
+ .byte $C0 ; Create file
+ .addr create
+
+ jsr $BF00
+ .byte $C8 ; Open file
+ .addr open
+
+ lda o_ref
+ sta w_ref
+ sta c_ref
+
+ jsr $BF00
+ .byte $CB ; Write file
+ .addr write
+
+ jsr $BF00
+ .byte $CC ; Close file
+ .addr close
+
+ rts
+
+UIP = __BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__
+END = __BSS_RUN__ + __BOOT_SIZE__ + __INIT_SIZE__ + __CODE_SIZE__ + __UIP_SIZE__
+
+create = __BSS_RUN__ + *
+ .byte $07 ; Parameter count
+ .addr name ; Pathname
+ .byte %11000011 ; Access: Standard full access
+ .byte $00 ; File type: Typeless file
+ .word $0000 ; Aux type: N/A
+ .byte $01 ; Storage type: Standard seedling file
+ .word $0000 ; Create date: Current date
+ .word $0000 ; Create time: Current time
+
+open = __BSS_RUN__ + *
+ .byte $03 ; Parameter count
+ .addr name ; Pathname
+ .addr _uip_buf ; IO buffer
+o_ref = __BSS_RUN__ + *
+ .byte $00 ; Reference number
+
+read = __BSS_RUN__ + *
+ .byte $04 ; Parameter count
+r_ref = __BSS_RUN__ + *
+ .byte $00 ; Reference number
+ .addr END ; Data buffer
+ .word $0200 ; Requested count
+ .word $0000 ; Transfered count
+
+write = __BSS_RUN__ + *
+ .byte $04 ; Parameter count
+w_ref = __BSS_RUN__ + *
+ .byte $00 ; Reference number
+ .addr UIP ; Data buffer
+w_cnt = __BSS_RUN__ + *
+ .word $2000 ; Requested count
+ .word $0000 ; Transfered count
+
+close = __BSS_RUN__ + *
+ .byte $01 ; Parameter count
+c_ref = __BSS_RUN__ + *
+ .byte $00 ; Reference number
+
+name = __BSS_RUN__ + *
+ .byte .strlen("/RAM")
+ .byte "/RAM/CONTIKI."
+n_ext = __BSS_RUN__ + *
+ .byte '1'
+
+error = __BSS_RUN__ + *
+ .byte $8D, '!'|$80, ' '|$80, 'y'|$80, 't'|$80, 'p'|$80
+ .byte 'm'|$80, 'e'|$80, ' '|$80, 't'|$80, 'o'|$80, 'n'|$80
+ .byte ' '|$80, 'M'|$80, 'A'|$80, 'R'|$80, '\'|$80, ' '|$80
+ .byte ':'|$80, 'r'|$80, 'o'|$80, 'r'|$80, 'r'|$80, 'e'|$80
+ .byte ' '|$80, 'l'|$80, 'a'|$80, 't'|$80, 'a'|$80, 'F'|$80
+
+.endif
+
+; ------------------------------------------------------------------------
+; The "INIT" segment will be overwritten by the heap
+
+.segment "INIT"
+
+; Clear the BSS data (and thus overwrite the "BOOT" segment)
+
+init: jsr zerobss
+
+; Call module constructors
+
+ jsr initlib
+
+; Push arguments and call main()
+
+ jmp callmain
+
+; ------------------------------------------------------------------------
+; Data
+
+.data
+
+rvsave: .res 3
+
+.ifdef __APPLE2ENH__
+
+intrpt: .byte $02 ; Parameter count
+ .byte $00 ; Interrupt number
+ .addr irq ; Interrupt handler
+
+.endif
\ No newline at end of file
diff --git a/contiki-apple2/lib/import.S b/contiki-apple2/lib/import.S
new file mode 100644
index 0000000..4ab774c
--- /dev/null
+++ b/contiki-apple2/lib/import.S
@@ -0,0 +1,11 @@
+;
+; Forced importing code for Contiki (Apple2 version)
+;
+; These symbols are necessary for (at least some) apps, but are
+; initialized by constructors which are currently not supported
+; for apps. Therefore we include these symbols into the Contiki
+; kernel to make them thus available to the apps indirectly via
+; the contiki-labels mechanism.
+
+ .forceimport __dos_type
+ .forceimport __cwd
diff --git a/contiki-apple2/lib/kfs.S b/contiki-apple2/lib/kfs.S
new file mode 100644
index 0000000..414170e
--- /dev/null
+++ b/contiki-apple2/lib/kfs.S
@@ -0,0 +1,178 @@
+;
+; Contiki kernel file system (Apple2 version)
+;
+; int __fastcall__ kfs_open(const char* name);
+; int __fastcall__ kfs_read(int fd, void* buf, unsigned count);
+; int __fastcall__ kfs_close(int fd);
+; char* kfs_getdir(void);
+;
+
+ .constructor init_kfs
+ .destructor done_kfs
+ .export _kfs_open, _kfs_read, _kfs_close, _kfs_getdir
+ .import _uip_buf, popax
+ .importzp ptr1
+
+PATHNAME := $0280
+MLI := $BF00
+
+GET_PREFIX_CALL = $C7
+OPEN_CALL = $C8
+READ_CALL = $CA
+CLOSE_CALL = $CC
+
+; ------------------------------------------------------------------------
+
+ .bss
+
+PREFIX: .res 1
+
+; ------------------------------------------------------------------------
+
+ .data
+
+OPEN_PARAM:
+ .byte $03 ;PARAM_COUNT
+ .addr PATHNAME ;PATHNAME
+ .addr _uip_buf ;IO_BUFFER
+OPEN_FD: .byte $00 ;REF_NUM
+
+READ_PARAM:
+ .byte $04 ;PARAM_COUNT
+READ_FD: .byte $00 ;REF_NUM
+READ_BUFFER: .addr $0000 ;DATA_BUFFER
+READ_COUNT_IN: .word $0000 ;REQUEST_COUNT
+READ_COUNT_OUT: .word $0000 ;TRANS_COUNT
+
+CLOSE_PARAM:
+ .byte $01 ;PARAM_COUNT
+CLOSE_FD: .byte $00 ;REF_NUM
+
+; ------------------------------------------------------------------------
+
+ .segment "INIT"
+
+init_kfs:
+ ; Check for full pathname
+ lda PATHNAME+1
+ cmp #'/'
+ beq prefix
+
+ ; Save name incl. length
+ ldx PATHNAME
+: lda PATHNAME,x
+ sta _uip_buf,x
+ dex
+ bpl :-
+
+ jsr MLI
+ .byte GET_PREFIX_CALL
+ .addr GET_PREFIX_PARAM
+
+ ; Append name to prefix
+ lda PATHNAME
+ clc
+ adc _uip_buf
+ sta PATHNAME
+ tax
+ ldy _uip_buf
+: lda _uip_buf,y
+ sta PATHNAME,x
+ dex
+ dey
+ bne :-
+
+prefix: lda PATHNAME
+ sec
+ sbc #.strlen("CONTIKI")
+ sta PREFIX
+ rts
+
+GET_PREFIX_PARAM:
+ .byte $01 ; PARAM_COUNT
+ .addr PATHNAME ; DATA_BUFFER
+
+; ------------------------------------------------------------------------
+
+ .segment "CONTIKI"
+
+_kfs_open:
+ ; Append name to prefix
+ sta ptr1
+ stx ptr1+1
+ ldy #$00
+ ldx PREFIX
+: lda (ptr1),y
+ beq :+
+ sta PATHNAME+1,x
+ iny
+ inx
+ bne :- ; bra
+: stx PATHNAME
+
+ jsr MLI
+ .byte OPEN_CALL
+ .addr OPEN_PARAM
+ bcs ERROR
+
+ ; Return fd
+ lda OPEN_FD
+ ldx #$00
+ rts
+
+_kfs_read:
+ ; Store count
+ sta READ_COUNT_IN
+ stx READ_COUNT_IN+1
+
+ ; Pop and store buf
+ jsr popax
+ sta READ_BUFFER
+ stx READ_BUFFER+1
+
+ ; Pop and store fd
+ jsr popax
+ sta READ_FD
+
+ jsr MLI
+ .byte READ_CALL
+ .addr READ_PARAM
+ bcs ERROR
+
+ ; Return bytes transfered
+ lda READ_COUNT_OUT
+ ldx READ_COUNT_OUT+1
+ rts
+
+done_kfs:
+ lda #$00
+
+_kfs_close:
+ ; Store fd
+ sta CLOSE_FD
+
+ jsr MLI
+ .byte CLOSE_CALL
+ .addr CLOSE_PARAM
+ bcs ERROR
+
+ ; Return 0
+ tax
+ rts
+
+_kfs_getdir:
+ ; Append '\0' to prefix
+ lda #$00
+ ldx PREFIX
+ sta PATHNAME+1,x
+
+ ; Return prefix
+ lda #<(PATHNAME+1)
+ ldx #>(PATHNAME+1)
+ rts
+
+ERROR:
+ ; Return -1
+ lda #$FF
+ tax
+ rts
diff --git a/contiki-apple2/lib/kfs.h b/contiki-apple2/lib/kfs.h
new file mode 100644
index 0000000..a305103
--- /dev/null
+++ b/contiki-apple2/lib/kfs.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2004, Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: kfs.h,v 1.2 2005/04/14 21:01:07 oliverschmidt Exp $
+ */
+#ifndef __KFS_H__
+#define __KFS_H__
+
+int __fastcall__ kfs_open(const char* name);
+int __fastcall__ kfs_read(int fd, void* buf, unsigned count);
+int __fastcall__ kfs_close(int fd);
+char* kfs_getdir(void);
+
+#endif /* __KFS_H__ */
diff --git a/contiki-apple2/loader/loader-arch.c b/contiki-apple2/loader/loader-arch.c
new file mode 100644
index 0000000..8ab73d8
--- /dev/null
+++ b/contiki-apple2/loader/loader-arch.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop OS
+ *
+ * $Id: loader-arch.c,v 1.3 2005/05/07 14:25:47 oliverschmidt Exp $
+ *
+ */
+
+#include <modload.h>
+
+#include "loader.h"
+#include "kfs.h"
+
+struct mod_ctrl ctrl = {
+ kfs_read
+};
+
+struct loader_arch_hdr {
+ char arch[8];
+ char version[8];
+
+ char initfunc[1];
+};
+
+/*-----------------------------------------------------------------------------------*/
+/* load(name)
+ *
+ * Loads a program from disk and executes it. Code originally written by
+ * Ullrich von Bassewitz.
+ */
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+load(const char *name)
+{
+ unsigned char res;
+
+ /* Now open the file */
+ ctrl.callerdata = kfs_open(name);
+ if(ctrl.callerdata < 0) {
+ /* Could not open the file, display an error and return */
+ /* ### */
+ return LOADER_ERR_OPEN;
+ }
+
+ /* Load the module */
+ res = mod_load(&ctrl);
+
+ /* Close the input file */
+ kfs_close(ctrl.callerdata);
+
+ /* Check the return code */
+ if(res != MLOAD_OK) {
+ /* Wrong module, out of memory or whatever. Print an error
+ * message and return.
+ */
+ /* ### */
+ return res;
+ }
+
+ /* We've successfully loaded the module. */
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+loader_arch_load(const char *name, char *arg)
+{
+ unsigned char r;
+ struct loader_arch_hdr *hdr;
+
+ r = load(name);
+ if(r != MLOAD_OK) {
+ return r;
+ }
+ hdr = (struct loader_arch_hdr *)ctrl.module;
+
+ /* Check the program header and see that version and architecture
+ matches. */
+
+ /* Call the init function. */
+
+ ((void (*)(char *))hdr->initfunc)(arg);
+
+ return LOADER_OK;
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/main.c b/contiki-apple2/main.c
new file mode 100644
index 0000000..0332ee3
--- /dev/null
+++ b/contiki-apple2/main.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgement:
+ * This product includes software developed by Adam Dunkels.
+ * 4. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: main.c,v 1.18 2006/06/28 23:10:43 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ek.h"
+
+#include "program-handler.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+
+#include "resolv.h"
+
+#include "www-dsc.h"
+#include "email-dsc.h"
+#include "ftp-dsc.h"
+#include "directory-dsc.h"
+
+#include "clock.h"
+#include "clock-arch.h"
+
+#if CTK_CONF_MOUSE_SUPPORT
+#define TICK_COUNT 2800
+#else
+#define TICK_COUNT 4200
+#endif
+
+unsigned char lanslot;
+unsigned char prefixok;
+
+#pragma bssseg(push, "UIPBUF");
+u8_t uip_buf[UIP_BUFSIZE + 2];
+#pragma bssseg(pop);
+
+/*-----------------------------------------------------------------------------------*/
+unsigned char
+uip_fw_forward(void)
+{
+ return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+uip_fw_periodic(void)
+{
+ return;
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ program_handler_load("config.prg", NULL);
+ break;
+ }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_PROCESS(init, "Init", EK_PRIO_LOWEST,
+ eventhandler, NULL, NULL);
+/*-----------------------------------------------------------------------------------*/
+clock_time_t
+clock_time(void)
+{
+ static clock_time_t count, clock;
+
+ count += tick;
+
+ if(count == TICK_COUNT) {
+ count = 0;
+ ++clock;
+ }
+
+ return clock;
+}
+/*-----------------------------------------------------------------------------------*/
+#define STACK_SIZE 0
+#if STACK_SIZE
+#include <conio.h>
+#include <stdlib.h>
+void
+stack_size(void)
+{
+ static unsigned char *c;
+ static unsigned int s;
+ c = (unsigned char *)(0xBF00 - STACK_SIZE);
+ while(*c++ == 0xA2) {
+ }
+ s = (unsigned char *)0xBF00 - c;
+ clrscr();
+ cputc('0' + s / 100 % 10);
+ cputc('0' + s / 10 % 10);
+ cputc('0' + s % 10);
+ cgetc();
+}
+#endif /* STACK_SIZE */
+/*-----------------------------------------------------------------------------------*/
+void
+#ifdef __APPLE2__
+main(void)
+#else /* __APPLE2__ */
+main(int argc, char *argv[])
+#endif /* __APPLE2__ */
+{
+
+#if STACK_SIZE
+ memset((void *)(0xBF00 - STACK_SIZE),
+ 0xA2, STACK_SIZE - (0xBF00 - *(unsigned int *)0x80) - 10);
+ atexit(stack_size);
+#endif /* STACK_SIZE */
+
+ ek_init();
+ ek_start(&init);
+
+ tcpip_init(NULL);
+ resolv_init(NULL);
+
+ ctk_init();
+
+ program_handler_init();
+
+ program_handler_add(&www_dsc, "Web browser", 1);
+ program_handler_add(&email_dsc, "E-mail", 1);
+ program_handler_add(&ftp_dsc, "FTP client", 1);
+ program_handler_add(&directory_dsc, "Directory", 1);
+
+ while(1) {
+ if(ek_run() == 0) {
+
+#ifdef __APPLE2__
+
+ program_handler_load("welcome.prg", NULL);
+
+#else /* __APPLE2__ */
+
+ static char *startup;
+ static char *slash;
+
+ if(argc == 1) {
+ startup = "welcome.prg";
+ } else {
+ startup = argv[1];
+ while(slash = strchr(startup, '/')) {
+ startup = slash + 1;
+ }
+ }
+ program_handler_load(startup, NULL);
+
+#endif /* __APPLE2__ */
+
+ break;
+ }
+ }
+ while(1) {
+ ek_run();
+ }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/readme.txt b/contiki-apple2/readme.txt
new file mode 100644
index 0000000..88a7e11
--- /dev/null
+++ b/contiki-apple2/readme.txt
@@ -0,0 +1,186 @@
+
+Contiki on the Apple ][ (Oliver Schmidt)
+========================================
+
+
+Contiki for the Apple ][ comes in two variants:
+
+1. 'Contiki40' runs in 40 column text mode and requires at least an Apple ][+
+ with Language Card resulting in 64kB memory.
+
+2. 'Contiki80' runs in 80 column text mode and requires at least an enhanced
+ Apple //e with Extended 80 Column Board resulting in 128kB memory.
+
+The remainder of this text describes Contiki80.
+
+
+Installation
+------------
+
+1. Get the 'cc65 complete cross development package' from 06/01/2006 or later:
+ http://www.cc65.org
+
+
+2. Build the two targets apple2enh and programsenh.
+
+
+3. Get the 'a2tools' by Terry Kyriacopoulos:
+ ftp://ftp.apple.asimov.net/pub/apple_II/unsorted/a2tools.zip
+
+
+4. Get the 'Apple][ ProDOS 8 system program for loading binary programs':
+ ftp://ftp.musoftware.de/pub/uz/cc65/contrib/loader-1.2.zip
+
+
+5. Use the 'a2tools' to copy these files into a DOS 3.3 disk image:
+
+ a2tools in b dos33.dsk CONTIKI.SYSTEM loader~1.sys
+ a2tools in -r b dos33.dsk CONTIKI contiki
+ a2tools in b.0000 dos33.dsk A2E.STDMOU.MOU a2estd~1.mou
+ a2tools in b.0000 dos33.dsk ABOUT.PRG about.prg
+ a2tools in b.0000 dos33.dsk ABOUT.DSC about.dsc
+ a2tools in b.0000 dos33.dsk CALC.PRG calc.prg
+ a2tools in b.0000 dos33.dsk CALC.DSC calc.dsc
+ a2tools in b.0000 dos33.dsk CONFIG.PRG config.prg
+ a2tools in b.0000 dos33.dsk CONFIGEDIT.PRG config~1.prg
+ a2tools in b.0000 dos33.dsk CONFIGEDIT.DSC config~1.dsc
+ a2tools in b.0000 dos33.dsk DHCP.PRG dhcp.prg
+ a2tools in b.0000 dos33.dsk DHCP.DSC dhcp.dsc
+ a2tools in b.0000 dos33.dsk DIRECTORY.PRG direct~1.prg
+ a2tools in b.0000 dos33.dsk DIRECTORY.DSC direct~1.dsc
+ a2tools in b.0000 dos33.dsk EMAIL.PRG email.prg
+ a2tools in b.0000 dos33.dsk EMAIL.DSC email.dsc
+ a2tools in b.0000 dos33.dsk FTP.PRG ftp.prg
+ a2tools in b.0000 dos33.dsk FTP.DSC ftp.dsc
+ a2tools in b.0000 dos33.dsk IRC.PRG irc.prg
+ a2tools in b.0000 dos33.dsk IRC.DSC irc.dsc
+ a2tools in b.0000 dos33.dsk MEMSTAT.PRG memstat.prg
+ a2tools in b.0000 dos33.dsk MEMSTAT.DSC memstat.dsc
+ a2tools in b.0000 dos33.dsk PROCESSES.PRG proces~1.prg
+ a2tools in b.0000 dos33.dsk PROCESSES.DSC proces~1.dsc
+ a2tools in b.0000 dos33.dsk SHELL.PRG shell.prg
+ a2tools in b.0000 dos33.dsk SHELL.DSC shell.dsc
+ a2tools in b.0000 dos33.dsk TELNET.PRG telnet.prg
+ a2tools in b.0000 dos33.dsk TELNET.DSC telnet.dsc
+ a2tools in b.0000 dos33.dsk WEBSERVER.PRG webser~1.prg
+ a2tools in b.0000 dos33.dsk WEBSERVER.DSC webser~1.dsc
+ a2tools in b.0000 dos33.dsk WELCOME.PRG welcome.prg
+ a2tools in b.0000 dos33.dsk WGET.PRG wget.prg
+ a2tools in b.0000 dos33.dsk WGET.DSC wget.dsc
+ a2tools in b.0000 dos33.dsk WWW.PRG www.prg
+ a2tools in b.0000 dos33.dsk WWW.DSC www.dsc
+ a2tools in b.0000 dos33.dsk LANCEGS.DRV lancegs.drv
+ a2tools in b.0000 dos33.dsk LANCEGS.DSC lancegs.dsc
+ a2tools in b.0000 dos33.dsk UTHER.DRV uther.drv
+ a2tools in b.0000 dos33.dsk UTHER.DSC uther.dsc
+ a2tools in b.0000 dos33.dsk BOUNCE.SAV bounce.sav
+ a2tools in b.0000 dos33.dsk BOUNCE.DSC bounce.dsc
+ a2tools in b.0000 dos33.dsk PLASMA.SAV plasma.sav
+ a2tools in b.0000 dos33.dsk PLASMA.DSC plasma.dsc
+ a2tools in b.0000 dos33.dsk SSFIRE.SAV ssfire.sav
+ a2tools in b.0000 dos33.dsk SSFIRE.DSC ssfire.dsc
+
+
+6. Use any ProDOS 8 file utility program capable of reading DOS 3.3 files to
+ copy the files from the DOS 3.3 disk to a ProDOS 8 disk.
+
+
+7. Use BASIC.SYSTEM to convert the loader from a BIN to a SYS file:
+
+ BLOAD CONTIKI.SYSTEM
+ DELETE CONTIKI.SYSTEM
+ CREATE CONTIKI.SYSTEM,TSYS
+ BSAVE CONTIKI.SYSTEM,TSYS,A$2000,L465
+
+
+Usage
+-----
+
+Select CONTIKI.SYSTEM from the ProDOS 8 dispatcher or use BASIC.SYSTEM:
+
+ - CONTIKI.SYSTEM
+
+1. CONTIKI.SYSTEM supports the ProDOS 8 startup file protocol. The startup file
+ will be initially launched instead of WELCOME.PRG.
+
+ The startup file support allows to open *.PRG files from the GS/OS finder:
+
+ a) Give your Contiki disk the volume name /CONTIKI
+ b) Copy contiki.icon to /CONTIKI/ICONS/CONTIKI.ICON
+ c) Set the filetype of CONTIKI.ICON to $CA aka ICN
+ d) Set the filetype of the *.PRG files to $FE aka REL
+
+2. Contiki includes mouse support for the AppleMouse II Card, the Apple //c and
+ the Apple IIgs. All slots are searched for mouse firmware but if non is found
+ the mouse support is silently turned off.
+
+ IIgs ROM 3 users: Make sure to have set 'Slot 4' in the 'Control Panel' to
+ 'Mouse Port' although this isn't necessary for GS/OS.
+
+
+Implementation Notes
+--------------------
+
+1. File I/O
+
+ Contiki loads programs, drivers and screensavers from disk using ProDOS 8.
+ The ProDOS 8 file I/O library in the cc65 C-library is to large to be used
+ to load WWW.PRG into a 64k Apple ][. Fortunately WWW.PRG itself does no file
+ I/O but delegates that to WGET.PRG which is a lot smaller than WWW.PRG. so
+ the solution is to have two different file I/O libaries.
+
+ The first one is as small as possible and is only capable of reading one file
+ at a time and only from the directory CONTIKI resides in. It is part of the
+ Contiki kernel and thus called 'KernelFileSystem' (kfs). ProDOS 8 needs a 1kB
+ I/O buffer aligned to a page boundary for every opoen file. The one and only
+ I/O buffer necessary for fks is placed at $0800-$0BFF and serves as buffer
+ for incoming/outgoing IP data as well.
+
+ The other one which is called 'ContikiFileSystem' (cfs) is mapped to the
+ existing cc65 C-library and linked into the programs (like WGET.PRG).
+
+2. Memory Layout
+
+ The Contiki memory layout is based on the standard cc65 layout which means
+ that the binary is loaded to the lowest available address ($0C00 here) and
+ contains the CODE, RODATA and DATA segments. The BSS segment is located
+ directly above those and set to zero programatically. The cc65 stack (not
+ to be confused with the 6502 stack at $0100-$01FF) starts at the highest
+ available address and grows downwards. The heap is located between the BSS
+ and the stack.
+
+ But to satisfy the memory requirements of the larger Contiki programs
+ several modifications were necessary:
+
+ Generally it's very hard to make use of memory mapping for an event driven
+ system like Contiki but the Apple //e allows to map only 8kB of Aux memory
+ to the address space $2000-$3FFF to facilitate double hires graphics. This
+ feature is accompanied by ProDOS 8 which allows to keep /RAM generally active
+ while doing double hires graphics by saving a 8kB file as first file to /RAM
+ and thus preserving $2000-$3FFF of Aux memory. Contiki makes use of all this
+ double hires support while just staying in text mode and using the 8kB as
+ additional memory.
+
+ The additional 8kB are used to store the code of the uIP TCP/IP stack. They
+ are mapped in both on calls from the Contiki event kernel to the TCP/IP stack
+ process (poll and event handler) and calls to the uIP API from programs. Most
+ of the time the 8kB are just kept mapped in when the uIP code calls other
+ code. This is possible because the only memory not reachable from the uIP
+ code are the corresponding 8kB of Main memory - and the Contiki kernel
+ objects are linked in an order which makes only CTK code (which is never
+ called by uIP code) use that 8kB of Main memory. The only call from uIP code
+ that triggers mapping out the 8kB of Aux memory is the uIP upcall into a
+ program for processing incoming IP data as some program may potentially call
+ CTK code while processing that data.
+
+ Beside that Contiki makes use of the Language Card bank 2 to store the code
+ of the C-libary. Most of this 4 kB can be considered free although officially
+ marked as reserved by ProDOS 8. Only $D100-$D3FF are actually used to store
+ the ProDOS 8 dispatcher. As it is only used after terminating Contiki it can
+ be saved to /RAM on startup and restored from there while cleanup.
+
+ The code doing all that code relocation gets overwritten on setting the BSS
+ segment to zero. The code doing this (and the C-library initialization) gets
+ overwritten later by the heap content.
+
+eof
\ No newline at end of file
diff --git a/contiki-apple2/uip/cs8900a.c b/contiki-apple2/uip/cs8900a.c
new file mode 100644
index 0000000..872691b
--- /dev/null
+++ b/contiki-apple2/uip/cs8900a.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the C64 RealAudio server demo project.
+ *
+ * $Id: cs8900a.c,v 1.8 2005/05/22 14:04:21 oliverschmidt Exp $
+ *
+ */
+
+/* cs8900a.c: device driver for the CS8900a chip in 8-bit mode. Mostly
+ written in 6502 assembler for speed. */
+
+#include "cs8900a.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+extern u8_t lanslot;
+extern u8_t *cs8900a_rxtxreg,
+ *cs8900a_txcmd,
+ *cs8900a_txlen,
+ *cs8900a_packetpp,
+ *cs8900a_ppdata;
+
+static u8_t idx;
+static u16_t len;
+static u16_t cnt;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_init(void)
+{
+ asm("lda %v", lanslot);
+ asm("beq %g", bailout);
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("sta %v", idx);
+ asm("tax");
+
+ /* Turn on transmission and reception of frames. */
+ /* PACKETPP = 0x0112;
+ PPDATA = 0x00c0; */
+ asm("lda #$12");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda #$c0");
+ asm("sta %v,x", cs8900a_ppdata);
+ asm("lda #$00");
+ asm("sta %v+1,x", cs8900a_ppdata);
+
+ /* Accept valid unicast+broadcast frames. */
+ /* PACKETPP = 0x0104;
+ PPDATA = 0x0d05; */
+ asm("lda #$04");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda #$05");
+ asm("sta %v,x", cs8900a_ppdata);
+ asm("lda #$0d");
+ asm("sta %v+1,x", cs8900a_ppdata);
+
+ /* Set MAC address. */
+ /* PACKETPP = 0x0158;
+ PPDATA = (ETHADDR1 << 8) | (ETHADDR0); */
+ asm("lda #$58");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v", uip_ethaddr);
+ asm("sta %v,x", cs8900a_ppdata);
+ asm("lda %v+1", uip_ethaddr);
+ asm("sta %v+1,x", cs8900a_ppdata);
+
+ /* PACKETPP = 0x015a;
+ PPDATA = (ETHADDR3 << 8) | (ETHADDR2); */
+ asm("lda #$5a");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v+2", uip_ethaddr);
+ asm("sta %v,x", cs8900a_ppdata);
+ asm("lda %v+3", uip_ethaddr);
+ asm("sta %v+1,x", cs8900a_ppdata);
+
+ /* PACKETPP = 0x015c;
+ PPDATA = (ETHADDR5 << 8) | (ETHADDR4); */
+ asm("lda #$5c");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v+4", uip_ethaddr);
+ asm("sta %v,x", cs8900a_ppdata);
+ asm("lda %v+5", uip_ethaddr);
+ asm("sta %v+1,x", cs8900a_ppdata);
+bailout:
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+cs8900a_send(void)
+{
+ asm("ldx %v", idx);
+ asm("beq %g", bailout);
+
+ /* Transmit command. */
+ asm("lda #$c0");
+ asm("sta %v,x", cs8900a_txcmd);
+ asm("lda #$00");
+ asm("sta %v+1,x", cs8900a_txcmd);
+ asm("lda %v", uip_len);
+ asm("sta %v,x", cs8900a_txlen);
+ asm("lda %v+1", uip_len);
+ asm("sta %v+1,x", cs8900a_txlen);
+
+ asm("ldy #8");
+tryagain:
+ /* Check for avaliable buffer space. */
+ asm("lda #$38");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v+1,x", cs8900a_ppdata);
+ asm("and #1");
+ asm("bne %g", send);
+
+ /* No space avaliable, skip a received frame and try again. */
+ asm("lda #$02");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v,x", cs8900a_ppdata);
+ asm("ora #$40");
+ asm("sta %v,x", cs8900a_ppdata);
+
+ asm("dey");
+ asm("bne %g", tryagain);
+bailout:
+ return;
+
+ /* Send the frame. */
+send:
+
+ /* First, send 14+40=54 bytes of header. */
+ asm("ldy #0");
+sendloop1:
+ asm("lda %v,y", uip_buf);
+ asm("sta %v,x", cs8900a_rxtxreg);
+ asm("iny");
+ asm("lda %v,y", uip_buf);
+ asm("sta %v+1,x", cs8900a_rxtxreg);
+ asm("iny");
+ asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+ asm("bne %g", sendloop1);
+
+ if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+ return;
+ }
+
+ /* Next, send rest of the packet. */
+ cnt = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+ asm("ldx %v", idx);
+
+ asm("lda %v", cnt);
+ asm("lsr");
+ asm("bcc %g", noinc);
+ asm("inc %v", cnt);
+ asm("bne %g", noinc);
+ asm("inc %v+1", cnt);
+noinc:
+
+ asm("lda %v", uip_appdata);
+ asm("sta ptr1");
+ asm("lda %v+1", uip_appdata);
+ asm("sta ptr1+1");
+
+ asm("ldy #0");
+sendloop2:
+ asm("lda (ptr1),y");
+ asm("sta %v,x", cs8900a_rxtxreg);
+ asm("iny");
+ asm("lda (ptr1),y");
+ asm("sta %v+1,x", cs8900a_rxtxreg);
+ asm("iny");
+ asm("bne %g", check);
+ asm("inc ptr1+1");
+check:
+ asm("cpy %v", cnt);
+ asm("bne %g", sendloop2);
+ asm("dec %v+1", cnt);
+ asm("bpl %g", sendloop2);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+skip_frame(void)
+{
+ asm("ldx %v", idx);
+
+ /* PACKETPP = 0x0102;
+ PPDATA = PPDATA | 0x0040; */
+ asm("lda #$02");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v,x", cs8900a_ppdata);
+ asm("ora #$40");
+ asm("sta %v,x", cs8900a_ppdata);
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t
+cs8900a_poll(void)
+{
+ asm("ldx %v", idx);
+ asm("beq %g", bailout);
+
+ /* Check receiver event register to see if there are any valid
+ unicast frames avaliable. */
+ /* PACKETPP = 0x0124;
+ if(PPDATA & 0x000d == 0x0000) {
+ return 0;
+ }
+ */
+ asm("lda #$24");
+ asm("sta %v,x", cs8900a_packetpp);
+ asm("lda #$01");
+ asm("sta %v+1,x", cs8900a_packetpp);
+ asm("lda %v+1,x", cs8900a_ppdata);
+ asm("and #$0d");
+ asm("cmp #$00");
+ asm("bne %g", noreturn);
+ /* No frame ready. */
+bailout:
+ return 0;
+
+noreturn:
+ /* Process the incoming frame. */
+
+ /* Read receiver event and discard it. */
+ /* RXTXREG; */
+ asm("lda %v+1,x", cs8900a_rxtxreg);
+ asm("lda %v,x", cs8900a_rxtxreg);
+
+ /* Read frame length. */
+ /* cnt = len = RXTXREG; */
+ asm("lda %v+1,x", cs8900a_rxtxreg);
+ asm("sta %v+1", len);
+ asm("sta %v+1", cnt);
+ asm("lda %v,x", cs8900a_rxtxreg);
+ asm("sta %v", len);
+ asm("sta %v", cnt);
+
+ asm("lsr");
+ asm("bcc %g", noinc);
+ asm("inc %v", cnt);
+ asm("bne %g", noinc);
+ asm("inc %v+1", cnt);
+noinc:
+
+ if(cnt > UIP_BUFSIZE) {
+ skip_frame();
+ return 0;
+ }
+
+ /* Read bytes into uip_buf. */
+ asm("ldx %v", idx);
+
+ asm("lda #<%v", uip_buf);
+ asm("sta ptr1");
+ asm("lda #>%v", uip_buf);
+ asm("sta ptr1+1");
+
+ asm("ldy #0");
+readloop:
+ asm("lda %v,x", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("lda %v+1,x", cs8900a_rxtxreg);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("bne %g", check);
+ asm("inc ptr1+1");
+check:
+ asm("cpy %v", cnt);
+ asm("bne %g", readloop);
+ asm("dec %v+1", cnt);
+ asm("bpl %g", readloop);
+ return len;
+}
+#pragma optimize(pop)
diff --git a/contiki-apple2/uip/cs8900a.h b/contiki-apple2/uip/cs8900a.h
new file mode 100644
index 0000000..2beae51
--- /dev/null
+++ b/contiki-apple2/uip/cs8900a.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: cs8900a.h,v 1.2 2005/01/26 21:33:30 oliverschmidt Exp $
+ */
+#ifndef __CS8900A_H__
+#define __CS8900A_H__
+
+#include "uip_arch.h"
+
+void cs8900a_init(void);
+void cs8900a_send(void);
+u16_t cs8900a_poll(void);
+
+#endif /* __CS8900A_H__ */
diff --git a/contiki-apple2/uip/lan91c96.c b/contiki-apple2/uip/lan91c96.c
new file mode 100644
index 0000000..28d1c10
--- /dev/null
+++ b/contiki-apple2/uip/lan91c96.c
@@ -0,0 +1,359 @@
+/*
+ * uIP lan91c96 (smc9194) driver
+ * Based on cs8900a driver, copyrighted (c) 2001, by Adam Dunkels
+ * Copyright (c) 2003, Josef Soucek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: lan91c96.c,v 1.6 2005/05/22 14:04:21 oliverschmidt Exp $
+ *
+ */
+
+#include "lan91c96.h"
+#include "uip.h"
+#include "uip_arp.h"
+
+#include <stdio.h>
+
+#define ETHBASE 0xc080
+
+#define ETHBSR ETHBASE+0x0e /* Bank select register R/W (2B) */
+
+/* Register bank 0 */
+
+#define ETHTCR ETHBASE /* Transmition control register R/W (2B) */
+#define ETHEPHSR ETHBASE+2 /* EPH status register R/O (2B) */
+#define ETHRCR ETHBASE+4 /* Receive control register R/W (2B) */
+#define ETHECR ETHBASE+6 /* Counter register R/O (2B) */
+#define ETHMIR ETHBASE+8 /* Memory information register R/O (2B) */
+#define ETHMCR ETHBASE+0x0a /* Memory Config. reg. +0 R/W +1 R/O (2B) */
+
+/* Register bank 1 */
+
+#define ETHCR ETHBASE /* Configuration register R/W (2B) */
+#define ETHBAR ETHBASE+2 /* Base address register R/W (2B) */
+#define ETHIAR ETHBASE+4 /* Individual address register R/W (6B) */
+#define ETHGPR ETHBASE+0x0a /* General address register R/W (2B) */
+#define ETHCTR ETHBASE+0x0c /* Control register R/W (2B) */
+
+/* Register bank 2 */
+
+#define ETHMMUCR ETHBASE /* MMU command register W/O (1B) */
+#define ETHAUTOTX ETHBASE+1 /* AUTO TX start register R/W (1B) */
+#define ETHPNR ETHBASE+2 /* Packet number register R/W (1B) */
+#define ETHARR ETHBASE+3 /* Allocation result register R/O (1B) */
+#define ETHFIFO ETHBASE+4 /* FIFO ports register R/O (2B) */
+#define ETHPTR ETHBASE+6 /* Pointer register R/W (2B) */
+#define ETHDATA ETHBASE+8 /* Data register R/W (4B) */
+#define ETHIST ETHBASE+0x0c /* Interrupt status register R/O (1B) */
+#define ETHACK ETHBASE+0x0c /* Interrupt acknowledge register W/O (1B) */
+#define ETHMSK ETHBASE+0x0d /* Interrupt mask register R/W (1B) */
+
+/* Register bank 3 */
+
+#define ETHMT ETHBASE /* Multicast table R/W (8B) */
+#define ETHMGMT ETHBASE+8 /* Management interface R/W (2B) */
+#define ETHREV ETHBASE+0x0a /* Revision register R/W (2B) */
+#define ETHERCV ETHBASE+0x0c /* Early RCV register R/W (2B) */
+
+#define BANK(num) asm("lda #%b", num); asm("sta %w,x", ETHBSR);
+
+extern u8_t lanslot;
+
+static u8_t slot_index;
+static u8_t packet_status;
+static u16_t packet_length;
+
+
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_init(void)
+{
+ asm("lda %v", lanslot);
+ asm("beq %g", L1);
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("asl");
+ asm("tax");
+
+ /* Check if high byte is 0x33 */
+ asm("lda %w,x", ETHBSR+1);
+ asm("cmp #$33");
+ asm("bne %g", L1);
+ asm("stx %v", slot_index);
+
+ /* Reset ETH card */
+ BANK(0);
+ asm("lda #%%10000000"); /* Software reset */
+ asm("sta %w,x", ETHRCR+1);
+
+ asm("lda #0");
+ asm("sta %w,x", ETHRCR);
+ asm("sta %w,x", ETHRCR+1);
+
+ /* Enable transmit and receive */
+ asm("lda #%%10000001"); /* Enable transmit TXENA, PAD_EN */
+ asm("sta %w,x", ETHTCR);
+ asm("lda #%%00000011"); /* Enable receive, strip CRC ??? */
+ asm("sta %w,x", ETHRCR+1);
+
+ BANK(1);
+ asm("lda %w,x", ETHCR+1);
+ asm("ora #%%00010000"); /* No wait (IOCHRDY) */
+ asm("sta %w,x", ETHCR+1);
+
+ asm("lda #%%00001001"); /* Auto release */
+ asm("sta %w,x", ETHCTR+1);
+
+ /* Set MAC address */
+ asm("lda %v", uip_ethaddr);
+ asm("sta %w,x", ETHIAR);
+ asm("lda %v+1", uip_ethaddr);
+ asm("sta %w,x", ETHIAR+1);
+ asm("lda %v+2", uip_ethaddr);
+ asm("sta %w,x", ETHIAR+2);
+ asm("lda %v+3", uip_ethaddr);
+ asm("sta %w,x", ETHIAR+3);
+ asm("lda %v+4", uip_ethaddr);
+ asm("sta %w,x", ETHIAR+4);
+ asm("lda %v+5", uip_ethaddr);
+ asm("sta %w,x", ETHIAR+5);
+
+ BANK(2);
+ asm("lda #%%00000000"); /* No interrupts */
+ asm("sta %w,x", ETHMSK);
+L1:
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+u16_t lan91c96_poll(void)
+{
+ asm("ldx %v", slot_index);
+ asm("beq %g", L0);
+
+ asm("lda %w,x", ETHIST);
+ asm("and #%%00000001"); /* RCV INT */
+ asm("bne %g", L1);
+
+ /* No packet available */
+L0:
+ return 0;
+
+L1:
+ asm("lda #0");
+ asm("sta %w,x", ETHPTR);
+ asm("lda #%%11100000"); /* RCV,AUTO INCR.,READ */
+ asm("sta %w,x", ETHPTR+1);
+
+ asm("lda %w,x", ETHDATA); /* Status word */
+ asm("lda %w,x", ETHDATA);
+ asm("sta %v", packet_status); /* High byte only */
+
+ asm("lda %w,x", ETHDATA); /* Total number of bytes */
+ asm("sta %v", packet_length);
+ asm("lda %w,x", ETHDATA);
+ asm("sta %v+1", packet_length);
+
+ /* Last word contain 'last data byte' and 0x60 */
+ /* or 'fill byte' and 0x40 */
+
+ packet_length -= 6; /* The packet contains 3 extra words */
+
+ asm("lda %v", packet_status);
+ asm("and #$10");
+ asm("beq %g", L2);
+
+ packet_length++;
+
+L2:
+ if(packet_length > UIP_BUFSIZE) {
+
+ asm("ldx %v", slot_index);
+
+ /* Remove and release RX packet from FIFO */
+ asm("lda #%%10000000");
+ asm("sta %w,x", ETHMMUCR);
+ return 0;
+ }
+
+ asm("ldx %v", slot_index);
+
+ asm("lda #<%v", uip_buf);
+ asm("sta ptr1");
+ asm("lda #>%v", uip_buf);
+ asm("sta ptr1+1");
+
+ asm("lda %v+1", packet_length);
+ asm("sta tmp1");
+
+ asm("ldy #0");
+L3:
+ asm("lda %w,x", ETHDATA);
+ asm("sta (ptr1),y");
+ asm("iny");
+ asm("bne %g", L4);
+ asm("inc ptr1+1");
+L4:
+ asm("cpy %v", packet_length);
+ asm("bne %g", L3);
+ asm("dec tmp1");
+ asm("bpl %g", L3);
+
+ /* Remove and release RX packet from FIFO */
+ asm("lda #%%10000000");
+ asm("sta %w,x", ETHMMUCR);
+ return packet_length;
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void lan91c96_send(void)
+{
+ /* First 14+40 (IP and TCP header) is send from uip_buf */
+ /* than data from uip_appdata */
+
+ asm("ldx %v", slot_index);
+ asm("beq %g", L0);
+
+ asm("lda %v+1", uip_len);
+ asm("ora #%%00100000"); /* Allocate memory for TX */
+ asm("sta %w,x", ETHMMUCR);
+
+ asm("ldy #8"); /* Wait... */
+L1: /* Wait for allocation ready */
+ asm("lda %w,x", ETHIST);
+ asm("and #%%00001000"); /* ALLOC INT */
+ asm("bne %g", L2);
+ asm("dey");
+ asm("bne %g", L1);
+L0:
+ return;
+
+L2:
+ asm("lda #%%00001000"); /* Acknowledge int, is it necessary ??? */
+ asm("sta %w,x", ETHACK);
+
+ asm("lda %w,x", ETHARR);
+ asm("sta %w,x", ETHPNR); /* Set packet address */
+
+ asm("lda #0");
+ asm("sta %w,x", ETHPTR);
+ asm("lda #%%01000000"); /* AUTO INCR. */
+ asm("sta %w,x", ETHPTR+1);
+
+ asm("lda #0"); /* Status written by CSMA */
+ asm("sta %w,x", ETHDATA);
+ asm("sta %w,x", ETHDATA);
+
+ asm("lda %v", uip_len);
+ asm("and #$01");
+ asm("beq %g", L3);
+
+ packet_length = uip_len + 5;
+ asm("jmp %g", L4);
+
+L3:
+ packet_length = uip_len + 6; /* +6 for status word, length and ctl byte */
+
+L4:
+ asm("ldx %v", slot_index);
+
+ asm("lda %v", packet_length);
+ asm("sta %w,x", ETHDATA);
+ asm("lda %v+1", packet_length);
+ asm("sta %w,x", ETHDATA);
+
+ /* Send 14+40=54 bytes of header */
+
+ if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) {
+
+ asm("ldx %v", slot_index);
+
+ asm("ldy #0");
+L5:
+ asm("lda %v,y", uip_buf);
+ asm("sta %w,x", ETHDATA);
+ asm("iny");
+ asm("cpy %v", uip_len);
+ asm("bne %g", L5);
+
+ } else {
+
+ asm("ldx %v", slot_index);
+
+ asm("ldy #0");
+L6:
+ asm("lda %v,y", uip_buf);
+ asm("sta %w,x", ETHDATA);
+ asm("iny");
+ asm("cpy #%b", UIP_LLH_LEN + UIP_TCPIP_HLEN);
+ asm("bne %g", L6);
+
+ packet_length = uip_len - (UIP_LLH_LEN + UIP_TCPIP_HLEN);
+
+ asm("ldx %v", slot_index);
+
+ asm("lda %v", uip_appdata); /* uip_appdata is pointer */
+ asm("sta ptr1");
+ asm("lda %v+1", uip_appdata);
+ asm("sta ptr1+1");
+
+ asm("ldy #0");
+L7:
+ asm("lda (ptr1),y");
+ asm("sta %w,x", ETHDATA);
+ asm("iny");
+ asm("bne %g", L8);
+ asm("inc ptr1+1");
+L8:
+ asm("cpy %v", packet_length);
+ asm("bne %g", L7);
+ asm("dec %v+1", packet_length);
+ asm("bpl %g", L7);
+ }
+
+ asm("lda %v", packet_length);
+ asm("and #$01");
+ asm("beq %g", L9);
+
+ asm("lda #%%00100000");
+ asm("sta %w,x", ETHDATA); /* Control byte */
+
+ asm("lda #%%11000000"); /* ENQUEUE PACKET - transmit packet */
+ asm("sta %w,x", ETHMMUCR);
+ return;
+
+L9:
+ asm("lda #0");
+ asm("sta %w,x", ETHDATA); /* Fill byte */
+ asm("sta %w,x", ETHDATA); /* Control byte */
+
+ asm("lda #%%11000000"); /* ENQUEUE PACKET - transmit packet */
+ asm("sta %w,x", ETHMMUCR);
+}
+#pragma optimize(pop)
diff --git a/contiki-apple2/uip/lan91c96.h b/contiki-apple2/uip/lan91c96.h
new file mode 100644
index 0000000..494653c
--- /dev/null
+++ b/contiki-apple2/uip/lan91c96.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: lan91c96.h,v 1.1 2005/03/13 21:33:57 oliverschmidt Exp $
+ */
+
+#ifndef __LAN91C96_H__
+#define __LAN91C96_H__
+
+#include "uip_arch.h"
+
+void lan91c96_init(void);
+void lan91c96_send(void);
+u16_t lan91c96_poll(void);
+
+#endif /* __LAN91C96_H__ */
diff --git a/contiki-apple2/uip/lancegs-drv.c b/contiki-apple2/uip/lancegs-drv.c
new file mode 100644
index 0000000..e25c2d0
--- /dev/null
+++ b/contiki-apple2/uip/lancegs-drv.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: lancegs-drv.c,v 1.3 2005/05/13 00:01:56 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "packet-service.h"
+
+#include "lan91c96.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:80:0F is the OUI of Standard Microsystems, A2:A2 just means Apple2 */
+static const struct uip_eth_addr addr =
+ {{0x00,0x80,0x0f,0xa2,0xa2,0x00}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": LANceGS", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(lancegs_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ lan91c96_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ /* Don't overwrite LSB */
+ memcpy(&uip_ethaddr, &addr, 5);
+ lan91c96_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = lan91c96_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ lan91c96_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/lancegs-dsc.c b/contiki-apple2/uip/lancegs-dsc.c
new file mode 100644
index 0000000..80fa020
--- /dev/null
+++ b/contiki-apple2/uip/lancegs-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: lancegs-dsc.c,v 1.1 2005/05/06 22:34:58 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon lancegs_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+ "LANceGS driver",
+ "lancegs.drv",
+ lancegs_init,
+ &lancegs_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char lancegsicon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char lancegsicon_textmap[9] = {
+ 'L', 'A', 'N',
+ '\\', 'c', 'e',
+ 'G', 'S', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon lancegs_icon =
+ {CTK_ICON("LANceGS driver", lancegsicon_bitmap, lancegsicon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/uther-drv-asm.S b/contiki-apple2/uip/uther-drv-asm.S
new file mode 100644
index 0000000..69ccb8b
--- /dev/null
+++ b/contiki-apple2/uip/uther-drv-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------
+ .export _cs8900a_rxtxreg
+ .export _cs8900a_txcmd
+ .export _cs8900a_txlen
+ .export _cs8900a_packetpp
+ .export _cs8900a_ppdata
+
+
+;---------------------------------------------------------------------
+
+ _cs8900a_rxtxreg = $c080
+ _cs8900a_txcmd = $c084
+ _cs8900a_txlen = $c086
+ _cs8900a_packetpp = $c08a
+ _cs8900a_ppdata = $c08c
diff --git a/contiki-apple2/uip/uther-drv.c b/contiki-apple2/uip/uther-drv.c
new file mode 100644
index 0000000..d05e8b5
--- /dev/null
+++ b/contiki-apple2/uip/uther-drv.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2001-2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: uther-drv.c,v 1.2 2005/05/13 00:01:56 oliverschmidt Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "packet-service.h"
+
+#include "cs8900a.h"
+
+#include "uip_arp.h"
+
+static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
+
+/* 00:0E:3A is the OUI of Cirrus Logic, A2:A2 just means Apple2 */
+static const struct uip_eth_addr addr =
+ {{0x00,0x0e,0x3a,0xa2,0xa2,0x00}};
+
+static const struct packet_service_state state =
+ {
+ PACKET_SERVICE_VERSION,
+ output
+ };
+
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(proc, PACKET_SERVICE_NAME ": Uther", EK_PRIO_NORMAL,
+ eventhandler, pollhandler, (void *)&state);
+
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(uther_drv_init, arg)
+{
+ arg_free(arg);
+ ek_service_start(PACKET_SERVICE_NAME, &proc);
+}
+/*---------------------------------------------------------------------------*/
+static void
+output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
+{
+ uip_arp_out();
+ cs8900a_send();
+}
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+ switch(ev) {
+ case EK_EVENT_INIT:
+ case EK_EVENT_REPLACE:
+ /* Don't overwrite LSB */
+ memcpy(&uip_ethaddr, &addr, 5);
+ cs8900a_init();
+ break;
+ case EK_EVENT_REQUEST_REPLACE:
+ ek_replace((struct ek_proc *)data, NULL);
+ LOADER_UNLOAD();
+ break;
+ case EK_EVENT_REQUEST_EXIT:
+ ek_exit();
+ LOADER_UNLOAD();
+ break;
+ default:
+ break;
+ }
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
+
+ /* Poll Ethernet device to see if there is a frame avaliable. */
+ uip_len = cs8900a_poll();
+ if(uip_len > 0) {
+ /* A frame was avaliable (and is now read into the uip_buf), so
+ we process it. */
+ if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
+ uip_arp_ipin();
+ uip_len -= sizeof(struct uip_eth_hdr);
+ tcpip_input();
+ } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
+ uip_arp_arpin();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ cs8900a_send();
+ }
+ }
+ }
+
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-apple2/uip/uther-dsc.c b/contiki-apple2/uip/uther-dsc.c
new file mode 100644
index 0000000..f088268
--- /dev/null
+++ b/contiki-apple2/uip/uther-dsc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: uther-dsc.c,v 1.1 2005/05/06 22:34:58 oliverschmidt Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon uther_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(tfe_dsc,
+ "Uther driver",
+ "uther.drv",
+ uther_init,
+ &uther_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char uthericon_bitmap[3*3*8] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char uthericon_textmap[9] = {
+ '/', 'U', '\\',
+ 't', 'h', 'e',
+ '\\', 'r', '/'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+#if CTK_CONF_ICONS
+static struct ctk_icon uther_icon =
+ {CTK_ICON("Uther driver", uthericon_bitmap, uthericon_textmap)};
+#endif /* CTK_CONF_ICONS */
+/*-----------------------------------------------------------------------------------*/