home *** CD-ROM | disk | FTP | other *** search
- DISKPLOT
-
- DISKPLOT was first published in the DEC 83 BYTE in an article by Dan
- Rollins. Rollins wrote the routines for TRS-80 Disk-BASIC and a IDS
- Paper Tiger printer. I took the basic programs and re-wrote some of
- the machine dependant parts for CP/M MBASIC and a generic printer.
-
- Files included are:
- DISKPLOT.BAS the diskplot routines.
- GENDRAGN.BAS Rollins original program as published above.
- MANDALA.BAS Plots polygons with all points connected.
- SINEWAVE.BAS Simple example of a f(x) plot.
- DISKPLOT.DOC this file
- DISKPLOT.MSG Messages I've received on diskplot.
-
- GENDRAGN, MANDALA, and SINEWAVE all require DISKPLOT.BAS to be merged
- in to run.
-
- GENERAL DOCUMENTATION
-
- As one can easily see, large plots with many dots would require mucho
- memory if one wnated to hold the entire plot in memory at one time.
- What Rollins did was to develop a method to hold the plot on disk,
- instead of memory, so that one is limited now only by disk space. I
- recommend the BYTE article ("A Dragon meets a Tiger") for a more
- indepth discussion of the dragon curve and the diskplot routines.
-
- Of course, some of the picture must be held in memory as the plot in
- generated. The part of the picture in memory can be considered a
- "window" to the entire plot held on disk. In some cases, for smaller
- plots and/or for programs that don't require much room, (leaving more
- room for the plot) the entire picture can be held in memory at one
- time.
-
- The plot is made of of "dots" - horizontal and vertical. The width is
- divided up into 128 dot "sectors", cooresponding to the normal string
- length in MBASIC. DISKPLOT will allocate as many sectors across as
- necessary. The vertical length is divided into "lines" - the number of
- dots per line is dependant on the number of dots per pass your printer
- will print. (Mine prints 7 per pass.) Each line is placed in a buffer
- in memory when dots are to be plotted in that line. The more lines
- that can be held in memory (that is buffers) at one time the better.
- Minimum number of lines held in memory is 3 (caused by the way the
- program is written - read the article to see why.)
-
- Summary of DISKPLOT routines:
-
- 1. Open file. requires: Maximum horizontal value
- (GOSUB 3000) Maximum vertical value
- Number of buffers to use
- filename to store plot
-
- This routine must be called first. Note the the size of the
- plot must be known before any plotting is done. X runs from 0 up, left
- to right; Y runs from 0 up, top to bottom. One can give diskplot the
- numbers to use for max X and Y and it won't ask for them. One can also
- have diskplot calculate the maximum number of buffers to use. (A
- danger in this - diskplot will try is use all available memory for the
- buffers, leaving little for additional programming variable space.)
-
- 2. Plot Point. (GOSUB 1500) requires: X,Y
-
- turns the point X,Y on.
-
- 3. Plot Line. (GOSUB 1000) requires: (x1,y1) and (x2,y2)
-
- turns all points between (x1,y1) and (x2,y2) on. Upon
- return, (x1,y1) will have the value of (x2,y2) making the creation of
- segmented lines easy.
-
- 4. Close file. (GOSUB 4000) requires: nothing
-
- 5. Print file. (GOSUB 5000) requires: filename to print
- number of sectors across
-
- both required variables may be passed.
-
- MACHINE DEPENDANCIES
-
- Terminal: the terminal control codes for clear screen and cursor
- positioning is used in a minor way. Although not necessary, it does
- make the status messages "neat".
-
- Printer: (all required) dot-addressable printer, with least
- significant bit at top of graphics "line". One must know, and patch
- into diskplot, the printer control codes for entering graphics, exiting
- graphics, and the code to do a graphics linefeed (so that the next
- graphics pass just lines up with the previous pass). Code is also
- included if the graphics escape character needs to handled differently.
- [On the IDS, ASCII <3> signals to go into graphics; <3>, <14> for a
- graphics linefeed; <3>, <2> to exit graphics; and <3>, <3> means print
- a graphics <3>.]
-
- System: Must be able to print (i.e. pass through from MBASIC to
- the printer) all graphics chars unchanged. If your BIOS mucks up some
- of the control characters, try setting all MSB's, providing of course
- that your printer ignores the MSB! That way ASIC code characters 0
- through 32 get sent as 127 through 159.
-
- DISKPLOT Variable Usage
- by Dan Rollins as in the Dec 83 BYTE
-
- the following variables are used by diskplot:
-
- P1 Record in buffer 1 (lowest in memory)
- P2 physical file sector # (used in GET and PUT)
- P3 current Record (Y/P12)
- P4 current bit to set
- P5 highest RECORD on disk
- P6 total number of BUFFERS (is forced to be odd)
- P7 Buffer currently being accessed
- P8 middle buffer (INT(p6/2)+1)
- P9 total vertical dots (maximum Y)
- P10 total horizontal dots (maximum X)
- P11 number of physical records per Buffer (line)
- P12 number of vertical dots per buffer (dots per line)
-
- PH number of string in buffer
- PL X offset within buffer string
- (also length of string to LPRINT)
-
- PP current value of byte to alter
- PQ temporary value, counter
- PI temporary value, counter
- PJ temporary value, counter
- PS sector to start clearing file
- PZ priming variable (=1 on first call to 1500)
-
- X horizontal ordinate to plot
- Y vertical ordinate to plot
- X1,Y1 starting point of line to draw
- X2,Y2 ending point of line to draw
-
- PD(n) value to OR for setting dot n (0 is top)
- PW(n,1) flag indicates that a Buffer has been changed
-
- PB$(n,1) Buffer storage strings (128 char length)
- PC$ 128 graphical blanks CHR$(0)
- PE$ graphics escape CHR$(3)
- PF$ disk filename for plotter image
- PQ$ priming flag (="O" for Overlay option)
- PR$ FIELDed string (funnels all disk data)
- PU$ PRINT USING image for plotting data
-
- L1 Distance of long-axis
- L2 Distance of short-axis
- L3-6 horizontal and vertical steps (1,-1 or 0)
- L7 duty master (for determining ratio)
- L8 temporary value, long-axis counter
-
- CS$ Clear Screen
- CPn$ Postion cursor to n'th line
-
- Other notes:
-
- One may overlay old file plots with new information, provided both use
- the same number of sectors per line. This is good for plotting on a
- predefined grid.
-
- If, upon entering diskplot and opening a file, P9 and/or P10 are zero,
- diskplot will ask for the size of the plot. Likewise upon printing a file,
- diskplot will ask for the filename and sectors per line if PF$ and P11 are
- <null> and 0 respectively.
-
- Several lines in diskplot are commented out for speed reasons. If you
- want to see how diskplot is working, at the expense of some speed,
- remove the comment marks.
-
- diskplot can be asked to calculate the number of buffers. (The number
- of graphics lines to be held in memory at one time.) Note that all
- available memory will be grabbed so do not use this option if many
- program variable are still to be defined.
-
- The three example programs show various ways of using diskplot.
- GENDRAGN calculated all of the points necessary and the size of the
- dragon curve BEFORE diskplot is ever called. MANDALA uses very few
- variables, so the lines are calculated as needed and immediately
- plotted. SINWAVE is an example of what can be done to plot a function
- of x.
-
- diskplot.msg contains more information in the form of messages sent and
- received.
-
- Additional routines, comments, bug reports, etc. are welcome. I
- reserve the right to ignore any or all of the same. This is a hackers
- program!
-
- Bob Bloom
- 5 McCord Drive
- Newark, DE 19713