diff -ruN pforth.orig/Makefile pforth/Makefile
--- pforth.orig/Makefile	Thu Jan  1 01:00:00 1970
+++ pforth/Makefile	Sat Jul 20 00:58:19 2002
@@ -0,0 +1,89 @@
+# @(#) rlsMakefile 97/12/10 1.1
+# makefile for pForth
+# Portable Forth written in 'C'
+# Phil Burk
+
+.SUFFIXES: .c .o
+
+# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
+# See "docs/pf_ref.htm" file for more info.
+
+SOURCEDIR = csrc
+OBJECTDIR = objects
+EMBOBJECTDIR = embobjects
+
+FULL_WARNINGS =  -Os \
+        -fsigned-char \
+        -fno-builtin \
+        -fno-unroll-loops \
+        -fpeephole \
+        -fno-keep-inline-functions \
+        -Wcast-qual \
+        -Wall -Wno-unused \
+        -Wwrite-strings \
+        -Winline  \
+        -Wmissing-prototypes \
+        -Wmissing-declarations
+        
+CCOPTS = -DPF_SUPPORT_FP $(FULL_WARNINGS)
+COMPILER = gcc
+XCOMPILER = arm-agb-elf-gcc -mthumb
+
+EMBCCOPTS = -DPF_NO_INIT -DPF_USER_FILEIO=\"user_fileio.h\" \
+    -DPF_NO_CLIB -DPF_STATIC_DIC -DPF_USER_CHARIO=\"user_chario.h\" #-DPF_GBA_MULTIBOOT
+
+#######################################
+# Build file lists from wildcards.
+PFITEMP    = ${wildcard ${SOURCEDIR}/*.h}
+PFINCLUDES = ${PFITEMP:${SOURCEDIR}/pfdicdat.h=}
+PFSOURCE   = ${wildcard ${SOURCEDIR}/*.c}
+PFTEMP     = ${PFSOURCE:%.c=%.o}
+PFOBJS     = ${PFTEMP:${SOURCEDIR}/%=${OBJECTDIR}/%}
+PFEMBOBJS  = ${PFTEMP:${SOURCEDIR}/%=${EMBOBJECTDIR}/%}
+
+COMPILE = $(COMPILER) $(CCOPTS) $(CDEFS)
+XCOMPILE = $(XCOMPILER) $(CCOPTS) $(CDEFS)
+
+${OBJECTDIR}/%.o:  $(PFINCLUDES)  ${SOURCEDIR}/%.c
+	$(COMPILE) -o ${OBJECTDIR}/$*.o -c ${SOURCEDIR}/$*.c
+	
+${EMBOBJECTDIR}/%.o:  $(PFINCLUDES) ${SOURCEDIR}/%.c ${SOURCEDIR}/pfdicdat.h 
+	$(XCOMPILE) -o ${EMBOBJECTDIR}/$*.o -c ${SOURCEDIR}/$*.c $(EMBCCOPTS)
+
+all: pforth pforth.dic
+
+pffiles:
+	echo "ITEMP FILES -----------------"
+	echo ${PFITEMP}
+	echo "INCLUDE FILES -----------------"
+	echo ${PFINCLUDES}
+	echo "'C' FILES ---------------------"
+	echo ${PFSOURCE}
+	echo "OBJECT FILES ------------------"
+	echo ${PFOBJS}
+	echo "EMBEDDED OBJECT FILES ------------------"
+	echo ${PFEMBOBJS}
+	
+# build pforth by compiling 'C' source
+pforth: $(PFINCLUDES) $(PFOBJS)
+	$(COMPILER) $(PFOBJS) -lm -o pforth
+
+# build basic dictionary by running newly built pforth and including system.fth
+pforth.dic: pforth
+	./pforth -i system.fth
+
+${SOURCEDIR}/pfdicdat.h: pforth pforth.dic
+	@(echo 'INCLUDE utils/savedicd.fth'; \
+          echo 'SDAD';         \
+          echo 'bye')                                 | \
+	./pforth -dpforth.dic
+	cp pfdicdat.h ${SOURCEDIR}
+
+
+pfemb: $(PFINCLUDES) $(PFEMBOBJS)
+	$(XCOMPILER) $(PFEMBOBJS) -lm -o pfemb
+	objcopy -O binary pfemb pfemb.bin
+	
+clean:
+	rm -f $(PFOBJS) $(PFEMBOBJS) pforth *.dic core ${SOURCEDIR}/pfdicdat.h pfemb
+
diff -ruN pforth.orig/csrc/mbv2lib.c pforth/csrc/mbv2lib.c
--- pforth.orig/csrc/mbv2lib.c	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/mbv2lib.c	Tue Jul 16 01:00:21 2002
@@ -0,0 +1,379 @@
+#include <stdio.h>
+#include "mbv2lib.h"
+//
+// v1.41 - Put received keyboard & file data in separate buffers
+//
+//  MB v1.41 or later pc software is required to use this library
+// software.
+//
+// NOTE: THIS LIBRARY USES GLOBAL INITIALIZED DATA SO YOU MUST USE
+// A CRT0.S AND A LINKER SCRIPT THAT SUPPORTS THIS AS WELL. GET
+// CRTLS V1.1 OR LATER FROM HTTP://www.devrs.com/gba FOR PROPER SUPPORT.
+//
+// The following library functions are supported:
+//
+// Library name   Standard Name      Function
+//   dprintf        printf       Print a string on PC console.
+//   dputchar       putchar      Print a char on PC console.
+//   dgetch         getch        Get a char from PC keyboard.
+//   dkbhit         kbhit        Return 1 if PC keyboard char is ready.
+//
+//   dfopen         fopen        Open PC file.
+//   dfclose        fclose       Close PC file.
+//   dfprintf       fprintf      Print a string to PC file.
+//   dfgetc         fgetc        Get char from PC file.
+//   dfputc         fputc        Write a char to PC file.
+//   drewind        rewind       Set file pointer to start of file.
+//
+// If you wish to use the standard naming conventions
+// rather than the library names then change "__ANSI_NAMES 0"
+// to "__ANSI_NAMES 1" instead.
+//
+// Notes:
+//
+//  Currently only ONE file may be open at a time.
+//
+//  If you are sending raw binary data to a PC file, use
+//  dfputc instead of dfprintf. Dfprintf will insert
+//  carriage return characters before linefeed characters
+//  on the PC side if the PC console software is running on
+//  dos/windows for proper text formatting.
+//
+//  If you are missing some .h files during compile than get
+// 'arminc.zip' from http://www.devrs.com/gba in the
+//  Apps / C Compilers section.
+//
+// Example command line:
+//    mb -s file.mb -c -w 50 -x 255 -m
+//
+//  In this example, after transferring "file.mb" to the GBA,
+// the PC goes into console/file server mode (-c) and also
+// shows all of the file open/file close/fgetc/fputc commands
+// (-m) on screen. The -w value should be a large enough value
+// where the -s is reliable and the -x value should be a large
+// enough value where the -c is reliable with the GBA.
+//
+//      [Sending a file & console mode each have
+//       their own delay settings because they
+//       each use a different method for transferring
+//       data. Each method is about ideal for it's
+//       application.]
+//
+// Example GBA Code:
+//
+//  #include "mbv2lib.c"
+//
+//  int main (void)
+//    {
+//
+//    int i,j,k;
+//    FILE* fp;
+//
+//    dprintf ("Hello world!");
+//
+//    // Get character from PC keyboard
+//    i = dgetch ();
+//
+//    // Copy SRAM to PC
+//    fp = dfopen("sram.bin","wb");
+//    for (i = 0; i != 0x8000; i++)
+//       dfputc(*(unsigned char *)(i + 0xE000000), fp);
+//    dfclose(fp);
+//
+//    // Read data from file
+//    fp = dfopen ("foo.bin", "rb");
+//    i = dfgetc (fp);
+//    j = dfgetc (fp);
+//    k = dfgetc (fp);
+//    dfclose (fp);
+//
+//    }
+
+// Data transfer format
+// --------------------
+//
+// PC -> GBA Comms:
+// Raw data is PC File read data.
+// ESCCHR 0x00 = nada (used for input polling)
+// ESCCHR 0x01 = Escape character from PC file read
+// ESCCHR 0x08 0x?? = Keyboard read data
+//
+//
+// GBA -> PC comms
+// Raw data is console print data.
+// ESCCHR = escape sequence
+// ESCCHR 0x00 = nada (used for input polling)
+// ESCCHR 0x01 = Escape character for console print
+// ESCCHR 0x02 = file open (gba -> PC)
+// ESCCHR 0x03 = file close (gba -> PC)
+// ESCCHR 0x04 = fgetc (gba -> PC)
+// ESCCHR 0x05 0x?? = fputc (gba -> PC)
+// ESCCHR 0x06 = rewind (gba -> PC)
+// ESCCHR 0x07 = fputc processed (gba -> pC) (Add CR before LF char if win/DOS machine)
+
+// Uncomment the following line to define the following types if needed
+#define INC_SHORT_NAME_TYPES 1
+
+#ifdef INC_SHORT_NAME_TYPES
+ typedef     volatile unsigned char           vu8;
+ typedef     volatile unsigned short int      vu16;
+ typedef     volatile unsigned int            vu32;
+ typedef     volatile unsigned long long int  vu64;
+
+ typedef     unsigned char           u8;
+ typedef     unsigned short int      u16;
+ typedef     unsigned int            u32;
+ typedef     unsigned long long int  u64;
+
+ typedef     signed char             s8;
+ typedef     signed short int        s16;
+ typedef     signed int              s32;
+ typedef     signed long long int    s64;
+#endif
+
+#define INC_REG_DEFS
+#ifdef INC_REG_DEFS
+ #define REG_BASE        0x4000000
+ #define REG_SIOCNT      (REG_BASE + 0x128)  // Serial Communication Control
+ #define REG_SIODATA8    (REG_BASE + 0x12a)  // 8bit Serial Communication Data
+ #define REG_RCNT        (REG_BASE + 0x134)  // General Input/Output Control
+#endif
+
+#define __FINBUFSIZE 256  //Must be a multiple of 2! (ex: 32,64,128,256,512..)
+#define __KINBUFSIZE 64   //Must be a multiple of 2! (ex: 32,64,128,256,512..)
+#define __ESCCHR 27
+
+#define __ESC_NADA   0
+#define __ESC_ESCCHR 1
+#define __ESC_FOPEN  2
+#define __ESC_FCLOSE 3
+#define __ESC_FGETC  4
+#define __ESC_FPUTC  5
+#define __ESC_REWIND 6
+#define __ESC_FPUTC_PROCESSED 7         // PC side add CR before LF if DOS machine
+#define __ESC_KBDCHR 8
+
+#define FILEHANDLE (0xdeadd00d)	// This is less likely to clash with stdout/stderr than 1
+
+unsigned char __outstr[__DOUTBUFSIZE];
+unsigned char __finstr[__FINBUFSIZE];
+unsigned char __kinstr[__KINBUFSIZE];
+int finptr = 0;
+int foutptr = 0;
+int kinptr = 0;
+int koutptr = 0;
+
+int __debug_shutup=0;
+
+int __dputchar (int c)
+{
+if(!__debug_shutup)
+   {
+   int rcv;
+   static int LastChar = 0;
+   static int KbdCharNext = 0;
+
+   // Set non-general purpose comms mode
+   *(u16 *)REG_RCNT = 0;
+
+   // Init normal comms, 8 bit transfer, receive clocking
+   *(u16 *)REG_SIODATA8 = c;
+   *(u16 *)REG_SIOCNT = 0x80;
+
+   // Wait until transfer is complete
+   while (*(vu16 *)REG_SIOCNT & 0x80) {}
+
+   // Wait until SC is low
+   while (*(vu16 *)REG_RCNT & 1) {}
+
+   // Force SD high
+   *(u16 *)REG_RCNT = 0x8022;
+
+   // Wait until SC is high
+   while ((*(vu16 *)REG_RCNT & 1)==0) {}
+
+   rcv = *(vu16 *)REG_SIODATA8;
+
+   if (KbdCharNext)
+      {
+      // Put into keyboard buffer
+      __kinstr[kinptr++] = rcv;
+      kinptr &= (__KINBUFSIZE-1);
+
+      KbdCharNext = 0;
+
+      // Make received char look like a NADA character
+      // so that it won't be buffered elsewhere.
+      LastChar = __ESCCHR;
+      rcv = __ESC_NADA;
+      }
+
+   if (LastChar == __ESCCHR)
+      {
+      // Process escape character
+      switch (rcv)
+         {
+         case __ESC_ESCCHR:
+            __finstr[finptr++] = __ESCCHR;
+            finptr &= (__FINBUFSIZE-1);
+            break;
+         case __ESC_KBDCHR:
+            KbdCharNext = 1;
+            break;
+         }
+      LastChar = 0;
+      }
+   else
+      {
+      if (rcv == __ESCCHR)
+         LastChar = __ESCCHR;
+      else
+         {
+         // If char received from PC then save in receive FIFO
+         __finstr[finptr++] = rcv;
+         finptr &= (__FINBUFSIZE-1);
+         }
+      }
+   return(1);
+   } else return 0;
+}
+
+int dputchar (int c)
+   {
+   (void) __dputchar(c);
+   if (c == __ESCCHR)
+      (void) __dputchar(__ESC_ESCCHR);
+   return (1);
+   }
+
+void __PrintStr (unsigned char *str)
+   {
+   while (*str)
+      (void) dputchar(*str++);
+   }
+
+int dgetch (void)
+   {
+   int c;
+
+   // If no character is in FIFO then wait for one.
+   while (kinptr == koutptr)
+      {
+      __dputchar(__ESCCHR);
+      __dputchar(__ESC_NADA);
+      }
+
+   c = __kinstr[koutptr++];
+   koutptr &= (__KINBUFSIZE-1);
+
+   return (c);
+   }
+
+int dfgetch (void)
+   {
+   int c;
+
+   // If no character is in FIFO then wait for one.
+   while (finptr == foutptr)
+      {
+      __dputchar(__ESCCHR);
+      __dputchar(__ESC_NADA);
+      }
+
+   c = __finstr[foutptr++];
+   foutptr &= (__FINBUFSIZE-1);
+
+   return (c);
+   }
+
+int dfread (void* ptr, size_t size, size_t nmemb, FILE* stream)
+{
+	int i;
+	for(i=0;i<size*nmemb;i++)
+		*((unsigned char*)ptr+i)=dfgetc(stream);
+	return nmemb;
+}		
+
+char* dfgets (void* ptr, size_t size, FILE* stream)
+{
+	int i;
+	for(i=0;i<size;i++)
+		*((unsigned char*)ptr+i)=dfgetc(stream);
+	return (char*)ptr;
+}
+
+int dfwrite (const void* ptr, size_t size, size_t nmemb, FILE* stream)
+{
+	int i;
+	for(i=0;i<size*nmemb;i++)
+		dfputc(*((unsigned char*)ptr+i),stream);
+	return nmemb;
+}
+
+int dkbhit (void)
+   {
+   return(kinptr != koutptr);
+   }
+
+FILE* dfopen (const unsigned char *file, const unsigned char *type)
+   {
+   __dputchar(__ESCCHR);
+   __dputchar(__ESC_FOPEN);
+
+   while (*file)
+      (void) dputchar(*file++);
+   dputchar(0);
+
+   while (*type)
+      (void) dputchar(*type++);
+   dputchar(0);
+
+   return((int*)FILEHANDLE);
+   }
+
+int dfclose (FILE* fp)
+   {
+   __dputchar(__ESCCHR);
+   __dputchar(__ESC_FCLOSE);
+
+   return(1);
+   }
+
+int dfgetc (FILE* fp)
+   {
+   __dputchar(__ESCCHR);
+   __dputchar(__ESC_FGETC);
+
+   return(dfgetch());
+   }
+
+int dfputc (int ch, FILE* fp)
+   {
+   __dputchar(__ESCCHR);
+   __dputchar(__ESC_FPUTC);
+
+   dputchar(ch);
+
+   return(1);
+   }
+
+void drewind (FILE* fp)
+   {
+   __dputchar(__ESCCHR);
+   __dputchar(__ESC_REWIND);
+   }
+
+void __PrintStrToFile (FILE* fp, unsigned char *str)
+   {
+   if(fp == (int*)stdout || fp == (int*)stderr)
+   	__PrintStr(str);
+   else
+	   while (*str)
+	      {
+	      __dputchar(__ESCCHR);
+	      __dputchar(__ESC_FPUTC_PROCESSED);
+
+	      dputchar(*str++);
+	      }
+   }
+
diff -ruN pforth.orig/csrc/mbv2lib.h pforth/csrc/mbv2lib.h
--- pforth.orig/csrc/mbv2lib.h	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/mbv2lib.h	Sat Jul 20 00:10:37 2002
@@ -0,0 +1,162 @@
+//#define __ANSI_NAMES 1
+//
+// v1.41 - Put received keyboard & file data in separate buffers
+//
+//  MB v1.41 or later pc software is required to use this library
+// software.
+//
+// NOTE: THIS LIBRARY USES GLOBAL INITIALIZED DATA SO YOU MUST USE
+// A CRT0.S AND A LINKER SCRIPT THAT SUPPORTS THIS AS WELL. GET
+// CRTLS V1.1 OR LATER FROM HTTP://www.devrs.com/gba FOR PROPER SUPPORT.
+//
+// The following library functions are supported:
+//
+// Library name   Standard Name      Function
+//   dprintf        printf       Print a string on PC console.
+//   dputchar       putchar      Print a char on PC console.
+//   dgetch         getch        Get a char from PC keyboard.
+//   dkbhit         kbhit        Return 1 if PC keyboard char is ready.
+//
+//   dfopen         fopen        Open PC file.
+//   dfclose        fclose       Close PC file.
+//   dfprintf       fprintf      Print a string to PC file.
+//   dfgetc         fgetc        Get char from PC file.
+//   dfputc         fputc        Write a char to PC file.
+//   drewind        rewind       Set file pointer to start of file.
+//
+// If you wish to use the standard naming conventions
+// rather than the library names then change "__ANSI_NAMES 0"
+// to "__ANSI_NAMES 1" instead.
+//
+// Notes:
+//
+//  Currently only ONE file may be open at a time.
+//
+//  If you are sending raw binary data to a PC file, use
+//  dfputc instead of dfprintf. Dfprintf will insert
+//  carriage return characters before linefeed characters
+//  on the PC side if the PC console software is running on
+//  dos/windows for proper text formatting.
+//
+//  If you are missing some .h files during compile than get
+// 'arminc.zip' from http://www.devrs.com/gba in the
+//  Apps / C Compilers section.
+//
+// Example command line:
+//    mb -s file.mb -c -w 50 -x 255 -m
+//
+//  In this example, after transferring "file.mb" to the GBA,
+// the PC goes into console/file server mode (-c) and also
+// shows all of the file open/file close/fgetc/fputc commands
+// (-m) on screen. The -w value should be a large enough value
+// where the -s is reliable and the -x value should be a large
+// enough value where the -c is reliable with the GBA.
+//
+//      [Sending a file & console mode each have
+//       their own delay settings because they
+//       each use a different method for transferring
+//       data. Each method is about ideal for it's
+//       application.]
+//
+// Example GBA Code:
+//
+//  #include "mbv2lib.c"
+//
+//  int main (void)
+//    {
+//
+//    int i,j,k;
+//    FILE* fp;
+//
+//    dprintf ("Hello world!");
+//
+//    // Get character from PC keyboard
+//    i = dgetch ();
+//
+//    // Copy SRAM to PC
+//    fp = dfopen("sram.bin","wb");
+//    for (i = 0; i != 0x8000; i++)
+//       dfputc(*(unsigned char *)(i + 0xE000000), fp);
+//    dfclose(fp);
+//
+//    // Read data from file
+//    fp = dfopen ("foo.bin", "rb");
+//    i = dfgetc (fp);
+//    j = dfgetc (fp);
+//    k = dfgetc (fp);
+//    dfclose (fp);
+//
+//    }
+
+// Data transfer format
+// --------------------
+//
+// PC -> GBA Comms:
+// Raw data is PC File read data.
+// ESCCHR 0x00 = nada (used for input polling)
+// ESCCHR 0x01 = Escape character from PC file read
+// ESCCHR 0x08 0x?? = Keyboard read data
+//
+//
+// GBA -> PC comms
+// Raw data is console print data.
+// ESCCHR = escape sequence
+// ESCCHR 0x00 = nada (used for input polling)
+// ESCCHR 0x01 = Escape character for console print
+// ESCCHR 0x02 = file open (gba -> PC)
+// ESCCHR 0x03 = file close (gba -> PC)
+// ESCCHR 0x04 = fgetc (gba -> PC)
+// ESCCHR 0x05 0x?? = fputc (gba -> PC)
+// ESCCHR 0x06 = rewind (gba -> PC)
+// ESCCHR 0x07 = fputc processed (gba -> pC) (Add CR before LF char if win/DOS machine)
+
+#define FILE int
+
+#include "vsprintf.h"
+
+extern int __debug_shutup;
+
+#define __DOUTBUFSIZE 256
+extern unsigned char __outstr[__DOUTBUFSIZE];
+
+extern int dputchar (int c);
+
+extern void __PrintStr (unsigned char *str);
+
+extern int dgetch (void);
+
+extern int dfgetch (void);
+
+extern int dkbhit (void);
+
+extern FILE* dfopen (const unsigned char *file, const unsigned char *type);
+
+extern int dfclose (FILE* fp);
+
+extern int dfgetc (FILE* fp);
+
+extern int dfputc (int ch, FILE* fp);
+
+extern void drewind (FILE* fp);
+
+extern void __PrintStrToFile (FILE* fp, unsigned char *str);
+
+#define dprintf(x...) ({ dsprintf(__outstr, x); __PrintStr(__outstr); })
+#define dfprintf(y,x...) ({ dsprintf(__outstr, x); __PrintStrToFile((FILE*)y,__outstr); })
+
+#ifdef __ANSI_NAMES
+  #define printf  dprintf
+  #define fprintf dfprintf
+  #define putchar dputchar
+  #define getch   dgetch
+  #define kbhit   dkbhit
+
+  #define fopen   dfopen
+  #define fclose  dfclose
+  #define fgetc   dfgetc
+  #define fputc   dfputc
+  #define rewind  drewind
+  #define fread	  dfread
+  #define fwrite  dfwrite
+  #define fgets   dfgets
+#endif
diff -ruN pforth.orig/csrc/pf_clib.c pforth/csrc/pf_clib.c
--- pforth.orig/csrc/pf_clib.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pf_clib.c	Tue Jul 16 00:47:30 2002
@@ -37,7 +37,7 @@
 /*    void *memset (void *s, int32 c, size_t n); */
 void *pfSetMemory( void *s, cell c, cell n )
 {
-	uint8 *p = s, byt = (uint8) c;
+	uint8 *p = (uint8*)s, byt = (uint8) c;
 	while( (n--) > 0) *p++ = byt;
 	return s;
 }
@@ -45,8 +45,8 @@
 /*  void *memccpy (void *s1, const void *s2, int32 c, size_t n); */
 void *pfCopyMemory( void *s1, const void *s2, cell n)
 {
-	uint8 *p1 = s1;
-	const uint8 *p2 = s2;
+	uint8 *p1 = (uint8*)s1;
+	const uint8 *p2 = (const uint8*)s2;
 	while( (n--) > 0) *p1++ = *p2++;
 	return s1;
 }
diff -ruN pforth.orig/csrc/pf_core.c pforth/csrc/pf_core.c
--- pforth.orig/csrc/pf_core.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pf_core.c	Tue Jul 16 00:56:42 2002
@@ -34,6 +34,7 @@
 ***************************************************************/
 
 #include "pf_all.h"
+#include <malloc.h>
  
 /***************************************************************
 ** Global Data
diff -ruN pforth.orig/csrc/pf_inner.c pforth/csrc/pf_inner.c
--- pforth.orig/csrc/pf_inner.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pf_inner.c	Tue Jul 16 00:56:59 2002
@@ -27,6 +27,7 @@
 ***************************************************************/
 
 #include "pf_all.h"
+#include <malloc.h>
 
 #define SYSTEM_LOAD_FILE "system.fth"
 
diff -ruN pforth.orig/csrc/pf_main.c pforth/csrc/pf_main.c
--- pforth.orig/csrc/pf_main.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pf_main.c	Sat Jul 20 01:09:56 2002
@@ -1,3 +1,6 @@
+#ifdef PF_GBA_MULTIBOOT
+volatile const unsigned char __gba_multiboot;
+#endif
 /* @(#) pf_main.c 98/01/26 1.2 */
 /***************************************************************
 ** Forth based on 'C'
@@ -40,6 +43,8 @@
 #define FALSE (0)
 #endif
 
+#include "mbv2lib.h"
+
 int main( int argc, char **argv )
 {
 	const char *DicName = "pforth.dic";
@@ -54,6 +59,10 @@
 	argc = ccommand(&argv);
 	#endif
 
+#ifdef PF_NO_CLIB
+	argc=1;	/* this should not be necessary with devkitadv >= r5 */
+#endif
+
 /* Parse command line. */
 	for( i=1; i<argc; i++ )
 	{
diff -ruN pforth.orig/csrc/pf_mem.c pforth/csrc/pf_mem.c
--- pforth.orig/csrc/pf_mem.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pf_mem.c	Tue Jul 16 00:49:17 2002
@@ -253,7 +253,7 @@
 	int32 AlignedSize;
 
 /* Set globals. */
-	gMemPoolPtr = addr;
+	gMemPoolPtr = (char*)addr;
 	gMemPoolSize = poolSize;
 	
 	dllSetupList( &gMemList );
diff -ruN pforth.orig/csrc/pfcustom.c pforth/csrc/pfcustom.c
--- pforth.orig/csrc/pfcustom.c	Tue Apr  7 20:04:26 1998
+++ pforth/csrc/pfcustom.c	Tue Jul 16 00:11:11 2002
@@ -80,8 +80,8 @@
 
 void *CustomFunctionTable[] =
 {
-	CTest0,
-	CTest1
+	(void*)CTest0,
+	(void*)CTest1
 };	
 #endif
 
diff -ruN pforth.orig/csrc/user_chario.h pforth/csrc/user_chario.h
--- pforth.orig/csrc/user_chario.h	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/user_chario.h	Sat Jul 20 01:05:28 2002
@@ -0,0 +1,7 @@
+#include "mbv2lib.h"
+
+#define sdTerminalOut dputchar
+#define sdTerminalIn dgetch
+
+static inline int sdTerminalFlush() { return 0 ; }
+static inline int sdQueryTerminal() { return 0 ; }
diff -ruN pforth.orig/csrc/user_fileio.h pforth/csrc/user_fileio.h
--- pforth.orig/csrc/user_fileio.h	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/user_fileio.h	Sat Jul 20 00:51:52 2002
@@ -0,0 +1,93 @@
+#include "mbv2lib.h"
+
+#include <errno.h>
+
+#define PF_SEEK_SET 1
+#define PF_SEEK_CUR 2
+#define PF_SEEK_END 3
+
+typedef FILE FileStream;
+
+#define PF_STDIN (0)
+#define PF_STDOUT (1)
+
+#define sdOpenFile dfopen
+#if 0
+static FILE* sdOpenFile (const unsigned char *file, const unsigned char *type)
+{
+	FILE* bla;
+	dprintf("file %s type %s\n",file,type);
+	bla=dfopen(file,type);
+	dprintf("dfopened\n");
+	return bla;
+}
+#endif
+
+#define sdFlushFile
+#if 0
+static int sdFlushFile(FILE* stream)
+{
+	dfprintf("flushing %d\n",stream);
+	return 0;
+}
+#endif
+
+#define sdReadFile dfread
+#if 0
+static int sdReadFile(void* ptr, int size, int nmemb, FILE* stream)
+{
+	int i;
+	dprintf("read ptr %x size %d nmemb %d, str %d\n",(unsigned int)ptr,size,nmemb,stream);
+	return dfread(ptr,size,nmemb,stream);
+}
+#endif
+
+#define sdWriteFile dfwrite
+#if 0
+static int sdWriteFile(const void* ptr, int size, int nmemb, FILE* stream)
+{
+	int i;
+	dprintf("write ptr %x size %d nmemb %d, str %d\n",(unsigned int)ptr,size,nmemb,stream);
+	return dfwrite(ptr,size,nmemb,stream);
+}
+#endif
+
+static int sdSeekFile(FILE* stream, long offset, int whence) {
+	dprintf("seek stream %d offset %d whence %d\n",stream,offset,whence);
+	if(whence!=PF_SEEK_SET || offset)
+	{
+		errno=-EINVAL;
+		return -1;
+	}
+	drewind(stream);
+	return 0;
+}
+
+#define sdTellFile
+#if 0
+static long sdTellFile(FILE* stream)
+{
+	dprintf("telling for %d\n",stream);
+	return 0;
+}
+#endif
+
+#define sdCloseFile dfclose
+#if 0
+static int sdCloseFile(FILE* stream)
+{
+	dprintf("closing %d\n",stream);
+	return dfclose(stream);
+}
+#endif
+
+//#define sdInputChar dfgetc
+static inline int sdInputChar(FILE* stream)
+{
+	unsigned char bla;
+	//dprintf("getting char from %d\n",stream);
+	bla=dfgetc(stream);
+	//dprintf("char is %d\n",bla);
+	return (bla==255?-1:bla);
+}
+
diff -ruN pforth.orig/csrc/vsprintf.c pforth/csrc/vsprintf.c
--- pforth.orig/csrc/vsprintf.c	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/vsprintf.c	Tue Jul 16 01:03:16 2002
@@ -0,0 +1,328 @@
+/*
+ *  linux/lib/vsprintf.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
+/*
+ * Wirzenius wrote this portably, Torvalds fucked it up :-)
+ */
+
+#include <stdarg.h>
+//#include <types.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "vsprintf.h"
+
+unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
+{
+	unsigned long result = 0,value;
+
+	if (!base) {
+		base = 10;
+		if (*cp == '0') {
+			base = 8;
+			cp++;
+			if ((*cp == 'x') && isxdigit(cp[1])) {
+				cp++;
+				base = 16;
+			}
+		}
+	}
+	while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
+	    ? toupper(*cp) : *cp)-'A'+10) < base) {
+		result = result*base + value;
+		cp++;
+	}
+	if (endp)
+		*endp = (char *)cp;
+	return result;
+}
+
+long simple_strtol(const char *cp,char **endp,unsigned int base)
+{
+	if(*cp=='-')
+		return -simple_strtoul(cp+1,endp,base);
+	return simple_strtoul(cp,endp,base);
+}
+
+/* we use this so that we can do without the ctype library */
+#define is_digit(c)	((c) >= '0' && (c) <= '9')
+
+static int skip_atoi(const char **s)
+{
+	int i=0;
+
+	while (is_digit(**s))
+		i = i*10 + *((*s)++) - '0';
+	return i;
+}
+
+#define ZEROPAD	1		/* pad with zero */
+#define SIGN	2		/* unsigned/signed long */
+#define PLUS	4		/* show plus */
+#define SPACE	8		/* space if plus */
+#define LEFT	16		/* left justified */
+#define SPECIAL	32		/* 0x */
+#define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */
+
+#define do_div(n,base) ({ \
+int __res; \
+__res = ((unsigned long) n) % (unsigned) base; \
+n = ((unsigned long) n) / (unsigned) base; \
+__res; })
+
+size_t dstrnlen (const char *s, size_t maxlen)
+   {
+   if (strlen(s) < maxlen)
+      return (strlen(s));
+   else
+      return (maxlen);
+   }
+
+static char * number(char * str, long num, int base, int size, int precision
+	,int type)
+{
+	char c,sign,tmp[66];
+	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
+	int i;
+
+	if (type & LARGE)
+		digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+	if (type & LEFT)
+		type &= ~ZEROPAD;
+	if (base < 2 || base > 36)
+		return 0;
+	c = (type & ZEROPAD) ? '0' : ' ';
+	sign = 0;
+	if (type & SIGN) {
+		if (num < 0) {
+			sign = '-';
+			num = -num;
+			size--;
+		} else if (type & PLUS) {
+			sign = '+';
+			size--;
+		} else if (type & SPACE) {
+			sign = ' ';
+			size--;
+		}
+	}
+	if (type & SPECIAL) {
+		if (base == 16)
+			size -= 2;
+		else if (base == 8)
+			size--;
+	}
+	i = 0;
+	if (num == 0)
+		tmp[i++]='0';
+	else while (num != 0)
+		tmp[i++] = digits[do_div(num,base)];
+	if (i > precision)
+		precision = i;
+	size -= precision;
+	if (!(type&(ZEROPAD+LEFT)))
+		while(size-->0)
+			*str++ = ' ';
+	if (sign)
+		*str++ = sign;
+	if (type & SPECIAL) {
+		if (base==8)
+			*str++ = '0';
+		else if (base==16) {
+			*str++ = '0';
+			*str++ = digits[33];
+		}
+	}
+	if (!(type & LEFT))
+		while (size-- > 0)
+			*str++ = c;
+	while (i < precision--)
+		*str++ = '0';
+	while (i-- > 0)
+		*str++ = tmp[i];
+	while (size-- > 0)
+		*str++ = ' ';
+	return str;
+}
+
+/* Forward decl. needed for IP address printing stuff... */
+int sprintf(char * buf, const char *fmt, ...);
+
+int vsprintf(char *buf, const char *fmt, va_list args)
+{
+	int len;
+	unsigned long num;
+	int i, base;
+	char * str;
+	const char *s;
+
+	int flags;		/* flags to number() */
+
+	int field_width;	/* width of output field */
+	int precision;		/* min. # of digits for integers; max
+				   number of chars for from string */
+	int qualifier;		/* 'h', 'l', or 'L' for integer fields */
+
+	for (str=buf ; *fmt ; ++fmt) {
+		if (*fmt != '%') {
+			*str++ = *fmt;
+			continue;
+		}
+
+		/* process flags */
+		flags = 0;
+		repeat:
+			++fmt;		/* this also skips first '%' */
+			switch (*fmt) {
+				case '-': flags |= LEFT; goto repeat;
+				case '+': flags |= PLUS; goto repeat;
+				case ' ': flags |= SPACE; goto repeat;
+				case '#': flags |= SPECIAL; goto repeat;
+				case '0': flags |= ZEROPAD; goto repeat;
+				}
+
+		/* get field width */
+		field_width = -1;
+		if (is_digit(*fmt))
+			field_width = skip_atoi(&fmt);
+		else if (*fmt == '*') {
+			++fmt;
+			/* it's the next argument */
+			field_width = va_arg(args, int);
+			if (field_width < 0) {
+				field_width = -field_width;
+				flags |= LEFT;
+			}
+		}
+
+		/* get the precision */
+		precision = -1;
+		if (*fmt == '.') {
+			++fmt;
+			if (is_digit(*fmt))
+				precision = skip_atoi(&fmt);
+			else if (*fmt == '*') {
+				++fmt;
+				/* it's the next argument */
+				precision = va_arg(args, int);
+			}
+			if (precision < 0)
+				precision = 0;
+		}
+
+		/* get the conversion qualifier */
+		qualifier = -1;
+		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
+			qualifier = *fmt;
+			++fmt;
+		}
+
+		/* default base */
+		base = 10;
+
+		switch (*fmt) {
+		case 'c':
+			if (!(flags & LEFT))
+				while (--field_width > 0)
+					*str++ = ' ';
+			*str++ = (unsigned char) va_arg(args, int);
+			while (--field_width > 0)
+				*str++ = ' ';
+			continue;
+
+		case 's':
+			s = va_arg(args, char *);
+			if (!s)
+				s = "<NULL>";
+
+            len = dstrnlen(s, precision);
+
+			if (!(flags & LEFT))
+				while (len < field_width--)
+					*str++ = ' ';
+			for (i = 0; i < len; ++i)
+				*str++ = *s++;
+			while (len < field_width--)
+				*str++ = ' ';
+			continue;
+
+		case 'p':
+			if (field_width == -1) {
+				field_width = 2*sizeof(void *);
+				flags |= ZEROPAD;
+			}
+			str = number(str,
+				(unsigned long) va_arg(args, void *), 16,
+				field_width, precision, flags);
+			continue;
+
+
+		case 'n':
+			if (qualifier == 'l') {
+				long * ip = va_arg(args, long *);
+				*ip = (str - buf);
+			} else {
+				int * ip = va_arg(args, int *);
+				*ip = (str - buf);
+			}
+			continue;
+
+		case '%':
+			*str++ = '%';
+			continue;
+
+		/* integer number formats - set up the flags and "break" */
+		case 'o':
+			base = 8;
+			break;
+
+		case 'X':
+			flags |= LARGE;
+		case 'x':
+			base = 16;
+			break;
+
+		case 'd':
+		case 'i':
+			flags |= SIGN;
+		case 'u':
+			break;
+
+		default:
+			*str++ = '%';
+			if (*fmt)
+				*str++ = *fmt;
+			else
+				--fmt;
+			continue;
+		}
+		if (qualifier == 'l')
+			num = va_arg(args, unsigned long);
+		else if (qualifier == 'h') {
+			num = (unsigned short) va_arg(args, int);
+			if (flags & SIGN)
+				num = (short) num;
+		} else if (flags & SIGN)
+			num = va_arg(args, int);
+		else
+			num = va_arg(args, unsigned int);
+		str = number(str, num, base, field_width, precision, flags);
+	}
+	*str = '\0';
+	return str-buf;
+}
+
+int dsprintf(char * buf, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, (char*)fmt);
+	i=vsprintf((char*)buf,fmt,args);
+	va_end(args);
+	return i;
+}
diff -ruN pforth.orig/csrc/vsprintf.h pforth/csrc/vsprintf.h
--- pforth.orig/csrc/vsprintf.h	Thu Jan  1 01:00:00 1970
+++ pforth/csrc/vsprintf.h	Tue Jul 16 00:31:56 2002
@@ -0,0 +1,10 @@
+#include <stdarg.h>
+//#include <types.h>
+#include <string.h>
+#include <ctype.h>
+extern unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
+extern long simple_strtol(const char *cp,char **endp,unsigned int base);
+extern size_t dstrnlen (const char *s, size_t maxlen);
+extern int sprintf(char * buf, const char *fmt, ...);
+extern int vsprintf(char *buf, const char *fmt, va_list args);
+extern int dsprintf(char * buf, const char *fmt, ...);
diff -ruN pforth.orig/makefile pforth/makefile
--- pforth.orig/makefile	Tue Apr  7 02:43:01 1998
+++ pforth/makefile	Thu Jan  1 01:00:00 1970
@@ -1,87 +0,0 @@
-# @(#) rlsMakefile 97/12/10 1.1
-# makefile for pForth
-# Portable Forth written in 'C'
-# Phil Burk
-
-.SUFFIXES: .c .o
-
-# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
-# See "docs/pf_ref.htm" file for more info.
-
-SOURCEDIR = csrc
-OBJECTDIR = objects
-EMBOBJECTDIR = embobjects
-
-FULL_WARNINGS =  -O2 \
-        -fsigned-char \
-        -fno-builtin \
-        -fno-unroll-loops \
-        -fpeephole \
-        -fno-keep-inline-functions \
-        -x c++ \
-        -Wcast-qual \
-        -Wall \
-        -Wwrite-strings \
-        -Winline  \
-        -Wmissing-prototypes \
-        -Wmissing-declarations
-        
-CCOPTS = -DPF_SUPPORT_FP $(FULL_WARNINGS)
-COMPILER = gcc
-
-EMBCCOPTS = -DPF_NO_INIT -DPF_NO_MALLOC -DPF_NO_FILEIO \
-    -DPF_NO_CLIB -DPF_STATIC_DIC
-
-#######################################
-# Build file lists from wildcards.
-PFITEMP    = ${wildcard ${SOURCEDIR}/*.h}
-PFINCLUDES = ${PFITEMP:${SOURCEDIR}/pfdicdat.h=}
-PFSOURCE   = ${wildcard ${SOURCEDIR}/*.c}
-PFTEMP     = ${PFSOURCE:%.c=%.o}
-PFOBJS     = ${PFTEMP:${SOURCEDIR}/%=${OBJECTDIR}/%}
-PFEMBOBJS  = ${PFTEMP:${SOURCEDIR}/%=${EMBOBJECTDIR}/%}
-
-COMPILE = $(COMPILER) $(CCOPTS) $(CDEFS)
-
-${OBJECTDIR}/%.o:  $(PFINCLUDES)  ${SOURCEDIR}/%.c
-	$(COMPILE) -O -o ${OBJECTDIR}/$*.o -c ${SOURCEDIR}/$*.c
-	
-${EMBOBJECTDIR}/%.o:  $(PFINCLUDES) ${SOURCEDIR}/%.c ${SOURCEDIR}/pfdicdat.h 
-	$(COMPILE) -O -o ${EMBOBJECTDIR}/$*.o -c ${SOURCEDIR}/$*.c $(EMBCCOPTS)
-
-all: pforth pforth.dic
-
-pffiles:
-	echo "ITEMP FILES -----------------"
-	echo ${PFITEMP}
-	echo "INCLUDE FILES -----------------"
-	echo ${PFINCLUDES}
-	echo "'C' FILES ---------------------"
-	echo ${PFSOURCE}
-	echo "OBJECT FILES ------------------"
-	echo ${PFOBJS}
-	echo "EMBEDDED OBJECT FILES ------------------"
-	echo ${PFEMBOBJS}
-	
-# build pforth by compiling 'C' source
-pforth: $(PFINCLUDES) $(PFOBJS)
-	$(COMPILER) $(PFOBJS) -lm -o pforth
-
-# build basic dictionary by running newly built pforth and including system.fth
-pforth.dic: pforth
-	pforth -i system.fth
-
-${SOURCEDIR}/pfdicdat.h: pforth pforth.dic
-	@(echo 'INCLUDE utils/savedicd.fth'; \
-          echo 'SDAD';         \
-          echo 'bye')                                 | \
-	pforth -dpforth.dic
-	cp pfdicdat.h ${SOURCEDIR}
-
-
-pfemb: $(PFINCLUDES) $(PFEMBOBJS)
-	$(COMPILER) $(PFEMBOBJS) -lm -o pfemb
-	
-clean:
-	rm -f $(PFOBJS) $(PFEMBOBJS) pforth *.dic core ${SOURCEDIR}/pfdicdat.h pfemb
-
Binary files pforth.orig/pfemb.bin and pforth/pfemb.bin differ
