Broke out code that can be used on many cc65 targets and put it in a separate directory
diff --git a/contiki-c64/Makefile b/contiki-c64/Makefile
index ae0c66c..d2d6ebc 100644
--- a/contiki-c64/Makefile
+++ b/contiki-c64/Makefile
@@ -30,10 +30,11 @@
 #
 # This file is part of the Contiki desktop environment
 #
-# $Id: Makefile,v 1.5 2003/04/18 00:14:13 adamdunkels Exp $
+# $Id: Makefile,v 1.6 2003/04/24 17:02:11 adamdunkels Exp $
 #
 
 CONTIKI=../contiki
+CONTIKICC65=../contiki-cc65
 
 usage:
 	@echo "Make sure the Contiki sources is in the directory $(CONTIKI)"
@@ -47,28 +48,16 @@
 	@echo '(Also check the Makefile for more targets to try...)'
 
 programs:
-	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.programs
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.programs
 tfe:
-	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.c64-tfe
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64-tfe
 rs232:
-	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.c64-rs232
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64-rs232
 rs232-conio:
-	$(MAKE) CONTIKI=$(CONTIKI) -f Makefile.c64-rs232-conio
+	$(MAKE) CONTIKI=$(CONTIKI) CONTIKICC65=$(CONTIKICC65) -f Makefile.c64-rs232-conio
 
-depend:
-	gcc -MM -D_CBM__ -D__C64__ -DCTK_HIRES -v \
-        -Iapps -Ictk -Iuip -Iconf \
-	-I$(CONTIKI)/lib -I$(CONTIKI)/ek \
-        -I$(CONTIKI)/ctk -I$(CONTIKI)/apps -I$(CONTIKI)/uip \
-        *.c */*.c $(CONTIKI)/*/*.c > Makefile.depend
-size:
-	od65 --dump-segsize *.o
-codesize:
-	od65 --dump-segsize *.o | egrep '\.o|CODE'
-clean:
-	rm -f *.o *~ *core contiki *.s *.prg contiki-labels
-d64:
-	c1541 -format contiki,64 d64 contiki.d64
-	c1541 -attach contiki.d64 -write contiki
-	c1541 -attach contiki.d64 -write about.prg -write email.prg -write memstat.prg -write netconf.prg -write processes.prg -write simpletelnet.prg -write www.prg -write calc.prg -write default.prg -write blueround.prg -write about.dsc -write netconf.dsc -write www.dsc -write dirload.prg
-	c1541 -attach contiki.d64 -list
\ No newline at end of file
+
+CCDEPFLAGS=-D__CBM__ -D__C64__ -DCTK_HIRES
+
+include $(CONTIKICC65)/Makefile.common
+
diff --git a/contiki-c64/Makefile.c64-rs232 b/contiki-c64/Makefile.c64-rs232
index e70f471..2469104 100644
--- a/contiki-c64/Makefile.c64-rs232
+++ b/contiki-c64/Makefile.c64-rs232
@@ -30,26 +30,22 @@
 #
 # This file is part of the Contiki desktop environment
 #
-# $Id: Makefile.c64-rs232,v 1.3 2003/04/18 00:14:13 adamdunkels Exp $
+# $Id: Makefile.c64-rs232,v 1.4 2003/04/24 17:02:10 adamdunkels Exp $
 #
 
 all: contiki contiki-labels.o
 
-include Makefile.common 
+SYS=c64
 
-CFLAGS:=$(CFLAGS) \
-        -DCTK_HIRES \
-        -DWITH_UIP -DWITH_RS232 -DWITH_LOADER_ARCH 
+include $(CONTIKICC65)/Makefile.common
 
-contiki-labels.o: contiki-labels.s
-	ca65 -o contiki-labels.o contiki-labels.s
-contiki-labels.s: contiki
-	./make-labels
+CFLAGS:=$(CFLAGSCOMMON) \
+        -DCTK_HIRES -DWITH_UIP -DWITH_RS232 -DWITH_LOADER_ARCH 
 
 contiki:  contiki-main.o petsciiconv.o \
  ctk.o ek.o dispatcher.o loader-arch.o \
  about-dsc.o netconf-dsc.o processes-dsc.o directory-dsc.o \
- fire.o ctk-mouse.o ctk-mouse-asm.o \
+ ctk-mouse.o ctk-mouse-asm.o \
  ctk-hires.o ctk-hires-asm.o ctk-hires-theme-default.o \
  $(UIP) rs232dev.o \
  program-handler.o
