RC/Funge-98
Description:
------------
  RC/Funge-98 is a funge interpreter based upon the Funge-98 specification
by Cats-Eye Technologies.  The full language specification (including the
'i', 'o', '=', and 't' commands) are supported.  Unefunge, befunge, and trefunge
all supported by RC/Funge-98, with befunge being the default mode.  Several
extensions are also provided, including minimal windows support (currently
only on unix version).

Handprint:
-----------
  RCS Funge interpreters can be identified with the following handprints:
      "RCSU" 0x52425355 Unix version

Built-in Fingerprints:
----------------------
      "BASE" 0x42415345 I/O for numbers in other bases    (RCS)
      "CPLI" 0x43504C49 Complex Integer extension         (RCS)
      "DIRF" 0x44495246 Directory functions extension     (RCS)
      "EVAR" 0x45564152 Environment variables extension   (RCS)
      "FILE" 0x46494C45 File I/O functions                (RCS)
      "FNGR" 0x464E4752 Fingerprint management extension  (RCS)
      "FPDP" 0x46504450 Double precision floating point   (RCS)
      "FPSP" 0x46505350 Single precision floating point   (RCS)
      "FRTH" 0x46525448 Some common forth commands        (RCS)
      "FIXP" 0x46495850 Some useful math functions        (RCS)
      "HRTI" 0x48525449 High resolution timer interface   (Cats-Eye)
      "IMAP" 0x494D4150 Instruction remap extension       (RCS)
      "INDV" 0x494E4456 Pointer functions                 (RCS)
      "MODE" 0x4D4F4445 Standard modes                    (Cats-Eye)
      "MODU" 0x4D4F4455 Modulo Arithmetic Extension       (Cats-Eye)
      "NULL" 0x4E554C4C Null                              (Cats-Eye)
      "ORTH" 0x4F525448 Orthogonal Easement Library       (Cats-Eye)
      "PERL" 0x5045524C Generic Interface to Perl         (Cats-Eye)
      "REFC" 0x52454643 Referenced Cells Extension        (Cats-Eye)
      "ROMA" 0x524F4D41 Roman numerals extension          (Cats-Eye)
      "STRN" 0x5354524E String functions                  (RCS)
      "SUBR" 0x53554252 Subroutine extension              (RCS)
      "TERM" 0x5445524D Terminal extension                (RCS)
      "TOYS" 0x544F5953 Standard Toys                     (Cats-Eye)
             (not yet fully implemented)
      "WIND" 0x57494E44 Windows extensions                (RCS)

Limits:
-------
  Maximum IPs         100
  Maximum Overloads   100
  Stack space per IP  1000 entries
  Stack Stacks        200
  Mini Funges         100
  Mini-funge size     40x10
These limits can be changed by altering funge.h and recompiling.

Enclosed Files:
---------------
  Makefile            Makefile to build RC/Funge
  main.c              Main source file
  ext.c               Source file for overloads
  mem.c               Memory manager
  mterm.c             Terminal functions
  mfunge.c            Mini-funge executor
  xfunge.c            Source file for x windows functions
  funge.h             Header file
Demo Files:
-----------
  base.f              Demonstration of number base extension
  over1.f             Demonstration of overlays
  over2.f             File loaded by over1.f
  overdemo.f          Demonstration of overloading
  roman.f             Demonstration of rom2.fl funge-lib
  subr.f              Demonstration of subr extension
  sys.f               Demonstrates = command (unix ls command)
  sysinfo.f           Shows information about your funge environment
  threads.f           Demonstrates concurrent threads
  win.f               Demo file for windows functions
Funge-lib Files:
----------------
  rom2.fl             Roman numeral extension


Memory Models:
  RC/Funge provides two memory models, Fixed and Dynamic:
  FIXED - In this mode the interpreter allocates the entire Funge-space
          at execution time.  If you want a large addressable Funge-space
          you could run out of memory.  This is the fastest of the two
          modes, and is therefore the default.
  DYNAMIC - This mode the virtual dimensioning used by Funge/98.  In this
            mode the dimensions are no longer a factor in memory usage.
            Instead a block of cells are allocated and can be located anywhere
            in Funge-space.  The current mechanism for implementing this 
            memory model is not so good, and therefore a bit slow.

