home *** CD-ROM | disk | FTP | other *** search
-
- The String command is used to mix printed characters and
- graphics. The characters are printed using the printer's normal
- character set. No facility is provided in PLOT33 to send <ESC>
- codes or control characters to the printer to change character
- sizes or font styles. The string is printed starting near the
- coordinates given in the command. The exact position will vary,
- but the first character will cover the coordinate location. The
- ambiguity comes from the fact that most printers can only print
- characters at their normal location on the page, and can't use
- graphics commands to position the characters at any arbitrary
- place on the line. In addition, a printed character can't be part
- on one line of print and part on another. Therefore, PLOT33
- computes the closest character location to the desired
- coordinates and begins the string there.
-
- The Text command will immediately send a text string to the
- printer when the command is encountered. This is quite different
- from the String command, because the text is not put in the
- memory map and is not part of the picture. This command is useful
- for positioning the plot on the page, for printing titles and
- headers, and for advancing to the next page after the plot is
- printed. Any ASCII characters may be included in the string,
- including control codes, escape sequences, carriage returns, and
- linefeeds. The only exception is the null character, 00H, which
- is used to signal the end of the string. The string may be of any
- length. This makes it a convenient way of imbedding a figure in
- the middle of a document, since all of the text above the figure
- can be included in one Text command, as can all of the text after
- the plot. Any text to be included in the plotting area itself
- must be entered one line at a time with the String command.
-
- Upload Command
-
- The Upload command deserves some special attention, because it is
- the least standard of all of the commands currently implemented.
- Most dot matrix printers can, of course, only print in black. To
- give these printers a "color" capability, different patterns have
- been programmed to produce shades of gray and distinctive cross
- hatched patterns. The cross hatched patterns are intended to be
- used for bar charts, dotted and dashed lines, etc. The shades are
- the closest that PLOT33 can come to true colors. The special
- patterns are very useful for matching patterns produced by other
- systems, and for anything that just can't be done with the other
- two methods. The Color command acts as a selector to choose
- between the pre-defined patterns. The Upload command is only
- needed if the default patterns are not capable of producing the
- desired effect. It will redefine the patterns from which the
- Color command can select.
-
- The cross hatched patterns are based on seven bytes that provide
- the basic patterns in both the vertical and horizontal directions
- for each cell. One byte from the seven is selected as the X
- pattern and one byte from the seven is selected as the Y pattern.
- The X pattern is extended vertically throughout the cell, and the
- Y pattern is extended horizontally throughout the cell. The two
- patterns are reversed (XOR'ed) where they cross. The effect is
- much like weaving a plaid material. The selection of the bytes
- for the X and Y patterns is made by the Color code. The lower
- three bytes of the Color value select the X byte and the next
- three bytes select the Y byte. The best way to determine the
- exact appearance of each pattern is to experiment by filling
- blocks with different patterns.
-
- If the existing patterns are not acceptable, new ones can be
- Uploaded. Set the number field, N, to 07H. The next seven bytes
- will be the bytes that form the basis for the patterns. Each bit
- corresponds to a dot in the pattern. A byte of 07H for the X
- pattern would produce the pattern .....*** . If an F0H is used
- for the Y pattern, the final cell will look like:
-
- *****...
- *****...
- *****...
- *****...
- .....***
- .....***
- .....***
- .....***
-
- The second type of pattern, used for the 15 special patterns, is
- specified by giving the 8 bytes that produce the pattern. Thus,
- the sequence 00H 00H 99H 00H 00H 99H 00H 00H will produce the
- pattern:
-
- ..*..*..
- ........
- ........
- ..*..*..
- ..*..*..
- ........
- ........
- ..*..*..
-
- These patterns are uploaded by specifying 120 for N followed by
- the 120 bytes that define all 15 of the special patterns. No
- facility is provided for just uploading one set of 8 bytes.
-
- The other method for producing patterns for "colors" is an eight
- by eight byte dither matrix. In this method, each byte in the
- matrix corresponds to one dot in the eight by eight dot cell.
- These cells tile the picture plane, as before. Color code values
- from 64 to 127 are used to select the 64 patterns created by the
- dither matrix. Each element of the matrix is assigned a value
- from 63 to 126. If the Color value is greater than the value in
- the matrix corresponding to a given dot, that dot is plotted.
- Thus, 127 is greater than all of the elements, and all dots in
- the matrix will be plotted, producing black. If each element of
- the matrix is assigned a different value, then a unique pattern
- will be associated with each Color value. For example, if the
- Color code is 64, only the element with a value of 63 will
- produce a dot. If the Color value is 65, those elements with 63
- and 64 will produce dots. As the Color code is increased, and
- figures are plotted, another dot in the "tile" has the potential
- for being plotted.
-
- The existing arrangement of values in the dither matrix is
- designed to produce shades of gray with a minimum appearance of
- organized patterns. This matrix came from Foley and Van Dam's
- "Fundamentals of Interactive Computer Graphics". A common use of
- the Upload command is to change the matrix to provide diagonal
- patterns for shading areas. This would produce a pattern that
- looks like (for four cells):
-
- ////
- ////
- ////
- ////
-
- To design an Upload sequence for a given pattern, lay out a
- matrix representing a single cell. Start with 63 and place the
- numbers in the matrix in the pattern desired. For example, a cell
- from the diagonal pattern above could be created from the matrix:
-
- 63 111 85 103 75 115 93 95
- 112 64 104 86 116 76 96 94
- 79 105 65 117 87 97 77 121
- 106 80 118 66 98 88 122 78
- 71 119 81 99 67 123 89 107
- 120 72 100 82 124 68 108 90
- 91 101 73 125 83 109 69 113
- 102 92 126 74 110 84 114 70
-
- To see the pattern, look at the matrix part way through its
- construction:
-
- 63 75
- 64 76
- 65 77
- 66 78
- 71 67
- 72 68
- 73 69
- 74 70
-
- For this matrix, the Color code 79 will result in all of the
- above points being plotted in any filled in area, and the
- diagonal pattern will emerge.
-
- Once the matrix is constructed, the Upload command to load it is
- formed by an ASCII "U" followed by 40H, 00H to indicate 64 bytes
- to come, and finally 03H, 6FH, etc., the bytes of the matrix. The
- matrix is read in one row after another (the [1,1] element
- followed by the [1,2] element, ... , to the [1,8] element, then
- the [2,1] element, ... ). All of the matrix values are binary 8
- bit values. In BASIC, use the MKI$ function to convert the
- integers to strings, then use the first character.
-
- To summarize the Upload command: The Color codes from 1 to 48 are
- produced by cross-hatched patterns based on eight pattern bytes.
- These can by Uploaded by a "U" 08H 00H followed by eight new
- pattern bytes. The Color codes from 49 through 63 are Uploaded by
- a "U" 78H 00H and the 120 bytes that define the 15 cell patterns.
- The Color codes from 64 through 127 are produced by a dither
- matrix. This is created by assigning elements of an eight by
- eight matrix the values 63 through 126. The matrix is Uploaded by
- a "U" 40H 00H followed by the 64 elements in row major order.
-
- Pitfalls and Limitations
-
- This section amplifies the more subtle points and limitaions of
- PLOT33's commands.
-
- The valid range for coordinate values is 0 to 1. This corresponds
- to binary integer values from 0 to 32767. As each point is
- plotted, a check is made to insure that the coordinate is within
- the memory map. If it is not, the point is not plotted. This is
- mainly to keep the program from running amok and writing over
- parts of memory that are not part of the memory map of the
- picture. This is not intended to be a form of windowing. If you
- want to zoom in on a part of a larger picture, the picture should
- be clipped by the application program. Note also, that most high
- level languages will not deal with positive integers that are
- larger than 32767, as these larger numbers represent negative
- integers.
-
- In contrast to the coordinate values used for all of the graphic
- commands, any coordinate value outside the picture used to
- indicate the start of printing a string will be set to zero. This
- is intended to make the String command act as much as possible
- like a normal printer. When the string goes off of the right hand
- side of the plot, the X coordinate for the next character will be
- set to zero and the string will wrap around - just like a
- carriage return without a linefeed. All characters that attempt
- to be printed above or below the plot will be printed on the
- bottom line.
-
- String has a few other points of interest. Only printable
- characters should be used. Control characters and escape codes
- will occupy their respective positions in the memory map but will
- not be printed. This will cause the rest of the line to be
- shifted to the left and destroy its alignment with the rest of
- the page. Also, the character pitch must agree with the character
- width set at assembly time, or the alignment will be affected.
-
- The coordinates for the start of the string are truncated to the
- nearest multiple of the size of the character. Thus the specified
- point will be within the first character, but the character will
- not be centered or aligned with the given coordinate position.
- This was done because most printers insist that the printed
- characters occupy these locations, and PLOT33 has to respect this
- or the alignment of the rest of the line will again be affected.
-
- PLOT33 prints the strings, it does not plot them as line
- segments. Because of this, a printed character will absolutely
- occupy its location on the plot, and any overlapping lines or
- points will not appear. If a character is printed on a patterned
- background, it will appear as if it were in a white box the size
- of the character. If true graphic characters are desired, they
- must be drawn by the application program as line segments. An
- additional implication of the printed characters is is their size
- relative to the graphic bit images that are sent to the printer.
- The graphics are printed in "strokes" that are one dot wide and
- seven dots high. Many printed characters are higher than seven
- dots especially those that have descenders. A printed character
- occupies a space that is seven dots high in the memory map. Thus,
- the top line of capital letters and the lower case descenders can
- overlap the graphics area above and below the nominal area of a
- printed character. The distance that the paper is advanced
- between lines is dictated by the height of a graphic "stroke",
- and is nearly always smaller than the normal single spaced
- distance. Printed lines must therefore be "double spaced" by
- specifying starting coordinates that are well separated
- vertically. This is a device dependent aspect, and a litle
- experimentation may be needed to achieve a good appearance.
-
- The last caution about the String command is that it MUST end
- with a carriage return character. This signals the end of the
- string, and without it, the program will continue to read the
- rest of the input file as part of the string until it either
- encounters a carriage return or the end of the file. The String
- and Text commands are the only commands with this potential, as
- all of the others have a definite number of bytes of data. All
- these caveats regarding the String command may sound a little
- gruesome, but it is really not much different from normal
- printing. If its limitations are too inhibiting, you must draw
- the characters instead of printing them.
-
- The Text command is output to the printer at a different time
- than any of the other commands. Its contents are sent immediately
- when it is read, whereas all other commands cause their actions
- to be stored in the memory map and only printed when an Output
- command is received. Thus, it cannot be used to send escape
- sequences to the printer in the middle of the plot. Whether
- graphics commands (such as Draw, Fill, etc.) preceed or follow a
- Text command is immaterial, since these commands affect the
- memory map at the time that they are read and not the printer.
- What really matters is the position of a Text command relative to
- the Output commands in the file.
-
- Like the carriage return at the end of the String command,
- omitting the 0 byte at the end of the Text command can have
- disasterous consequences.
-
- The line spacing used in the Text command is different from the
- line spacing in the plot itself. The Output command sets the line
- spacing to be appropriate for graphics, and then resets it to the
- normal text single spacing when done. If a uniform appearance is
- required throughout, each Text command should contain the control
- characters or escape sequences required to set the line spacing
- to match that used in the plot itself.
-
- The final consequence of the line spacing is that the form length
- and the top of form position set in the printer will be wrong.
- The Output command will result in the printer being positioned at
- the bottom of the plot. This is to allow several plots to be
- printed sequentially as one continuous picture without any gaps
- between them. In order to advance to the top of the next page,
- the Text command must be used to issue the correct number of line
- feeds and then tell the printer to reset the top of form.
-
- The Output command does not erase the existing picture. Thus
- several copies of the same plot can be produced by repeating the
- command. In addition, this allows building up a picture in stages
- and printing it at each stage. To print one plot and start anew,
- you must Output the first, set the Color to white, Erase the
- page, and then set the Color back to the plotting color or
- pattern. The program does not automatically execute an Output
- command at the end-of-file or when Quitting. You must include an
- Output command to get any output at all. This philosophy is to
- accomodate those devices, like graphic terminals, that display
- the plot as it is being made, and only need an Output command for
- hardcopy.
-
- Error Messages
-
- Disk is Full.
-
- Fatal error. No more room exists on the designated disk for
- writing the output file. Ensure that enough room is available and
- run PLOT again. Note that a different disk drive may be specified
- for the output file than the one used for the input file. If disk
- space is not available, run PLOT in the direct printing mode.
-
- Any remnant of the output file may be printed, but the last
- record will probably contain an incomplete graphic output
- sequence. The printer will expect to receive additional bytes of
- graphics. This will produce a swath of dots with a random
- apperance, unless nulls are sent. In addition, the printer line
- spacing will remain set for the size of the graphic output.
-
- End of File.
-
- Fatal error. The end of the input file was encountered when PLOT
- attempted to read the next record. Add a Quit command for the
- normal termination of the program.
-
- File not Found.
-
- Fatal error. The file name given for the input file could not be
- found on the disk. Make sure that the spelling was correct, that
- the proper drive is specified in the file name, or the right
- drive is logged in as the default drive.
-
- No Directory Space Available.
-
- Fatal error. When PLOT tried to make a new output file, there was
- no more room in the disk directory. Erase a file, use a different
- diskette, or run PLOT in the direct printing mode, without making
- an output file.
-
- No File Specified.
-
- Fatal error. No input file name was given. PLOT will not prompt
- you for a file name, and there is no interactive mode for
- entering commands. Create an input file and try again.
-
- Undefined Command Character Encountered.
-
- Warning error. When PLOT attempted to interpret the ASCII letter
- portion of a command, a character was found which did not
- correspond to one of the established commands. PLOT ignores these
- characters and attempts to interpret the next character as a
- command. If a command does not have the proper number of data
- bytes, or if an extraneous character is inserted in the middle of
- the data portion of a command, the rest of the file will be out
- of sequence. Eventually, PLOT should get back in step with the
- command stream, but the overall effects are unpredictable.
-
- PART 2. APPLICATION PROGRAMS
-
- BASIC Programs
-
- Several sample BASIC application programs are included as
- examples of possible implementations. BASIC was selected because
- it is almost universally available on CP/M systems and is a good
- language for quick one-of-a-kind plots. The first file is
- GRAPH.BAS. This file contains a plotting "library" of routines
- that give direct access to the low level commands used by PLOT.
- It also includes routines for scaling, and for drawing a complete
- graph with labeled axes. This file is used by the other programs.
- For each command that can be written to the .VEC file, there is a
- corresponding subroutine in GRAPH.BAS.
-
- To use these subroutines, first load the appropriate variables
- with the necessary data. For example, to draw a line segment, set
- X1 and Y1 to the starting coordinates, and set X2 and Y2 to the
- ending coordinates (remember that all coordinate values are
- between 0.0 and 1.0). Then GOSUB to the subroutine for that
- function, in this case the DRAW LINE SEGMENT routine, which is
- currently line 177. That's all that is required. Drawing axes or
- graphs is done the same way. Set the required values and GOSUB to
- the appropriate routine. All of the variables are documented in
- the REM statements at the top of the file, and a sample plot is
- depicted, followed by the settings that would produce it. The
- BASIC package automatically issues the commands to initialize the
- plotting area, so you can start plotting immediately when the the
- application part of the program starts executing. End the plot by
- calling the QUIT PLOTTING routine, at line 200. This will
- automatically add the commands to print the picture and close the
- file.
-
- Four statement functions are provided to make it easy to scale
- your data and compute plotting coordinates. Functions RX and RY
- will convert your "real world" values to X and Y coordinates for
- plotting. Functions UX and UY do just the opposite, converting
- coordinates on the page to the equivalent coordinates in the user
- defined plane. These functions require that you have established
- the margins, etc. as if you were plotting a graph. The default
- values for these settings will result in the conversion functions
- simply returning the same value as their input. Note that
- although the margins are useful for confining the plotting to one
- section of the page, no clipping is done to insure that all of
- the points plotted are indeed confined to that area.
-