diff --git a/contiki-c64/Makefile.c64-rs232-conio b/contiki-c64/Makefile.c64-rs232-conio
index 18981ff..a272ef2 100644
--- a/contiki-c64/Makefile.c64-rs232-conio
+++ b/contiki-c64/Makefile.c64-rs232-conio
@@ -30,7 +30,7 @@
 #
 # This file is part of the Contiki desktop environment
 #
-# $Id: Makefile.c64-rs232-conio,v 1.2 2003/04/08 19:10:12 adamdunkels Exp $
+# $Id: Makefile.c64-rs232-conio,v 1.3 2003/04/24 17:02:11 adamdunkels Exp $
 #
 
 all: contiki contiki-labels.o
@@ -39,8 +39,7 @@
 
 CFLAGS:=$(CFLAGS) \
         -DCTK_CONIO \
-        -DWITH_UIP -DWITH_RS232 -DWITH_LOADER_ARCH \
-	-DWITH_WWW -DWITH_TELNET
+        -DWITH_UIP -DWITH_RS232 -DWITH_LOADER_ARCH 
 
 contiki-labels.o: contiki-labels.s
 	ca65 -o contiki-labels.o contiki-labels.s
@@ -53,5 +52,5 @@
  fire.o \
  $(CTK_CONIO) \
  $(UIP) rs232dev.o \
- program-loader.o
+ program-handler.o
 	cl65 -C c64.cfg -Ln contiki-labels -o contiki -t $(SYS) $^
