Date: 18 Jan 1984 13:54:34 EST (Wednesday) From: Robert Bloom Subject: Plotting w/ a dot-matrix To: All Ever get frustrated because you have this great multi-k$ CP/M machine with a dot-matrix printer probably with graphics capability and you can't do any kind of graphics other than the dumb typewriter character pictures while the Apple, Atari, IBM, Commodore (etc.) people have those nice screen drawing and screen dump to the printer programs that just drive you green from jealousy? Is that's what bothering you bunky? (Boy, would my English teacher have fun with that paragraph!) Well, I can't help you intirely but based on a Dec BYTE article you can at least make a token response if you have MBASIC. The BYTE article described "Dragon Curves" - those curves that result from folding and unfolding a strip of paper. (You got to read the article to see what I mean.) These curves were then plotted ON DISK which was then output to a dot-matrix printer put in graphics mode, reproducing the plot on paper without any need to display it on the screen. The BYTE program was written in TRS-80 Disk Basic and for a IDS Paper Tiger (6 dots per pass). I've re-written it for MBASIC making the following changes: allowing any number of dots per pass (7 is what my printer does, I believe the Epsons print 8) unlimited width and length, and auto file sizing is possible. So, if your interested in the capability of making pictures to be output on a graphics dot-matrix printer WHILE USING A VANILA CP/M SYSTEM read on. I've made up two examples of programs that use the diskplot routines - one does the dragon curves of the BYTE article and the other draws "mandalas" - a plot of a polygon where a line is drawn from every vertex to every other. Both are standard MBASIC files. Files are gendragn.bas and mandala.bas. The diskplot program has the following routines: set up (must be called first - initializes disk file for plot, asks for size of plot if not given); plot a single point at X,Y; plot a line from X1,Y1 to X2,Y2; close file; and print file. More information is available in the BYTE article. If interested, try them yourself and report back to me. Please forward to others, tell you friends, etc. After any obvious bugs are found/corrected, I'll make a general annoucement to net.micro.cpm. As written there is some easily identifiable hardware-specfic code for clear screen/cursor positioning. The printer I used was a IDS Microprism 480. (7 dots per pass, 84 dots/inch) What I really like to see is someone take these algorithyms (or something like that) and convert to .ASM or .C or something compileable. (Maybe add routines for scaling of the plot, plot circles, arcs?) DiskPlotting in MBASIC is not fast, it took ~100 minutes to plot the 13 order Dragon curve (~8000 segments) and ~2.5 HOURS for a 25 point polygon mandala (314 lines). It only takes 2 minutes of so to print the plot after is is generated. The order 13 dragon (classical w/ segment size 2) diskplot file was 69k, the 25 point mandala 29k. can upload these too if anyone asks (full 8-bit binary files). Tell what you think of it! -Bob Bloom ----------------------------------------------------------------------------- Date: Fri, 20 Jan 84 9:47:16 EST From: Eli H. Freedman To: Bob Bloom cc: George Keller Subject: Purty pictures, anybody? You are so right!! I am sooo envious of the plotting capabilities of what are otherwise inferior micros that I turn multicolor, not just green. This program appears to run OK with MBASIC (interpreter). Please suggest some good input values for a 10-15 min run. My own major requirement for a graphics program is not for one that will produce a figure; rather, I need a program that will produce a line plot from a given equation, and that will superimpose small circles or squares on this plot. I have seen ads for such programs in MICROSYSTEMS mag. Do you know anything about them? I'd be glad to order one if I was confident it would do the job. --------------------------------------------------------------------------- Date: Sun, 29 Jan 84 21:57:03 EST From: Bob Bloom To: All Subject: Eli's answer Eli (and George): Later on in this msg is an example .BAS file for your type problem - adapt to suit. Notes on the DiskPlot routines: 1. Diskplot assumes one dot per x or y value (Horz or Vert) 2. x runs from 0 to [the given max horz value] and is plotted from left to right; y runs from 0 to [the given max vert value] and is plotted TOP TO BOTTOM. 3. after plotting a line from (x1,y1) to (x2,y2), Diskplot returns with the old value of (x2,y2) in (x1,y1). Therefore, by just redefining (x2,y2) and calling 1000 (GOSUB 1000) repetitively will plot a continous segmented line. 4. Diskplot must know the size of the plot BEFORE the plot is started. One may pass the size to diskplot (in p9,p10) or diskplot will ask for the size. GenDragn calculates in the autocentering routine the max size of the dragon before calling diskplot. 5. Before any plotting is done, call 3000 (GOSUB 3000) to intialize plot and file. Then do plot. Close file with GOSUB 4000 and print with GOSUB 4000. 6. One can OVERLAY plots - open a "old" plot file and diskplot will put the new lines overtop the old plot. This is good if one has a grid with axis as a template file and wish to plot over it. 7. Scaling and offset must be applied BEFORE plotting so all value are positive and within maximums. The program will not crash but will complain about out-of-range points. 8. take the "'" mark off statements number 1580, 2720, and 2820 to watch as points are plotted. It will run half as fast. 9. As diskplot is written now, the character to put the printer into graphics mode is 03 (^C), graphics new-line is 03,14; print a 03 is 03,03; and exit graphics is 03,02. Check these against you printer documentation. Also my printer prints 7 dots at a pass (diskplot variable p12). Bit 7 (MSB) is initialized as set so a graphics "space" is output as 80h. This was done because my parallel output BIOS driver was doing something funny with some of the lower characters. Again, check what your printer expects. for a fast running GenDragn: use any order less than 8 and segment size less than 10; use autocentering. For a fast running Mandala: use a radius of 60 or less and 5 or less points. (George: would a discussion of diskplot be germane to cp/m hackers? - I'd be willing to discuss it and give pointers on how to use the routines) Now: a sample program to plot a F(x)=sin(x); x in rads. <<< see SINEWAVE.BAS >>> Copy lines 1000 through 6000 from mandala (or gendragn - there're the same) for the diskplot routines and add them on to the end of this. (NOTE: I did not try to run this yet - but it "should" work. I'll try it later and msg you if i goofed anywhere.) I'll also leave it as an "exercise for the reader" to write subroutines to draw boxes, circles, etc. around designated points; fancy axis; labeling; etc. It's not hard, just teadious. As Richard Conn likes to say, enjoy! -bob bloom ----------------------------------------------------------------------------- Date: Sun, 29 Jan 84 20:56:45 EST From: Ferd S. Brundick To: Bob Bloom Subject: Graphic Alphabet Haaah, Friday night I typed in the DotPlot program, then read the Byte article and my printer manual. I haven't actually run the program yet because I have 256 byte sectors (like the TRaSh 80) and my printer prints all 8 bits. There are some other peculiarities as well. I wrote a little BassIC program to try out graphics mode, and when it worked I got a little crazy -- yesterday and today I built an alphabet! I found a "balloon" alphabet in a cross stitch book of mine: each letter (upper case) is 20 dots high by 15 dots wide [I have lower case patterns but haven't installed them yet]. At a resolution of 144 dots per inch the letters come out a reasonable size (of course I'll bring samples to work). I simply (but tediously) built an array AL(26,2,14) [each index starts at 0] where each cell contains an 8-bit value. Here is a sample letter: XXXXXXXXXXXX XXXXXXXXXXXXXX Of course this example is distorted because XXXXXX XXX the X's are not square. I had to write the XXXXX XX program in NEC-BASIC because EBASIC doesn't XXXXX have an LPRINT command OR POKE OR USR (and it XXXXX can't print 8-bit anyway). That means I XXXXX can't upload the file, but I did run off a XXXXX hard copy. Once the program worked, I XXXXXX modified it so that it would either print a XXXXXXXXX string or display a single letter on the CRT XXXXXXXXX (using PSET). My future goal is to write a XXXXXX CP/M program (hopefully in Turbo Pascal) that XXXXX would be an interactive character editor XXXXX (similar to Fancy Font). Storing alphabets XXXXX in files would be a LOT easier than stuffing XXXXX them into DATA statements. Stay tuned.... XXXXX XX XXXXXX XXX XXXXXXXXXXXXXXX XXXXXXXXXXXXXX dsw, fferd ---------------------------------------------------------------------------- Date: Fri, 3 Feb 84 13:44:13 EST From: Eli H. Freedman To: Bob Bloom Subject: Graphics on EPSON--how? Do you know anyone who has used your graphics program with an EPSON printer? I cannot figure out what value PE$ should be. If I understand the Manual, I'm supposed to specify the no. of columns in each line. Can this be so? ---------------------------------------------------------------------------- Date: Sat, 4 Feb 84 22:08:32 EST From: Bob Bloom To: Eli H. Freedman Subject: Re: Graphics on EPSON--how? PE$ is the character (or characters) than when sent to the printer put it into the graphics mode. There is also some code to be able to send PE$ as a graphics CODE, vs. sending it as a control-code. If you'll bring the EPSON manual over to my office, I'd be quite willing to try to see what you need to do.