Invokation:
-----------
funge [switches] source-files
-1      Use single dimension Funge-space
-2      Use two dimensional Funge-space (default)
-3      Use three dimensional Funge-space
-93     Allow only Funge/93 instructions
-c n    Change maximum number of cells in dynamic memory model (def 10000)
-d      Enable debugger
-D      Delay between instruction execution
-i      Change stack sIze (def 1000)
-md     Dynamic memory model
-mf     Use fixed memory model (default)
-r n    Change maximum number of rows in dynamic memory model (def 1000)
-s      Map Funge-space to screen
-S      Suppress summary
-t      Enable tracing mode
-v      Show version
-w      Enable warnings
-x n    Change x dimension of Funge-space for fixed memory model (def 100)
-y n    Change y dimension of Funge-space for fixed memory model (def 100)
-z n    Change z dimension of Funge-space for fixed memory model (def 1)
-Y      Use official version of 'y' command

Funge/98 Instruction Set:
-------------------------
     Nop
!   (n -- !n)           Logical Negate
"                       Toggle string mode
#                       Skip next cell
$   (n -- )             Drop top stack entry
%   (n1 n2 -- n1%n2)    Modulo
&   ( -- n)             Read number from stdin
'   ( -- c)             Push next cell onto stack
(   (gnirts n -- )      Overload functions A-Z
)   (gnirts n -- )      Unload functions A-Z
*   (n1 n2 -- n1*n2)    Multiplication
+   (n1 n2 -- n1+n2)    Addition
,   (n -- )             Print tos as a character
-   (n1 n2 -- n1-n2)    Subtraction
.   (n -- )             Print tos as a number
/   (n1 n2 -- n1/n2)    Division
0   ( -- 0)             Push 0 onto stack
1   ( -- 1)             Push 1 onto stack
2   ( -- 2)             Push 2 onto stack
3   ( -- 3)             Push 3 onto stack
4   ( -- 4)             Push 4 onto stack
5   ( -- 5)             Push 5 onto stack
6   ( -- 6)             Push 6 onto stack
7   ( -- 7)             Push 7 onto stack
8   ( -- 8)             Push 8 onto stack
9   ( -- 9)             Push 9 onto stack
:   (n -- n n)          Duplicate tos
;                       Skip to next ;
<                       Set ip delta to -1,0,0
=   (0gnirts -- n)      Pass string to underlying system
>                       Set ip delta to 1,0,0
?                       Set ip delta to random direction
@                       Terminate thread
A-Z                     Overloadable functions
[                       Turn ip delta to the left
\   (n1 n2 -- n2 n1)    Swap top two stack elements
]                       Turn ip delta to the right
^                       Set ip delta to 0,-1,0
_   (n -- )             does > if tos is zero, else <
`   (a b -- n)          Pushes 1 if a>b else pushes 0
a   ( -- 10)            Push 10 onto stack
b   ( -- 11)            Push 11 onto stack
c   ( -- 12)            Push 12 onto stack
d   ( -- 13)            Push 13 onto stack
e   ( -- 14)            Push 14 onto stack
f   ( -- 15)            Push 15 onto stack
g   (v -- n)            Get value stored in funge cell
h                       Sets ip delta to 0,0,1
i   (v f 0gnirts -- vs vo) Load a file, Acts as r on failure
j   (n -- )             jumps ip delta * tos;
k   (n -- )             Execute command in next cell n times
l                       Sets ip delta to 0,0,-1
m   (n -- )             Does l if tos is zero else h
n                       Clears stack
o   (vs vo 0gnirts -- ) Write funge space to file
p   (n v -- )           Put value into funge cell
q   (n -- )             Immedietly quit program, tos is return code
r                       Reflect the delta
s   (n -- )             Take tos and store into next cell
t                       Start new thread
u                       Transfer entries between soss and toss
v                       Set ip delta to 0,1,0
w   (a b -- )           do ] if a>b, [ if a<b, otherwise z
x   (x y z -- )         Set ip delta from stack
y   (n --)              Get System information
z                       nop
{   (n -- )             Begin Block
|   (n -- )             does v if tos is zero, else ^
}   (n -- )             End Block
~   ( -- c)             Input character from stdin

System Information - y Command:
-------------------------------
  RC/Funge interprets the 'y' command a bit differently from the specification.
According to the specs, a positive argument will leave the n'th cell from the
y command on the stack.  I thought that it is more useful to allow n to 
specify which information entry rather than cell.  Entries 1-9 will work
excactly as the specification, but 10 up act differently.  According to the
spec 55+y would retrieve one cell from the vector of the current IP
location.  RC/Funge instead returns the entire vector.  Entry 11 would
then contain the entire vector for the current IP's delta, whereas in the
specs, 11 would return the second cell of the location vector in befunge or
trefunge OR the x delta in unefunge.  I felt it more useful to be able to
directly specify an information item rather than have to calculate beyond
entry 9 in order to find the correct cell.
  If you desire the behaviour of the official specification, then use a -Y
on the command line.

Entry   Description
1       Flags
        bit 0 = 1 if 't' command is implemented
        bit 1 = 1 if 'i' command is implemented
        bit 2 = 1 if 'o' command is implemented
        bit 3 = 1 if '=' command is implemented
2       Number of bytes per cell
3       Handprint
4       Version number
5       Operating Paradigm
        0=unavailable
        1=Equivalent to c language system()
        2=Equivalent to interpretation by specific shell program
        3=Executes in shell funge was started from
6       Path separator character
7       Number of scalars per vector (1=unefunge, 2=befune, 3=trefunge)
8       ID of current IP
9       not used
10      Vector for location of current IP
11      Vector for delta of current IP
12      Vector containting storage offset of current IP
13      Vector pointing to smallest address with non-space contents
14      Vector pointing to largest address with non-space contents
15      (year-1900)*256*256 + month*256 + day
16      hour*256*256 + minute*256 + second
17      Number of stacks on the stack stack
18      Size of each stack on the stack stack
19      The command line
20      The environement, each environment entry is in the form of a 0gnirts
        name=value string.  double zeros denote the end of the list

Supported Fingerprints:
-----------------------
"BASE" 0x42415345
B   (n -- )             Ouptut top of stack in binary
H   (n -- )             Ouptut top of stack in hex
I   (b -- n)            Read input in specified base
N   (n b -- )           Output n in base b
O   (n -- )             Ouptut top of stack in octal

"CPLI" 0x43504C49
A   (ar ai br bi -- r i) Add two complex integers
D   (ar ai br bi -- r i) Divide two complex integers
M   (ar ai br bi -- r i) Multiply two complex integers
O   (r i -- )            Output a complext number
S   (ar ai br bi -- r i) Subtract two complex integers
V   (r i -- n)           Absolute value of a complex integer

"DIRF" 0x44495246
C   (0gnirts -- )        Change directory
M   (0gnirts -- )        Make a directory
R   (0gnirts -- )        Remove a directory
All functions act as r on failure

"EVAR" 0x45564152
G   (0gnirts -- 0gnirts) Get value of an environment variable
N   ( -- n )             Get number of environment variables
P   (0gnirts --)         Put a value into the environemnt (form: name=value)
V   (n -- 0gnirts)       Get n'th environmnt variable (form: name=value)

"FILE" 0x46494C45
C   (h --)              Close a file
G   (h -- h 0gnirts b)  Read string from file (like c fgets)
L   (h -- h n)          Get location of file pointer
O   (Va m 0gnirts -- h) Open a file (Va=i/o buffer)
    m: 0 = read
       1 = write
       2 = append 
       3 = read/write
       4 = truncate read/write
       5 = append read/write
P   (h 0gnirts -- h)    Write string to file (like c fputs)
R   (h n -- h)          Read n bytes from file to buffer
S   (h m n -- h)        Seek to position n in file
    m: 0 = from beginning
       1 = from current location
       2 = from end
W   (h n -- h)          Write n bytes from buffer to file
All file functions on failure act as r.  Functions W and R write cells as
bytes, any cells containing values greater than 256 will have the top bits
stripped.

"FNGR" 0x464E4752
A   ( -- )              Set ( and ) to work in absolute mode
B   ( -- fp 1)          Create a Blank extension on top of stack
                        (all entries are set to transparent).  The standard 
                        fingerprint id for this copy will be 0xFFFFFFFF. 
                        This is useful to create a customized
                        extension containing pieces from many others.
C   (new n old o -- )   Copy instruction 'old' in fingerprint 'o' to 
                        instruction 'new' in fingerprint 'n'
D   (inst n-- )         Delete an instruction from fingerprint with id n
F   (fp -- n)           Get current id for specified fingerprint
                        (fp is a 1 cell version, like from ) )
K   (n -- )             Kill extension at selected position in fingerprint stack
N   ( -- n)             Get number of fingerprints loaded
O   ( -- )              Return ( and ) to the official functions
R   ( -- )              Set ( and ) to work in roll mode
S   ( -- )              Set ( and ) to work in swap mode
T   (fp n -- )          Tag stack entry n with new fingerprint fp
X   (n n -- )           Exchange the positions of two fingerprints in the stack
All instructions on failure act like r.
The fingerprint stack and fingerprint ids as used by this extension:
The fingerprint stack consists of all loaded fingerprints.  When a fingerprint
is loaded it is pushed onto this stack.  When an A-Z instruction is executed
the tos of this stack is the first searched for the command, and then on 
downwards through the stack, if the bottom is hit, then an r command will be 
executed.  For most all commands in this extension, the fingerprint id is 
actually the position on the fingerprint stack.  The top has id 0, the second 
id 1, and so on.  So, if you were to execute "'A1D" This would delete the 'A'
command from the extension sitting on the second position on the fingerprint
stack.
Absolute Mode:
In absolute mode, the ( and ) instructions take on new meanings:
  (  - A number is popped of off the stack, this numbers is the fingerprint id
       (stack position) of what should be considered the top of stack.  It does
       not actually move anything, it only changes where the instruction search
       starts.  Extensions on the stack above the selected one will not be
       searched whereas the selected and donward will still be searched. 
       Executing "0(" will return the search to the top of the fingerprint
       stack.
  )  - A number is popped of off the stack, this number specifies which
       fingerprint is to be copied over the top of the current top of stack.
       The extenstion that is currently on the top of the fingerprint stack
       will be deleted amd the selected one takes its place.  The selected
       entry also remains in its original stack position, only a copy is made.
       The search point is then reset to the top of the fingerprint stack.
       Unlike the ( command, this will allow all other stack entries to be
       searched.
Roll Mode:
In roll mode, the ( and ) instructions take on new meanings:
  (  - A number is popped off the data stack and is used to roll the
       fingerprint stack.  The item at the selected entry is removed and
       moved to the top of stack, while all other entries are moved down.
       This operates like the forth "roll" command.
  )  - This works like (, but the roll is reversed.  The top of stack is
       moved to the selected position while all other entries are moved up.
       This operates like the forth "-roll" command.
Swap Mode:
In swap mode, the ( and ) instructions take on new meanings:
  (  - A number is popped from the data stack.  This specifies which entry
       in the fingerprint stack is to be swapped with the top of the
       fingerprint stack.
  )  - This command uses no arguments from the data stack.  It merely
       swaps the top two entries on the fingerprint stack
Note: In all modes, on failure ( and ) will act like r.

"FPDP" 0x46504450
A   (a b -- n)          Add two double precision fp numbers
B   (n -- n)            Sin of double precision fp number
C   (n -- n)            Cosin of double precision fp number
D   (a b -- n)          Divide two double precision fp numbers
E   (n -- n)            Arcsin of double precision fp number
F   (n -- n)            Convert integer to floating point
G   (n -- n)            Arctangent of double precision fp number
H   (n -- n)            Arccosin of double precision fp number
I   (n -- n)            Convert floating point to integer
K   (n -- n)            Natural  logarithm of double precision fp number
L   (n -- n)            Base 10 logarithm of double precision fp number
M   (a b -- n)          Multiply two double precision fp numbers
N   (n -- n)            Negate double precision fp number
P   (n -- )             Print a floating point number
Q   (n -- n)            Double precision square root
R   (0gnirts -- n)      Convert ascii number to floating point
S   (a b -- n)          Subtract two double precision fp numbers
T   (n -- n)            Tangent of double precision fp number
V   (n -- n)            Absolute value of double precision fp number
X   (n -- n)            Exponential of double precision fp number (e**n)
Y   (x y -- n)          Raise x to the power of y

"FPSP" 0x46505350
A   (a b -- n)          Add two single precision fp numbers
B   (n -- n)            Sin of single precision fp number
C   (n -- n)            Cosin of single precision fp number
D   (a b -- n)          Divide two single precision fp numbers
E   (n -- n)            Arcsin of single precision fp number
F   (n -- n)            Convert integer to floating point
G   (n -- n)            Arctangent of single precision fp number
H   (n -- n)            Arccosin of single precision fp number
I   (n -- n)            Convert floating point to integer
K   (n -- n)            Natural  logarithm of single precision fp number
L   (n -- n)            Base 10 logarithm of single precision fp number
M   (a b -- n)          Multiply two single precision fp numbers
N   (n -- n)            Negate single precision fp number
P   (n -- )             Print a floating point number
Q   (n -- n)            Single precision square root
R   (0gnirts -- n)      Convert ascii number to floating point
S   (a b -- n)          Subtract two single precision fp numbers
T   (n -- n)            Tangent of single precision fp number
V   (n -- n)            Absolute value of single precision fp number
X   (n -- n)            Exponential of single precision fp number (e**n)
Y   (x y -- n)          Raise x to the power of y
Notes: Trig functions work in radians

"FIXP" 0x4649585
A   (a b -- a and b)    And
B   (n -- arccos(b))    Find arccosin of tos
C   (n -- cos(b))       Find cosin of tos
D   (n -- rnd(n))       RanDom number
I   (n -- sin(b))       Find sin of tos
J   (n -- arcsin(b))    Find arcsin of tos
N   (a -- 0-a)          Negate
O   (a b -- a or b)     Or
P   (a -- a*pi)         Multiply by pi
Q   (a -- sqrt(a))      Square root
R   (a b -- a**b)       Raise a to the power of b
S   (n -- n)            Replace tos with sign of tos
T   (n -- tan(b))       Find tangent of tos
U   (n -- arctan(b)     Find arctangent of tos
V   (n -- n)            Absolute value of tos
X   (a b -- a xor b)    Xor
The functions C,I,T,B,J,U expect their arguments times 10000,
 for example: 45 should be passed as 450000.  The results will also be 
 multiplied by 10000, thereby giving 4 digits of decimal precision.
Note: Trigonometric functions work in degrees. not radians.

"FRTH" 0x46525448
D   ( .. -- .. n)       Push depth of stack to tos
L   ( .. n -- .. n)     Forth Roll command
O   (a b -- a b a)      Forth Over command
P   (.. n -- .. n)      Forth Pick command
R   (a b c -- b c a)    Forth Rot command

"HRTI" 0x48525449
E   ( -- )              Erase timer mark, this makes T act like r
G   ( -- n)             Get smallest tick size (in microseconds)
M   ( -- )              Mark current timer value
S   ( -- n)             Get number of microseconds since last full second
T   ( -- n)             Get time since last marked (in microseconds)

"IMAP" 0x494D4150
C   ( -- )              Clear all instruction remaps
M   (new old -- )       Remap an instruction
O   (n -- )             Return instruction n to its old function

"INDV" 0x494E4456
G   (Vp - n)            Pointer get number
P   (n Vp -- )          Pointer put number
V   (Va -- V)           Pointer get vector
W   (V Va --)           Pointer put vector
Pointer functions pop a vector off the stack which points to another
vector in memory which is the pointer to the target cell.
Vectors are stored in memory with a delta of 1,0,0 with Z being first
in trefunge, and Y first in befunge.

"MODE" 0x4D4F4445
H                       Toggles hover mode (relative vs absolute delta changes)
I                       Toggles invert mode (push to bottom of stack)
Q                       Toggles queue mode (pop from bottom of stack)
S                       Toggles switch mode (alters [,].{.}.(.) commands)

"MODU" 0x4D4F4455
M   (a b -- a mod b)    x-floor(x/y)*y
U   (a b -- a mod b)    Unsigned result
R   (a b -- a mod b)    C-language remainder

"NULL" 0x4E554C4C
A-Z                     All set to reflect

"ORTH" 0x4F525448
A   (a b -- a and b)    And
E   (a b -- a exor b)   exor
G   (y x -- v)          Get value stored at x,y
O   (a b -- a or b)     Or
P   (v y x -- )         Store value in funge space x,y
S   (0gnirts -- )       Print string located on stack
V   (n --)              Change IP Delta X to tos
W   (n --)              Change IP Delta Y to tos
X   (n -- )             Change IP x coordinate to tos
Y   (n -- )             Change IP y coordinate to tos
Z   (n -- )             If zero, act like #

"PERL" 0x5045524C
E   (0gnirts -- 0gnirts) Evaluate a string in perl
I   (0gnirts -- n)       Evaluate a string in perl, returning integer
S   ( -- n)             Pushes 0 if underlying system is perl, else 1

"REFC" 0x52454643
R   (Va -- r)           Produce a single cell reference to a vector
D   (r -- Va)           Return the vector referenced by r

"ROMA" 0x524F4D41
C   ( -- 100)           Pushes 100 on stack
D   ( -- 500)           Pushes 500 on stack
I   ( -- 1)             Pushes 1 on stack
L   ( -- 50)            Pushes 50 on stack
M   ( -- 1000)          Pushes 1000 on stack
V   ( -- 5)             Pushes 5 on stack
X   ( -- 10)            Pushes 10 on stack

"STRN" 0x5354524E
A   (0gnirts 0gnirts -- 0gnirts) Append bottom string to upper string
C   (0gnirts 0gnirts -- n)       Compare strings
D   (0gnirts --)                 Display a string
F   (0gnirts 0gnirts -- 0gnirts) Search for bottom string in upper string
G   (Va -- 0gnirts)              Get string from specified position
I   ( -- 0gnirts)                Input a string
L   (0gnirts n -- 0gnirts)       Leftmost n characters of string
M   (0gnirts s n -- 0gnirts)     n characters starting at position s
N   (0gnirts -- 0gnirts n)       Get length of string
P   (0gnirts Va -- )             Put string at specified position
R   (0gnirts n -- 0gnirts)       Rightmost n characters of string
S   (n -- 0gnirts)               String representation of a number
V   (0gnirts -- n)               Retreive value from string
Note:  functions G and P use deltas of 1,0,0

"SUBR" 0x53554252
C   (Va n -- Va Vd .. ) Call a subroutine
J   (Va -- )            Jump to another location
R   (Va Vd .. n -- ..)  Return from subroutine
J and C each set delta to 1,0,0 at target, R restores the delta before the call.
When C is executed, the tos specifies how many stack entries to retrieive
from the stack and then place back onto the stack after the retrurn address
and delta vectors are pushed on the stack.
When R is executed, the tos specifies how many stack entries to retrieve
from the stack before retrieving the delta and address vectors.  The popped
entries will be restored to the stack after the vectors are popped.

"TERM" 0x5445524D
C   ( -- )              Clear the screen
D   ( n -- )            Move cursor down n lines
G   (x y -- )           Put cursor at position x,y (home is 0,0)
H   ( -- )              Move cursor to home
L   ( -- )              Clear to end of line
S   ( -- )              Clear to end of screen
U   ( n -- )            Move cursor up n lines

"TOYS" 0x544F5953
A   (a n -- a(n) )      Pushes n copies of a on stack
C   (Vd Vsz Vsrc -- )   Low order copy of funge space
D   (n -- n)            Decrement tos
E   (.. -- n)           Pops all stack values and pushes back the sum
I   (n -- n)            Increment tos
H   (a b -- v)          Shift left on +b, right on -b
K   (Vd Vsz Vsrc -- )   High order copy of funge space
L   ( -- n)             Get value to left of the ip's track
M   (Vd Vsz Vsrc -- )   Low order move of funge space
N   (n -- n)            Negate tos
P   (.. -- n)           Pops all stack values and pushes back the product
Q   (n -- )             Puts value in cell directly behind ip
R   ( -- n)             Get value to right of the ip's track
S   (v Vsz Vorg -- )    Fill area with value v
U   ( -- )              Replaces itself with < > ^ v h or l
V   (Vd Vsz Vsrc -- )   High order move of funge space
X   ( -- )              Increments IP's delta X
Y   ( -- )              Increments IP's delta Y
Z   ( -- )              Increments IP's delta Z

"WIND" 0x57494E44
B   (x1 y1 x2 y2 h -- ) Draw a box
C   (h -- )             Close GC
D   (h -- )             Drop (lower) Window
E   (h -- )             Call event checker
I   (Va e h -- )        Install event handler
  e:   1 = Mouse Down
       2 = Mouse Up
       3 = Mouse Motion
       4 = Key Pressed
       5 = Expose
       6 = Configuration
K   (h -- )             Kill a window
L   (x1 y1 x2 y2 h -- ) Draw a line
M   (x y h -- )         Move a window
O   (h -- )             Open GC
P   (x y h -- )         Draw a point
R   (h -- )             Raise Window
S   (x y h -- )         resize a window
T   (0gnirts x y h --)  Draw text in a window
W   (x y w h -- h)      Open a window
Note: Drawing commands: B, L, P, and T require an open GC

Mini-Funge:
-----------
  When a fingerprint is requested that is not built into the interpreter,
RC/Funge will search for a file corresponding to the fingerprint.  The
filename is built from the ascii characters associated with the fingerprint
and using an extension of 'fl'.
  example fingerprint: 0x524F4D41 would search for file ROMA.fl
If the file is found it is loaded as the semantics for the overloaded
functions.  The file must be in the funge-lib file format.

The following commands are not available in Mini-Funge:
(   (gnirts n -- )      Overload functions A-Z
)   (gnirts n -- )      Unload functions A-Z
=   (0gnirts -- n)      Pass string to underlying system
h                       Sets ip delta to 0,0,1
i   (v f 0gnirts -- vs vo) Load a file, Acts as r on failure
l                       Sets ip delta to 0,0,-1
m   (n -- )             Does l if tos is zero else h
o   (vs vo 0gnirts -- ) Write funge space to file
q   (n -- )             Immedietly quit program, tos is return code
t                       Start new thread
u                       Transfer entries between soss and toss
x   (x y z -- )         Set ip delta from stack
{   (n -- )             Begin Block
}   (n -- )             End Block

The following commands have altered functions in Mini-Funge:
'   ( -- c)             Push next mini-funge cell onto stack 
@                       Terminate mini-funge program
g   (v -- n)            Get value stored in main funge-space cell
p   (n v -- )           Put value into main funge-space cell

The following are commands added to Mini-Funge:
B                       Move calling ip backwards one delta unit
D   (v -- )             Set delta of calling ip
E   (.. -- n)           Push depth of stack
F                       Move calling ip forwards one delta unit
G   (v -- n)            Get value stored in mini funge-space cell
K   (.. n -- .. n)      Forth Pick command
L   (v -- )             Set location of calling ip
O   ( .. n -- .. n)     Forth Roll command
P   (n v -- )           Put value into mini funge-space cell
R                       Reflect the delta of calling ip

  Unless otherwise noted above, accesses to funge space access the mini-
funge space.  All stack access are from the stack of the calling ip.
  
  An entire mini-funge program executes in a single tick in comparison
to other concurent funge ip pointers.

funge-lib file format:
----------------------
  A funge-lib file contains the funge source code for commands which can be
loaded into A-Z with the ( command.
  Each command starts with a line beginning with = and an uppercase letter.
All lines up til the next = line are the funge source lines for the function.
  Example: Here is a funge-lib file describing Cat's-eye's ROMA extension:
=I
1@
=V
5@
=X
a@
=L
a5*@
=C
aa*@
=D
aa5**@
=M
aaa**@

Debugger:
---------
back                    - Move ip backward by its delta
del bp x [y [z]]        - Delete a breakpoint
del trap c              - Delete a command trap
drop                    - Drop top entry from stack
fore                    - Move ip forward by its delta
pop                     - Pop and display top of stack
push n                  - Push a number onto the stack
quit                    - Quit program
run                     - Prevent single stepping on current ip
set bp x [y [z]]        - Set a breakpoint
set cell v x [y [z]]    - Set value in specified funge cell
set ip delta x [y [z]]  - Set ip delta
set ip pos x [y [z]]    - Set ip position
set trap c              - Set a command breakpoint
show bp                 - Show breakpoints
show cell x [y [z]]     - Show value in specified funge cell
show ip                 - Show ip information
show fingers            - Show A-Z overloaded fingerprints
show mapper             - Show instruction mappings
show stack              - Show stack for current ip
show stacks             - Show entries in all stacks
show traps              - Show command breakpoints
steps n                 - Allow the current ip to step n instructions
<enter>                 - Step one instruction
  Note: Any single character command will be executed as the associated
funge instruction (example, . will do the same as pop, with only a single
keystroke.)

For more information:
---------------------
For more information on funges, visit:
  http://www.cats-eye.com/funge/




"JSTR" 0x4a535452
P (Vd Va n -- )		pop n cells off of the stack and write at Va with 
delta
			Vd.
G (Vd Va n -- 0gnirts)  read n cells from position Va and delta Vd, push 
on
			stack as a string.

This extension is the Right Way to handle string writing/reading in 
fungespace.
multidimensionality, people!

"SGNL" 0x53474E4C
H ( Va n -- )           sets code at position Va to be handler for signal 
n.
K ( p n -- )            send signal n to PID p
R ( n -- )              restore default handler for signal n.  Not a 
stack!
M ( h n -- )            adjust signal mask by n with method h. 
X ( c -- )              set current cell to character c. esp. useful with 
'Y'.
Y ( -- )                stall; ip will not advance, delta is maintained.

All signals start with their default handlers.
When a signal is received, pid of sender and signal number are pushed onto
stack, in that order. A new thread is created to handle each signal; to 
exit
the signal handler, kill the thread with @.
For the 'M' command, h can be one of 0(SIG_BLOCK), 1(SIG_UNBLOCK), or 
2(SIG_SETMASK).
Whatever X becomes has no effect on the ip that triggered it. 

"NCRS" 0x4E435253
B ( -- )        Beep or visible beep.
E (m -- )       Set echo mode to m (1 == echo, 0 == noecho). 
G ( -- c)       get character c, modified by various flags
I (m -- )       initialize curses mode if m == 1, else end curses mode.
K (m -- )       set keypad mode to m (1 == keypad, 0 == nokeypad)
M (x y -- )     move cursor to x,y
N (m -- )       toggle input mode to m (1 == wait for newline, 0 == 
cbreak)
R ( -- )        refresh(update) window. 
U (c -- )       unget character c. only guaranteed to work once.
P (c -- )       put the character c at the current cursor location.
S (0gnirts -- ) write given string at current cursor location.
C (m -- )       clear all or part of the screen. m can be one of 0(whole
                screen), 1(end of line), or 2(bottom of screen).

All functions act as r on error.  K is useful for getting KEY_foo codes,
i.e. arrow keys, other special keys.  R must be called for the results of
other operations to be displayed. You *must* call 'I' at the beginning 
*and* end of each program that uses NCRS.