diff --git a/contiki-c64/apps/directory-dsc.c b/contiki-c64/apps/directory-dsc.c
deleted file mode 100644
index 3c1496a..0000000
--- a/contiki-c64/apps/directory-dsc.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2003, Adam Dunkels.
- * All rights reserved. 
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution. 
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.  
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
- *
- * This file is part of the Contiki desktop environment
- *
- * $Id: directory-dsc.c,v 1.1 2003/04/18 00:10:47 adamdunkels Exp $
- *
- */
-
-#include "dsc.h"
-
-extern struct ctk_icon directory_icon;
-/*-----------------------------------------------------------------------------------*/
-DSC(directory_dsc,
-    "Directory reader",
-    "directory.prg",
-    directory_init,
-    &directory_icon);
-/*-----------------------------------------------------------------------------------*/
-static unsigned char directoryicon_bitmap[3*3*8] = {
-  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
-  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
-  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
-
-  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
-  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
-  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
-
-  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
-  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
-  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
-};
-
-static char directoryicon_textmap[9] = {
-  '+', '-', '+',
-  '|', 'o', '|',
-  '+', '-', '+'
-};
-
-static struct ctk_icon directory_icon =
-  {CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
-/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-c64/apps/directory-dsc.h b/contiki-c64/apps/directory-dsc.h
deleted file mode 100644
index fb0a1a6..0000000
--- a/contiki-c64/apps/directory-dsc.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2003, Adam Dunkels.
- * All rights reserved. 
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution. 
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.  
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
- *
- * This file is part of the Contiki desktop environment
- *
- * $Id: directory-dsc.h,v 1.1 2003/04/18 00:10:47 adamdunkels Exp $
- *
- */
-#ifndef __DIRECTORY_DSC_H__
-#define __DIRECTORY_DSC_H__
-
-#include "dsc.h"
-
-DSC_HEADER(directory_dsc);
-
-#endif /* __DIRECTORY_DSC_H__ */
diff --git a/contiki-c64/apps/directory.c b/contiki-c64/apps/directory.c
deleted file mode 100644
index bec8e00..0000000
--- a/contiki-c64/apps/directory.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * 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: directory.c,v 1.1 2003/04/18 00:10:47 adamdunkels Exp $
- *
- */
-
-#include <stdlib.h>
-#include <cbm.h>
-#include <string.h>
-
-#include "ctk.h"
-#include "dispatcher.h"
-#include "loader.h"
-
-#include "program-handler.h"
-
-#define MAX_NUMFILES 20
-
-static struct dsc *dscs[MAX_NUMFILES];
-
-static struct ctk_window window;
-
-static struct ctk_button filenames[MAX_NUMFILES];
-
-static struct ctk_bitmap icon =
-  {CTK_BITMAP(0, 0, 3, 3, "")};
-static struct ctk_label description =
-  {CTK_LABEL(4, 1, 32, 1, "")};
-
-static DISPATCHER_SIGHANDLER(directory_sighandler, s, data);
-static struct dispatcher_proc p =
-  {DISPATCHER_PROC("Directory browser", NULL, directory_sighandler, NULL)};
-static ek_id_t id;
-
-/*-----------------------------------------------------------------------------------*/
-static struct cbm_dirent dirent;
-/*-----------------------------------------------------------------------------------*/
-static void
-show_statustext(char *text)
-{
-  ctk_label_set_text(&description, text);
-  CTK_WIDGET_REDRAW(&description);
-}
-/*-----------------------------------------------------------------------------------*/
-#define LFN 9
-static void
-loaddirectory(void)
-{
-  unsigned char i;
-  
-  if(cbm_opendir(LFN, 8) != 0) {
-    show_statustext("cbm_opendir error");
-  } else {
-    i = 0;
-    while(cbm_readdir(LFN, &dirent) == 0) {
-      if(strcmp(&dirent.name[strlen(dirent.name) - 4], ".dsc") == 0) {
-	dscs[i] = LOADER_LOAD_DSC(dirent.name);
-	if(dscs[i] != NULL) {
-	  ++i;
-	}
-	if(i >= MAX_NUMFILES) {
-	  break;
-	}
-      }
-    }
-    cbm_closedir(LFN);
-  }
-}
-/*-----------------------------------------------------------------------------------*/
-static void
-makewindow(void)
-{
-  unsigned char i, x, y;
-
-  ctk_window_clear(&window);
-  CTK_WIDGET_ADD(&window, &description);
-  CTK_WIDGET_ADD(&window, &icon);
-
-  x = 0; y = 5;
-  for(i = 0; dscs[i] != NULL; ++i) {
-    CTK_BUTTON_NEW(&filenames[i], x, y, strlen(dscs[i]->prgname),
-		   dscs[i]->prgname);
-    CTK_WIDGET_ADD(&window, &filenames[i]);
-
-    x += 18;
-    if(x == 36) {
-      x = 0;
-      ++y;
-    }
-  }
-
-  if(i > 0) {
-    CTK_WIDGET_FOCUS(&window, &filenames[0]);
-    show_statustext(dscs[0]->description);
-    if(dscs[0]->icon->bitmap != NULL) {
-      ctk_bitmap_set_bitmap(&icon, dscs[0]->icon->bitmap);
-      CTK_WIDGET_REDRAW(&icon);
-    }
-  }
-    
-}
-/*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(directory_init)
-{
-  if(id == EK_ID_NONE) {
-    id = dispatcher_start(&p);
-    
-    ctk_window_new(&window, 36, 16, "Directory browser");
-
-    loaddirectory();
-    makewindow();
-    
-    dispatcher_listen(ctk_signal_widget_activate);
-    dispatcher_listen(ctk_signal_widget_select);
-    dispatcher_listen(ctk_signal_window_close);
-  }
-  ctk_window_open(&window);
-}
-/*-----------------------------------------------------------------------------------*/
-static void
-quit(void)
-{
-  unsigned char i;
-
-  ctk_window_close(&window);
-  for(i = 0; dscs[i] != NULL; ++i) {
-    LOADER_UNLOAD_DSC(dscs[i]);
-  }
-  dispatcher_exit(&p);
-  id = EK_ID_NONE;
-  LOADER_UNLOAD();
-}
-/*-----------------------------------------------------------------------------------*/
-static
-DISPATCHER_SIGHANDLER(directory_sighandler, s, data)
-{
-  unsigned char i;
-  DISPATCHER_SIGHANDLER_ARGS(s, data);
-  
-  if(s == ctk_signal_widget_activate) {
-    for(i = 0; dscs[i] != NULL; ++i) {
-      if(data == (ek_data_t)&filenames[i]) {
-	program_handler_load(dscs[i]->prgname);
-	quit();
-	break;
-      }
-    }
-  } else if(s == ctk_signal_widget_select) {
-    for(i = 0; dscs[i] != NULL; ++i) {
-      if(data == (ek_data_t)&filenames[i]) {
-	show_statustext(dscs[i]->description);
-	if(dscs[i]->icon->bitmap != NULL) {
-	  ctk_bitmap_set_bitmap(&icon, dscs[i]->icon->bitmap);
-	  CTK_WIDGET_REDRAW(&icon);
-	}
-	break;
-      }
-    }
-  } else if(s == ctk_signal_window_close &&
-	    data == (ek_data_t)&window) {
-    quit();
-  }
-}
-/*-----------------------------------------------------------------------------------*/