1/26/87 	    GRAFTRAX.COM as a BASIC subroutine.

     There  are  several files on this disk.   Information  about
them is presented here to speed the use of GRAFTRAX.COM as a sub-
routine.

o    GRAFTRAX.COM  is  NOT  the version on the	BBS  systems.  It
represents  the latest version of the program,	with several  im-
provements, and a change making possible its use as a subroutine.

o    CALLGRAF.BAS  is  a short BASIC demo program  with  all  the
setup stuff to use GRAFTRAX.COM as a CALL from BASIC.  It assumes
that GRAFTRAX.COM has already been loaded.

o    CALLGRAF.TXT  is  the ASCII saved version	of  CALLGRAF.BAS,
suitable for TYPEing.

o    GRAFTRAX.ASM is the source code for GRAFTRAX.COM!	This is a
commented version of the program,  complete with conditional com-
pilation for the C.Itoh 8510a printer and a way to use MACROS for
other  printers with Bit-Plot capabilities.  If it is run through
the IBM(tm) MACRO ASSEMBLER (MASM), without changing anything, it
will  compile for the EPSON MX GRAFTRAX(tm)  or IBM  PC  Graphics
Printers.  GRAFTRAX.COM  works best with GRAFTRAX,  as you  might
expect. If you want to know how GRAFTRAX.COM does its thing, this
is the place.

o    GRAFTRAX.LST is the formatted listing, with addresses.

o    GRAFTRAX.OBJ  is  the object file,  which LINK  will  create
GRAFTRAX.EXE from.  GRAFTRAX.EXE has to be converted with the DOS
command  -- EXE2BIN GRAFTRAX.EXE GRAFTRAX.COM -- before the  pro-
gram is usable.


     In  order to use my GRAFTRAX program as  a  subroutine,  the
following piece of code is CALLed from BASIC:

 0000				cseg	segment
					assume	cs:cseg
 0000				subrt	proc	far
 0000  55				push	bp
 0001  8B EC				mov	bp,sp
 0003  8B 76 06 			mov	si,[bp+6]  ; passed value is
 0006  8B 1C				mov	bx,[si]    ; the address of a
 0008  8B E3				mov	sp,bx	   ; pointer to some
 000A  CD 05				int	5	   ; space we use as
 000C  8B E5				mov	sp,bp	   ; a temporary stack
 000E  5D				pop	bp
 000F  CA 0002				ret	2
 0012				subrt	endp
 0012				cseg	ends
					end


     The  assembler routine is quite simple.  It gets the address
of  some  open	space passed to it by BASIC and uses  this  as	a
temporary stack.  BASIC only provides a 16 byte stack for a CALL,
or 8 words,  and GRAFTRAX.COM at some points is 39 words deep  in
the stack.

     Selection	of  whether  the routine prints  small	or  LARGE
graphics  is  done  with a POKE into the  GRAFTRAX  routine.  The
routine won't work with the BBS versions without a LOT of  incon-
venience.  They  get  confused	by the fact that  the  subroutine
doesn't have a shift key pressed.  This version allows a  default
in the absence of a shift key being pressed,  and this can be set
to either manner of printing.

     The BASIC demo does the following:
     Lines 300 to 350 are just a simple setup to get to the color
board and draw some simple graphics.

     Lines 80 and 90 initialize the variables used in the routine.
Make sure these  are defined  as  integers,  either  with a DEFINT
statement, or the integer descriptor (%).

     Lines 100-110 POKE the assembler routine into the array CG%.

     Line 120 finds the segment where DOS has  put  GRAFTRAX.COM,
and stores this value in GRSEG%.

     Line 130 asks whether you want a small or LARGE screen print.

     Line 170 uses the information from 130 to POKE a 1 (small) or
2  (LARGE) into location x'0175' of GRAFTRAX's segment.  This can
be  a  separate subroutine in your program,  since the	value  it
POKEs will be maintained through several CALLs.

     Lines 160 and 210 are the actual routine. The routine is all
self-contained	in  BASIC's  data segment,  so no space  need  be
allocated  beforehand.	GRAFTRAX%  is set to the address  of  the
array  where the routine is stored.  Y% is set to the address  of
the last element of array STACK%,  since a stack builds  downward
in memory.  The routine is CALLed and itself generates and INTer-
rupt  5 instruction the same way as if the Shift + PrtSc keys had
been pressed, except when it checks for the shift key.

     Line 60 & 70 are the DATA for the POKEs into array CG%.

     That's it! If you really wanted to BLOAD GRAFTRAX.COM into a
BASIC program,	you should be able to figure out what to do  from
the assembler file.


     Good  luck with this.  If you have any problems,  or want to
show me what my routine is up to,  drop me a line,  or	call,  or
send some electronic mail.

			   Marty Smith
		      COMPUSERVE 72155,1214
		      310 Cinnamon Oak Lane
		      Houston, Texas  77079
	(713) 462-5760 - Office , (713) 464-6737 - Home.
