home *** CD-ROM | disk | FTP | other *** search
-
- The next file is called TEST.BAS. It is a sample program that
- illustrates how to use the routines in GRAPH.BAS. To use TEST,
- enter BASIC-80, then LOAD "GRAPH.BAS". MERGE "TEST.BAS", and RUN
- it. The program can produce one or both of two plots. The first
- is a polygon with all of the vertices connected to each other.
- This provides a good test of the line drawing capabilities of
- PLOT. The second plot is a graph of a damped sine wave. It
- illustrates nearly the complete range of PLOT's capabilities.
-
- Two programs, FILLS and UPLOAD, are an aid to experimenting with
- the patterns used to represent colors by PLOT33. Both are to be
- used with GRAPH.BAS in the same way as TEST.BAS. FILLS.BAS will
- produce an array of blocks showing the stipple patterns used to
- represent each "color". This makes an easy reference for future
- plotting. UPLOAD.BAS is similar to FILLS.BAS, except that before
- plotting the blocks, it Uploads new definitions for the patterns.
- The dither matrix used is like the example used in the previous
- section. The DATA statements of this program can be changed to
- experiment with different definitions and then incorporated into
- your applications.
-
- The final program is HANDPLOT.BAS. This is a general purpose
- program for manual plotting of data. The program uses a menu to
- display the BASIC plot package settings and allow them to be
- changed. Data can be typed in from the keyboard, saved in a disk
- file, and plotted. A limited number of symbols are avalilable for
- identifying data points and the points may optionally be
- connected by straight lines. Plotting scales and axes may be
- specified manually, or determined automatically from the range of
- values in the data. To make it easy to enter this program
- directly from the operating system command level, the routines in
- GRAPH.BAS have already been included and no MERGE operation is
- required.
-
- When HANDPLOT is first entered, it prompts the user for the name
- of the .VEC file, and for the dimensions of the data arrays. It
- then displays the menu. The menu is divided into three parts
- which are concerned with the data, the format of the graph, and
- the activities that can be performed by the program. It will look
- like this:
-
- DATA SETTINGS
- No. of Variables 0 No. of Points 0
- 1> Data Entry KEYBOARD 2> Input File
- 3> Output File
- 4> X Variable 5> Y Variable
- 6> Symbol NONE 7> Connect points FALSE
-
- GRAPHIC SETTINGS
- X Axis 8> Min 0 9> Max 1 10> DeltaX 1
- 11> Label Chars 0 12> Divisions 0
- Y Axis 13> Min 0 14> Max 1 15> DeltaY 1
- 16> Label Chars 0 17> Divisions 0
- Margins 18> Left 0 19> Right 0
- 20> Bottom 0 21> Top 0
- 22> Color Value 127 23> Auto-Scale TRUE
- 24> Clear Plot Area First FALSE
- 25> Plot Output File Name JUNK.VEC
-
- ACTIONS
- 26> Read New Data 27> Edit data 28> Write Data
- 29> Plot Graph Axes 30> Plot Data 31> Title Plot
- 32> Advance Page 33> End Program
-
- Enter Number of SETTING or ACTION?
-
- From here, the program is operated by giving all of the required
- settings their correct value, and then selecting the desired
- action. This is done by entering the number printed next to the
- entry on the menu. Each setting will then prompt you for the data
- that it needs, if any. Several settings, such as Data Entry, only
- toggle between two values; in this case, KEYBOARD or DISK. The
- settings may be entered in any order.
-
- The first thing you will probably want to do is to enter some
- data to be plotted. If the data is to be read from a disk file
- instead, then enter 1 to toggle to DISK. You will then have to
- enter 2 to have the program prompt you for the input file's name.
- If the data is to be typed in, you are already to go. Now enter
- 26, and the program will start to read the disk file, or prompt
- you for the data. Once the data has been read in, it can be
- changed using option 27, Edit Data. The data can also be stored
- on disk using option 28. The output file name is handled in the
- same way as the input file name.
-
- Next you will want to indicate, using settings 4 and 5, which
- variables are to be used for the X and Y axes and whether the
- points should be plotted with one of the available symbols and/or
- connected with straight lines.
-
- If you are simply plotting a figure, you are ready to plot it
- using option 30, Plot Data. If you are plotting a graph, then all
- of the settings in the next section should be given their correct
- value before plotting the axes with option 29. Several sets of
- data can be plotted on the same graph, simply by changing the X
- and Y variables and symbol and plotting the data again. Strings
- can be printed anywhere on the graph using Option 31.
-
- The DeltaX and Divisions settings are linked to each other, as
- are the DeltaY and Divisions setting for the Y axis. When the
- DeltaX or DeltaY setting is changed, the Divisions settings will
- be reset to indicate the number of divisions between the Min and
- Max values. If the Divisions setting is changed, the DeltaX or
- DeltaY setting will be calculated to give a good engineering
- value (multiples of 1, 2, 5, or 10), and the Divisions setting
- will reflect the revised number of divisions. Thus the value you
- enter into the Divisions setting will only be approximately the
- value that will ultimately result. If your engineering esthetics
- differ from the program's, you will have use the DeltaX and
- DeltaY settings.
-
- In a similar fashion, the Auto-Scale option will reset the Max
- and Min values to include the actual range of the data, and will
- use the Divsions settings to indicate the approximate number of
- labels to use for each axis.
-
- Advance Page will issue an Output command, clear the frame, and
- set the color to black for further plotting. The frames will be
- plotted one after the other with no space in between them. End
- Program will issue an Output command, close out all files and,
- return to the BASIC command level.
-
- Several plots can be put on one page, simply by adjusting the
- margin values between plotting each graph. If Clear Plot Area
- First, setting 24, is TRUE, the area inside the margins will be
- erased to white using the Fill command before the axes are
- plotted. This is useful for plotting one graph as an inset within
- a larger figure.
-
- The data file has a simple format, and can be made using your
- editor or another program, rather than laboriously entering all
- the data with HANDPLOT. The first record contains the number of
- variables, or fields, in the data records to follow. The next
- entries are names, up to 20 characters long, for each of the
- variables. These can be on the same line, separated by commas, or
- each may be on a record by itself. The data values are next. One
- value for each variable is read in turn, until the end of the
- file is encountered. The values on any given line are separated
- by commas, and each logical record (one value for each variable)
- may be spread over several lines of data. A sample data file is
- shown below:
-
- 3 <--- Three Variables
- X, Y, Z <--- Names for each variable
- 123, 4.56, 78.9 <--- First record: X=123, Y=4.56, Z=78.9
- 10.11,1213,1516.17
- 18.0, 19.0, 20 <--- Last record
-
- TURBO PASCAL Library
-
- Turbo Pascal support is provided in the form of two "include"
- files and one test program. GRAF1.PAS contains the global
- declarations and lowest level routines. These provide direct
- access to the commands in the .VEC file. It also provides
- functions to do scale conversions. GRAF2.PAS uses these routines
- to provide the additional capability to plot graphic characters,
- plot axes, and do whole Cartesian grids. Each routine and its
- calling arguements are summarized in Table 2.
-
- Plotting is initiated with the procedure GRINIT. This procedure
- opens the disk file and initializes the plot, as discussed
- previously. It also initializes all global variables. The GRFINI
- routine writes the Output and Quit commands and closes the plot
- file.
-
- The following routines correspond directly to commands in the
- plot file: COLOR, ERASE, FILL, GPRINT, GSTRNG, GMOVE, POINT,
- SEGMNT, and VECTOR.
-
- Scaling is accomplished by using RWINDO to set the real world
- limits and SWINDO to map the real world limits to a specific area
- on the page. In the interest of execution speed, no clipping is
- done to ensure that the plotting is confined to either window.
- The functions SX and SY are used to convert from the real world
- coordinates to the normalized device, or "screen" coordinates.
- The reverse conversion is performed by RX and RY.
-
- GRAPH plots a complete grid given the range of data and area on
- the page. AXIS can be used to make special graphs and DXDY will
- calculate good engineering values for AXIS. The graphic
- characters and strings are plotted by GCHAR and GWRITE,
- respectively.
-
- TABLE 2
-
- TURBO PASCAL ROUTINES
-
- Name Inputs Outputs Function
-
- ----------------------------------------------------------------
-
- color Sets color/pattern- sends Color command.
- code integer which selects color or pattern
-
- erase Clears page- sends Erase command.
-
- fill Fills trapezoidal area- sends Fill command.
- x1 normalized X coordinate for start of segment
- y1 normalized Y coordinate for start of segment
- x2 normalized X coordinate for end of segment
- y2 normalized Y coordinate for end of segment
- yf normalized Y coordinate for fill level
-
- gmove "Pen up" move to point- sends Move command.
- x normalized X coordinate
- y normalized Y coordinate
-
- gprint Prints picture- sends Output command.
-
- grinit Initializes .VEC file
- name string specifying name of .VEC file
-
- grfini Quits plotting, closes .VEC file
-
- gstrng Prints string- sends String command.
- x normalized X coordinate for first character
- y normalized Y coordinate for first character
- strng string to be plotted (no <CR> at end)
-
- point Plots point- sends Point command.
- x normalized X coordinate
- y normalized Y coordinate
-
- segmnt Plots line segment- sends Draw command.
- x1 normalized X coordinate for start of segment
- y1 normalized Y coordinate for start of segment
- x2 normalized X coordiante for end of segment
- y2 normalized Y coordinate for end of segment
-
- vector "Pen down" move- sends Increment command.
- x normalized X coordinate
- y normalized Y coordinate
-
- Name Inputs Outputs Function
-
- ----------------------------------------------------------------
-
- rwindo Establishes real window for scaling.
- xmini real world value at left side of window
- xmaxi real world value at right side of window
- ymini real world value at bottom side of window
- ymaxi real world value at top side of window
-
- swindo Establishes window on page for scaling.
- sxlti normalized X coordinate for left side
- sxrti normalized X coordinate for right side
- syboti normalized Y coordinate for bottom side
- sytopi normalized Y coordinate for top side
-
- sx Converts from real world to normalized coord
- rxi real world X coordinate
- sx normalized X coordinate
-
- sy Converts from real world to normalized coord
- ryi real world Y coordinate
- sy normalized Y coordinate
-
- rx Converts from normalized to real world coord
- sxi normalized X coordinate
- rx real world X coordinate
-
- ry Converts from normalized to real world coord
- syi normalized Y coordinate
- ry real world Y coordinate
-
- axis Plots axis at arbitrary orientation.
- r1 real world value at start of axis
- r2 real world value at end of axis
- dri real world increment for tic mark intervals
- sx1 normalized X coordinate for start of axis
- sy1 normalized Y coordinate for start of axis
- sx2 normalized X coordinate for end of axis
- sy2 normalized Y coordinate for end of axis
- ticlen normalized length of tic mark
- ticang CCW angle, in deg, from horiz. to tic mark
- lblnum integer number of char's in tic mark label
- lbldec integer number of char's after decimal pt.
- lblang CCW angle, in deg, from hor. to lbl X axis
-
- Name Inputs Outputs Function
-
- ----------------------------------------------------------------
-
- graph Plots complete Cartesian grid.
- xmini real world value at left side of graph
- xmaxi real world value at right side of graph
- nx integer- approximate number of X intervals
- ymini real world value at bottom side of graph
- ymaxi real world value at top side of graph
- ny integer- approximate number of Y intervals
- sxl normalized X coordinate for left side
- syb normalized Y coordinate for bottom side
- sxr normalized X coordinate for right side
-
- chset Sets size and orientation of graphic char's
- xsize normalized width of character
- ysize normalized width of character
- theta CCW angle, in deg, to char X axis from hor.
-
- gchar Plots graphic character.
- cx normalized X coord of bottom left corner
- cy normalized Y coord of bottom left corner
- charin ASCII character to be plotted
-
- gwrite Plots string of graphic characters.
- x normalized X coord of bottom left corner
- y normalized Y coord of bottom left corner
- chars string to be plotted
- nchar integer number of characters to be plot
-
- dxdy Calculates arguements for axis.
- x1 real world value at start of axis
- x2 real world value at end of axis
- nx integer- approximate number of intervals
- lblnum integer number of char's in tic mark label
- lbldec integer number of char's rt. of decimal
-
- posang Converts angle to range in 0 to 360 deg
- angle angle to be converted
- posang converted angle
-
- ticend Calculates values for ends of axis
- rmin raw real world value for start of axis
- rmax raw real world value for end of axis
- dr real world increment between intervals
- pr1 converted real world value at start of axis
- pr2 converted real world value at end of axis
-
- Name Inputs Outputs Function
-
- -----------------------------------------------------------------
-
- writecmd Buffered output of command string to file.
- cmd output string
- cmdlen integer number of characters to be output
-
- buffout Flushes buffer.
- outunit file variable specifying output file
- outbuf string of characters forming buffer
- size number of characters to be sent out
-
- concat2 Concatenates portions of strings.
- strng1 first string to be concatenated
- nchar1 number of characters from strng1
- strng2 second string to be concatenated
- nchar2 number of characters from strng2
- strng3 string containing strng1 and strng2
-
- FORTRAN Library
-
- A collection of FORTRAN routines is also included in GRAF.FOR.
- This file is the FORTRAN complement of the Turbo Pascal library.
- The input and output requirements for the FORTRAN routines are
- similar to those of the Pascal routines, and are fully documented
- in the comments within them. They communicate with each other
- through a labeled COMMON block. These routines have been run
- under Microsoft FORTRAN-80, but may require some modification for
- other compilers.
-
- PART 3. INSTALLATION INSTRUCTIONS
-
- Sizing the memory map
-
- PLOT33 has been designed to keep the printer driver program small
- while providing the necessary primitive graphic operations for
- producing most pictures and plots. The reason for the simplicity
- of the of the command set is because the bit map for the picture
- is LARGE. It can use as much memory as your computer can give it.
- The size of the memory available for the bit-map, in conjunction
- with the resoultion of your printer, sets the size of the plot
- that can be made. The first step in installing the program is to
- decide how large the memory area for the bit map can be. The
- program itself occupies about 4K. Subtract this from the size of
- the TPA, and reduce the result by a little more to provide a
- conservative pad. The end result is the target size for the size
- of the memory map.
-
- Divide the target size by the printer resolution (dots per inch)
- in the horizontal direction, and divide again by the printer's
- vertical resolution. Multiply this result by 7 (7 dots are stored
- in each byte). You now have the number of square inches that can
- be plotted. Take the square root, and round down to a convenient
- size for each side of the plot.
-
- Now multiply the height of the plot by the printer's vertical
- resolution and round down to the nearest multiple of 7. The
- number of dots in the vertical direction should be a multiple of
- 7 because seven dots are stored in each byte of the memory map.
- PLOT33 has no provisions for handling a byte which is contains
- bits that are part in and part out of the map. You now have the
- total number of dots in the vertical direction, and dividing by 7
- gives the number of lines that will be printed when the plot is
- made. Finally, divide the number of dots in the vertical
- direction by the vertical resolution to get the final size, in
- inches, of the plot.
-
- Multiply the final size of the plot by the horizontal resolution
- to get the final number of dots accross the page. The final map
- size is the product of the number of dots horizontally multiplied
- by the number of dots vertically, divided by 7.
-
- As an example, consider a 56K CP/M system. Subtracting 4K for the
- PLOT program and 100H for the start of the TPA:
-
- Target Size = 57344 - 4096 - 256 = 52992 bytes
-
- The Epson MX-80 has 60 dots per inch horizontal and 72 dots per
- inch vertical resolution.
-
- Target Size/ Hor. Res./ Vert. Res. * 7 =
- 52992 / 60 / 72 * 7 = 85.9 sq.in
- ==> 9.2 in. per side
-
- Since the MX-80 can only plot 8 inches horizontally, the plot is
- limited by the physical limits of the printer, not by the memory
- avalilable. Calculating the vertical number of dots for an 8 inch
- plot:
-
-
- 8 * 72 = 576 dots ==> 82 lines @ 7 dots/line
- ==> 574 dots vertically
-
- Since only 2 dots were lost due to truncating to the nearest
- number of whole bytes, there is little point in trying to adjust
- the horizontal size to keep the plot square. The horizontal size
- is therefore:
-
- 8 * 60 = 480 dots
-
- The final map size is calculated as:
-
- 480 * 574 / 7 = 39360
-
- Printer settings
-
- Once the plot has been sized, you are ready to modify the
- settings in the assembly language source file (PLOT33.ASM). This
- file is large, over 70K, so watch the disk space. If your editor
- cannot handle a file this large, the CP/M standard editor, ED,
- can. ED can also read from one disk and write to another, if
- necessary. For each type of printer there is an associated flag
- that controls the conditional assembly for that printer. Set the
- flag for your printer to TRUE and set the others to FALSE. If
- your printer is not listed, it may be similar to one that is. For
- example, the Gemini-10 operates identically (for the purposes of
- this program) with the Epson printers. The IDS printers use the
- same method as the Okidata printers for their graphics, and the
- NEC printers act the same as the C.Itoh printers.
-
- Next, the settings for your printer must be changed or verified.
- MAPSIZE should be set to the value calculated above. MAXX and
- MAXY must be set to 1 less than the number of dots in the
- horizontal and vertical directions. For the example above,
- MAPSIZE becomes 39360, MAXX is set to 479, and MAXY to 573.
-
- Once the settings are made for your printer, exit the editor and
- assemble the program using ASM or another 8080 assembler. Use
- LOAD to create the .COM file from the .HEX file, and the
- installation is finished.