Micro_Cornucopia_#50_Nov89 Micro Cornucopia #50 Nov89
Micro_Cornucopia_#50_Nov89 Micro_Cornucopia_%2350_Nov89
User Manual: Micro_Cornucopia_#50_Nov89
Open the PDF directly: View PDF .
Page Count: 100
Download | ![]() |
Open PDF In Browser | View PDF |
No. 50 November-December 1989 THE TECHNICAL M o 3D Graphics In Depth This whole issue is a project. Put UNIX on your 386, build a board to grab video images, build another to analyze voices, and then display all your graphics in 3D. 3D-Surface Generation page 8 The PC Video Frame Grabber page 16 LIMBO, Part Three Our robot project rolls on. page 22 PostScriptal Two page 32 A very graphic look at a very graphic language. UNIX For The PC page 40 Which UNIX should you purchase for your new 386? There are some real bargains. And More • • • On Your Own An inside look at the lives of silicon valley consultants. o $3.95 7447019388 3 J 0 URN A.L . COPIA Ufl!lf?!iiJ J/@fl!lf? fP©lEifl5Ju O!iiJ(1@ ill [§J@r:JQf?iJfl!lO [Lo@@f?o(1@f?J/ O!iiJ@ &!iiJ@O!iiJQQf?O!iiJ@ (1@@ODDD Introducing ... The PC-LabCard Family Only from HSC Electronic Supply Dig ital 1/0 and Counter Card • 32 Digital Input Channels - TTL compatible - Low loading: 0.2 mA at OAV input • 32 Digital Output Channels - TTL compatible - Driving capacity: Sink 24 mA, source 15 mA • Intel 8253 Timer/Counter - 3 channels of timer/counter - Breadboard area for flexible user configuration PCl· 720 ...............................$160.00 I ~ . ~- ~ • • .~ ~ /;: ,-{:: ..,., ~.'" • Large breadboard area (3290 holes) • Independent memory and 1/0 address decoders built-in • Memory and I/O ports are jumper selectable • All bus signals are buffered, marked, and ready for use PCL-750 .................................... $74.00 "PC-LabCard" is a family of add-on cards to turn your PC into a high performance data acquisition/ testing system at an attractive price. - I ~ t. -; -:-:-~-,--< ?;:~,.-;<, It includes not only the hardware cards, but also the software, accessories and application support packages which come together to make a thoughtful solution to your PC-based automation needs. ... ' ~ '. Prototype Development Card IBM PC/XT/AT and it's compatible models are moving into Industrial/Laboratory applications at an increasing rate. The reasons for this include their price/performance ratio and short user learning curve. PC-based data acquisition boards are now taking the place of the traditional data loggers or recorders which cost. several times more. . ,:;:l!::~ 14 Bit Super-Lab AID + DIA + DIO +Counter -Analog Input (AID converter) - 16 different channels" - 14 bit, 25K/sec sample~ate ' ...•... ' -:-Input range: +5V to-5V, +1Vto.;1V •• >~naloglnput (t\IDconverter) ,·16single~ended channels, 12 bit -Input range:<+5Vto ~5V,+1Vto ~.1V -Analog Output (D/Acomierter) ~ DIA Channels: r standard/loptional -14 bit, +/- 5Vfullrage .' . • Analog (:>utput( 01A converter) ~ • 2channel,12 bit.· . ~O,,:+5Vfullrange ~•••• Digital I/O ~16phannelse~:lCh, TTLcompatible • Counter >r6hanneloftimer/counter ~.' PrOgrammable pacer function l=>CL~712 .. ~ .. ~; ....... ,.; ....... ;..... $295.00 llfl~~'(Q)f/~{ffJg~©D§JO'§J Steppi n9 rvlotor Control·Card • .Digital I/O .. .; 1 channel. of timer/counter .:.Programmable'pacerfuhdiori· PCL-714 .. ;.... " ... ~·..• ;.;,.~L.·..•.•.. ;.; ..$495.00 '\'; ,':1 f,' Call ,the ,~@@/Jjl1rdJ{j)[r~gl/'(#)@g ",' . . :~~It~~~:ff~p~~~~~ outPutE/~g::~~iC ~{ffJf/§J .©U§1~i/©A\ . . @~'fl PCL.73a.~~""':""~""r"';"I .... ;$395.0oRe~g~fce Etectro~g~p~{~~~~e~~~~upPlies HSC of Sacramento'· HSC,of$anta Rosa sa " sc'r5a,4mgeHn9tom,'COCAkg84t9' ,',;"8' 6cSolt9atRI"eCdAw090SdS4D1r. (916) 338-254S " (707) 792-2277' ' .vv~ ship'Uf$~9()D , ' We shipto,APO/FPO . • Counter • Independen,t; simultaneous operation of up to 3 motors • ProgrammablespeedJrom 3.3 to 3410, ppS • Built~inacceleration control • OneClock'(pulse,·Direction) or two,clock (OW, CCWPulses) output mode :~~~~lg~~~~~tpu~~~~~iri°utPuts i -16channels each, TTLc()r11patibl~ ,(408) 732~2814 '·"S>'/:3 . '" " " '" '-'1"1,,"""" tsICle"CCiUfQt'l"li.a NowI Galif~(jrnla ,:,,:,:~ I r-(·.'.,~· !.,\lI.i:'';-.,~,~(.1 ,'"(",',,,./c-,ct0/;' ~ ,! : ':; ';.',;~.::... ,:::.": ',~~(.»,~'j :.~, "~:;,·.\ "',.I·~'. , !.'t;,I. i·;. , ·,. i.~: 1.l~l~r~~l~rl) F , r.• .•.:..1.·.i.•i,i,.:,;.•. .:.,i•.I.:.••.•.;..• ,,~-- "," '~:;;v 'i'<"~'- ,,'::~'-' ~.<"<~·t:",!/.~:,·:,~~~·~,,1·,JJ<{,;:'·'j ,j;/ ••• V,;\ i)': 'A:r,·.,!,H i;'+Y' , fi~'t.•;J?ifJ :\',,'1;;;',\ 1i', h"":"""';'"I':'~I"':! ',' }.', ;<:~.;:~\} , ': Twelve function keys for increased Erasable template automatic to label ;vur function operation. key assignments. Switch allows ;vu to swap position of Ctrl and Caps Lock. FJ Separate numeric keypad that switches to a multifunction business calculator with tilt-up LCD display. Includes memory, square root and percent keys. Solar panel Keyboard and to power the calculator status calcu/atorindicator lights. Switch-selectable for all IBM XT, AT, PS/2 and compatible systems. Extra large Backspace and Enter keys. even when the computer is turned off! $149~5 buys you both the hot-selling spreadsheet and the ............... TurboCalc-lll QUAl fRO Keyboard/ Calculator. charge your spreadsheet and typing performance. Like our famous tactile, positiveresponse keys that give you a much better feel for the road. So you can type faster with fewer mistakes than ever before. And the new, enhanced For just $149.95-less IBM"lOl-key layout with than Quattro's street some logical improveprice, and a lot less ments-including separate than its $247.50 sugnumeric and cursor keys gested retail price, you that let you cruise through can now get both Borspreadsheet data entry land's best-seller and""" . ·.~"i"!"T without ever having to the keyboard you need "More than 1-2-3" at shift Num Lock. to drive it at top speed. less than half the cosr Get better mileage Namely, the TurboThat's what PC Mggazine from your desktop. Calc-ill~ Keyboard! says about Quattro," the In case you haven't noticed Calculator from !wt-selling spreadsheet already, the keypad Datadesk. from Borland Imagine doubles as a full-function Boost your what theyU say about business calculator comoverall performance. this ~~dinary plete with its own pop-up With its built-in, utiau LCD display. Which saves presentation-quality graphics, intellispace on your desktop and lets you gent recalcs, unlimited macros, easy perform any calculation with a single installation and compatibility with keystroke-no matter what software leading spreadsheet and database you're driving. software, Quattro is made to order What's more, the keypad packs a for your business. solar panel, so you can start up the And TurboCalc-ill is made to calculator even when your computer order for Quattro. Or for any other is idle. software you like to drive. We wouldn't steer Because, as you can see, it's loaded you wrong. with features designed to turboFrankly, getting into a Datadesk keyReader Service Number 8 board would be an inspired idea at this price even if you didn't get Quattro in the bargain. After all, as InfoWorld says, "if you haven't looked at Datadesk's keyboards, you ought to:' According to the Washington Post, "for ingenUity of design and sheer dollar value, Datadesk can't be beat:' And when it comes to your peace of mind, nothing beats our two-year send them back within 30 days and well cheerfully refund your $149.95. No questions asked. How, you ask, can you take advantage of this remarkable offer? Just fill out the coupon and send it in. Better yet, call us toll-free. And tell us to step on it. warranty. What's more, if Quattro and TurboCalc-ill don't blow the doors off the vehicles you're currently drivrng,just rr: .,' $149 95 I - DA.TA.DESK All individual trademarks and copyrights are acknowledged. 1;1§:\la:~"t: Bundle includes Datadesk's TurboCa\c-11l . - Keyboard/Calculator for IDM" and compatibles and Borland's Quattro sllreadsheet. Add $10 shipping and handling per urut (Continental U.S. only). CA reSIdents please add $9.75 sales tax per unit. Amount Enclosed: # of Units: Disk Size: o 3lh" 05%" Com~uter Type*: *1£ P /2, include additional $5 for cable adapter. Payment: o VISA DMC DAMEX o CHECK Exp.Date: Card No: , <.• Me <; Name Company Name ••• Daytime Tek/>hone Zip State City .......• Mail to: Datadesk, 7651 Haskell Ave., Van Nuys, CA 91406. FAX: (818) 780-7307 ': Or Call: (800) 826-5398. In cA, Call: (800) 592-9602 .'> '" Address ~ .. ....' ... ,' ...:. -\ .}ml~fAW , .,. "., '" ..... '.:C." '-=C,' 'c' .> .....'...;.•·\"1~'.i':'!,,•. , /. ,.......... ',.: .... ,.,'.';., - - - - - - - - - - - - - - - - - - - - , ._._-----------_._--- fiNAllY A debugging tool tough enough to handle the DOS Nasties. New Version 2.0 How Soft-ICE Works Soft-ICE memory range break points help you track down memory over-write problems whether you are doing the over-writing or another program is over-writing you. Soft-ICE uses the power of the 80386 to surround your program in a virtual machine. This gives you complete control of the DOS environment, while Soft-ICE runs safely in protected mode. Soft- ICE uses the 80386 to provide real-time break points on memory locations, memory ranges, execution, II 0 ports, hardware &: software interrupts. With Soft-ICE you get all the speed and power of a hardware-assisted debugger at a software price. Hung program? No problem! Don't want to switch debuggers? Nasty over-write? No sweat! You don't have to! When the system hangs, you now have hope. With Soft-ICE you can break out of hung programs no matter how bad the system has been trashed. And with Soft-ICE's back trace ranges you can re-play the instructions that led up to the crash. Soft-ICE can run stand-alone or it can add its powerful break points to the debugger you already use. Use your favorite debugger until you require Soft-ICE. Simply pop up the Soft-ICE window to set powerful real-time break points. When a break point is reached, your debugger will be activated automatically. Program too large? Not with Soft-ICE! Soft-ICE runs entirely in extended memory. This means you can debug even the largest DOS programs. And since your program runs at the same address whether Soft-ICE is loaded or not you can find those subtle bugs that change when the starting address of your code changes. System debugging? Soft-ICE is a natural! Soft-ICE is ideal for full source level debugging of TSRs, interrupt service routines, self booting programs, DOS loadable device drivers, real-time kernels, non-DOS O/Ss and ROMs. Soft- ICE can even debug within DOS & BIOS. MagicCV with Soft-ICE Using Soft-ICE with CodeView gives you the features necessary for professional level systems debugging. MagicCV and Soft- ICE can work in concert with CodeView to provide the most powerful debugging platform you will find anywhere. "These may be the only two products I've seen in the last two or three years that exceeded my wildest expectations for power, compatibility and ease-of-use." -Paul Mace Paul Mace Software New Soft-ICE 2.0 features $386 $199 $199 Soft-ICE MagicCV MagicCV for Windows CJ Back Trace Ranges CJ Symbolic &: Source level debugging D EMS 4.0 support with special EMS debugging commands Buy Soft-ICE &: MagicCV(W) -Save $86. Buy MagicCV and MagicCVW -Save $100. -Save $186. Buy All 3 30 day money-back guarantee Visa, MasterCard and AmEx accepted CJ Windowed user interface ™iV Nu-Mega \j-TECHNOLOGIES • Y T I CALL TODAY (603) 888- 2386 or FAX (603) 888-2465 A W A . 0 O' O'P' .... CTIOl'ol PO. BOX 7607 • NASHUA, NH • 03060- 7607 2 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 Reader Service Number 110 RUN CODEVIEW~TM IN 8K -" MagocCV j;,':, '. CodeView is a great integrated debugger. but it uses over 200K of conventional memory. MagicCV uses advanced features of the 80386 to load CodeView and symbols in extended memory. This allows MagicCV to run CodeView in less than 8K of conventional memory on your 80386 Pc. NEW-Version 2.0 includes EMS 4.0 driver. Attention Windows Developers! Version available for CVW. THE M I C R 0 TECHNICAL J 0 URN A L MICRO CORNUCOPIA NOVEMBER/DECEMBER 1989 - ISSUE NO. 50 8 16 22 32 40 Gregory K. Landheim 3D-Surface Generation 58 C'ing Clearly Take a two dimensional illustration and turn it into a three dimensional image? Sure. But it's not trivial. 65 Culture Corner The PC Video Frame Grabber 66 86World Want to put your 'favorite' TV personality on your favorite dartboard? Want a stock of real-life images for your paint program? Then this is your project. 70 On Your Own 78 Units and Modules 80 Shareware 90 Techtips 82 Tidbits 96 Last Page Gene Toner Bob Nansel LIMBO, Part Three This time we're deeply into the mechanics of this moving project. Larry Fogg PostScript Programming, Part II Larry probes further into the graphic mysteries of FORTH, oops, I mean PostScript. Bob Morein UNIX Packages For The PC This is the most complete comparison and discussion of 386 UNIX packages I've seen. 49 54 Linda and Karl Lunt Life, Bliss, And Rocky Mountain SOG A View From The SOG Bruce Eckel Capturing & Graphing A Voice, Part 1 Bruce tackles another intriguing I/O project. Great information, even if you're not in great voice. Cover Illustration by Rob Sanford. MICRO CORNUCOPIA, #50, Nov-Dec, 1989 3 THE MICRO TECHNICAL JOURNAL MICRO CORNUCOPIA Editor and Publisher David J. Thompson Associate Editors Gary Entsminger Larry Fogg Cary Gatton Contributing Writers Anthony Barcellos Bruce Eckel Michael S. Hunt Scott Ladd Laine Stump Advertising & Distribution Erik Huston Accounting Sandy Thompson Reader Services Nancy Ellen Locke Graphic Design & Production Carol Steffy MICRO CORNUCOPIA asSN 0747-587X) is published bi-monthly for $18 per year by Micro Cornucopia, Inc. 155 NW Hawthorne, Bend, OR 97701. Second-class postage paid at Bend, OR and additional mailing offices. POSTMASTER: Send address changes to MICRO CORNUCOPIA, PO Box 223, Bend, OR 97709. SUBSCRIPTION RATES: 1 yr. (6 issues) $18.00 2 yr. (12 issues) $34.00 3 yr. (18 issues) $48.00 1 yr. Canada & Mexico $26.00 1 yr. Other foreign (surface) $36.00 1 yr. Foreign (airmail) $50.00 Make all orders payable in U.s. funds on a U.S. bank, please. AROUND THE BEND By David J. Thompson Fifty Isn't Old If You're A Magazin~ ... Half A Century As Sandy and I hand-stapled all 500 copies of the first issue of Micro C at our kitchen table, we had no idea that eight years later Micro C would still be around, and we'd be working on our 50 th is~ue. Yep, and in those 50 issues there have been so many changes in this silly technology that even the changes have changed. And innovations? Boy, have we seen innovations. Once we had only software. Now we have freeware, shareware, crippleware, vaporware, underware, and beware. We've progressed from public domain programs with bugs to commercial programs with bugs. (Actually, commercial programs always had bugs, it's just that the nasty little critters are getting harder to work around.) Nowadays we're aiming for a computer on every desk. When we began Micro C, we hoped for one in every garage. Anyway, with the big 50 upon us, I guess that means the honeymoon is over. It's time to get down to serious business-nose to the grindstone and ear to the ground. We've got to get off the fence and take a stand. «Larry, is there anything we can do about these stupid cliches without Dave noticing? -Cary) (Probably not. -Dave» CHANGE OF ADDRESS: Please send your old label and new address to: MICRO CORNUCOPIA P.O. Box 223 Bend, Oregon 97709 CUSTOMER SERVICE: For orders and subscription problems call 503-382-8048,9 am to 5 pm, Pacific time, M-F. TECHNICAL ASSISTANCE For help call 503-382-8048, 9 am to noon Pacific time, M-F 1-800-888-8087 BBS - 24 hrs. 300-1200-2400 baud 8 Bits, No Parity, 1 Stop Bit 503-382-7643 Copyright 1989 by Micro Cornucopia, Inc. All rights reserved ISSN 0747-587X 6 4 The Audit Bureau MICRO CORNUCOPIA, #50, Nov-Dec, 1989 Salmon BBQ at the Port Alberni SOG Continued on page 73 Lattice Tools & Libraries for DOS and OS/2 We're the company that writes the language and the tools. Our libraries give you hundreds of ready-to-use functions, compatible with our compiler and other products. Compiler Companion $100 Ten proven UNIX-like tools provide a complete programming environment, and reduce file handling tasks, regardless Qf programming language. dBC III & dBC III Plus $250/$500 Networking & non-networking libraries let you write fast C programs to create, access and update files compatible with dBASE III. Communications Library $250 A comprehensive set of high- and lowlevel functions for asynchronous communications programs using XMODEM, YMODEM, KERMIT or ASCII protocols. C-Food Smorgasbord $150 A selection of utility functions including a BCD decimal arithmetic package, I/O functions, IBM PC BIOS interface, a Terminal Independence Page and functions including directory, clock and string. Curses V Library $125 84 C screen management functions and macros that help you port between UNIX System V and the Pc. SSP!PC $350 More than 145 subroutines eliminate tedious and difficult mathematical programming. Includes scientific, engineering and statistical mathematical routines as extensive and accurate as similar packages used on mainframes. PANEL Plus with Source $495 A collection of interactive screen design tools plus more than 150 functions to help you create application screens. HighStyle -Programmer's Publishing Tool $375 HighStyle gives you everything you need to create attractive, highly polished documentation for your programs. Automatically creates tables and charts! Includes: Word Processor, Page Previewer, Snapshot Utility, Style Guides, Spelling Checker, Icon Editor, Bar Code Generator, Font Manager, and more. To order Lattice C 6.0, send $250 in check or money order to: Lattice, Inc., 2500 S. Highland Avenue, Suite 300, Lombard, IL 60148. Or order by credit card at (800) 444-4309. FAX # (312) 916-1190, TELEX 532253. Reader Service Number 153 Letters Organize, Query, & Make Connections Between Files of Information MICRO EINSTEIN The Expert System Shell • Create expert systems easily in minutes • With pulldown menus and windows • Automatic rule generator • Context-sensitive help • Free example expert systems • Interactive full-screen text editor • DOS access from shell • Turbo fast execution (NOW 5 times faster!) For Diagnosing ... Monitoring ... Indexing ... Organizing .. . Classifying .. . & Discovering links between files of information. Only $100! (Plus $5 StH) Reader Service Number 72 I.----C~-_-I=1----' ACQUIRED INTELLIGENCE P.o. BOX 2091 • DAVIS, CA 95617 • (916) 753-4704 6 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 More Metaphysics Reading your recent letters regarding Micro C's excursion into the metaphysical realm, I thought I should write and add my vote of support for your editorial experiment. One of the reasons (there are many) I like Micro C is that those behind it come through as people, and interesting people at that. Your editorial was part of that. The same applies to the bits of National Geographic material another letter writer referred to. Anyway, those who complained are entitled to their opinions. But I think an editor should be able to write whatever he wants in an editorial. As for those who cancelled their subscriptions, it seems to me pretty silly to give up 94 pages of great technical information just because you don't like the other two pages. John Wells 467 Fraser st. Victoria, B.C. Canada V9A 6H2 ~ ~ Editor's note: Thanks John. After the initial flurry of letters (which ran 50% pro and 50% con), we've received a steady stream of letters, BBS messages, and calls, most of them starting out discussing something else but ending with comments like yours. These are running 99% in favor. I've noticed some local controversy now that our hospital is teaching "healing touch" therapy to its nurses. It's a healing technique in which (with patient permission) the nurses support the patient's energy field. (Very similar to the Reiki healing techniques I've learned.) Several people wrote angry letters to the local paper and one even picketed the hospital. But after that initial outburst, the nurses have received solid support from both the local lay community and the medical profession. Reflections On The Radar Equation The confusion between the radar equation and the behavior of reflected light on the part of Bob Nansel and Don Sweet is because the radar return consists of scattered radiation. The usual target is irregularly shaped and each surface element reflects the incident radiation in a different direction. So the target looks like a new source whose brightness is proportional to the inverse square of its distance from the radar. The signal returned to the radar is subject to the same law, so you do indeed multiply the two inverse squares to get the signal strength received per unit cross-section. The mirror, on the other hand, simply changes the direction of the incident light (if we consider it to be a perfect reflector), and it is proper to use the inverse square of the total distance. In other words, the proper analog to the radar is obtained by replacing the plane mirror with a polished ball bearing or a matte surface, which I think is what Nansel assumed for his maze runner. The radar equation has nothing to do with mirrors. No doubt you will get a number of responses on this one, but maybe this will help. Karl Theobald 1030 Granite Dr. Granite Shoals, TX 78654 Editor's note: From the flood of responses to this raging controversy, it appears that interest in a topic is proportional to the fourth power of that topic's abstrusity (means it's not perfectly clear to everyone on first glance). Read on for another illuminating view. Letters continued on page 77 Introducing ..• The 1st Family of Low Cost, Powerful Text Editors $ 29 VEDIT Jr. VEDIT $ 69 VEDIT PLUS $185 Finally, you can choose the best editor for your needs without compromising performance or paying too much. And organizations that want the "same" editor for everyone can pick VEDIT® for most users and VEDIT PLUS for their power users. The new family of VEDIT text editors are upwards compatible, easy to use and offer exceptional performance, flexibility and stunning speed. (3 to 30 times faster than the competition on large files where speed really counts.) Call for your free evaluation copy today. See why VEDIT has been the #1 choice of programmers, writers and engineers since 1980. VEDIT Jr.- Unmatched performance for only $29. All VEDIT editors include a pull-down menu system with "hot keys;' context sensitive on-line help, pop-up status and ASCII table, a configurable keyboard layout and flexible, unlimited keystroke macros. Edit files of any size and any line length. Perform block operations by character, line, fileorcolumn. Undo up to 1000 keystrokes- keystroke by keystroke, line by line, or deletion by deletion. Automatic indent, block indent and parentheses matching speed program development. Word wrap, paragraph formatting, justification, centering, adjustable margins and printing for word processing. Run DOS programs. VEDIT-A best value at only $69. Simultaneously edit up to 36 files and split the screen into windows. Search/replace with regular expressions_ Includes the best compiler support available-menu driven, easy selection of compiler options, supports "Include" files and MAKE utilities. VEDIT PLUS-Ultimate programmer's tool for only $185. VEDIT PLUS adds the most powerful macro programming language of any editor. It eliminates repetitive editing tasks and permits creating your own editing functions. The macro language includes testing, branching, looping, user prompts, keyboard input, string and numeric variables and control over the size, pOSition and color of windows. Source level macro debugging with breakpoints and tracing. Macros developed with VEDIT PLUS also run under VEDIT. 30 day money-back guarantee. Call for pricing of XENIX, OS/2 and FlexOS versions. Very attractive quantity pricing is available for schools, hardware and software vendors. FREE Evaluation Copy* Call 1·800·45·VEDIT Compare Features and Speed Pull-Down menus Pop-Up ASCII table Keystroke macros Regular Expressions "Cut and Paste" buffers Text (book) markers Undo keystroke by keystroke Undo line by line Normal/max Undo levels Variable tab positions Configurable keyboard Integrated mouse support FILE LIMITS Edit files larger memory Maximum line length Maximum lines/file COMPILER SUPPORT Menu driven Select Compiler options Support "Include" files BENCHMARKS 50K FILE Simple search Save and continue 1000 replacements BENCHMARKS 3 MEG FILE Simple search Save and continue 60,000 replacements Block-column copy (40 x 200) Insert 1 Meg file in middle of 1 Meg file PRICE VEDIT and CompuView are registered trademarks of CompuView Products, Inc. BRIEF is a trademark of U nderWare, Inc. Norton Editor is a trademark of Peter Norton Computing Inc. OEdit is a trademark of SemWare. 'Supports IBM PC, XT, AT, PS/2 and clones withCGA, MGA, EGA, VGA, Wyse 700, Amdek 1280 and other displays. Also supports Concurrent DOS, DESOview, Microsoft Windows, PC-MOS/386 and most networks. 'Also available for MS-DOS (CRT terminals), TI Professional and others. 'Free evaluation disk is fully functional and can edit small files. Reader Service Number 7 BRIEF 2.10 Norton 1.3 DEdit 2.07 VEDIT Yes No No Yes No Yes No No 1 No 100+ 100+ Yes Yes No No 36 1 1 100 10 10 No No Yes Yes No No Yes No No No 500/1000 30/300 Yes No No Yes Yes Yes Difficult No Yes No Yes No Yes >8096 8,388,607 Yes 512 65,535 Difficult 65,535 >65,535 None No Difficult No - No 512 20,000 None Yes Menu Yes 0.2 sec 1 sec 3 sec 1 sec 2 sec 19 sec 1 sec 2 sec 17 sec 0.3 sec 1 sec 2.5 sec 1:40 min 1:05 min 3:18 min 2 sec 1:36 min 3:23 min 1:44 hour 30 sec Cannot Cannot Cannot Cannot Cannot Cannot Cannot 2 sec 1:11 min $69 15:13 min $195 Cannot $75 Cannot $54.95 - CompuView P.O. Box 1586, Ann Arbor, MI48106 (313) 996-1299, Fax (313) 996-1308 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 7 3D-Surface Generation An In-Depth Look At Graphics, Part 1 Rereading the last 35 issues of Micro C, you're probably thinking that PCX and Mandelbrot are all you need to know about graphics. Wrong, Ruffy. There's something else, and it's three dimensional. (We go for depth,) thought it would be nice if there were a public domain utility that did surface plotting, with hidden line removal. It would let you view the surface from any horizontal angle from 00 through 3600 and any elevation angle from -900 to +900 • I couldn't find one, so I wrote my own. I planned to tum it over to the public domain, so I scrupulously reinvented the wheel at every step to avoid stepping on someone else's toes. My Bresenham's line drawing function turned out to be nowhere near as nice as the one Professor Rasala of Northeastern University wrote in Pascal. So I translated his implementa- I 8 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 tion to C and asked his permission to use it. He was amused that I bothered to ask, since Bresenham's is so standard. But if you think it's easy to do one that's compact, true, and fast, go ahead and write it yourself. The project turned out to be a bear (actually, more of a female dog). When I got stuck on one thorn (or claw or tooth, to keep the metaphor straight) or another, I amused myself by translating a Pascal high resolution printer graphics module I wrote a few years ago into C. The work dragged on, so I translated another module for scalable, rotatable, justifiable (well, just barely) character string plotting that works with the printer graphics module. Finally the thing became a true nightmare. I was too far along to quit, and too far gone to continue. I locked myself in my house, along with several pounds of high grade Sumatran coffee, a box of cheap cigars, and more cases of beer than I could count. a use base 5 to count on my fingers, and with my left hand for the ones, and my right hand for the fives, and a beer tucked in my elbow, I just couldn't get that high.) I sacrificed my Christmas and New Year and my entire tight brain to finish the damned thing before my liver failed. How This Article Happened Now that I had created it, I had to tum it loose. I sent it to the good folks at Micro C and asked them to distribute it to the public domain for me. Somewhere in the letter (I felt guilty about the inability of the code comments to tell the full story) I offered to write an article. (In my delirium tremins I actually said I would be happy to do so.) They must have smelled the beer on the printout. They took me up on my offer. So, here goes. What We Have Here If you've been paying attention, you have a good idea already: (1) threed.c-a general purpose mod- By Gregory K. Landheim 123 Greene St. North Andover, MA 01845 ule for plotting 3-D surfaces with hidden line removal using an axonometric projection, viewable from' any horizontal angle from 00 through 360 0 and elevation angles from -90 0 through +90 0 • (See Figure 6.) You can use it, as is, on any plot de-vice that uses left-handed, rectangular, integer coordinates with (0,0) in the upper left comer, and for which you can supply a line drawing function. (2) grafprt.c-an IBM Graphics Printer (and compatibles, e.g., Epson FX and LX) high-resolution graphics module. It supports both Portrait and Landscape mode drawings, and it draws on 8" by 105fs" of a page. (3) grafstr.c-scalable, rotatable, justifiable (left, right and center) string plotting module for use with grafprt.c (4) arrays.c-contains a function to dynamically allocate 2-dimensional arrays of any type and size (not limited by 64K segments) up to the size of the memory available in the heap. It uses pointers to pointers to any type, but we won't quibble. Editor's note: Part 2 of Gregory's article +Z (0,0,0) Ymln Xmax +X Figure l-Coordinate Geometry and Matrix Correspondences (in issue #51) will cover grafprt.c, grafstr.c, and arrays.c) Why This Article Is So Long Most graphics articles in technical magazines give you a brief discussion of the math and the method. This is especially true of articles on 3-D surface plotting. They show you how to do it for a special case, then wave their hands and say something like, "Other view angles can be dealt with by appropriate matrix element exchanges and transformations." This is great if you're a mathematician, but then you wouldn't be reading the article, would you? These authors are perfectly justified by the niggardly attitude of editors who would rather fill their magazines with something useful, . like advertising. Fortunately, Micro C's 2 1 ~ Viewer ~ -x 3 9h +x 4 -y Figure 2-Quadrants and View Angles MICRO CORNUCOPIA, #50, Nov-Dec, 1989 9 In all that follows, I assume all the coordinate systems except the plot device's are right-handed and Cartesian. I also ignore a lot of fine points, but I'm just talking about basics. A coordinate system can be left- or right-handed. Handedness refers to whether rotation angles are specified as clockwise from a reference axis, or counterclockwise. In right-handed systems, the rotations are counterclockwise. Make a fist with each hand, thumbs pointing at you, and note the direction your fingers curl. If the reference axes are orthogonal (at right angles to one another), the system is rectangular. If the scales are the same on each axis, the rectangular system is called Cartesian. Points in space are specified by coordinate pairs (x,y) in two dimensions, and triples (x,y,z) in three dimensions. The coordinate elements can be either positive or negative. A coordinate such as (-4.3,2.7,1.5) means you can locate the point by moving 4.3 units in the negative x direction, then 2.7 units in the positive y direction, then 1.5 units in the positive z direction. In a 3-D right-handed system, if you point the index finger of your right hand along the positive x-axis, the middle finger along the positive y-axis, and the thumb up; the thumb points along the positive z-axis. Which axis actually golden-hearted editors turn down volumes of advertising to give you indepth articles and massive amounts of code. My background is in physics, math, and mechanical engineering, and I have never formally studied computer science. Working with C.S. people, I find a circle of confusion (cold confusion) where they should be keeping coordinate geometry and matrices. So I'll dwell a lot on the basics. I'll explain the methods behind the 3D surface plotting module, the printer graphics module, and the associated string drawing module. Nonetheless, I shall attempt to keep things brief without sacrificing substance. Coordinate Systems-The Basics Cartesian geometry acquired its name from Rene Descartes (1596-1650), who invented the system. Mathematicians, physicists, and other sensible folk like to use right-handed Cartesian systems, while computer scientists prefer lefthanded systems. I suspect that, somewhere in the history of computer science, the math departments wouldn't loan their coordinate transformation routines to the C.S. departments, so the C.S. people did their own and got it backwards. (In fairness, I admit that most plot devices are intrinsically left-handed.) points up is arbitrary. When you learn Cartesian geometry, you start out with a flat surface, the x-y plane, and spend a lot of time learning the rules for 2-D. When extending it to 3-D, the instructor is used to drawing things on the blackboard, so y becomes "up" and z becomes "out" (unless they're computer scientists; then z is "in"). I liked to cut classes and learned with my paper flat on my desk, so I chose to make positive z "up". Since two lines define a plane, in a 3D system we have an x-y plane, an x-z plane, and a y-z plane. With positive z "up," the x-y plane is the reference plane. This means that surfaces are specified as z = f(x,y). Figure 1 shows the coordinate system used by the 3-D surface module. Grids And How To Use Them Surfaces tend to be smooth, but drawing a smooth surface takes a lot of computational time. So we fake it by computing the surface at grid locations. A rectangular grid is specified by the number of points in the x-direction and the number of points in the y-direction, referred to, respectively, as nx and ny. To make life easy, we make the spacing between grid points constant in a given direction. The domain over which we plot the surface extends from Xmin to Xmax and from Ymin to ymax. Figure 1 shows the relationship between a grid in the x-y Figure 4-Three Coordinate Systems, CRT Display Figure 3-Axonometric Projection [0,0] ox (IXmax , IVmax) (Pmax ; Omax) = (Xmaxw; Vmaxw) OV ~ T Zlj = f(xlj;Ylj) .p +--- I -7=-------T-----------~ +p --~-~ ~ ___ I /' ~ +V IV ------ ---1/ (0,0) 10 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 i (Pmln; Omln) = (Xmlnw; Vmlnw) IX (OXmax,OVmax) plane and its axial coordinates. The elements in square brackets correspond to matrix subscripts. You could, for example, store all the coordinates that describe the surface in arrays declared: float x[nx] [ny],y[nx] [ny],z[nx] [nY)i This quickly eats up storage space. Since we're smart enough to use a Cartesian system, we can completely specify the surface by the values Xm.in, Xmax, ym.in, ymax, nx, ny, and a 2-D array containing z. For use in surfaceO, the storage can be accomplished thus: = = zmin 1.7e38; zmax -1.7e38i deltax = (xmax - xmin) / (nx-1)i deltay = (ymax - ymin) / (ny-1)i stead I use the more natural concept of elevation angle (eel) defined as the angle above the x-y plane at the location of the viewer's eye. Axonometric Projection This method of rendering 3-D objects in two dimensions was invented during the dark ages (Le., before computers). It was quick and easy then, and it's quick and easy now. You lose perspective (especially when you're on your third six-pack and have to close one eye to read code). But it is quicker than a perspective transformation (I think, don't quote me on this), and with surfaces you rarely need depth cues. If you would like a nice perspective transformation, see Reference (3). When I developed the 3-D module, I began by defining the math transformations with the viewer's eye located in or above quadrant 1. Figures 1 and 3 show views in that quadrant. Figure 3 shows the transformation from (x,y,z) coordinates to projected (p,q) coordinates. Careful study reveals that for any point (x, y,z): Quadrants And View Angles In the x-y plane, the coordinate axes divide the plane into four quadrants. By mathematical convention, Figure 2 shows their labeling. Also shown is the relationship between the viewer's eye and the horizontal view angle (8h) in the x-y plane. I depart from the standard mathematical convention of specifying the vertical view angle as the angle rotated downward from the positive z axis. In- x = xmini for (i=Oi izmax) zmax = z [i] [j] i Y += deltaYi x += deltaxi Add lightning fast graphics to your programs quickly and easily through the popular PCX file format. Why reinvent the wheel? Make your programs immediately compatible with hundreds of packages from Aldus PageMaker to ZSoft's PC Paintbrush with these linkable graphic libraries. Figure 5-Filling A Triangle "An exceptional product" - Programmer's Journal, Aug NEW! Version 3.5 of the PCX Programmer's Toolkit gives you over 60 powerful functions to manipulate bitmapped graphics. Use Virtual screens, Super VGA modes, LIM 4.0 support, a 300 page manual, 9 utilities including screen capture and display, and the fastest routines on the market. $195 Xa [1] ~] Va [1] ~] ~ 11 Xa [0] [J1 Va [0] [J1 Need Special Effects, but caught in a GRASP? Why create a demo when you can create the real thing? Don't be trapped in a slideshow editor or demo program when you can use PCX Effects for the PCX Toolkit and your favorite programming language. A Music Language and spectacular effects for exploding your graphics! $99 Blazing Graphics Text With PCX Text you can display text with graphics as fast as it always should have been. Display characters, strings, fixed and proportional text, background transparency, and more. Includes a font editor, 85 fonts, and text utilities for blazing graphics bitmapped text. $149 All packages support 12 compilers for C, Pascal, Basic, Fortran, Assembly, and Clipper. All modes of the Hercules, CGA, EGA, VGA, and Super VGA adapters are supported, up through 800x600x256 (22 modes in all). Assembly Language source code is optionally available. Trademarks are property of their respective holders. MICROPROGRAMMING 11315 Meadol'! Lake. Houston. Texas 77077. (713) 87(}0737 No Royalties! 30-day Money Back Guarantee. VISNMC/AMEXICOD/PO accepted. MICRO CORNUCOPIA, #50, Nov-Dec, 1989 11 = y*cos(~) = -y*sin (~) p q - X*cos(~) - x*sin (~) + z*cos (8e 1) 3-D Mandelbrot Set Traditional (pre-computer) ax- . onometric projections do not consider an elevation angle and do not multiply Z by its cosine. I do it to fake a vertical viewpoint. So where do 'I' and come from? If you look straight down at the x-y plane (eel = 90°) as in Figure 2, then: But and 'I' are functions of eel, and of the viewer's quadrant. It's weasel time now. I would fonnally like to derive the following relations for you (I did it for myself), but it would take too much space, so I'll sketch an outline. -Intuitively, for eel = 0°: = 0°, and 'I' = 0°. For other values of eel, as we rotate eh from 0° to 45°, then from 45° to 90°, = 'I' at 45° and and 'I' must reverse their respective values on opposite sides of the dividing line fonned by eh = 45°. The resulting transfonnation, valid in all four quadrants, is: ~' ¥ = tan -1 ( = (90°) sin (~) / cos (~) - ($') sin (~) = sin (8.1) * sin ($') cos (~) = cos ($') = sin (8.1) * = cos (¥) sin (¥) sin (~) cos (~) In quadrant I, of course, ' = eh. The inverse tangent function is necessary to get the transfonnation correct in the other three quadrant"s. transfonn_anglesO perfonns this work for later use in axonometricO. More Coordinate Transformation-Will It Never End? Okay. We now know how to get from 3-space to 2-space, but we're still working with real, or floating point, numbers. We want to display the surface in a window, in integer coordinates. For printer graphics, we'll need transfonnations in both Portrait and Landscape modes; but lefs keep it simple by just considering Portrait mode. You use this mode on a CRT display (unless you do your work lying sideways). We still have three coordinate systems (Figure 4): P-Q our projected coordinates; IX-IY, a right-handed, rectangular, space; and DX-DY, a left-handed, rec- 12 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 tangular space (the plot device's natural coordinate axes). IX-IY and DX-DY are integer spaces where you count by pixels on your CRT display. They map one-toone onto each other and are non-Cartesian if the aspect ratio does not equal 1. You could easily skip the IX-IY space in making these transformations, but I find it a lot easier to decide where to place a window on a screen if (0,0) is in the lower left comer. IXmax is the pixel width of the CRT minus I, and IYmax is the pixel height minus 1 (we start counting at (0,0), hence the minus 1). You can find (pmin, qrnm) and (pma", qmax) by projecting the eight comers of a box drawn to completely enclose the surface: (Xrni.n, yrni.n, Zmin), (Xmin, Ymax, Zmin), (xmax, ymin, zrnm), (xmax, Ymax, Zmin), (Xmin, Ymin, Zmax), (Xmin, ymax, Zmax), (xmax, ymin, Zmax), and (Xmax, Ymax, Zmax). ' This is done in get_max_minO, determining which of the projected values define (pmm, qmin) and (pmax, qmaJ and saving the projected coordinates for later use to draw a box around the surface. In my source code, I never use variables explicitly declared as p or q (corresponding to the description given in this text) preferring to think of them as x and y values, or reusing already declared variables. I define P-Q space in this discussion purely for illustrative purposes. p and q are, however, used as arrays in dosurf0 and drawfillrectangleO to store plot device coordinates. This is just a coincidence. Remember: Consistency is the bugaboo of small minds. You get to specify where the window will go. (Xminw, yminw) and (Xmaxw, ymaxw) define this in Figure 4. P-Q coordinates are then transformed to IX-IY coordinates by: ix = Xlllinw / iy = yminw / + (Xmaxw - Xminw) * (p - Plllin) Yminw) * (q - (Pmax - Pmin) + (Ymaxw - (~ax - ~in) ~n) This is done by defregO and transf(). "defreg" means "define region." It's really a window definition, but I was afraid of conilicting with someone else's window definition function name if I used "wind" as part of the name. All you need to get into plot device pixel space (in Portrait mode) is: dx dy = ix = IXmax - iy itransfO handles this. It also plots in Landsca pe mode. If you use surfaceO . only in Portrait mode, you can speed things up by eliminating the Landscape transfonnation and making itransfO into a macro. The Painter's Algorithm dosurfO contains the painter's algorithm. It is conceptually simple, but confusing when drawing in all four quadrants. If we all had mainframes, we could use matrix manipulation routines and swap Z values around for the proper perspectives. That would keep the loops in You asked for a place to put your things... The Tele™ FILE SYSTEM is just the thing BerryComputers presents The Tele Toolkit - a complete Operating Systems Kernel If It's Data, It Must Be A File Tele's file system is modular at several levels. FS is responsible for all storage and transfer of data. The physical interface to disk devices is through MS-DOS installed device drivers (MS-DOS itself is by-passed). Therefore, Tele will work with the same devices that MSDOS supports. Separate from the physical interface is the directory structure. Tele supports installable file systems; each device can have a unique media format. Only MS-DOS compatible media are supported in FS. Some other Tele components involve installable file systems. For instance, the UX component emulates the Unix kernel. Most of its code supports Unix media. Networks are supported by an installable file system that causes directory operations to be performed on a device in a remote computer system. FS itself only supports MS-DOS media, but it provides the main hooks by which any other file system' can be emulated. The bulk of Tele FS code supports hierarchical directory structures and file redirection. Because MS-DOS is not involved, you can use FS to avoid its restrictions. Tele FS also includes serial communications support. 8250 controllers are supported in bidirectional interrupt mode. Ring and break indicators are also supported. Serial ports can be accessed directly, or redirected through the file system. Files can also be redirected from the keyboard and to the console display and printer. To support efficient communication and storage, FS contains a modified Huffman compression algorithm. The modification automatically recognizes fields within records and applies a different compression tree to each type of field. Compression can be processed directly on blocks or continuously and transparently within the file system. All source code, in C and assembly, is included. Tele SK is required for FS. CD is also required for console device support. Demo Diskette SK system kernel CD console display FS file system OS core $ 5 $50 $40 $40 $130 (refundable with purchase) (multitasking) (windows, requires SK) (MS-DOS media, requires SK) (SK, CD, and FS) Telephone support is freely available. The Tele Toolkit is available from: Crosby Associates P.O. Box i48 Sutter Creek, California 95685 CALL NOW TO ORDER: (209) 267-0362 (FAX) (209) 267-0115 Visa, Mastercard, American Express & Discover Card accepted. MS· DOS is a trademark of Microsoft Corporation. Unix is a trademark of AT&T Reader Service Number 147 MICRO CORNUCOPIA, #50, Nov-De~, 1989 13 Figure 6-Code for 3D Surface Drawing /* header for threed.c */ int surface ( float xmin,float xmax, float ymin,float ymax, float zmin,float zmax, int xminw,int xmaxw,int yminw,int ymaxw, int hmax,float **z, float horangle,float elangle, int nx,int ny,int box, intfillcolor,int edgecolor,int boxedgecol, void far csetfunc(int color), void far linefunc(int xl,int y1,int x2,int y2»; /* start #include #include #include #include #include of threed.c */ "threed.h" "grafprt.h" "arrays.h" #define PI 3.141592653589793238 #define BIGNUM 1.7e38 /* module threed.c, turbo c v 2.0, large code model. released to the public domain by Gregory K. Landheim on January 1, 1989, (c) all rights reserved. anybody is authorized to use this code for any purpose whatsoever on the condition that they realize I assume absolutely no liability and give no warrantee for its use or performance. it is distributed "as is." */ /*-------function prototypesl----------*/ void degrees to rads(float *horangle,float *elangle); int get quad~ant(float horangle); void transform angles (float horangle,float elangle, int quadrant); void get max min(float xmin,float xmax,float ymin, float ymax,float zmin,float zmax, float *yminp,float *ymaxp, float *zminp,float *zmaxp); void axonometric(float x,float *y,float *z); void dosurf(float xmin,float xmax,float ymin, float ymax,int nx,int ny, float **z,int iO, int i1,int inci,int jO,int j1,int incj, int incmode,int fillcolor,int edgecolor); void drawfillquadrangle(int p[2] [2],int q[2] [2], int fillcolor,int edgecolor); void filltriangle(int x1,int y1,int x2,int y2, int x3,int y3,int fillcolor); void swapcoords(int *x1,int* y1,int* x2,int* y2); void transformbox(void) ; void drawboxbottom(int boxedgecolor); void drawboxback(int quadrant,int boxedgecolor); void drawboxtop(int boxedgecolor); void drawboxfront(int quadrant,int boxedgecolor); /*'-------aglobal declarationsl---------*/ int **Xa; int **Ya; /* storage for */ /* filltriangle() edge lines */ float Cosphi,Sinphi,Cospsi,Sinpsi,Cosel; /* constants for axonometric projection */ float Yb[5],Zb[5],Yt[5],Zt[5]; /* arrays for box bottoms and tops in projected real coordinates */ int Pb[5],Qb[5],Pt[5],Qt[5]; /* arrays for box bottoms and tops in transformed integer coordinates */ void far (*Linef) (int x1,int y1,int x2,int y2); /* address of plot device line drawing function */ void far (*Csetf) (int color); /* address of plot device set color func */ /* surface () - general-purpose surface plotting routine to plot a surface described as a matrix of gridded z-values in the xy domain. int surface ( 14 float xmin,float xmax,float ymin,float ymax, float zmin,float zmax, int xminw,int xmaxw,int yminw,int ymaxw, int hmax,float **z, float horangle,float elangle, int nx,int ny,int box, int fillcolor,int edgecolor,int boxedgecol, void far csetfunc(int color), void far linefunc(int x1,int y1,int x2,int y2» extern int Maxheight; /* declared in mod grafprt */ float temp; int quadrant,bufsiz,incmode,invert; float ymaxp,yminp,zmaxp,zminp; /* max and mins of projected surface */ if (abs(elangle) > 90.0) return(l); (elangle < 0.0) ? (invert 1) : (invert = 0); /* allocate memory for the arrays: */ bufsiz ymaxw - yminw; if «xmaxw - xminw) > bufsiz) bufsiz xmaxw - xminw; Xa (int **) alloc 2d array(2,bufsiz,sizeof(int *), - sizeof(int»; if (!Xa) return(2); Ya (int **) alloc 2d array(2,bufsiz,sizeof(int *), - sizeof(int»; if (!Ya) return(3); /* change the angles from degrees to radians: */ degrees to rads(&horangle,&elangle); /* dete~i~e the viewing quadrant: */ quadrant get_quadrant(horangle); /* determine the global projection angles: */ transform angles(horangle,elangle,quadrant); /* swap xitin/xmax and ymin/ymax in quads 2 and 3: * / switch (quadrant) { case 1 break; case 2 case 3 temp = xmin; xmin xmax; xmax temp; temp = ymin; ymin ymax; ymax temp; break; case 4 break; = = = = = /* find max and min of the real coordinate domain: */ get_max_min(xmin,xmax,ymin,ymax,zmin,zmax, &yminp,&ymaxp,&zminp,&zmaxp); /*set max pixel height of device and def plot region*/ Maxheight hmax; defreg(yminp,ymaxp,zminp,zmaxp, xminw,xmaxw,yminw,ymaxw); /* assign color setting and line drawing function addresses to global variables: */ Csetf csetfunc; Linef linefunc; /* put an optional box about the surface: */ i f (box) { transformbox () ; invert? drawboxtop(boxedgecol) drawboxbottom(boxedgecol); drawboxback(quadrant,boxedgecol); = = = /* plot the surface as a function of quadrant. make certain it draws from back to front: */ switch (quadrant) { case 1 : (horangle > PI/4.O) ? (incmode 0) (incmode = 1); dosurf(xmin,xmax,ymin,ymax,nx,ny, z,0, nx-1,1, 0,ny-1,1,incmode,fillcolor, edgecolor); break; case 2 (horangle > 3.0*PI/4.0) ? (incmode = 1): (incmode = 0); dosurf(xmin,xmax,ymin,ymax,nx,ny,z,nx-1, 0,-1,0,ny-1,1,incmode,fillcolor, edgecolor); break; case 3 (horangle > 5.0*PI/4.0) ? (incmode 0): (incmode = 1); dosurf(xmin,xmax,ymin,ymax,nx,ny,z,nx-1, = = Continued on page 87 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 ----------------------- dosurfO simple, but it adds a lot of overhead. So we end up with a function that gives me a headache. The painter's algorithm simply draws the projected quadrangles that form the gridded surface from back to front, filling (or painting) the quadrangle interiors with a background color as each is drawn, to cover up the quadrangle edge lines behind the current quadrangle. Quadrant 1 serves as the basis of the whole thing. For 8h less than 45°, you draw each quadrangle in the column nearest the y-axis (Figure 1), then move one column out in the direction of the positive x-axis and draw that column. Repeat for all columns. For 8h greater than 45°, you draw each quadrangle in the row nearest the x-axis, then move one row out in the direction of the positive y-axis and draw that row. And so on to the end. Argument "incmode" of dosurfO controls whether to increment along the x- or y-axis. In either mode, an initial for loop over k and I projects, transforms to device coordinates, and fills the first quadrangle in each column (or row). After that, we only need to project and transform two new points for each quad- rangle, because the other two are saved from the previous quadrangle. The quadrangle is drawn and filled by a call to drawfillrectangleO. (I know, I should have called it drawfillquadrangleO, but I wasn't thinking straight at the time.) Drawing And Filling I don't see any way to fill a quadrangle without breaking it up into two triangles. This is what drawfillrectangleO does. One vertex of each triangle is the one farthest from the viewer, another is the one closest to the viewer. After the triangles are filled, the quadrangle edge lines are drawn. filltriangleO does the dirty work. It first sorts the vertices of the triangle in ascending vertical order (in device coordinates). In order to use loops instead of if statements, I pretend the long side of the triangle consists of two lines, one of which has zero length. This trades off storage space for speed. I used a variation of Bresenham's linedrawing algorithm to compute the coordinates of the triangle edge lines and store them in global arrays Xa and Ya. The computation is performed by divid- QEditTM ADVANCED THE~' The fast, easy to use, fully featured text editor at an affordable price. If you are looking for the right combination of price and value in a text editor, then give QEdit a try. At ONt y $54.95 and a money-back guaranteeyou just can't go wrong. QEdit is fast, easy to use, and simple to install. At the same time you get all of these features and more. I Completely configurable, including keyboard and colors I Edit as many files simultaneously as will fit in memory I Open up to eight windows I 99 scratch buffers for cut-and- • _ '" 'ti1~ EDITOR paste or template operations I Exit to DOS (or a DOS shell) from within QEdit I "Pop-Down" menu system and customizable Help Screen • Column Blocks I Easy to use macro capability including keyboard recording I Wordwrap and paragraph reformat capabilities I Recover deleted text I Automatic indentation for C programming iii Import files and export blocks I Locate matching braces and parentheses I Execute command line compilers from within QEdit ing the triangle into two conceptual triangles with an imaginary horizontal line at the mid vertex (Figure 5). The outer loop controls whether the computations are for the upper or lower triangle. The inner loop computes the actual edge lines coordinates. A final loop fills the triangle by drawing blank horizontal lines from (Xa[O][jJ,Ya[O][jD to (Xa[1][jJ,Ya[1][j]). The j subscript indicates the h pixel working from the top to the bottom of the triangle. Ya[1][j] equals Ya[O][jJ for all j. To make threed.c as general as possible, I use the same line drawing function for horizontal lines as for all the other lines. However if you have a high speed horizontal line drawer, use it. t References (1) Advanced C Tips and Techniques, Paul Anderson and Gail Anderson, Howard W. Sams & Co., 1988. (2) "High-Resolution Printer Graphics," Mark Bridger and Mark Goresky, BYrE, Nov 1985, pp. 219-232. (3) ''The Painter's Algorithm," Richard Chandler and Gary Faulkner, PC Tech Journal, November, 1985, pp. 181-187. ••• •• This small, blazing-fast editor lets program instructions, memos, letters, and assorted text databases flow easily between brain and computer.', David M. Kalman, Editor-in-Chief, Data Based Advisor (September, 1988) • i The editor's speed, windows, and other features make it among the best text editors I've ever used. " George F. Goley IV, Contributing Editor, Data Based Advisor (September, 1988) I QEdit supports 101 key keyboards, EGA 43·line mode, and VGA 50-line mode I Great for use with laptopsQEdit edits files entirely in memory, saving drain on laptop batteries I Compact-Even with all these features, QEdit requires less than 50k of disk space ;'. ~ IIJiiliiiIJ fIii!Pl .'""""": 'CAN Cards ' Full 30 day money-back guarantee , COO's accepted-please add $3.00 • . Georgia residents odd 4% soles tox System Requirements _ _ __ QEdit requires an IBM PS/2, PC/AT, PC/XT, PC, Pc/Jr, or compatible. Minimum system requirements are 64 KB of memory, PC· DOS 2.0 or MS· DOS 2.0 or greater, 50 KB of disk space. QEdit runs GREAT on floppy based systems and laptops. To order direct call 404·428·6416 ~ . Add $3.00 for shipping-$lO.OO , for overseas shipping. UPS 2nd , DAY AIR available within the U.s. for ONLY $5.00 SEMWARE™ 730ElkCoveCt.· Kennesaw,GA 30144 QEdit and SemWare are trademarks of Applied Systems Technologies, Inc. © 1989 Applied Systems Technologies, Inc. Reader Service Number 127 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 15 <'. . . . . /1/ ', •• $ . I { Desktop graphics are quite possible. But possible and easy are two different things. Here's a video frame grabber that might just shortcut the process. This is yet another way to use an AID convertor. here I was trying to come up with a catalog for IDEC's line of PC clone computers using one of our AT compatibles, Ventura Publisher, and our laser printer. The idea was to do as nice a job as possible on this document so that our customers could see what a desktop publishing system could do for T 16 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 their efforts. I wanted to let our customers see one of our systems. See it in print. Credibility. Yeah, that's the ticket. How do I get a picture of our computer into our computer? My associate, Dr. Rao, tripping over one of the many extension cords strung out on the floor, suggested we needed a scanner to make the idea work. He was carrying a box of hard drives. ''They're about a thousand dollars," he said. I wondered if he was referring to the scanners or the hard drives. Turned out it was the scanners. Then I looked at what I had to do: take a black and white picture of the subject; develop and print the picture; copy the picture on a copy machine to reduce glare; scan the picture; suck the result into Ventura; and then print it on the laser printer. Sounded like a lot of work. So I proceeded to draw pictures of computers and disk drives for our catalog using a paint program and a mouse, pixel by pixel. That was a lot of work. ''There's gotta be a better way," I grumbled. . There is. The obvious solution is to hook a video camera into the computer. We immediately confiscated our little VHS/C camcorder for the project. Sorry, no more baby pictures! Using video added the dimension of being able to take pictures from tape. The situation was improving by the minute. What Would It Take? The two happiest days in a sailor's life are the day he buys his boat and the day he sells his boat. When it comes to engineering projects, the two happiest days are the day you design the hardware to do the job and the day you think you've fixed the last bug in the software. Some projects never have the final bug fix, some have it a great many times. This project seems to be of the latter variety. Having decided to build the World's Greatest Low Cost Video Digitizer, there remained but a single question: How to do it? We needed some kind of AID converter. What speed? It was going to have to put its data somewhere. PC memory? Dedicated memory? The Specification We wanted to digitize standard RS170 video. Cameras, camcorders, and VCRs output this on their video output connectors. And, we wanted to do this in real time. That's a computer buzz word if there ever was one. What is real time? Real time and beauty must be very much alike By Gene Toner IDEC, Inc. P.O. Box 69 Fountainville, PA 18923 (215) 249-0673 because they both depend on the beholder.Real time in the RS-170 video world is about V60 of a second. This is the time it takes to paint one field of video. The rewards for being able to digitize one field of video in real time are definitely worth the effort. If one can digitize "on the fly," a "snapshot" can be extracted from any video source. Without this capability, the subject of the picture must remain still, or the video source frozen. Some cameras and VCRs do a credible job of this, but we (and perhaps you) don't have this feature on our video gear. So we want to digitize an entire field in real time. Where do we put it? RAM is an attractive place. We could use one of the system's DMA channels for depositing the result of the AID conversion directly into memory. How many pixels? How many shades of grey? Well, the best PC video adapters around these days are VGA. They have a grey scale mode which allows 320 x 200 resolution with 64 shades of grey. ~ f one can digitize "on the fly," a "snapshot" can be extracted from any video source. Figure l-Grabber Block Diagram INPUT VIDEO AMPLIFIER VIDEO SOURCE SYNCH SEPARATOR ODD/EVEN FRAME 1 I 1 I 20 MHZ GATED OSCILLATOR PIXEL CLOCK CONTROL DIVIDE BY 4 i • I 256 STATE PIXEL COUNTER ADDRESS GENERATOR n- 256 STATE LINE COUNTER ADDRESS GENERATOR J I/O SERVICE PORT PC BUS VIDEO DC RESTORATION I/O ADDRESS + ADDRESS DECODE - t FLASH 6 BIT A/D CONVERTER DATA (6 BITS) 64KBYTE CAPTURE MEMORY CARD SELECT BUS 1 DATA BUS COMMAND LATCH DATA BUFFER J MICRO CORNUCOPIA, #50, Nov-Dec, 1989 17 Sounds like a good place to start, especially since a field of RS-170 video has only about 244 lines of vertical resolution available. (Actually 2621/2 lines, but some of these get consumed by vertical retrace.) Because we work in a digital world, the number 256 is much more appealing than 320 or 244. So we went with 256 x 256 x 64 shades of grey. In a standard video signal, every horizontal line takes roughly 63 Jlseconds. Of that 63 JlSec, video takes up about 53 JlSec, with the remaining time devoted to horizontal synchronizing information. After the dust settles over the calculator, the result requires a sampling rate of 5 MHz to slice that 53 JlSec up into 256 samples. Another result is that with a normal PC-XT (4.77 MHz) computer, you wouldn't have enough bandwidth available to stuff all these samples into computer memory using the machine's DMA chanilel. You would have to use dedicated memory. The Lost AID Converter Figure 1 shows the frame grabber (actually a field grabber, each frame made up of an odd and even field) in block diagram form. Figure 2 is the schematic of the final version of the grabber. The heart of the system is the RCA3306 6-bit flash A/D converter. This, however, was not always the case. There are other offerings in the flash A/D race, including a very nice 8-bit Samsung part. It, along with the A/D converter, has some very nice signal clamping circuits. Samsung advertised the part heavily and, upon our request, sampled us a few parts, with the assurance that unlimited quantities would be available when we needed them. So we prototyped a system using this part. Then came the worldwide DRAM shortage, and Samsung decided to build DRAMS instead of flash A/D converters. Can't imagine why, but they left us with a very functional video capture board and no way to get parts. We then made a mad search to find a replacement A/D converter, preferably American, with at least one second source. What we found was the RCA 3306 6-bit converter chip, second sourced by Micro Power Systems. We were in business once again. Not often does a designer have the opportunity to go back and rethink all the design tradeoffs he made during the design, but it happened here. Because of 18 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 Real-time Grab. Fast! this, we were able to squeeze more performance out of the capture card. The System We brought the signal from the camera into the capture card as standard R5-l70 video, which has a 1 V peak to peak (black to white) amplitude. The input video amp (ICl) serves two purposes. (See Figure 1.) As a differential amplifier, it not only provides signal gain but also noise reduction. This output goes to two other modules, the sync separator (IC2), and the DC restoration block (IC3 and IC4). The National LM188l handles sync separation. Fed a standard video signal, it produces composite, vertical, odd/even frame and burst gate/black level timing information. We use the odd/even signal to capture even frames (those with a complete line of video on the first line of a frame). We use the black level signal to sample the incoming video for its reference black level. The DC restoration block is the LM 398 sample and hold amplifier which holds and filters the video black level for later subtraction from the video signal. After subtracting the detected black level from the incoming video, we have a ground referenced video signal with black at ground and white at roughly 3.3 volts-perfect for conversion by the RCA 3306 flash converter (IC13). A gated crystal oscillatot operating at 20 MHz and divided by 4 controls the conversion process. Each rising edge of this sample (pixel) clock causes the A/D to take another look at the video signal. It then shifts the previous sample to its output. The Conversion Process The PC bus address decoder (IC17 and IC18) decodes a write to the board, and a command to capture a video frame loads into the command latch (IC19). This command places the capture memory in a writeable condition and allows the capture of the next even field. When the sync separator senses the next even field, it allows the gated oscillator to operate for 256 samples of the pixel clock as counted by the pixel counters (IC9 and IClO). When it reaches the count of 256, the pixel clock shuts off until the next horizontal sync pulse shows up. (Line counters, ICll and IC12, also get incremented here.) These counters generate the addresses for the video capture memories. The falling edge of the pixel clock strobes in the data. The process continues until the carry bit of the last line counter resets the command latch and stops the process. The computer monitors the command latch to determine the completion of the sample. At the end of the process, video memories return to a readable condition. The computer resets the pixel counters and the line counters. Then, once a signal from the command latch has replaced the pixel clock, the computer can access video memory. When the computer forces this signal line high and then low, the pixel counters and the line counters are incremented. This way the computer can read the contents of video memory and transfer those contents into its own memory. The Software Once the data resides in main memory, the software takes over. The program was written using Microsoft C 5.1 and the Zortech libraries. We found the Zortech windows libraries not only well done, but also a bargain at $50. Everybody has their favorite C compiler, and ours is Microsoft's. Its wide, third-party support is one of the reasons, CodeView another. The intent was to produce reasonable pictures on the laser printer, and we accomplished this using a technique called dot dithering. This technique forms a macro-pixel made up of several dots and simulates grey scale by the percentage of dots printed. Here, we chose a four dot by four dot cell to simulate 16 grey levels. (This doesn't seem to be too grainy.) We can display the video on all the standard monitors. The most impressive is the VGA, presenting the picture in its full 64 shades of grey. We can also reproduce this picture on an IBM graphics compatible printer. Here, we use each printer dot as a cell and strike it up to four times to simulate four levels of grey. Finally We Get To The Desktop Recent investigation showed that both Ventura Publisher ver. 2.0 and Aldus PageMaker ver. 3.0 support grey scale images in the TIFF file format. Discussions with the technical support group at Aldus yielded a TIFF developers software kit for the meager price of $30. After tearing into the developers kit, we discovered that the TIFF file format is well thought out and easy to use. We wrote a file format converter to take our format QDC) and convert it to TIFF. Once we had conquered TIFF, Ventura 2.0 accepted our image files. We now take video photographs and incorporate them into desktop publishing. Thanks to TIFF, we can also print the resulting documents on the printer while maintaining grey scale information. Quality has been very good. With the VGA and its 64 shades of grey, an image direct from the camera (tape tends to d,egrade the image slightly) comes very close to black and white broadcast quality. Editor's note: Idee's Supervision software and a sample captured screen are available on the Micro C BBS and the Issue #50 listings disk. They've offered Micro C readers a special price for the Grabber Board and software ($175 + s/h). Kits are also available. Call Idec for details. ••• The Complete Diagnostics Solution for Your PC/Xl, PCI AT, or Compatible INCLUDES... DRIVE TESTS-Complete diagnostics for Hard and Floppy drives. including controller cards. Tests read. write. and format capability as well as seek timings. hysteresis and rotation timings. I/O PORTS-For both parallel and serial ports. confirms internal and external loopback capabilities at all baud rates and configurations. MEMORY-Performs over eight different tests to check standard extended. and expanded memory. KEYBOARD-Verifies that all keys send correct key codes. including shift. CNTL and ALT modes. CPU. NUMERIC COPROCESSOR-Verifies that all single and multiple instructions perform correctly and accurately. as well as testing all internal registers. VIDEO DISPLAY-Checks video controller cards. Confirms attributes. graphics. colors (if applicable). and CRT alignment patterns. COMPLETE PC/XT DIAGNOSTICS SET (save 528) $ 29 $ 29 $ 19 $ 49 PCI AT System Diagnostic Software PCI AT Disk Diagnostics (wI test diskettes) PCIAT 110 Loopback Test Plugs $ 29 $ 29 $ 19 COMPLETE PC/AT DIAGNOSTICS SET (save 528) $ 49 BOTH PCIXT and PCI AT SETS (save 575) $ 79 PCIXT System Diagnostic Software PCIXT Disk Diagnostics (wI test diskettes) PCIXT 110 Loopback Test Plugs Capital Software presents the definitive disk-based diagnostiCS package for the IBM PC AT and Xl Atechnical tool detailed enough for the repair technician. A friendly interface that places problem-solving skills in the hands of the end user. An uncompromising solution. SEND CHECK OR MONEY ORDER TO USE YOUR VISA OR MASTERCARD CALL TOLL FREE (800) 541-0898 REAL TIME CLOCK-Verifies correct timing. all internal registers. and battery backed-up RAM. C.APIT.Ai SOFTWARE 951-2 OLD COUNTY ROAD SUITE 224 BELMONT, CALIFORNIA 94002 FOR INFORMATION CALL: ...and many more features to Insure the Integrity of your computer. 408-293-5279 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 19 Figure 2-Grabber Schematic J2 IC2 LM1881 R3 SI1 IX B VCC 7 R2 +5 ODD 6 :511 lX SET 5 BST 75 Rl -=- IC5 LS04B Co4 JUF RB 6801( J3 3 -:- +5 D2 IN''14B R17 2.2K CB .22l.f' 13 330 330 +:5 +5 VGET 3 6 IC6 lSOOA D5 IC13 B6 2 +5 B5 OF 3 VSS 0 0 4 M VZ M 5 4: IC17 U J1.A31 (X) (X) J1.BI3 ClK PH 'JRO \0 9 u :x: HC407:5A 9 'WRI 10 RDO 17 B4 16 RC 15 B3 14 B2 13 Bl 12 D3 D2 Dl VIDEO +:5A I CI0 .1UF _ REF'+ Cll J,IUF -=RIB +12 Zl 3.3V HC4075C Jl.Bl Jl.B31 Jl.B3 1- 1 +5 -:- 111111111111 TIIITIIIIIII Jl.B29 +5A Jl.B7 -12 BYPASS CAPACITORS Jl.B9 +12 CI2 - C23 All .01lF 20 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 - - - - - - - - - - - - - - - - - - - -_._---_....__ ._--- +5 ~ 220 1/2 'W UNUSED GATES IC5 Rll VIIlED 10K IX 7 R14 R12 10K IX IC4 10K IX R13 VRI ~----------------~------------+---~------------------~------------------~ +5 ~ +5 ~ ,M NID" IC14 ~r;;- 7A3 r--M---§.. A4 ~ DOll DO Dl 12 »2 113 Dl D315 D2 D3 A7 ~ 3 A7 \0 D4 16 25 ~,!{l D5 17 D4 D5 A9 24 A9 A6 AS 4A6 ~ ~ All AlO 23 All ~A12 ~Al3 A14 1 Al4 ~ D6 Al 9 Al A2 8 A2 DO Dl ~ A9 24 A9 D6,l!- A7 ~ D7~ 7 6 5 4 ~ AID 21 AlD All 23 All A12 2 Al2 vr~ Al3 26 Al3 A14 1 Al4 1£ r!L-J!L. r1L-1!L A3 A4 AS A6 3 A7 \0 25 ~!{l A3 A4 AS A6 ~ '--r---- 20 10 D2~ D3 D4 r!L--!!!rlL--!!L r.!2- 2D ~ DO 2~ YNJrlB~______• Dl 4 tAl YAI r16~______-+-t D2 6 tAe 8 1 1A3 D3 vr rR- YA2 ~ JLA7 YA3r!L-- JLA6 r~ ~ D4 17 IBO ~ ~~ IBI r r--------'l'"'i 1B2 l .-------:19~1B3 YBD ~ r - - JLA5 f- YBI f-- JLA4 YB219 f-- JI.A3 YB3r--r-- JLA2 Ls2ill 1£ '--r---- 22 «« D5~ D7 M NID" NM.1Il «« r;;-- NJ ~ M NID" CD"'o", IC1S ~Al ~A2 A3 ~ MCIIID" .nlD" «« o_N('l) «« +5 +5 22 ~----------~-~ +5 10 JLA8 _ _~12=-t D SD Q L,...Y.GET Al5 5 IC:S ",,6 r -_ _..:;;;ll'"l>lcp RD a o!- IC1~LS74B V~~----~------------~ MICRO CORNUCOPIA, #50, Nov-Dec, 1989 21 LIMBO Part Three Building The Mobility Base It's time to get out the bailing wire and tin snips. This time Bob builds LIMBO's action fraction. maze robot ain't much fun if it can't cruise through the maze without getting stuck. Mazebots get stuck in many ways, usually by running headlong into something. We can usually blame inadequate sensor coverage. Even a single one-inch gap in the bumper perimeter will be catastrophic, eventually. Of course, there are other ways to get stuck, losing traction being a popular one. The concrete surface on which members of the Seattle Robotics Society run maze robots looks flat, but the robots know better. Mazebots with two drive wheels and two castors tend to wobble like four-legged stools in our maze. To maintain traction, the wheels need to conform to the irregularities of the running surface. That requires some kind of springy suspension. Why not make a robot with a rigid three-point suspension instead of fourpoint? Small bumps and hollows wouldn't bother a three-wheeled robot because, like a three-legged stool, each wheel makes contact with the ground. However, I find that three-wheelers are more tipsy than four-wheelers. Also, four-wheelers can have more traction because the weight can be placed right over the drive wheels, an impossibility with three-wheel designs. (Perhaps the ideal system would be a gyro stabilized twowheeler, or even a unicycle. Imagine: a robot able to do a high wire act.. . .) LIMBO is round as viewed from above, with a four-point spring suspension. The drive wheel/motor combinations mount rigidly to the chassis, while the front and back castors are spring A Mazebots get stuck in many ways, usually by running headlong into something. mounted. The drive motors mount inside an aluminum box. I call the motor box, combined with the castors and spring, the undercarriage. The undercarriage bolts on underneath the bumper contact skirt. This whole assembly is known in robotics slang as a mobility base, or just base. A superstructure, which carries the batteries, sensors, and control electronics, bolts on top of the base. Wires from the undercarriage run up to the superstructure through a central wire access hole. This time we'll build the LIMBO mobility base. Preparing The Motors Tools: Hacksaw, drillpress, Vee-blocks, clamps, hand reamer, metal files, 200 W soldering gun, 6" machinist metal rule, flux brush, rubber mallet, drills. Materials: Nesting brass tubing (91.32" o.d. to ¥8" o.d.), IMC stepper motors, rosin-core solder, rosin flux pa~te, cotter pins. 22 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 -------------------------------- Step 1. Make drive shaft sleeve adaptor. The IMC motor I chose has 1A" shafts on each end, one 0.7" long with flats, the other 1.55" long, no flats. The motor body has a 2.25" square mounting flange with one ear cut off and standard 3116" mounting holes in the remaining three. The long shaft is just right for mounting the wheel. Unfortunately, it's on the opposite end from the mounting flange, so you'll need spacers to mount the motor inside its box. Also, you need to add a sleeve to the lf4" shaft so it'll fit into the 3/8" hole on the wheel. You can accomplish this with nested brass tubing, available at any hobby shop. You need four sizes from 91.32" to 3/8" o.d. with 11.32" wall thickness. It's best to take the motor and wheel you plan to use with you to make sure the sizes are right. These brass tubes usually come in 12" lengths, more than sufficient for two motors. Get brass tubing, not aluminum, be- By Bob Nansel 816 North lOSth St. Seattle, W A 98133 LIMBO Exploded View Top Disk Middle Disk Bumper Skirt cause aluminum tubes are too soft and are very difficult to solder. First, nest all the tubes together. They should be very nearly all the same length. If not, sand or file the tube ends (still nested) until they are. Next, telescope the tubes out on one end so that about %" of each tube shows. Then brush soldering flux paste on these exposed ends (but not on the inside of the smallest tube, nor on the outside of the largest tube). Slide the tubes back together, repeat this procedure on the other end and then slide back flush. Using minimum pressure, clamp the nested tubes in a bench vise with one end of the tubes perpendicular to the bench top. Heat up the top end with a soldering gun and sweat a small amount of solder into the flush ends. Be careful not to get solder on the inside surface of the smallest tube. Allow the tubes to cool, then flip the tubes over to solder the other end. The idea is to make the tubes " Suspension Spring Motor Box Microswitch Disk a single unit for cutting and drilling. From each soldered end, measure 1.5". Use a hacksaw to cut a piece from each end slightly longer than the marked length. Sand or file these to 1.5". Remove the burr inside the cut ends with a hand reamer. Ream away any excess solder on the other end, too. Clean off any flux or brass particles with a paper towel, then slide the completed sleeves onto the stepper motor shafts. They should slide on easily. If they don't, you will either have to ream the ends some more or squeeze the tubes back to round. You can avoid most of the work above if you can find tubing with %" Ld. and 3/8" o.d. (I couldn't find any). In this case, just cut two pieces to length, file, ream and you're done. Step 2. Drill cotter pin hole. The long shafts of the steppers don't have flats ground in them, so you can't use setscrews to secure the ada ptor sleeves and wheels to the shafts. I don't trust setscrews for high torque drives anyway (they tend to come loose midway through your best run), so I use cotter pins for really positive drive. Our problem now is how to drill cotter pin holes precisely through the V4" hardened steel shafts of the steppers and to perfectly match holes through the sleeve adaptors. The problem breaks down into how to hold the work-pieces and how to assure proper alignment. Holding the workpieces is best done with machinist type Vee-blocks and clamps. Alignment will be perfect if the holes are drilled through both the sleeves and the shafts simultaneously (see photo). Mark a line around the sleeve adaptors 7;-32" from the soldered ends, then slide them onto the long shafts, ends flush with the ends of the shafts. Use two Vee-blocks to support both front and back shafts. Slide scrap tubing left over MICRO CORNUCOPIA, #SO, Nov-Dec, 1989 23 Motor Box Layout 1-1.--- 4' (reF) ---·-11 ~================~ I I 3 5/8' - - - - t 2 45/64' ---t : 125/32'i-!---{f}-i+--.- I ,-- I --;------It--I I I I PUNCH 1/2' DIA. -ft>'-tt--"- DRILL 3/16' x 3 I I I ~:~~~~~~~~~~~~~~~~ LEFT SIDE from Step 1 onto the front (short) shaft, so the two Vee-blocks support the motor evenly between them. Clamp the Vee-blocks to the drillpress table using C-clamps or bar clamps. Don't tighten the clamps completely yet; leave. them loose enough that you can adjust the work position by tapping with a rubber mallet. Chuck up a 31.32" bit in the drillpress. Then, with the drill press still turned off, bring the bit gently down to touch the sleeve adaptor. Adjust the Vee-blocks until the bit comes down squarely on the '132" mark. An old machinist trick to tell if the bit is perpendicular to the round shaft is to put a 6" metal rule on the shaft, then bring the bit down (power still off!) with enough pressure to hold the rule in place. Adjust the blocks around until the rule is perfectly level and perpendicular to the drill bit. This will ensure that the hole is drilled through the diameter. Remove the rule and check to see where the bit touches now. H you're lucky, it will still be right on the '132" mark; if not, keep fiddling with it. When everything is right, tighten the clamps, then check to make sure everything is still aligned. Also check to see that none of the clamps will interfere with the drill chuck. Remember that the chuck will come 318" closer to the work by the time you've drilled all the way through the shaft and sleeve. Safety tip: use masking tape to hold the wires out of the way. Now drill the hole slowly, backing the bit out often to clear chips. Take care not 24 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 TOP RIGHT SIDE to drill too far; Vee-blocks are not cheap. Does everything look centered? H .not, something slipped. The setup takes a while to get right. But once done for the first motor, you'll be able to do the second without any changes, provided everything is still clamped down tight. You should still check alignment before drilling the second shaft. You now have two stepper motors with cotter pin holes drilled perfectly. The cotter pins should fit snugly. A little sanding or filing to clean up the drill exit burrs, and smile: you've just done precise machining by eyeball. corner to corner will .do just fine). Measure all locations with respect to the center points, and use the trisquare to line up holes the same distance from center. Or, you can tape templates to the panels and directly transfer the hole locations with a prick punch. Templates can be made by either enlarging the accompanying illustrations or ordering the full. sized plans (you can find the details in the parts list table). Whatever way you choose, lightly· centerpunch all hole locations. Back up areas being centerpunched with scraps of wood to prevent deforming the panels. Step 2. Drill and punch motor box holes. Drill 1116" pilot holes at every marked hole location. You can use a hand-held drill for this if you're careful, but I prefer the drill press. Examine the results. Do any of the pilot holes seem off-center? If so, now's the time to correct this by nibbling away metal from the side you want the· hole to move toward. Do this with the corner of a file or the prick punch. Aluminum is soft, so don't overdo it. Once you're satisfied with your pilot holes, enlarge them with a 3116" bit. The two shaft holes should be drilled with a 1f,i" bit, then enlarged to 318" with the hand reamer. (Or, you can use a 1;2" chassis punch.) Punch the wire access hole with a 1 3/8" Greenlee chassis punch. The punch should be on the inside of the box, the die on the outside. It is much easier to turn the wrench this way, and it will make the inside edge rounded and Constructing The Motor Box Tools: Prick punch, metal scribe, 1%" chassis punch, drills, or hand drill, machinist trisquare, machinist compass, pin vise, files, hand reamer. Materials: 6"xS"x4" aluminum project box, modified stepper motors from Step I, plastic training wheels, aluminum hex standoffs, #10-32 machine screws, wood scraps. Step 1. Layout Hole Locations. LIMBO uses a two-piece aluminum project box to protect the stepper motors and undercarriage wiring. With the cover mounted, it also serves as a ,rigid, lightweight mount. Since the stepper motors are mounted directly to the box, it pays to be exact when doing the mounting hole layout so the drive shafts are accurately aligned. Begin by locating the vertical center line of the side panels and the center of the top piece (scribing diagonals from V-block Setup On Drill Press Using Machinists' Rule Trick to Line Up Drill Inserting the Cotter Pin with Needle Nose Pliers smooth so it won't chafe the wiring. Oil the threads of the chassis punch before you begin punching; less friction will make the job easier and your punch will last longer. If you don't have a chassis punch (they cost about $25), scribe a 13/8" circle on the box before drilling the pilot holes. Use a nibbling tool to cut a circular slot starting from the center and spiralling out to follow the scribed circle line. You'll need to do some filing to smooth the cut. Either way, finish by deburring all the holes with a file or X-acto knife. Step 3. Mounting the motors and wheels. We need standoffs to mount the stepper motors. I special ordered the 113116" standoffs to save time. You might wish to find 2" spacers that you can file down to size, though you'll want to get the ends as square as possible. First, loosely mount the standoffs to the stepper motors, then fit the motors inside the motor box one at a time. You'll probably need to slide the standoffs around a little to get them to line up with your mounting holes. Once you've gotten all three outside screws in, you can tighten the inside screws. The shafts may look somewhat askew before you dose the box up, but the box will flex a little with the bottom cover in place so the shafts should then appear to line up with each other. If they don't, loosen the outside screws a bit and slide the motors around until they do, then retighten. Remove the adaptor sleeves from the motors and slide the plastic wheels onto the sleeves. Mark which sleeve went with which wheel and motor. With the cotter pin holes visible, mark the hub of each wheel adjacent to the holes. Remove the sleeves. The hubs of the wheels don't protrude far enough to allow directly drilling the hole, so you'll have to use the 31.32" bit in a pin vise. The holes will be angled inward slightly, so you'll need to offset them to compensate (see photo). Once you have the holes drilled, slide the sleeves back on the motors, lining up the holes with a small nail. Without moving the shafts, slide each wheel onto its sleeve. Getting the wheels aligned can be tricky. You may have to drill the holes in the wheel hub to a larger size. Once aligned, force a new cotter pin through each hub/sleeve/shaft hole, then bend the ends of the cotter around the hub. The wheels are now MICRO CORNUCOPIA, #50, Nov-Dec, 1989 25 Castor Suspension Spring Diagram DRILL 3/16' DIAMETER PUNCH 1 .3/B' DIAMETER 0.040 ALUMINUM , ~ M ru ......- - - - 4 13/16' - - - - . - . . . - - - - - 5 lIB' -----oaot----- 4 13/16' - - - -.... ~---------------------------- 14 3/4' (ref) --------------------~ solidly mounted, and the motor box is complete. Making The Castor Suspension Tools: Same tools as Motor Box procedure, plus aviation snips or bench shear, ball peen hammer, C-clamps, plastic protractor, bevel gauge. Materials: 6"x14.7S"x 0.040" Aluminum (SOSl), swivel castors, scraps of wood, #12-24x1;2" machine screws and nuts. Step 1. Preparing the suspension spring blank. The castor suspension spring for both front and back castors is a single piece unit made from a 6"x14.7S" sheet of aluminum. Buy at least a few extra inches length when you have the metal shop cut a piece for you so you can discard the bent corners (metal dealers seem to save their best pieces for bigger customers). Try to get the width as close to 6" as possible to save trimming. Using the trisquare, scribe a square line across the best end, then make all measurements relative to this line. layout the fold lines first, then the tapered outlines, and finally centerpunch the hole locations. Use either direct measurements or transfer the locations from the motor box completed previously. Cut to the outline using either aviation snips or a bench shear, if you're lucky enough to have one. Drill and punch the mounting 26 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 holes and the wire access hole as you did for the motor box. Step 2. Bending the suspension spring and mounting the castors. If you have access to a sheet metal brake, this step will be easy. If not, a few S" C-clamps and some blocks of wood and a hammer are all that you need. Clamp the blank between two solid scraps of wood, straight edges lined up right on the scribed fold line. The first bends to make are the inner, wide ones. Set your bevel gauge to about l1So. Begin the bend by pushing from one side of the metal blank with a block of wood. As the bend proceeds, you'll need to use considerable persuasion with the hammer to keep the bend crisp. Don't hit the metal directly with the hammer, but indirectly through a block of hardwood. Check the angle with the bevel gauge often. Take your time, and don't break your thumb (you'll need it later). After you finish the four bends, mount the castors in place with #12 screws. Make sure that the castors can swivel freely over the screw heads. Take the castor / spring assembly and temporarily mount it to the motor box with #10 screws and nuts. Does it stand up straight and proud? Is it level with no wobbles? No? Bend the spring a little to make it level. The angles given should put the cast:ors slightly lower than the drive wheels so that the castors contact the ground , before the drive wheels do. This is called preload. The function of the preload is to provide enough tension in the suspension to prevent rocking, but not so much that the drive wheels lose traction. If the preload seems a bit much now, remember you'll have at least five more pounds of robot. Put a bag full of sugar on top (C&H granulated works best). Adjust the preload if it seems either too stiff or too wobbly. The Bumper Contact Skirt Tools: Same tools as above, plus nibbling tool, 1%" wood boring auger or spade bit, sabresaw or coping saw. Materials: 12"x24"xlf4" plywood, #1032 screws and "Tee" nuts, #4 roundhead wood screws, microswitches, 22 gao stranded hookup wire (9 colors), 24 gao solid buss wire, nylon cable ties, 9-pin connector, 14" Superpot tray. Step 1. Making the bumpers. A robot's interactions with its environment can be only as good as its sensor data. The bumper contact skirt is the first and most basic of LIMBO's sensor suite. For a $2 flower pot tray to function as a super sensitive and reliable bumper contact sensor, you must make a few modifications (Le., don't plan on using this baby to start tomatoes next year). at tool~ ~cP~ ..tWO gre .~. 4~~f~ ~ SAYWHAT?! The breakthrough ~/ DBMS toolkit for Pascal If you'd like to combine the raw power ~ and speed of Turbo Pascal or MicroC~ . soft's QuickPascal with the simplicityL ~ ~~'lGY\. / and elegance of dBASE, Topaz is L~~~~ / just what you're looking for. ?~~ That's because Topaz was ,"''' specially created to let you enjoy the best of both worlds./.~'JV [) The result? You create com- '6?J'/~ plete, truly dazzling applicat- / / _ (/-'7 ions in a very short time. And no wonder. ,,~'.....!> Topaz is a comprehensive toolkit of ~\ dB~SE--like commands and functions, .,\ \ \\ desIgned to help you produce outstanding, polished programs, fast. Check out these powerful features: Whether you're a novice programmer longing for simplicity, or a seasoned pro searching for higher productivity, you owe it to yourself to check out Saywhat. You see, with /'";; S aywh at, you can build (beautiful,elaborate,colorI coded screens in minutes! }/ That's right. Trulyfantastic ~ screens for menus, data entry, data display, and help-panels that can be displayed with as little as one line of code in any language. "\. ",/11 j~ )/' Here's what you get: ___ iL\l • Over 200 routines all with easy-touse, dBASE-like syntax. ORDER NOW. YOU RISK NOTHING. Thousands of satisfied customers have already ordered from us. Why not visit your dealer or call toll-free, right nowand put Saywhat and Topaz to the test yourself? They're fully guaranteed. You don't risk a penny. Special limited-time offer! Save $26. Buy Saywhat?! and Topaz together for just $99 (plus $5 shipping and handling). Visit your nearest dealer or call toll-free: 800-468-9273 In California: 800-231-7849 International: 415-571-5019 • Design screens, windows, and moving bar menus! • Easy-to-use, powerful editor lets you create screens in a jiffy. • Pop up your screens and menus with one line of code in dBASE, all the dBASE compilers, your favorite BASIC, Pascal, or any other language! • Screen Library Manager. • Generates runtime code. • No runtime license or royalty fees. • Comes with a 100 page manual, plus dozens of sample programs and free utilities. • Data entry routines like SAY, GET, PICTURE, RANGE, color selection, unlimited data validation. • Open up to 10 DBF files, with up to 7 indexes with USE, SELECT, SKIP, APPEND, PACK, INDEX ON, SET INDEX TO, and FIND. • No need to buy dBASE. CREATE; BROWSE and REPORT utilities included. • Easily implement Saywhat and Lotus-style moving bar menus. • BROWSE any DBF file with just one line of code! Programmable and windowed too. • Pick from windowed data or filenames with one line of code. Software Science. Inc. The Research Group 100 Valley Drive. Brisbane. CA 94005 Q;:; • ~~ j:;-r;-i T I ~- ,\ I ) \ \ )\ l I/o Y,~~, J fc A ~ \'-\ -----.....: ~0'4.f~ TOPAZ The lightning-fast screen generator. , t ~v.() ''<2 '),-)')J"""T) --)-)-;\ Comprehensive Time & Date math in 7 international formats. A~1/ 'MONE:VBACKG:U~EE. ~. Powerful code and report generators I D~ / /] Ifyouaren tcompletelydehghtedWlthSaywhat . 1 d d' f (( _'..Jj: exchqet l:ineto forall def.··.%Oraw %. copy the generator value %. use it to •• index into x ... coordar.ray %·put.generato.rvalue.back·ontopof·stack llIuse it to get they;..coord %.d.rawthe line segment %d.Oit • for each point in the generator 1$ l'utsendpoirit13o(each .segntent .ofgenerator on stack % (noPal:'ams)leavesgensegsinr~ve.rseorder (B-1) % for count=GenSize-l « » xref : « ;coaversio. t.~le ;9662:eee7 : 9682 : eee'J :9682:eee. ;1.0" rqister WI .:IV ;868Z:ee9i .:IV ;9682:9919 ;»»> Conversion Section les 4i Address If s .:IVZX bx ----------- ---- - - ex Hel p repz st e ; 9682 : 991Z »xref =<86899>« :coaversion t.~le ;9682:991£1 ;9682:991b get \yte cont ;8682 :99tr ;Store AI. at IS:(DII :8682:9911 :Turn 0" Interrupts _IV dX,1cOOh iut 1.1h :8682:991Z :8682: 99l~ DOS: 1c- tertii IWte Reader Service Number 142 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 53 Capturing & Graphing A Voice In Real-Time: Part 1 Analog Signal-Conditioning This isn't just an analog project, but here's the analog portion: as complete a discussion of analog filter design as you'll see in any magazine. this project. To breadboard the amplifier I filter circuit and connect it to the AID board, I use Real-Time Device's XB40 prototype board and cable (the Advan tech has a similar prototype kit). ast issue, I looked at several commercially available I/O boards for the Pc. All those boards included analog-to-digital conversion and usually some kind of digital I/O and counter I timers. One had a D I A converter as well. This issue, I'll use one of the boards (the Real-Time Devices ADI000) and step through a complete interfacing project. The project will capture a voice and display it on the screen using Turbo C and the Borland Graphics Interface (BGI), which works with any common display adapter. Although I'm using the Real-Time Devices AD1000, you can also use the Advantech PCL-BI2 or 7I2E board from Rapid Systems or Halted Specialties for The Circuit It's one thing to understand a circuit; it's something else to design one. My friend Brinkley Barr breathes electronics. This circuit took him about five minutes to design; it would have taken me days. When you're trying to accomplish something, it makes a lot of sense to go to an expert. You pay for the expert's experience, but you'd pay for the experience one way or another. Figure 1 shows the voice signal-conditioning circuit. It consists of a microphone, a two-stage amplifier, and a 3pole anti-aliasing filter to remove frequencies higher than 6 KHz (most of the information in your voice is below 6 KHz). Aliasing occurs when the frequency of your input hits half the sampling rate of your AID converter-the L converter doesn't get enough information about the waveform, so the information is garbled. The circuit's three op-amps reside on a single chip, so the parts count is quite low: the chip, a microphone, and some resistors, diodes, and capacitors. All the parts are inexpensive and easy to mailorder (details later). Let's walk through each section of the circuit so you understand what's going on. The Microphone Several different types of microphones are available: condenser, crystal, magnetic, ceramic, etc. Brink selected an electret microphone because it's simple (it doesn't need a high-voltage bias like condenser microphones). You'll be amazed at how tiny these little guys are. They look like spy microphones, but they contain a field-effect transistor (PET) so the signal is already boosted by the time it gets to your amplifier. +9Yofts Stage 1 30 dB Amplifier 6 KHz Butterworth Low·Pass Filter Stage 2 30 dB Amplifier 2.2K Mylar Monolithic Output to AID ·5Vto +5Y' Resistors: 5% (Gold tolerance band)- 54 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 ---- .------ By Bruce Eckel Revolution2 308 Meredith St. Kennett Square, P A 19348 BIX: beckel Compuserve: 72072,3256 The Amplifier The amplification stage consists of two identical sections. The input to each stage passes through a high-pass filter consisting of a series 0.47 J..lF capacitor and a 12K resistor to ground. This serves two purposes-it removes 60 Hz hum and it keeps OC (called an offset) from reaching the inputs of the first and second stages. The output of any amplifier contains DC, which, if passed on to the next stage, is magnified along with the signal. Which isn't what we want. The amplifier stages are simply opamps. The 68K and 2.2K resistors provide a gain of 30 for each stage. The gain for this op-amp configuration is calculated as 1+(68K/2.2K}. The combined gain (calculated by multiplying the individual gains) is 900. I've written about op-amps in my first book, Computer Interfacing with Pascal & C (available from Micro Cornucopia). Electric Circuit Analysis by Johnson, Hilburn, and Johnson is also worth checking out. You may wonder why the amplifier is in two stages instead of just one (Le., why not just change the values of the 68K and 2.2K resistors to create a gain of 1000 with a single stage?) Good question. Answer: because op-amps are introduced to novices as "ideal components," and in many ways they are ideal, but this circuit displays one of their limitations. Gain-Bandwidth Product If you're carrying a heavy weight, you can't run fast. If you force op-amps to provide a lot of gain, their frequency output (bandwidth) becomes limited. The relationship between gain and bandwidth is called the gain-bandwidth product. If we ask for a gain of 1000 out of a single 4136 stage, we'll limit its output to 1 KHz, maximum. But our filter cuts off G a i n Pole at 1O~ hz i n ( \.. D e K \ c I B e I 10 100 1K 10K 20dB/decac e \ \ 100K \ 1M 10M Frequency (Hz) Figure 2- Bode Frequency Plot at 6 KHz. By limiting the gain of each stage to 30, we get a bandwidth of about 30 KHz. The amplifiers will pass all the relevant infonnation, and the filter will do the work of removing the highfrequency components. Filters Usually, we describe a filter, or the filtering properties of any electronic device (even if it isn't specifically designed to be a filter), with a frequency plot. A frequency plot (also called "Bode plot") shows the size (amplitude) of the signal (usually as a ratio of output size to input size) on the vertical axis and its frequency in a logarithmic scale on the horizontal axis. In a Bode plot, the vertical axis is 20*log(base 1O} of the output amplitude over the input amplitude (i.e., the gain in deciBels). Although there's an interesting history to these numbers, you shouldn't worry too much about why you use 20*log(base lO}(output/input} instead of just (output/input). Figure 2 shows an example Bode plot, similar to what you'll see in electronic data books when you're looking for parts. Where the line is straight, signals of that frequency (shown on the x-axis) pass uniformly. Where the line bends, signals fall off. Figure 2 shows the signals passing up to 10 KHz, where the bend begins. You can create any wavefonn by combining simple sine waves of different amplitudes and frequencies (we call this Fourier analysis). Thus, your voice contains components of 20 Hz, 500 Hz, 5 KHz, etc. H your filter has a bend at 2.5 KHz and you pass a voice signal through it, all the frequency components of your voice above 2.5 KHz will be reduced or eliminated. There might still be enough infonnation in the lower frequencies for you to hear the words, but they'll sound different. The straight-line part of the plot (called the passband) shows which frequencies pass. After the bend, you MICRO CORNUCOPIA, #50, Nov-Dec, 1989 55 enter the stopband, because the filter doesn't pass the signals anymore. The sharpness of the bend shows how quickly the filter switches from passing signals to stopping them. Here the poles of the filter come inthe poles determine how quickly the filter switches from passband to stopband. The more poles at the cutoff frequency (10 KHz in Figure 2), the sharper the cutoff. The quality factor Q, which you'll see mentioned in the databooks, measures the sharpness of a filter. The ideal filter would be a perfect step transition be- +12 Volts From PC 20 deciBels (dB) per decade (change in the frequency by 10 times). A deciBel is the unit on the vertical axis of the Bode plot equal to 20*log(base 10) of the output/input. If you add a pole at the same cutoff frequency, the Bode plot will decrease at 40 dB/decade; a third pole will cause a decrease of 60 dB/decade (which is what our filter does at 6 KHz). Zeros of the function (points where the numerator goes to zero) have the opposite effect-they make the Bode plot increase by 20 dB/decade. Thus, designing a filter is a matter of figuring out how to manipulate the poles and zeros of supplies brought out from the PC on the XB40 prototype board. To do this, use a 9.1 V zener diode on each line along with an electrolytic capacitor to smooth out the noise caused by the diode. The diode will turn on whenever the voltage at its cathode exceeds the voltage at its anode by 9.1 V. Thus, the top diode will maintain its cathode at +9.1 volts, and the bottom diode will maintain its anode at -9.1 volts. The 150 ohm resistors in Figure 3 are essential. Without them, the zener diodes would suck current until they fried something. These resistors also determine 150 ohms +9 Volts 9.1 V Zener Diode + 1N4739A or 1N52398 100uF 16Voll Electrolytic 11 Texas Instruments AC4136N QuadOp-amp -12 Volts From PC -9 Volts 9.1 V Zener Diode 1N4739A Or 1N52398 + 100uF 16Volt Electrolytic Figure 3-Power Supply tween passband and stopband. If you're wondering why you can't just add a bunch of poles until this happens, it turns out to be a multi-way tradeoff. First, more poles require more components, which costs money. If you don't need a 12-pole filter, don't buy one. Also, adding poles can cause other side-effects, like "rippling" in the passband (which causes distortion). Thus, you won't often see a filter that is more than 4 poles (the one used in this project has 3). Why Call Them Poles? To design a filter, you represent it mathematically. The mathematical equation for a filter has a numerator and denominator, which have points passing through zero. When the denominator goes to zero, the expression becomes infinite. If you look at the equation in a three-dimensional space, a pole looks like a tent-pole under the plane (the canopy) representing the function. Each pole of the function causes the Bode plot to bend and start decreasing at 56 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 the filter function to generate the right Bode plot. There are several ways to manipulate these poles and zeros, and these ways are named after their inventors. In this circuit, I used Mr. Butterworth's method ($5 says Dave inserts a comment about syrup here). the maximum current the circuit will provide: (12V - 9V)/150 Ohms = 600 milliAmps which is more than enough. Usually you don't have to think about poles and zeros, since most reference books have the equations worked out for you; all you need to know is the cutoff and the quality factor you want. If you want to know more about filters, an excellent reference is An Introduction to Filter Theory,. by David Johnson, Prentice-Hall,1976. Buying Parts I needed to shop at two outlets to get the parts. Digi-key has the electret microphone and the IN4739A zener diodes. (Digi-key also has an extensive line of resistors and capacitors. If you do projects like this a lot, you should look into their prepackaged assortments.) You can get their catalog by calling (800) 344-4539. JDR Microdevices «800) 538-5000) and Jameco «415) 592-8097) both have the RC4136N quad op-amp (four amplifiers on a chip). Power Supply Figure 3 shows the power supply circuit. To achieve a voltage swing between -5 V and +5 V at the input of the A/D converter, we need to reduce the ±12 volt Types Of Capacitors I ordered parts (from Digi-key) before I realized I didn't have the right capacitors in my parts cabinets. JDR (where I bought the op-amp) didn't have a great Editor's note: $10 says I don't. Just proves you can't sweet-talk me into adding editorial comments to your articles. selection of capacitors. I asked Brink if I couldn't substitute ceramic disk capacitors for some of the values I couldn't find in tantalum or monolithic. He said that ceramic disk caps are the scuzziest type around and should only be used as bypass caps. Their values can change by as much as 80%. Once, as an experiment, he hooked one up in a filter circuit connected to an oscilloscope. He could squeeze the capacitor with his fingers and see a radical change! There are many types of capacitors: electrolytic, tantalum, monolithic, silver mica, ceramic disk, polyester, polypropylene, metalized film, etc. They vary in production cost and properties. Electrolytic capacitors, for example, come in large values and some can handle high voltages (they're also physically large), so they're ideal for smoothing the ripples in power supplies. But they're polarized; you get the plus lead hooked to the minus side of the supply, and poof! Ceramic disk capacitors are cheap and good for bypassing chips (routing supply line noise to ground). But their capacitance isn't stable (they drift with time and temperature) so you can't use them in critical applications, such as filters. Silver mica capacitors (they sound expensive, don't they) are pricey but they don't drift. JDR didn't have .0027 J.lF or .0039 J.lF in mylar, nor 680 pF in monolithic, but Brink said silver mica would work just fine. JDR didn't have the right ones in stock, so I got smaller values and paralleled them to generate approximately the right values. Editor's note: Ceramic and electrolytic capacitors are relatively cheap. However both are unstable, capacitance-wise, and considered lossy. That means that some DC current leaks through the insulation between the plates. Electrolytics also have a fairly high impedance so they don't pass high frequencies. If you need a high capacitance (>1 JlF) polarized capacitor that can pass high frequencies, use a tantalum capacitor. If you need a capacitor for frequency (e.g., filter) applications, you can use just about anything other than a ceramic, electrolytic, or tantalum. Products Mentioned Prom Kit - $179 Annabooks 12145 Alta Carmel Ct., Suite 250-262 San Diego, CA 92128 (619) 271-9526 Schematics prepared with OrCAD SDT OrCAD Systems Corp. 1049 SW Baseline Street, Suite 500 Hillsboro, OR 97123 (503) 640-9007 AD1000 - $295 Real-Time Devices P.O. Box 906 State College, P A 16804 (814) 234-8087 FAX 234-6864 Digi-Key P.O. Box 677 ~ief River Falls, MN 56701 (800) 344-4539 Advantech PCl-812 or 712E Rapid Systems Seattle, WA 98103 (206) 547-8311 or Halted Specialties 3500 Ryder Street Santa Qara, CA 95051 JDR Microdevices 2233 Branham lane San Jose, CA 95124 (800) 538-5000 Jameco Electronics 1355 Shoreway Road Belmont, CA 94002 (415) 592-8097 FAX 592-2503 I Goodbye BASIC, C, COBOL-hello PASCAL! Now, to make this most advanced language available to more micro users, we've cut our price-to an amazing 529.95! This astonishing price includes the complete JRT Pascal system on diskette and the comprehensive new user manual. Not a subset, it's acomplete Pascal. Check the features. Separate compilation of external procedures • AutD-loading • 14 digit FLOATING POINT arithmetic • True dynamic storage • Verbal error messages • Fast one-step compiler: no link needed • Graphing procedures • Statistics procedures • Activity analyzer prints program use histogram • Operating system interface Next Time THIS IS THE SAME SYSTEM WE SOLD FOR 5295! So how can we make this offer?-why the unbelievable deal? Very simply, we think all software is overpriced. We want to build volume with the booming IBM market, and our overhead is low, so we're passing the savings on to you. Next issue I'll show you the code to make this all work. We'll display graphics in windows, allocate data dynamically, and talk to the AID board. AND AT NO RISK! When you receive JRT Pascal, look it over, check it out. If you're not completely satisfied, return the system within 30 days and your money will be refunded in full! THAT'S ••• • RIGHT-COMPLETE SATISFACTION GUARANTEED OR YOUR MONEY BACK! In addition, if you want to copy the diskette or looseleaf manual-so long as it's not for resale-it's o.k. with us. Pass it on to your friends! This is a Umited-Time-Offer. SO ACT TODAY-DON'T DELAY ENJOYING PASCAl:S ADVANTAGES-AT $29.95, THERE'S NO REASON TO WAIT! 8m r···································r. To: JRT SYSTEMS P.O. Box 187 Enola, PA 17025 phone 717/732·1093 O.K. You've sold me. Send me JRT Pascal by return mail. I understand that if I'm not complete~ satisfied, I can retum it within 30 days for a full refund. I need 0 51/4" disk or 0 3'/2" disk. 0 Send me the JRT Pascal program formatter too, for only $14.95. Name _________________________ Address _ _ _ _ _ _ _ _ _ _ ___ City State _ _ Zip _ _ o Check/M.D. 0 COD 0 Company P.O. [add $20) PA residents add sales tax. Add $10 for shipping outside US/Canada. US funds on a US bank only. Needs only 192K and 1 floppy drive. L--_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. Reader Service Number 154 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 57 Tuning CRITTERS By Scott Robert Ladd 705 West Virginia Gunnison, CO 81230 (303) 641-6438 Scott recovers from SOG just soon enough to dash out this issue's column. Stay tuned as he discusses: Bull, CRITTERS, and a graphics character generator. t's over-but it isn't. Rocky Mountain SaG. It was a big success. We didn't do it alone; I'd like to thank everyone who helped us with making RM SaG a success. Special thanks go to Jim Nutt and Linda Lunt for their abovethe-call-of-dutyassistance. The raft trip was, as always, an adventure. I kept losing my paddle; but then again, I've never had my oars in the water. One boat lost its guide; another boat was swamped by high waves. The Taylor River provided one of the most exciting raft trips of my life. Fortunately, I remembered to bring dry shoes for the ride home this year. Will we hold another SaG? You bet! Maria and I can't conceive of a SOGless summer. So, we're scheduled again for 1990: June 14-16, here in Gunnison. The theme of Rocky Mountain SOG-II will be graphics and animation, with (we hope) a special focus on robotics. If you couldn't come this year, maybe you can try it next year. There's nothing like cool mountain air and friendly people. In fact, because of Rocky Mountain SaG, I'm going to make a change. From now on, I'm releasing all program code published in this column into the public domain. Copyrighting it is both a waste of time and a nuisance. So go to it, folks-this code's for you. I'm writing this column during the first days of August, just a few days after our SaG. While SaG was great fun, it was also a considerable amount of work for Maria and me. So, things that should have been done for this column weren't and I'm making a minor course correction. While the fractal landscape generator is almost complete, it isn't finished. Look for it in issue #51, along with a speedy auto-sensing graphics library. Fortunately, I received a lot of questions and I 58 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 comments about the column. So this is going to be a potpourri of answers. We'll begin by looking at some new hardware that wandered in the door. (Fast hardware can be a bane as well as a boon.) Bull Bull is the name of my latest computer. It's from BFM Computing of Rhinelander, Wisconsin. A 20 MHz 80386 with 4 megabytes of memory, a 64K static RAM cache, 28 millisecond 65 megabyte Mitsubishi hard drive, and 16-bit VGA, Bull certainly has improved my computing environment. He benchmarks out at 23.0 on the Norton 51 scale, considerably better than my "old" 16 MHz 386 box. BFM offers an amazing 3-year warrantee on the motherboard, and so far, this machine is impressive. I don't want this to be an advertisement, but if you'd like to contact the company, you can reach them at: BFM Computing 701 Washington St. Rhinelander, WI 54501 (715) 362-4712 Inefficient Code High-powered hardware is great but those of us who write programs may find that our super machines are hiding a problem: inefficient code. Even a sloppy program will be fast on a 386. However, put those programs on a lowly 8088, V-20, or even 80286, and they crawl. Such is the case with the CRITTERS program introduced last issue. I've rewritten CRITTERS. The self-extracting file CRITTER4.COM contains everything you need. You can find it on the Micro C BBS, on the listing disk for this issue ($6 plus $2 S/H to foreign countries) from Micro C, or from me for a disk and postage. It's just too big to publish in the magazine. If you get a copy, feel free to distribute it via BBSs and users groups. I had several goals when I rewrote CRITTERS. First, I wanted it to be faster-much faster. Second, I needed to make the program High-POWered hardware is great but those of us who write programs may find that our super machines are hiding a problem: inefficient code. more generic so people with non-Microsoft compilers could compile it. Third, I wanted to add some new features. I broke out my tool kit and got to work. Profilers are among the least used and most ignored tools for programmers. A profiler analyzes your program's execution, creating a report showing how much time it spends in which functions. It can even track variable accesses to tell you which data gets used most. I use the MMC AD Systems profiler called PMon. It works very simply. You compile your program to create a .MAP file, which is then fed to a processing program called MapVar. Then, PMon works as a shell to run your program; at regular intervals, PMon checks to see where your program is using the output from MapVar to locate different parts of your program. When your program is done, PMon outputs a report which tells how many times each function in your program was "hit." The more hits, the more often that section was executed. typedef . unsigned. char CHAR DEF{S); typedefCH.A1LOEFc.aAk_SE'.r [256]; CllAR_OEF.grid_char; CHAR .• SE'.r . cset: char~setname[641 ;/* const char * version /*nia..tdxto •.·hold one . charactf:lr */ l*u;ay of all chf1rsin>a. set *1 l*createlilorldngcharacter setvarial:>les = "1.10"i 1* function· prototypes */ ",oid>JlIain(intarqc,char *argv:[]); voidshow·screen(void); int\edit:set{void)i . 1*~odifY~urrentcha.rset*1 ",oid nOrlllblock (intI, int c); l*.~f)~block to"o~fU .*1 void blink block (int1, . i n t c ) r > < ··.J*cursor */ void reverse block (int l,int c);j.""s~t:blockto 1I0nn*/ void save char (unsigned char) ;I*writ.echartoset*/ unsigned ~har select_char (void):l~.ch0osechar toedit*/ void main(int argc, char *argv:£l) ( FILE *csfile; f* character set file char reply; f* . user input~/ inti, 1; 1* loop variables *1 intsave_set; printS(··\:;~:i~~~arD!:·.···Gre~i~¥){j%S %s·.···%s\n" ~ l~i~~:~~w~i~jj. • l>y . . j~IT~r •. •.~~.7j.~ • . ·.Ttr~.,.\n\Xl. '.~. : printf(,'Enter.· a. character.setn.ame: •. "); gets (setname) : . . putcha.r ('.\n'); i f (!str1en (setnamf))'{ printf ( II \ 7Noset name entered . Exit~\n'~ r: exit (1) i ) else strcpY(tJet:~ame;argv: [11); if (Npt.L==(csf~le.·.=::Jopen(sf)tnCUllf),tlrb··»). { p\intf (n~:~~a:rr%S~ot .• fo~llci ..• ~ke . '• . it . ••• (~IN) 1", = while (!kbhit() ).; reply (char)getche 0; reply:::::toupper (reply) ; putchar C\n f); l.f (reply • ='. '''.{') for '•• (l.= 0; i><. 256;<+tl.) for (1 =0; 1<8:++1) cset[l.]{l].:::::O: else '. { Continued on page 60 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 59 - printf ("Program. terminated. \n"); exit (2); blink b10ck(1/a} 1 } break; ca.e SO ; 1* DOWN' *1 if (1 < 7) ( nom block (l,a) ; ++1;- } } else fread(aset,sizeof(aset),l,asfile): felose(asfile); disp_open(); disp setattr(7); show screen(); save-set. edit Bet C); disp moveCO,O); disp-eeop(); disp alose()i disp-move(O,O); if (save set) if {io:t.L - (asfile .. fopen(setname, llrib")}) printf("Char set %saannot be written. \ Saving as. CHARBET.DAT. \nll); asfile - fopen("CHAIUJET.DU",lw+b"); bli~b10ck(l,a); ) break; ) break; case 'X, : save_char(aurch); stop • 1; ret_val .. 1; break; . case 'Q' : stop • II ret_val - 0; break; cas. 32 rever.. block(l,a); break; case'S' ; save char(aurch); aurCb - seleat char(); } else fwrite(cset,sizeof(aset),l,csfile); falose (asfile); } void show screen () ( int i; - disp_move(O,O); disp eeop(); disp_move (1,1); dispyrintf ("11) ; disp_move(17,1); dispyrintf(IIII); for (i - 2; i < 17; i - i + 2) { disp move (i,l); disPYrintf(" "}; } for (i - 3; i < 16; i.- i disp move(i,l); dispyrintf ("11); 1 • 0; a - 0; - blink block(l,a): break; } return ret val; } - + 2) void no%JD. block (int 1, int a} { ) disp_move(3,31)i dispyintf(IIcursor Keys move aursor"); disp move (5,31); dispyrintf(IIX" Exit and Savell); disp move (6,31) ; dispyrintf(IIQ .. Quit (without Saving)II); disp move(O,3l); disPJ>rintf(IISpaae Bar .. Reverse Current Block"); disp move(10,31); dispJ>rintf(IIS .. select Character to Edit"}; } int edit set () ( unsigned char key, £key, aurah; int stop - 0; int 1; a; int ret_val; - 1 - 0; a .. 0; aurch .. seleat char(); blink block(l,c); while- (t stop) ( while (tkbhit(» i key .. (char)getch(); switah(toupper(key» aase 0 if (kbhit (» { fkey. (ahar)getch(); switah (ney) ( case 72 : I*vp *1 if (1 > 0) .{ no%JD. block (1, a) ; --1;- blink_b10ak(1,a); } break; case 75 : 1* LEFT *1 if (a>O) ( nO%JD._block(l,a); ·"0; blink block(l,a); } break; case 77.: . 1* lUGHT *1 if (a< 7) { no%JD. block (Ii a) ; ++a;- - - unsigned int val, aI, aa; al .. (1 * 2) + 2; aa - (a * 3) val .. dispyeekw(el,aa); val - val & Ox7rrr; disp..,J>Okew(el,aa,val); ++aa; val .. dispyeekw(el,aa); val - val & Ox7rrr; disp..,J>Okew(el,aa,val); + 2; J void blink bloak(int l,int a) { unsigned int val, aI, aa; - a1. (1 * 2) + 2; aa .. (a * 3) +.2; val - dispyeekw(el,aa); val .... val 1 Ox8000; disp..,J>Okew(el,aa,val); ++aa; val .. disp-p-ekw(el,aa); val .'val I Oz8000; disp..,J>Okew(el,aa,val); } void reVerse block(int 1, int a) ( unsigned char bit; int aI, aa; - a1 .. (1 * 2) + 2; aa .. (a * 3) + 2; bit- 1 «~(charla; if (grid_char [1) 'bit) ( grid char[l) ,- ~bit; dispykew(el,aa,Oz87BO); disp..,J>Okew(el,ac+l,Ox07BO); } else. ( grid char[l) I- bit; dispykew(el,cc,OXS7DB); disp..,J>Okew(el,cC+l,OxS7DB); } void saVe char (unsigned char no) ( melllcpy(caet[no) ,grid':"char,sizeof(grid_char»; - Continued on page 62 60 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 C CODE FOR THE PC source code, of course NEW! NEW! NEW! NEW! NEW! NEW! NEW! NEW! Updated! NEW! Updated! NEW! NEW! NEW! Updated! MS-DOS File Compatibility Package (aeate, read, &. write MS-DOS file systems on non-MS-DOS computers) • • $500 $500 CSource Application Program Generator ~ MBAC (includes all source cOde; generator &. libraries) . . . . $325 dB2c (dBase-to-C translator; includes dB-Files for C anddB_Thols for C). • • . • • • • . . • . . • . • . pBaae (relational DBMS with ~ebugging calls and spa.rae table &. repeated field support) . • • . . • . • • . • $325 COL Que~ Sp.tem (SOL retrievals on B-trees plus wmdows) . • • . . • • • • . • • . • . . . • • ~ . · $325 $325 GraphiC S.O (~gh-reaolution, DISSPLA-style scientific plots in color &. hardcopy) • • • • . . • . . • . . • . . • • . . • . • • $300 Draidl Oiap with Crules (~p library and programmin~ enviro~ent with r:ule p~ing capability; natural language example) . . . . $300 Greenleaf Data WlOdowa (Windows, menus, data entry, mteracuve form des1i; spectfy compiler) . • . • . . . • • • . • . • . • • • PC Olraea (Aspen, Software, System V comP;8tible, extens~~ d~umentation ••..•..•.••••.....•..•.... • $290 $260 Code Base (database manager, dBase and Oipper: compaubile lOdes &. data lea; Vemon 4.0). . . . . • • • • . • . . • • • • • . $250 MEWEL (extensible window and even~ library by Magma Software; message-passing &. object-oriented; SAA-compatible; dialog editor) ThrboThX(Release 2.Q; HP, PS, dot dnvers; CM fonts; La'Ji3X; MetaFont) • -. . . • • • • • . . • . • • . . • . . . . . • • • . •. $250 .$250 PC PosiSaipt (complete PostScript interpreter (ROM Version 47.0A), 80286/386 only, many device drivers, optimized graphics, fast) db.Fale &. db.Rctricye (B-tree. and ne~ork database with SOL query and report writer) .' • . : . • . • . . . • . • • . . • . • · $245 Greenleaf Commurucatlons library (m:errupt mode, modem control, XON-XOFF; speafy compiler) . • . . . . . • . . . . . . • $225 CDirect (multi-user hashed file manager; variable length fields, binary or ASCII data, alternate keys). . . . . . . . • . . . . . • · $210 BOlL COmpiler (this is not C source but BOlL source; BOlL is the mother of C) . • . • • . . • • • • . . . . • . • $195 OuickGeometry'Library (large collection of mathematics, graphics, display &. DXF subroutines for CAD/CAMICAE/CNC) · $170 CBTh:e (B+tree ISAM driver, multiple variable-length keys) . . • . . . . • . . • • . • . . • · $165 ThrboGeometry (library of routines for computational geometty, Version 3.0). • . • . • . . . • . · $160 AT BIOS Kit (roll your own BIOS with this complete set of baSIC input/output functions for A'IS) •• · $160 WKS library Verslon 2.0 (C program interface to Lotus 1-2-3, dBase, Supercalc 4, Ouatro, &. Cfipper) · $155 OS/88 ~ ..x-like operating system, many tools, aoss-development from MS-DOS) • • . . • . . • • $150 Cephes Mathematical library (over 100 high"'9uality, double-precision scientific functions) • • . . • . . . · $150 ME Version 2.1 (programmer's editor with C-like maao language by Magma Software; Version 1.31 still $75) • $140 Vmem/C (virtual memory manager; least-recently used pager; dynamic expansion of loWap file) •. . . . . · $140 Thrbo G Graphics library (all popular adapten, hidden line removal) • . • . . • . . : . • . . . . . . • $135 vUB (270 C functions for windows, menus, forms, pop ups, mouse support, and input editing) . . . • . . · $125 Power Search by Blaise Computing (regular-expression compiler; generates machine code on the fly) • • $120 Install 2.3 (automatic installation program; user-selected partial installation; CRC checking) . • • . · $120 TE Editor l>eveloper's Kit (full saeen editor, undo command, multiple windows) • . . . • • . . • · $105 Minix Operating System (Version 1.3; U -_x-like operating system, includes manual) . . . . . • . . • . . . $105 $100 H~tIeXt Viewer (simple hypertext system; multi-file documents; includes TIny Curses) . • • . . . . . • • $100 PCIIP (C.MU/MITTOJ/IP for pcs; Ethernet'.~J?pletalk &. NETBIOS drivers, RVD, update by Dan Lanciani) . $100 B-Th:e Library &. ISAM Dnver (file system utibtle5 by Softfocus) . • . • . . . . . . . . . . . . . . . • The Profiler (program execution profile tool) • • . • . • • • • • • • • • • • • • • . • • . • . . • • . $100 OC88 C compiler (ASM output, small model, no longs, floats or bit fields, 80+ function library) . . . . . . . . $90 Otter 1.0 ~autiful theorem-prover by Bill McOlne; includes manual &. two books by Wos; complete starter kit) . $80 $80 C Windows '!boltit (pay-up, pull-down, spreadsheet, CGA/EGA/Hercules) . . • . . . • . . . . . . . . . JATE Async Thrminal Emulator (includes file transfer and menu sUbsystem) . . . . . . . . . . . . . . . . $80 $80 MultiDOS Plus (DOS-based mu~ti~ting, intertask messaging, semaphores) . . • . . . . . . $75 Make Sacros, all languages, budt-lD rules) • • . • . . . . . . • . • • . . . • . • . . . $75 evalO C function to evaluate ASCII infix expression string; 17 built-in functions) . . . . . . . XT BI S Kit (roll your own BIOS with this complete set of basic input/output functions for XIS) $75 Professional C Wmdows (lean &. mean window and keyboard handler). . • . . . . . . . . . . . $70 Screenlib (simple screen definitions, windows, pop-up menus, context-sensitive help) . . . . . . . $65 Heap ~nder (virtual memory manager using expanded memory, extended memory, and disk space) $65 $60 SYSKIT (rommable or TSR debuglmonitor; easily expanded) . . • • . • . . . . • . . . • . • $60 Quincy (interactive C interpreter) • • • . . • . . . . • . • . . . . . . . . . . • • . . . . $60 Symtab (general-purpose symbol table construction and management package) . . . . . . . • • . $60 P'Iree (general-purpose parse tree construction and management package) . . . . . . $60 Coder's Prolog {Yersion 3.0; inference engine for use with C programs) . . . . . . . $55 ~-Thrmio (Unix V com~tible serial interface for MS-DOS; stty, ioctl, SIGINT, etc.) . . . . . . . $50 Baam &. Restore Utility by Blake McBride (multiple volumes, file compression &. encryption) . . . . $50 Su rep (exceptionally fast, revolutionary text searching algorithm; also searches sub-directories) . . $50 R GX Plus (search a~d replace string mampula!ion routines base~ on regular expressions). . '. . . • OBJASM (convert .0bJ files to .asm files; output IS MASM compatible) . . • . . . . . . . . . . . $50 Polyglot TSR Package (includes reminder, bookmark, virus catcher, cache manager, &. speech generator) $50 Multi-USer BBS (chat, mail, menus, sysop displays; does not include modem driver) . . . . . $50 CUPS (rule-based expert system generator, Version 4.3; advanced manuals available) . • . . $50 Fortran-to-C Thlnslator by Polyglot . • . . . . . . . . . . . . . . . • . . . . . . . . $40 AcxList (doubly-linked lists o(arbitrary data with multiple access methods) . . . . . . . . . $40 Virtual Memory Manager by Blake McBride (LRU pager, dynamic loWap file, image save/restore) $40 Heap I/O (treat all or part ofa disk file as heap storage) . . . . . . . . . . . . . . . . . . $40 OOPS (collection of handy C+ + classes by Keith Gorlen of NIH; Version 2.2) . . . . . . . . . • . . • • . . . . . . . . $35 Bison &. PREP \lACCworkalike parser generator &. attribute grammar preprocessor; now includes documentation) . . . . . . $35 PC-XINU (Comer's XINU operatlDg system for PC) . . . . . . . • . . . . . . . • . . . . . . . • . . . . . . . . . $35 RXC &. EOREP (Regular EXpression Compiler and Pattern Matching; RXC makes finite state machine from regular expression) $35 $30 Polyglot RAM Disk (chanidisk size on the fly; includes utilities) . . . . . . . . . . . . . . . . . . . . . . . . . . . . GNO Awk &. Diff for PC th programs in one package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $30 Thlnslate Rules to C (YA: C-like function generator for rule-based systems) . . . . . • . . .. .. .. $30 6-Pack of Editors (six public domain editors for use, study &. hacking) . . . . • . . . . . . $30 Crunch Pack (14 file compression &. expansion programs) . . . . . . . . . . . . . . . . $30 Pascal P-Code Compiler &. Interpreter or Pascal-to-C 'Ihinslator (Wirth standard Pascal) . . . $25 $25 FLEX (fast lexical analyzer generator; new, improved LEX; official BSD Version 2.1 with docs) $25 Arrays tor C (macro package to ease handling of arrays). . . . . • . . . . • . . . $20 A68 (68000 cross-assembler) . . . -. . • . . . • . . . . . . . . . . . . . . . list-Pac (C functions for lists, stacks, and queues) • . . . . . . . . . . . . . . . $20 $20 XLT Maao Processor (general purpose text translator) Data Protein Sequences (over 10,000 sequences; includes demo disk of Pearson FAST/A programs). . . . . . Smithsonian Astronomical ObselVatory Subset (right ascension, declination, & magnitude of 258,997 stars) Mob)' Words (500,000 words &. phrases, 9,000 stars, 15,000 names) . . . . . . . . . . . . U. S. aties (names &. longitude/latitude of 32,000 U.S. cities and 6,000 state boundary points) . The World Oigitized (100,000 longitude/latitude oCworld country boundaries) . • . . . . . KST Fonts (13,200 characters in 139 mixed Conts: specify 1EX or bitmap format) . • . . . . US NO Interactive Computer Ephemeris (high-precision moon, sun, planet &. star positions) U. S. Map (15,701 points of state boundanes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Austin Code Works 11100 Lea/wood Lane acw!in/o@uunet.uu.net Austin, Texas 78750-3409 USA Free surface shipping for cash in advance For delivery in Texas add 7% Voice: (512) 258-0785 BBS: (512) 258-8831 FAX: (512) 258-1342 MasterCard/VISA Reader Service Number 4 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 $60 $60 $55 $35 $30 $30 $30 $15 61 Figure 2-CS_Disp (Character Set Display Routines) unsigned char se1ect_char(void) ( . 1* unsigned char sel, bit; int 1, e, el, ee; disp move(19,31); disPJrintf("Enter a character to be defined: "); disp move(19,64)1 whil;(rkbh1t(» ; sel • (char)getch(); dispmove(19,31)1 disPJrintf(" I.); memcpy(grid_char,caet[se11,sizeof(grid_char»; for (1 - 0; 1 < 8; ++1) for (c - 0; e < 8; ++c) ( cl - (1 * 2) + 2; ee • (e * 3) + 2; bit - 1 « (char)c1 if (grid_char [1) 'bit) { disP-fOkew (el,ec,Ox07DB); disP-fOkew (cl,ec+l,Ox07DB); Version: Language: Environ: Purpose: 1.10 11-Aug-1989 Zortech C v1.07. MS-DOS, IBN-PC compatible Load and display character seta created with CSG. Written by: Scott llobert r.add *1 'include "es_disp.h" 'include "zipgraph.h" 'include "stdio.h" typedef unsigned char CHAR DEI" [8] ; typedef CHAR_DEF CHAR_SE~[256J; int es load(char * cs.t_nam.) } else { disP-fOkew (el,ee,Ox07BO); disP-fOkew (cl,ec+l,Ox07BO); ( - * FILE cset_file; } ) return se1; if (cset file return 1; ) ••• fread(cset, BOLL) sizeof(CHAR_SE~), 1, cset_file); felose(eset_file); return 0; ) void .eSJ>utch(int line, int col, unsigned char ch, unsigned char fcolor, unsigned. char bcolor) { int x, y; unsigneci ehar bit; for (x - 0; x < 8; ++x) ( for (y • 0; y < 8; ++y) cr PP rJ 'aI7Le TurboFlow is serious flowcharting software at a price that won't cost you your kingdom. It's easy to use and more ~~;il~=r'r~~ powerful than Merlin's magic. TurboFlow runs on an IBM PC !l:: ~~lQ:Im~lt9JI~and features a complete set of ANSI /b(Jl'!r~::..::3~~-"""i'i~_~s':1.ym=bo~ls!..,lS~'~m~e~n~u driven, interfaces with desktop publishing . software, and supports a variety of printers and plotters. So stop living in the dark ages. Call 1-800-8825822 and order I your copy, or ask for our free bro'------'-J.........JLL;~~BIIIIIIi. .IiiII!!~~==----l chure. { bit - (unsigned char) (1 void csJ>uts(int line, int col, ehar *str, unsigned charfcolor, unsigned char bcolor) ( char * eh; ch -.str; while (ch) { csJ>utch (line, col, *ch, fcolor, bcolor); ++ch1 col fa 8; ••• Reader Service Number 174 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 y); if (cset[ch] [x] 'bit) plotpixel(col+y,line+x,fcolor); else plotpixel (col+y, line+x, bcolor); } 62 « It turned out that CRITTERS spent 80% of its time in Microsoft's graphiCS routines! Even worse, the two routines using 60% of the program's time were setting and resetting the EGA card! Yuck! This becomes even more significant when you realize that Microsoft's graphics library is faster than most of the others (including Borland's). The obvious solution is to get a faster graphics library. While I have severallibraries around the house, I decided to roll my own. So I wrote FasCEGA and Fast_HGC, two small assembly language graphics modules for EGA and Hercules Graphics cards. These modules do three things: turn on graphics, turn off graphics, and plot pixels. That's all that CRITTERS needs. The CRITTER4.COM file includes both modules. Many people purchase commercial libraries rather than write their own (usually because the commercial versions are already debugged), but there are significant advantages to building your own. First, your function libraries are yours (i.e., you know them from top to bottom, and they work exactly the way you want them to). Most importantly, you can tailor your library, as I have done here, to fit the application. Commercial packages are also designed to handle a variety of situations, so they tend to be large. You end up linking-in all sorts of things you don't need. And, when performance is an issue, it's best to build your own. Another problem reared its ugly head when I started to use Hercules graphics. The CRITTERS dIsplay has a short status line at the bottom, indicating the number of moves elapsed and the current number of living critters. The IBM-PC ROM BIOS can display characters on a graphics screen (albeit slowly>-but the Hercules card doesn't use the IBM BIOS! In order to write characters to the screen on a Hercules adapter, you have to put the characters there pixel-bypixel. So I wrote a quick program to generate 8x8 bit-mapped character sets and a set of functions to display them. This turned out to be a good thing, since my bit-mapped chara~ters are displayed many times faster than those put out by the BIOS. The C EXPLORATIONS section below describes the character set generator and display functions. The original version of CRITTERS read screen pixels to determine if they • SEE HOW PROGRAMS WORK • EASILY MODIFY PROGRAMS SOURCER'M creates detailed commented source code and listings from memory and executable files. Built in data analyzer and simulator resolves data across multiple segments and provides detailed comments on interrupts and subfunctions, liD ports and much more. Determines necessary assembler directives for reassembly. Includes a definition file facility to include your own remarks and descriptive labels, force data types, and more. Complete support for 8088/87 through 80386/387, 80486, and V20N30 instruction sets. We welcome comparisons with any other product, because no product comes close to the ease of use and output clarity of SOURCER. Sourcer is the best disassembler we've ever seen! -PC Magazine, January 17, 1989, page 101 resetprn.ht SAMPLE Sourcer Listing ResetPRN vl.02 PAGE OUTPUT 18-Sep-89 1:41 pm Page I 60.131 RESETPRN Fully automatic Program header Created: Version: Passes: 14-Aug-89 1.01 8 Analysis flags on: H .386c • 0008 @prn_port) equ ; (0040:0008·378h) :-- ___________________________________________________ -------sega----- Assembler directives seg_a seglT'ent para usel6 public - assume cs:seg.a, ds:secLa, ss:stack.seQ.b resetprn 658E:0000 65&:0000 E813 658E:0001 51 65 73 658[:0008 51 4E 10 65&:000E 303100 658[:0011 0040 658E:0013 00 OA 51 658[:0019 74 10 50 658[:00IF 74 65 71 658E:0015 658E:00150[ 658[:0016 IF 65&:0017 .SA 0013 65&:001A 8409 658[:001C CO 11 Determines data areas and type Detailed comments proc far jl11J db short lac 1 ·ResetPRN-vl.01', OOh dw db 40h COh, OAh. 'Reset Printer? S' push pop II'WJY c50 ds d,.oflset data 3 ah,9 - int 21h start: 65 74 50 76 31 1E 65 73 65 71 69 6E 3F 10 14 data 1 data) 10c_l: ; (558[:0013·00h) : DOS Services ah-function09h ; Simulator follows segment changes 80386 and 80486 support 658[:001E 658[:0030 84 01 CD 11 ""V ah.1 11h 658[:0031 65&:0034 65&:0036 658[:00lA 658[:003[ 65&:0041 65&:0043 3C 79 751A 8E IE 0011 88 160008 83 C1 01 8008 [[ c"" joe al.79h short loc3 ds,data1- 658[:004466:8900010000 658E:004A 658E:004A 67: [1 FD 658[:0040 800C 658E:004F EE int ""V add ""V out dx,ds:@prn port 1 d',1 al.8 dx,al , get keybd char al. with echo ; 'y' ;Ju"" If not equal ; (658E:00ll.40h) ; (0040:0008.378h) -; po!"t 37Ah, prlnter-2 control ; al.8, Inltlallzeprlnter ecx.10000h locloop_1: loopd locloop1 al,OCh- : loop,lf ecx)o 0 out d.,al : port 37Ah. printer-2 control ""V ; 658E:0050 658[:0050 658E:OQ51 Easy to read format display char Hring at ds:dx : DOS Services ah.functionOlh ""V 84 4C CD 11 Int resetprn ah,4Ch 11h al. OCh, Inlt & strobe off 'l' ; DOS Services ah·functlon 4Ch : terminate with aI-return code endp seg_a ends :-____________________________________________________ -- stack.seg.b ---- stack.se9.b segment para use16 stack db ends 191 dup (OHh) stack_se9_b end start 6593:000000CO[H) (Source code output and inline cross reference can also be selected) BIOS SOURCE • CHANGE AND ADD FEATURES • CLARIFY INTERFACES for PS/2, AT, XT, PC, and Clones The BIOS Pre-Processor'M with SOURCER provides the first means to obtain accurate legal source listings for any BIOS! Identifies entry pOints with full explanations. Resolves PS/2's multiple jumps for improved clarity. Provides highly descriptive labels such as "video_mode" and much more. Fully automatic. SOURCER Commenting disassembler $99.95 SOURCER with BIOS Pre·Processor 139.95 UNPACKER ,. Unpack packed EXE files and more ASMtool'· Assembly source analyzer and flowcharter $39.95 89.95 Shipping & Handling: USA $3; Canada/Mexico $10; Other $15; CA Res. add sales tax; PS/2 trademark of IBM Corp. NOT COPY PROTECTED 30-DAY MONEY-BACK GUARANTEE If within 30 days of purchase you find our product does not perform in accordance with our claims. call our customer service department and we will gladly arrange a refund. For orders and information, call: I VISA I IZ:Z:SJ 1-800-662-8266 ffi V COMMUNICATIONS, INC. 303 t Tisch Way, Suite 802, Dept. MC4, San Jose, CA 95128 (408) 296-4224 62 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 63 were food. This is slow and tedious, taking about 10% of the program's time. So I created a bit array which indicates the location of food. When food is plotted on the screen, a bit is set in the array. When a critter moves, it checks the bit array rather than having to read the screen. At this point, I began to add new features to CRITTERS. The little guys now mutate their color, maximum energy level, reproduction cycle, and life-span. Critters now move in eight directions instead of four. In addition, I have added a mutation that can "sense" food. This is implemented as a radial search, the distance controlled by the critter's sense gene. It turns out that senses are a very positive mutation; within a few hundred moves, the critters that have gained senses wipe out the "senseless" ones. More additions are on the way. Carnivores and omnivores will be interesting. How about disease and disaster? Different species of food? Different food in different parts of the "world"? And, of course, what about bisexual reproduction? (Editor's note: What about it? This is a family magazine.) The possibilities are endless. Of course, I tightened code here and there and removed some redundant loops. By the time I was through, CRITTERs had gone from 2,000 moves per hour to over 20,OOO! With the new graphics library, the program now compiles under the Microsoft, Borland, and Zortech compilers. Using Zortech C in integer-only tiny model produced a new CRITTERS program 40% smaller than the first. C EXPLORATIONS Now let's look at the character set generator, called CSG. CSG, shown in Figure I, is a Zortech C program which lets you design complete 8x8 bit characters, visually. Figure 2 shows CS_Disp, a module containing the functions to load and display characters on the screen. Let's look at CSG first. The idea behind CSG is simple. An array of eight 8-bit bytes holds each character. The array CHAR_DEF defines the structure of a character. CHAR_SET is an array of 256 CHAR_DEFs and represents a complete character set. mainO begins by checking to see if you've entered the name of a character set on the command-line. If not, it asks 64 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 for a file name. If the file exists, the program lets you edit the character set. When you've finished, it saves the changes. All very neat and simple, huh? It's the editor which is tricky. When a character is displayed for editing, it is shown in an 8x8 matrix on the left side of the screen. Each block in the matrix represents one pixel. One block blinks; this is the current cursor position. Pressing the keypad arrow keys moves the cursor around in the matrix. Background cells are grey, foreground cells are white. To toggle the state of a cell between foreground and background, just press the space bar. Press S to select the character to be edited. CSG will then ask which of the 256 characters you want to edit. You can enter the character directly (e.g., by pressing the "g" key to edit the lower case g), or you can hold the Alt key and enter the decimal value of the character on the keypad. Once you've selected a character, the matrix displays its current representation for editing. Pressing X will exit the program and save the character set; pressing Q will exit the program without saving. All in all, a very simple process. As cells are toggled, the CHAR_DEF matrix changes bits for the current character. The routines for blinking, setting, and unsetting cells contain some interesting video-display algorithms. There is no reason CSG could not handle different size characters. I made it simple to handle some simple graphics text problems. CS_Disp is the module which makes the character sets useful. The function cs_IoadO copies a character set from disk into memory; only one character set can be loaded at a time. cs_putchO displays a single character, and cs_puts outputs a complete line. A specific pixel location on the screen displays characters. These are fairly simple routines. I've found that having my own character generation and display routines has made graphics programming much easier and more· pleasant. My routines run considerably faster than those provided by most vendors, and they use far less. disk and memory space. Use them and abuse them; after all, that's why they were published. As always, I appreciate comments. products this time around. Microsoft C 6.0 should have been out by now, but the development of a new "power programmer's" environment and CodeView 3.0 has delayed it. Lattice 6.0, which is supposed to get them back into the race, should also be out, but I haven't seen that either. Such is life.... RESOURCES One book you must have if you use PC-compatible video displays is called Programmer's Guide to PC & PS/2 Video Systems, by Richard Wilton (Microsoft, 1987, ISBN 1-55615-103-9). This is the best nuts-and-bolts volume I've ever seen on every standard video adapter from Hercules to VGA. Wilton's book is written for assembly language programmers, which can be a problem for people unfamiliar with that art. If you're a C programmer (which I assume you are if you read this column), another good book is Graphics Programming in C, by Roger Stevens (M&T Books, 1988, ISBN 1-558-51018-4). This book contains virtually no assembly, and the code in it works with Borland's Turbo C and others. This book isn't as deep as Wilton's, but it covers the subject well. NEXT TIME I've got more things to talk about than can possibly fit in the next few (years of) issues-but I'm going to try. The next issue will feature my quick minimalist auto-sensing graphics library, ZIPGRAPH, a cornerstone of most of the graphics work I do. It's needed for the FRACLAND program, which generates fractal landscapes. If possible, I also intend to do some work with ray-tracing in 640x400 by 256 color mode. Then there's the star-chart generator and the c++ library and the planetary system generator and more CRITTERS and some interesting new applications for fractal geometry and the 32-bit fixed-point math library and .... An author's work is never done, especially if he's having fun. MMC AD Systems Box 360845 Milpitas, CA 95035 (408) 263-0781 NEWS AND REVIEWS Sorry folks! There aren't many new ••• By David Thompson Micro C Staff Do You Feel Invisible? CULTURE CORNER • Surviving On Caffeine & Sugar • Getting Technical Work Without Technical Training • Pocket Protectors • Advanced Pocket Protectors • Fiction Writing • Creating A Work History (prerequisite: Fiction Writing) • Moving Into Management • Dressing For Distress • Cashing Your Paycheck First • 100 Most Asked Party Questions • Advanced Mumbling know the problem. It's Friday night and you're attending yet another fantastic party. But, for all intents and purposes, you might as well be invisible. You notice others who naturally attract crowds, who are the centers of attention as they move about the room. People cling to them and to their every word. Who are these popular people? What makes them so interesting? There's one now, let's see what we can discover. Immediately you notice he's gripping a can of Jolt in one hand, a halfeaten twinkie oozes slowly from the other. It's obvious that the color of his skin precisely matches the dingy whites of his eyes. Check out the ink-stained pocket protector safety-pinned to his Tshirt. Notice the thick, dirty glasses. We approach within earshot: "Are Y OU the clones really compatible?" "Who designed the original IBM?" "What year did Lotus invent the spreadsheet?" "Does Adam Osborne really paint his toenails?" Notice that he answers only in carefully phrased monosyllables. This man is clearly no lightweight. This man must be: AN ENGINEER. Of course he is. And his suave party dress and studied manner shows he's a USED engineer, a graduate of Universal Systems Engineering Development's new program: VaporTraining. From the company that introduced VaporWare, VaporTraining is the most successful program for prospective engineers and other party animals. Plus, unlike universities, USED is no ordinary diploma mill. Nowhere else will you get the training you really need to be the complete engineer. USED classes include: Order any two classes and get the third class free. Complete four classes for a USED Bachelor's Degree. Complete six for a USED Master's, or all twelve for a USED Ph.D. (For a limited time, we offer special discounts to already USED party animals.) And, our diplomas are so beautiful you'll want to display all of them in your party room. So send in your money ($5,000 per class) to: USED VaporTraining 1001 Federal Penn Way Lompoc, CA 93400 FINE PRINT: Include payment in small bills or other untraceable funds only. Foreign funds O.K. from countries with which the u.s. has no extradition treaty. We make no warrantee on usability of USED information or on your ability to understand it. From time to time we may actually ship USED products; such an accident in no way requires us to ship a product to any other purchasers. FINER PRINT: If you can read this, you're ready for our new course, Squinting Without Eyestrain. ••• MICRO CORNUCOPIA, #50, Nov-Dec, 1989 65 Generating zao Controller Code On An AT Clone By Laine Stump % Redhouse Press Merkez PK 142 34432Sirkeci Istanbul, Turkey Laine finds that his fancy 18 MHz 80286 machine doesn't generate 280 code. Herein he talks about some alternatives to buying a cross assembler. (And he talks about Turkey, and character sets, and .... ) remember it as vividly as last night's dinner. The long talks about why I was going off alone. The last few moments of being together, trying to tie up all those loose ends that you never think about until it's time to go. The final, tearful farewell as I headed off across the ocean and into the future, not knowing when or if we would see each other again. Yes, I have missed my Big Board. In the four years since I left it sitting dejectedly in the xray tube box in my brother's garage, I can't count the number of times I wished I had this or that program. The stack of 80 or so 8" single density CP 1M floppies is stashed in the closet in Woodinville, Washington. From time to time I have even considered sending for myoid companion. ("I won't work for you unless you buy a first class seat for my CP 1M machine.") But the desire to have a CP1M machine has faded with the passage of time. After all, I do all my work on MS-DOS and XENIX these days. And I definitely don't have a shortage of programming tools anymore (C, C++, Modula, Pascal, MASM, CodeView, Zortech Debugger, numerous database and display libraries, countless editors ... ). I Turking It Up After arriving in Turkey in 1985, I saw the first hints of a niche market that lately has been the source of most of my income. It has to do with the six characters in the Turkish alphabet which don't appear in either the IBM PC Graphics character set or in any ISO or ANSI character set. These characters are simply normal characters with the addition of an accent (like 0 or C;). When computers first arrived in Turkey, 66 people were so glad just to have computers that they ignored the missing accents. This made computerized bank statements look quite juvenile (half the words were misspelled). That, they were told, was the price they paid for computerizing. Around the time I arrived here, things started to get better. A few companies figured out how to change the character generator EPROMs on their video cards and write a TSR that changed the keyboard mapping. Suddenly everybody had to have Turkish. "Does it do Turkish?" became such a common question that most companies began listing "Turkish EPROM" as a feature of their equipment. These days, the first unit of a new model printer or video card goes straight to the "R & E" (Reverse Engineering) department to figure out where the character font is, how it's organized, and how to install the Turkish characters. The Process Lately I have been acting as the R & E department for several companies in Istanbul and Ankara. To aid me in this work, I have written (actually, "caused to evolve" is a better term) a program called BITED, a sort of visual version of DEBUG. When I'm converting a machine, I usually search around in the machine's EPROM with BITED until I see something that looks like character bitmaps. Then I massage the display format a bit until it looks understandable. I replace the original characters with the Turkish characters and burn a new EPROM. Nowhere in the process do I ever need to pay any attention to what processor is in the machine, or worry about any assembly language. I'm just modifying data. For example, most of today's dot matrix printers use an NEC integrated 8-bit MPU chip called the uPD78C10. I have Turkified probably ten different printers which use this chip. Although I have a data book for the uPD78C10, I've never needed to look at it. MICRO CORNUCOPIA, #50, Nov-Dec, 1989 ---.--~------------------ Character Set Standards All the equipment that I Turkify plugs into IBM compatible micros. Almost all equipment that plugs into IBM compatible micros supports the IBM PC Graphics character set (which includes international (accented) characters at the codes between 80h and A7h). It happens that the Turkish standard for this character set puts the special Turkish characters in place of already existing characters not used in Turkish. There is already a bitmap corresponding to the Turkish character code. When the printer receives that code, it knows it should display the bitmap. A Bird Of A Different Feather I recently had to deal with something slightly different. I was adding Turkish to the display and keyboard of the Olivetti WS-685 terminal (a private label of an Ampex product), which is a clone of a DEC VT-220 terminal. The VT-220 (and, hence, the WS-685) uses an ANSI character set instead of the IBM PC Graphics set. This character set contains more international characters than the IBM set, but they are in a different range (AOh - FEh). The codes from 80h to 9Fh are used as control commands (similar to the familiar ASCII codes between OOh and 1Fh). There were plenty of empty spaces in this ANSI set to add Turkish characters without displacing existing characters. But after I added them to the bitmap, the terminal refused to display them. That meant I needed to dig into the control program in the terminal's EPROM. Luckily, the WS-685 is based on the Z80 processor. ("AHA!" you say. "Now I know why you babbled on about your Big Board!") Unluckily, I have absolutely no Z80 development tools that run under DOS. A quick search through my list of acquaintances came up with zero who had a Z80-based CP 1M machine. After searching through four or five dusty boxes full of books, I found my well-thumbed Mostek Z80 Reference Manual (from the days of EE 325) and began to disassemble by hand. This disassembling led me to a table with one byte for each character code, telling what action to take with the code. I changed the table and, viola, it worked. Capitalizing Now that I could display Turkish, it was time to modify the keyboard so I could type Turkish. I searched through a dump of the program EPROM until I saw the familiar "QWERTY" (strangely, only in upper case). I changed a few bytes. After burning a new EPROM, I could type Turkish, but it always came out in upper case. Another search through the EPROM revealed no lower case table for the keyboard. That must mean that there is a tolowerO subroutine somewhere that is called when shift or caps lock isn't down. Back to the Z80 reference and the notebook scratched full of ones and zeros .... After some time, I had managed to deduce my way into the tolowerO subroutine. Assuming that tolowerO would be entered with the character in the A register, and a compare would be done with the upper and lower limits of the capital letters, I hand assembled those few instructions and searched for them with SYMDEB. Amazingly, I found them. (Lucky for me, since the program EPROM is 32Kbytes and it's full! I think I'd rather eat moss than try disassembling 32K of Z80 code by hand .... ) I modified tolowerO for the special cases of the Turkish characters. The new EPROM worked, and I was done (for the moment). Never Again This whole experience started me thinking again about my Big Board. Just think if it had been here, sitting next to my X24. I could have easily finished the job in one-fourth the time (it took me two days). What about next time? Surely there will be another terminal based on the Z80 that needs to be Turkified. I thought again how my Big Board uses 8" diskettes. I remembered that, with drives, it weighs something slightly less than a 1963 VW Beetle. I realized that, no matter how much loving care we put into its construction, it almost surely wouldn't survive the bashings it would receive on a flight from Seattle to Istanbul. A Solution Then I thought of something else. What about that little Micro Solutions Z80 Coprocessor card that Emerald Microware is selling? That doesn't even weigh as much as the left front fender of a '63 Beetle. Besides, it's faster than my Big Board (probably faster than a '63 Beetle, too). And it will eliminate all the problems of transferring data between two incompatible machines. A few fax messages later, I had a Z80 coprocessor card and U niDOS winging my way. Ten days later I got the note declaring that it was in customs. I should come down to the docks and find out which body parts they wanted to secure its release. (Don't ask me why the airmail customs office is on the waterfront. Probably for the same reason it took them seven days to notify me that I -had an Overnight Express Mail package waiting for me.) I hiked down the hill from my perch in Cihangir, overlooking the Bosphorus, and walked the short way to the Customs Post Office. Luckily, while waiting in line for the third time to get a piece of paper stamped, I ran into a familiar customs official. He'd been around a few weeks before when I came down to pick up a suspicious looking package from PC Tech. He remembered me (actually, he remembered I had promised to look for an American wife for him) and mentioned to the agent clearing my package that I wasn't such a bad kid. "Look here!," said the agent, pointing at the line on my paper that said "Duty to be Paid." "You should be paying duty on this, but I'm not charging you because you can speak Turkish." (So few foreigners take the time to learn Turkish that anyone who can utter anything resembling a complete sentence impresses them.) I thanked him, grabbed my new toy, and left. Micro Solutions Z80 Coprocessor The Micro Solutions Z80 Coprocessor card is a half-length card that can plug into any empty slot on a PC or AT compatible. The card contains a Z80H (8 MHz), 64K of RAM (8 x 4164), and a few TTL glue chips. Other than one address jumper used to set the location of the Z80 <-> 8086 communications port, there is nothing about the card that needs mentioning. It's small and cute; you plug it in and forget about it. Included with the Coprocessor card are two pieces of software: UniDOS and UniForm. UniDOS is a TSR program that enables you to run any CP IM-80 program on a PC with the Z80 Coprocessor installed. UniForm is a combination device driver and TSR that allows reading, writing, and formatting of dozens of different CP 1M format diskettes in your PC's drives. MICRO CORNUCOPIA, #50, Nov-Dec, 1989 67 UniDOS UniDOS is the software interface which manages communication and coordination between the Z80 and the 8086. After installation, UniDOS runs CP 1M programs while making itself almost completely invisible to the user. It accomplishes this by trapping all DOS calls to execute a program and checking if the program you're requesting is a Z80 CP1M program. If so, it loads the program into the Coprocessor memory and starts up the Z80. While the CP IM-80 program is running, UniDOS also handles all I/O requests, translating display, keyboard, disk, and printer commands from CP1M to DOS. It handles both BOOS and BIOS requests properly, even translating some of the important fields in FCBs (file control blocks) for those programs that make use of the information. UniDOS decides a program is CP IM-80 if one of the following is true: the file has a .COM extension and is on a CP1M format disk (accessed by UniForm); the file has a .COM extension and is in one of the directories specified by the "CPMDIR" command; or the file has an extension of .CPM. 68000 SK*DOS - A 68000/68020 DOS containing everything you expect in a DOS - on-line help. multiple directories, floppy and hard disk support, RAM disk and/or disk cache, I/O redirection, and more. Supplied with editor, assembler, Basic, powerful utilities. Supported by Users' Group and BBS. Software available from other vendors includes C compiler, Basic, editors, disassemblers, cross-assemblers, text fonnatter, communications programs, etc. Priced at $165 with configura- CP/M Compatibility UniDOS seemed near perfect in its emulation of CP1M. I didn't encounter problems with any of the CP1M programs I ran (including ZSID, DDT, ZZSOURCE, Turbo Pascal 2.0, M80, LBO, VEDIT, EXPRESS), although I avoided some programs on purpose. UniDOS has one problem w~th programs that do direct I/O (e.g., MODEM730). There are provisions for sending hardware I/O requests to the 8086, though. These programs could be patched to make these requests (MODEM730 must be patched for each different type of machine anyway). Both CP1M and DOS programs can access both CP1M and DOS diskettes. I even ran DU77 (a CP1M disk sector editor) to look at MSDOS disks (floppy and hard) and it worked perfectly. UniDOS even cooked up some disk parameters for DU to display (number of tracks, sectors, allocation groups, etc.). Integration of CP/M and MS-DOS I also became curious about how well UniDOS integrates the running of CP/M programs in with MS-DOS. To test this, I tried running CP 1M programs from within other programs (Le., somewhere else than the DOS prompt). First I went into XTREE and told it to execute a CP 1M program. It worked perfectly (although only if it was a CP1M .COM file in a directory marked by the CPMDIR command). Then I went into EXPRESS and gave a command to execute an external CP1M command. This also worked. About the only thing you must avoid is losing track of which .COM files are MS-DOS and which are CP/M. Don't mix them together. Either keep all the CP 1M programs in their own directory and mark it with CPMDIR, or rename all CP1M .COM files to .CPM the second you copy them onto your hard drive. tion kit, less if already configured for your system. HARDWARE - 68xxx systems Mt. Kisco NY 10549 (914) 241-0287/ Fax (914) 241-8607 Reader Service Number 40 UniForm UniForm is a program that creates a new virtual disk drive. This makes a CP1M diskette inserted in your floppy drive appear to DOS programs as a DOS diskette. Uniform version 2.13 (data version 1.12) contains 204 different diskette formats from ABC to Zorba, including Kaypro (and Pro-8) and Morrow. Most are CP 1M formats, although there are a few strange MS-DOS formats, such as 96 tpi DEC Rainbow. I expected UniForm would only 68 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 --------------- allow me to copy to and from CP 1M diskettes with special, internal commands. I was favorably surprised when I discovered that the "Uniform Disk" works with just about any DOS command. Not only can I use COPY, DIR, and ERASE, but I can also use XTREE, Brief, Zortech C++, Turbo Pascal, or any other program. People using the same word processing program on incompatible systems and sharing files can just edit the file right there on the floppy diskette; no need to transfer it first. Again, Micro_ Solutions has integrated their software into DOS almost seamlessly. The Seams A few seams appear in other areas, though. My first complaint is that UniForm doesn't support CP1M user areas. All files come up as user o. This doesn't seem to be much of a problem (all the files are still there) until you have two files in different user areas with the same name. Although I haven't tried this, the UniForm manual states that "unpredictable results may occur." My second complaint is that they did not include the formats for Slicer diskettes. That would be okay, except there is no documentation on adding your own formats to the UniForm data file. I remember getting a letter from a Micro C reader a while back telling me how to do this, but it has become impossibly lost in my famous cardboard box file system. Until I find it, I just have to live without all those programs I carefully packed onto 788K Slicer diskettes. (I deported the Slicer two years ago for lack of proper documentation.) Something slightly related to this: it would be wonderful if UniForm would attempt to narrow down the drive type selections for me. It could look at the diskette and throw out all formats that didn't match the diskette's physical format (e.g., only display disk types that are 1024 bytes per sector, double sided). I have some unlabeled disks, and it takes a long time to discover what format they are by trial and error. DOS 4.0 Incompatibility My last complaint about UniForm is that it doesn't work with DOS 4.0. The resident part of UniForm is in a device driver. When I try to boot DOS 4.0 with UniForm, the system locks as soon as it loads UNIFORM.5YS. I have two versions of UniDOS, the Coprocessor version and the Interpreter version (discussed below). The Coprocessor version (1.25) locks up under DOS 4.0, while the Interpreter version (1.11) runs just fine. Fortunately I repartitioned my hard drive recently to make the DOS partition less than 32 Mbytes (making space for XENIX). Because of this, I can still read the drive with DOS 3.3 (which is compatible with UniForm). If you use DOS 4.0 for the large drive partitions, though, you'll have to use UniForm and UniDOS with a floppy-only system. These problems are just slight annoyances. Mostly I am quite impressed with UniForm and UniDOS. Interpreter Version Of UniDOS The version of UniDOS I have been talking about is specially tailored to work with the Z80 Coprocessor card. There is another version, though, that uses software to interpret the Z80 machine code. I tried this version and was mildly surprised. Memory dumps with DDT scrolled past the screen at nearly the same speed as SYMDEB. VEDIT and EXPRESS even edited text at a reasonable speed (except wordwrap). Very acceptable. ZZSOURCE did start to bog down a bit when its symbol table got large, but it was still workable. Of course, I'm running a 12 MHz, 0 wait state 286. On an 8 MHz 8088, it might be a dog. However, the interpreter version has a mode that runs 8080 (a subset of Z80) programs on a V20 chip. Although not all programs contain only 8080 instructions, the ones that do will run just as fast on the V20 as on the Coprocessor board. You may think now that you should forget about the Coprocessor card and get the interpreter version of UniDOS. I suggest thinking a bit more. The Coprocessor board is $169 and includes UniDOS and UniForm. The price of the Interpreter UniDOS with UniForm is $135 (including a V20 chip). Unless you need that slot for something else, I think it's worthwhile to spend $34 more and get the Coprocessor board. Note, however, that the UniDOS included with the Coprocessor board does not support the interpreter or the V20 mode. Another Suggestion Don't even think of getting UniDOS without UniForm, although the opposite would be useful if you just needed to exchange data files. UniDOS would have been worthless to me if I hadn't been able to read the programs from the pile of Kaypro disks I've hoarded these last four years. Related Products Micro Solutions sells several other interface cards for use with UniForm. These cards allow you to read and write diskettes for Apple II, MacIntosh, North Star hard sector, and most 8" single and double sided formats. Why? You may now be wondering why "Laine the DOS Jock" has spent so much time talking about a "mere Z80." What good is it to you? Why should you waste your money on it? If you only work with DOS, and never do any work with embedded controllers or anything else that might contain a Z80, UniDOS is slightly less than worthless. You may as well spend the money on flea collars for your armadillos. If you're doing development work on anything that has a Z80, you can save yourself a considerable sum of money by buying the Z80 Coprocessor. Consider that a Z80 cross assembler running under DOS can easily cost $500. Alternatively, you can pay $169 for the Z80 card and UniDOS and buy the Z80 Macro Assembler from Micro C (disk K25) for $6 (plus $2 S/H to foreign countries). I've even seen copies of CP 1M, complete with all utilities, for $25. Of course, if you're running something like a publishing house (or a magazine) where you get in writers' work on anything from papyrus to 112" mag tape, UniForm could do wonders for your sanity. All you newcomers to the Micro C clan could use the Z80 Coprocessor to see for yourselves what it was like in the old days. Conclusion I have several other "Turkifization" projects waiting. I'm sure that at least one of the machines in question will have a Z80 processor. When it's time to work on that machine, I'll be ready. Emerald Microware P.O. Box 1726 Beaverton, OR 97075 (503) 641-8088 ••• Rack &Desk PC/AT Chassis Integrand's new Chassis/System is not another IBM mechanical and electrical clone. An entirely fresh packaging design approach has been taken using modular construction. At present, over 40 optional stock modules allow you to customize our standard chassis to nearly any requirement. Integrand offers high quality, advanced design hardware along with applications and technical support all at prices competitive with imports. Why settle for less? Accepts PC, XT, AT Motherboards and Passive Backplanes Doesn't Look Like IBM Rugged, Modular Construction Excellent Air Flow & Cooling Optional Card Cage Fan Designed to meet FCC 204 Watt Supply, UL Recognized 145W & 85Walso available Reasonably Priced -_ ...... -. .......= -- -- ........ _. ii=W=~6r~-=-" -.~. :: ':! _ ii;;=:;' ~~~ ~ ~~ Call or write for descriptive brochure and prices: 8620 Roosevelt Ave. • Visalia, CA 93291 209/651-1203 TELEX 5106012830 (INTEGRAND UD) FAX 209/651-1353 We accept Bank AmericardlVlSA and MasterCard IBM, PC, XT, AT trademarks of International Business Machines. Drives and computer boards not included. Reader Service Number 22 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 69 The Mercenaries: Silicon Valley Contractors By Todd Hoff 1075 W. Remington Dr. Sunnyvale, CA 94087 (408) 730-8410 Want to turn your C experience into $25 to $125 per hour? Want to work 80+ hours a week? Just print up some business cards and catch the next flight to Silicon Valley. Of course, there are a few things that money won't buy, but you'll find out about those after you arrive. 've become something my mama warned me against-a Silicon Valley contractor, a software mercenary. Constantly chased by headhunters, scurrying from company to company, I lead a dangerous but interesting life in the Valley. Silicon Valley, everyone's heard of it. Many dream of coming here. What will you find when you arrive? What's it like to be a contractor in the fabled Valley? Read on. Four years ago I packed my bags, leaving my beautiful but job-starved emerald isle of Eugene, Oregon, for the techy promised landSilicon Valley. At the time, all I knew about Silicon Valley lay printed in the San Jose Mercury News help wanted section; literally page after page of engineering jobs stared back at me, beckoning me with opportunity, challenging me to come. So I did. Here I, along with the thousands of other immigrants from Russia, India, Vietnam, Taiwan, Sweden, Germany, Ohio, and Texas, found both opportunity and challenge in this former land of oak trees, apricot orchards, and old tractors. I Getting To Know The Territory As a mercenary, the first thing you want to know is the lay of the land. Every place in this area is specified in relation to the San Francisco Bay. Silicon Valley, although existing on no map, is the little kingdom on the western shore of the Bay, usually referred to as the South Bay. East Bay lies to the east. This area is expanding exponentially and includes Bezerkly (Berkeley of BSD fame), Oakland, and Concord. The North Bay includes the politically correct cities of Marin and Sausalito. Last, but certainly not 70 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 least, is the Peninsula, home of The City, northern California's favorite son, San Francisco. The whole area is one frenetic job producing machine. Producing, as in war, perfect conditions for the software mercenary. Contracting in the Valley is perhaps unlike contracting in any other place in the world. There's a tangible energy in the Valley, flowing from the people and companies continuously pummelling and pushing at technology's frontiers. There's a fever here, causing normal people to work 80 hour weeks for months on end. Always omnipresent, like a golden carrot, lies the hope that your stock options will become more valuable than your toilet paper (although never as comfortable). Power Brokers Next, the veteran mercenary must know the major players. Everybody's here. All the biggest companies and all the wanna-be-biggest companies have active development staffs in the Valley. Opportunities are nearly endless-during good times, of course. The mercenary can take advantage of strained super power relations (DEC, IBM, Amdahl), or border skirmishes (SUN, MIPS, Apple), or foreign powers (NEC, Sony), or countless other third world countries (start ups). Rarely, however, do you contact a client directly (as you would if you were an independent contractor). Normally, introductions are made through an intermediary (job shop). Job shops are like floating countries, hiring the mercenary for an hourly fee, finding a needy company, and then reselling your services at a higher rate. Sometimes a considerably higher rate. Independent contracting is good if you can get it. You get to keep the full fee and your hours are very flexible. But (and there are lots of buts to independent contracting), the marketing, the problems of running a small business, and the responsibilities to clients often push folks into job shops. "Tom Jones," a local independent contractor As a mercenary, the first thing you want to know is the lay of the land ... The whole area is one frenetic job producing machine. who wishes to remain anonymous, got in via a career switch. "I started 15 years ago," Tom says, "with no contacts, no nothing. Like most independents, I got all my jobs through referrals. It was tough at first, but over the years I've built a steady and loyal clientele." Now Tom is in the envious position of being picky. "1 look for a synergy when accepting clients," says Tom. "I've upped my value by specializing in one area. I look for clients who fit into my specialty so I can make my jobs work together. One drawback is that I'm on call 24 hours a day. If there's a problem, I have to fix it and fast because many of my programs perform vital functions." For those potential mercenaries who don't want to build clientele, but still want to play, job shops offer attractive rates, some benefits, and extreme ease of use. Job shops do all your marketing. They contact all the clients. They set up the interviews. They negotiate rates. All you have to do is interview ... and work. "I have a few customers I've built relationships with," says Mark Lewis, a local contractor with over ten years ex- perience, "but I go primarily through job shops. My long term goal is to become an independent contractor. The longest I've been without a contract is seven days, and another guy I know was without a contract for a total of three days in three years." Tour Of Duty "UNIX porting is popular," says Anna Osborne, a local contractor. "If you just mention porting you got it made. Of course, everybody wants X Windows. Databases, networking, graphics, and surprisingly, firmware. I was originally a compiler person, but there weren't very many compiler jobs." UNIX and C are hot. Almost any experience with either will get your foot in the door. I knew someone, don't quote me, who just read a UNIX manual, had programmed in C on MSDOS, and got a UNIX job. Perhaps not completely ethical, but he was sure he could handle it-and he did. A mercenary must be honest enough about his or her abilities to make these judgments. Not surprisingly, this area offers many contracts for the Macintosh if you're comfortable with MPW or C. Also in demand are testing and technical support positions. It's difficult to find permanent people who'll take these dirty jobs so companies often hand them out to mercenaries. The Timid Need Not Apply No matter what the job, a mercenary position is not for the timid. Many people need the patronage of a large company. Why would anybody leave the comfort and security of a large company for the fetid jungles and night marches of contracting? The answers may surprise you. Mark found contracting attractive for having " ... more freedom, less responsibility, and more pay. The less responsibility aspect is something I think most people don't consider. You have a project. You don't have to worry about the long term implications of anything. Working for a couple of start ups, I carried a lot of responsibility. I got tired of worrying about it." Anna left the fold of a large company because "after working at a company for a while, technology passes you by. I was so caught up in the bureaucracy, I wasn't free to do anyMICRO CORNUCOPIA, #50, Nov-Dec, 1989 71 thing. As an employee it doesn't look good if you jump from company to company. But as a contractor, you can jump around and stay up to date on the latest stuff." For many, contracting is predestined. The Valley's environment almost encourages you to become a contractor. Very few people I know ever stay at a job more than two or three years. Job turnover in the Valley averages 50% every two years. Explaining the process Mark says, "I moved every two years, anyway. It was never my intention. That's just how it worked out. After having six or seven jobs in ten years, I decided to make it permanent." War Is Hell Risk is inherent in the mercenary's work. The mercenary must always be weary of surprise attacks. Tom has many gruesome stories. "One guy I know has worked for three companies that closed down with no notice. At one place, he showed up for work Monday morning to find the doors locked." Company loyalty-at least in the Valley-is dead. Mercenaries merely recognize the reality. "Many people I know," says Anna, "say that once they've learned all they can learn at their company, they'll leave. Nobody cares because the companies don't care." Lack of loyalty stems from the cycles of innovation and obsolescence. On the upward portion of the cycle, people are worth more than gold, vital assets to be treated royally. On the down side, people are dust, liabilities that must be exorcised from the ledgers. I've heard that many companies turn to contractors for public relation reasons: firing contractors doesn't make headlines. Another problem for the mercenary is getting paid, sometimes a battle. "One of the beauties of working for a job shop," Tom says, "is that you always get paid. I've never worked for free, but it's been close. One tactic companies use for getting out of paying is complaining about your work. No matter how detailed a spec you have, there are always misunderstandings. Sometimes a client won't pay because 'I didn't do what they wanted.' This usually means the company doesn't need the software anymore so they don't want to pay me for it." Several times people have asked me to work for free. Here's the deal: I work 72 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 my butt off, day and night. I forego even the semblance of a family life. For what? For some stock options and promise of payment when the product sells "to this long list of customers just begging for it." Another deal used by start ups is to pay up front for three months' work. The contractor then works six months assuming there's payment and bonus ready when the product is done. If the startup happens to go under, as many do, you're out of luck. Although contractors are one of the first in line to be paid from bankruptcy proceedings, chances are you'll never see a cent. Cleanup Latrine duty is very common. Industry often brings in contractors to fix poorly designed, badly implemented projects. Somehow it never occurs to management that they should pay for the expensive people up front, not when it's almost too late. The "almost" means that contractors are often seen as cannon fodder. Because a person is only a contractor, asking them to work 7 days and 90 hours a week is okay. Oh well, mercenaries work for money, not glory. Always remember: as a contractor you are just meat satisfying a temporary hunger. Eventually you will leave, expectedly or unexpectedly, but you will leave. As a mercenary you have no ties, no loyalty. None is asked, none is offered. For money, you give someone the right any day, any time, to say good-bye. Wages Of Sin Software mercenaries, however, eat well. As a beginning contractor, say with 2-3 years solid technical experience, you could start at $35 per hour. With a couple of years of contracting experience, you've proven yourself so you can command $40-$50 per hour. A medium level specialist, say in X Windows, device drivers, kernel work, or networking, can ask $50-$70 per hour. For high level specialists, with lots of pertinent experience, the sky's the limit. I know several people who get $100-$125 per hour and one who gets $250. Granted, contracts at this level may be shorter term-but who cares! The Field Is Bloody Lest you think these rates too high, remember: Silicon Valley workers deserve both hazardous duty pay and housing allowances. The Bay Area is beautiful, but all is not well in Oz. Dennis Hayes quotes some startling statistics in his book, Behind the Silicon Curtain. It's estimated 60% of high-tech workers are seeing psychiatrists. This area has more divorces than marriages. In 1987, over $500 was spent on drugs per man, woman, and child in San Jose, although both Anna and Mark say they don't see much drug use. Anna jokes, "Do caffeine, sugar, and cigarettes count as drugs?" Also, Silicon Valley has more Superfund sites than any other area in the nation. And the hills become a little harder to see every year. Housing is atrocious. Only 9% of the people in California can afford a house. A house in Palo Alto, 1300 square feet on Vs of an acre, sold recently for more than $600,000. More reasonable areas offer cheaper houses but tack on an hour to your commute. By the year 2000, the state's average house is supposed to reach a cost of $470,000. The average commute, now 45 minutes, is projected to be 2 hours by 2010. Lovely. People also forget the cost of little things they take for granted at a company. Health insurance is expensive. Retirement plans are nonexistent. And all those· paid holidays for employees are unpaid for mercenaries. I hear you saying that as a mercenary you get all the benefits of being a small business. Not so. New rules have made it much more difficult for contractors to qualify as businesses. The mercenaries' mercenary-the IRS-now takes a dim view of W-2 contractors saying they are a business. And because of IRS pressure, most job shops won't 1099 you anymore. You are, in effect, an employee of the job shop. In reality, of course, this is total BS. Why Do They Keep On Keeping On? When the dust has settled, the battle ended, wounds bandaged, the mercenary moves on. Mark, Anna, and Tom all say that they like contracting and won't stop. To them the advantages outweigh the perils. Most people wouldn't agree. But as Anna says, "Contractors are obsessed with independence. Disillusioned with large business, they want to do it all themselves." ••• Continuing AROUND THE BEND Coming Up The whole idea of picking topics for issues happens to be a bit controversial around here. "Don't set topics, let readers be surprised." "Writers will see the topics and assume we're not interested in anything else." "It locks us in for a whole year." It's also nice, however, to have something to work on. Some . direction. So here goes. • January-Embedded Systems • March-Object Oriented Programming • May-Micro Controllers • July-Operating Systems • September-Data Collection • November-Graphics You'll notice that the major topics alternate between hardware and software. I'd also considered running contrasting subjects, such as running Exposed Systems following the issue on Embedded Systems. Running Micro Supporters after the issue on Micro Controllers. Running Nonoperating Systems (should be a great issue) after Operating Systems. And running Data Dispersal after Data Collection. (By this time you should have a pretty graphic idea how we pick the special subjects.) Port Albemi SOG You can take the SaG out of the country, but you can't take the country out of SaG. Port Alberni, Canada, was definitely country and the event was definitely SOG. A solid (even solider after the salmon barbeque) 50 SOGgy families showed up at the local college and made it an event that reminded me of the very early SOGs. Good companionship, good food, good weather, good camping (and Bed & Breakfasting), and great scenery. The local community went out of its way to make us feel welcome, and our hosts (David Stern and Randy Young) had a great time despite their initial nervousness. (Neither had even attended a SOG before.) The only down sides of the whole event were customs and gasoline prices. Don Jindra and wife (and sons) drove all the way from Denton, Texas, to show off their $25 network package. (It really works.) Canadian customs wanted $1,200 duty for his three demo computers. No $1,200, no entry. After turning around and heading back toward Texas (I understand he first exchanged a few words with the customs officer-something about backward countries remaining backward because of petty officials), he decided to try another entry point. Under the eagle eye of a new customs agent, they dug out the computers and again explained why they were taking them into Canada. This time the officer wished them luck and let them through. This was just one of their trials. Their first Hertz van broke down two hours from home. Then their keys got locked in the second van. Fortunately it happened during the barbeque and we had a handy hardware engineer and a handy hardware debugge~ (often mistaken for a coat hangar). Made me wonder how many software folks it would have taken to unlock the vanassuming of course they couldn't just disassemble it. Gunnison SOG If the Port Alberni SaG featured food and scenery, the Gunnison SaG featured high mountain thunderstorms and energy. Human energy. Check out Karl's write up of this fine SaG and you'll understand what I'm talking about. Thanks for a great SaG, Scott and Maria. On Your Own I led a group discussion at the BC SOG about my favorite subject, being on your own. We shared tales of failures: unpopular T-shirts, unmarketed hardware, and a dishonest distributor. And successes: the $25 network (again), a hospital package, and a kit robot. When I suggested the possibility of turning a product over to marketing folks, there were hisses from the audience. (I might have mentioned used cars in the same breath.) However, after the dinner, David Stern took my arm and suggested that I (we) might be a bit mistaken. "Technical types design the product and then they look for a market. Marketing types find the market first. Then they see if someone can build the product." He's right. We can all point to situations where the design came first and the market followed: CP 1M, Apple, Byte, VisiCalc, C, Osborne. (Osborne? That was the company which created the market for Kaypros.) However, the computer marketplace has become a lot more mature and a lot bigger. Owning a small niche can be as lucrative as owning the whole shootin' match six years ago. You just need a lot sharper aim to hit the niche. That's where the Interested Folks at Robotics Demonstration, Port Alberni marketing type, a real marketing type, can make himself invaluable. Now, finding a real, knowledgeable marketing person and making sense of the information he generates ... well, that's another story. You And Micro C? Speaking of marketing, it's definitely time to expand Micro C. We should be exposing ourselves to more people, contacting more potential advertisers, even possibly gqing monthly. (Did I really say that?) MICRO CORNUCOPIA, #50, Nov-Dec, 1989 73 · So, we're looking for a partner. A go-for-it person or group who wants to invest time, money, ideas, and energy in making Micro C the significant player it can be. We're ready to take a look at focus, market, everything. (The only things that have to stay are the light style, the informality, the readability, and the editorial. Not necessarily in that order.) If you feel you and Micro C might be a good fit and you're willing to take a very significant (and demanding) role in a more and more significant magazine, then let's talk (503-3825060). (Bend is a wonderful place to raise a family.) A Surplus Idea One of the best suggestions to come out of this year's regional SaGs so far: "Have readers send in information about their sources for surplus parts. Then print the list in Micro c." Wow! What an idea. Part of my startup time on a new project gets spent locating sources of parts. As difficult as it is finding normal retail sources, it's nearly impossible to find surplus dealers who have what I need. But, surplus prices can make the search worthwhile. I remember purchasing 25 lb. grab boxes at the Tektronix surplus store. They wouldn't let me open them on the premises, so I didn't have the slightest idea what was inside (usually just a tangle of small parts swept off the floor at a board assembly area). On occasion I found brand new power cords, reed relays, transformers, ICs in their original tubes, used soldering sta- Mandelbrot Explorer 3.0 Fantastic fractal grapnzcs on 16-color EGAjVGA to 800x600. Magnifies up to 16.5 trillion times. Stop and start at wil~ save and retrieve, collage, full control over color boundaries, "zoom box, " display ofperiodic orbits, auto-backup, all optimizations for speed including pi,'tel interpolation and 386 integer support. Comes with seven ready-made pictures for immediate gratification. $30 Peter Garrison 1613 Altivo Way Los Angeles, CA 90026 2136651397 When ordering please specify EGA/VGA and disk format Overseas orders please add $4 Reader Service Number 112 74 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 tions, and, well, other wonderful surprises. As for the floor sweepings, I'd hate to guess how many hours I spent sorting resistors and capacitors. At $7.50 per box, I was hooked. Like the Tektronix outlet, some surplus stores are connected with corporations. Though many are for employees only, the rest are quite happy to sell to the public. Then there are the independent outlets. They often purchase overstock by the pound (often for the value of the silver, gold, or tin). Then these shops try to sell as much as they can to hobbyists and start-ups before stripping the rest of their precious metals. Many of these stores haven't the slightest idea what it is they are selling. If it's big or impressive, they ask more. After something has blocked an aisle for six months, they ask less. Shopping in person is by far the most interesting (and the safest). Many stores have a plethora of high-tech orphans. Since orphans almost never show up in catalogs, they're only available to browsers. They're also often just what you need (though you wouldn't have realized it if you hadn't seen them). Anyway, if you're a junk aficionado, or just have regular dungeons where you stir up dust with the buddies on Saturdays, send us the scoop on them. (Just include those that deal with the public.) Include: 1) Name, address, phone number; 2) Person to talk to; 3) Days/hours they're open; 4) Whether they sell by mail/phone, to walk-in customers, or both; 5) Whether they have a catalog. What does it cost? 6) Their specialty (if they have one); 7) Whether they also sell non-surplus parts. (Give a general description); 8) Whether they have a return policy. What is it? 9) Prices (high/low /variable/wildly variable/ chaotic). You might mention two or three examples of products and prices; 10) Include a paragraph or two about how they are to deal with, how knowledgeable they are about their stock, amount of stock. Is it mostly junk or prime, have you had trouble with them ... ? 11) Include any additional information you think is germane to Micro C readers. If there's a shop you've just heard about but haven't tried, send the information you have and we'll try to get in contact with them. Now, there's a reward for you in this. You receive a free Micro C issue disk (or Micro C back issue) for each firm you report on. (The disks and issues might not be surplus, but their price is right.) Pascal Book I don't use many books when I'm programming-for a long while just Borland's Turbo Pascal reference manual. However, not too long ago I found myself struggling with a sticky little graphics problem. It was so bad that I dug through all my Pascal books. Nothing, until I found Complete Turbo Pascal, Third edition. How Jeff Duntemann has time to put this much effort into a book while being editor of... (well, it was Turbo Technix) escapes me. But he's done it. He's thrown in lots of sample routines, including, fortunately, copious comments on Borland's Graphics Interface. (He also does mouse drivers, inline and outline assembly language, low level system hooks, and lots more.) It's a readable book and it has a good index. Plus, Duntemann isn't afraid to talk straight. I get a strong feeling that Borland doesn't print anything in its manuals that might sound like a bug. So I turn to Duntemann at least as often as I tum to Borland. Complete Turbo Pascal Third Edition (Covers 5.0) 822 pages $24.95 By Jeff Duntemann Scott Foresman and Company ISBN 0-673-38355-5 Speaking Of Books One of the most famous and discerning places to get technical books, walk-in or mail order, is Computer Literacy. They're famous because they're famous. They're discerning because they've carried Micro C since around 2 BC (2 years Before the fancy Covers). The New York Times, another significant publication (though they still don't have fancy covers) mentioned Computer Liter- acy in its July 25 issue: "Engineers on their way back to their cubicles at AT&T or Xerox Corporation can stop at another valley landmark, the Computer Literacy Bookstore, where the magazine section includes copies of Micro Cornucopia and HyperAge." Computer Literacy will sell you just about everything you'll need for those all-nighters, except the Jolt. So if it's technical, has pages, and has covers (not blankets), they probably have it. They say they ship within one day (national and international), they track down obscure books for no extra charge, and they'll be glad to put you on the mailing list for their free newsletter. I usually see Dan Doernberg, founder of Computer Literacy, when I attend the' West Coast Computer Faire, and I've always enjoyed talking to him. He's a great source if you're looking for the latest book on hi-tech arcane and obscure. Computer Literacy Bookshop 520 Lawrence Expressway Sunnyvale, CA 94086 (408) 730-9955 Ventura 2.0 Most of you have watched us fumble our way into desktop publishing. Despite the tribulation (which always occurs at deadline), I've found that desktop is as much an improvement cYFh~C,R\der The C Programmer's Companion Now Available for OS/2 II! CCSYM - C Symbol Compiler • Analyzes ANSI C source code. MicrosofVTurbo extensions supported. • Automatically generates separate commented function prototype files for all global and local (static) functions. • Log File lists all your symbol definitions with detailed usage statistics. • Generates a "symbol database" which CCRIDER uses to quickly retrieve ANY symbol definition in your application, no matter how large it is. • Incremental compilation supports efficient database updates. CCRIDER - POP-Up Symbol Lookup • Pop-up utility which converts your own editor into a powerful hypertext programming environment. • Point at a symbol in your editor, then pop-up its definition in a window. • One keystroke "Edit" command allows you to edit the definition in your own editor, no matter which file or directory it was defined in. • "Paste" command inserts the definition into your currently edited file. • Supports multiple editing sessions under OS/2. DOS Version $89 OS/2 Version $179 FREE DEMO Western Wares Box C Norwood. (303) 327-4898 Reader Service Number 169 co 81423 YOU WANT THE SOURCE1! WELL HOW YOU CAN BAVE IT! The IIASTBR.FOL DTS'SSEllBLER. (1ID86) vill create HASH coapatible source code fro. program files (EXE or COK). And the files are labeled and co •• ented so they become USEABLE. KD86 is an interactive disassembler with an easy to use,. vord processor like interface (this is crucial for the REAL progra.s you vant to disassemble). With its built-in belp screens you won't have to constantly refer to the .anual either (although there are valuable diSCUS-~ sions on the ins and outs of disassembling vhich you won't vant to miss). 1 f::; t -n. c... ..... n'· HD86 is a professionally supported product and yet costs no .. ore than "shareware". And of course, it's not copy protected. YBRSIOI 2 10& AVAILAlLKt IID86 n is om.Y $67.SO ($I.SO sQ) + tax C.C" Software, 1907 Alvarado Ave., Walnut Creek, CA 94596, (415) 939·8153 Reader Service Number 31 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 75 over the old paste up procedures as word processing is over a typewriter. I couldn't go back. We've used Ventura Publisher from the beginning. Version 1.0 was buggy, sure, but with three different ways to do any one thing, there was usually a work-around. As revisions rolled in, we spent more and more time doing the work and less and less time doing the around. Now, with version 2.0 things seemed to take a giant step backwards. The most consistent thing was inconsistency. An article (chapter) that went together and saved perfectly might be garbage when called up again. Or, we'd load a figure into a frame and a nearby headline would get weird. Page numbers changed into headlines, often refusing to change back. Sometimes Carol could fix the problems. Sometimes she couldn't. Either way, the next time the file was edited, there might be a whole new set of problems. I called Xerox. The only thing the support person asked about was memory. How much RAM? (640K.) Were we running TSRs? (No.) Did we have at least 52 OK of free memory before running Ventura? (Definitely.) I hadn't been too concerned about RAM because version 1.X was running precisely, though slowly, on the same machine (as an article got long or complex, the older version would swap data between memory and disk). Something about this new version was definitely not right. ICs PROMPT DELIVERY!!! SAME DAY SHIPPING (USUALLY) QUANTITY ONE PRICES SHOWN for SEPT. 3, 1989 DYNAMIC RAM 256Kx36 80 ns $400.00 1Mx9 70 ns 180.00 (2) 1Mx9 80 ns 135.00 256Kx9 100 ns 45.00 1 Mbit 1Mx1 100 ns 12.75 41256 256Kx1 60 ns 6.95 41256 256Kx1 80 ns 4.95 256Kx1 100 ns 3.75 41256 256Kx1 120 ns 3.40 41256 4464 64Kx4 120 ns 4.50 41264 (3) 64Kx4 120 ns 9.65 EPROM 128Kx8 200 ns $22.00 64Kx8 200 ns 9.50 32Kx8 150 ns 7.25 16Kx8 250 ns 4.50 STATIC RAM 62256p-10 32Kx8 100 ns $18.95 8Kx8 120 ns 5.50 6264p-12 6116AP-12 2Kx8 120 ns 4.50 SIMM SIMM SIMM SIMM I (1) Version 2.0 supports EMS memory. According to the manual, you don't have to have EMS memory (unless you want fancy hyphenation), but it supports it. So when Carol got exasperated with this issue's 3-D article (page two became totally strange the instant she loaded either of the two illustrations), I packed up her machine and headed for MicroSphere. My hunch was that extra memory was more important than Ventura was letting on. I suspected that overflowing stacks or misaimed pointers were causing the problem. "I want EMS, lots of EMS," I said as I dumped the dismembered machine onto their service bench. Fortunately RAM prices have come down a bunch. Unfortunately, Howard, Ed, and Allan were up to their ears in other work. Ah well, I can stuff RAM and set dip switches with the best. So I did. Five hours and six false starts later, I had added 1.5 meg of EMS. (The EMS board was very smart, by the way, letting me configure its RAM as any combination of extended, expanded (EMS), and main memory. In fact, for over an hour it was a lot smarter than I was.) The instant I got back to the office I cobbled up Carol's monitor, keyboard, printer, fired up Ventura, selected "Desk" (to get the version display), then pointed the mouse arrow to the word "Ventura" and clicked. Up came the secret diagnostic window. (Kind of like a secret decoder ring, but useful.) Sure enough, Ventura recognized 1.5 meg of EMS. Then I loaded the troublesome 3-D article and looked at page two. Wow! The page number displayed correctly, unruly text from other pages had disappeared-the whole thing worked. I tried another article, and another, and another ... everything worked. Ain't desktop fun? Longhorn SOG Reborn After seeing Don and Kim Jindra at both the Canadian and Colorado SaGs, I wasn't too surprised when I got a call from Kim. What did surprise me was the subject. The Longhorn SaG. "We've got to do something more than the regular meeting at the Info Mart. I got hold of Stuart, he's hard to reach, and volunteered to take over the SaG arrangements. He said fine, so I've got it." It turns out she's lined up meeting space for SaG talks, a barbeque, a place for two JoIt SIGs, T-shirts, and more. She's arranging SaG sessions on Friday in Denton, Texas (25 miles north of the Dallas/Ft. Worth Airport), then taking the group to Dallas for Saturday's Info Mart meeting. If there's any chance you can attend, or speak, or whatever, get in touch with Kim right away. (Check the Longhorn SOG information box in this issue.) I'll see you there. Longhorn SOG-Oct.13-14 Kim Jindra P.O. Drawer F Denton, TX 76202 (817l?87) o Reader Service Number 37 76 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 ._-------------------_ ... - idL~~pson ito--'& Publisher Letters \ continued from page 6 The Nature Of Radar Regarding LIMBO's distance sensor ("Letters," Issue #49, p. 75): Whether the intensity of reflected light, or a radar signal, is inversely proportional to the square or to the fourth power of distance depends on the nature of the reflecting target. If the reflection is from a plane surface that reflects without scattering, the inverse square applies. If scattering occurs at the target, inverse square applies for both the forward and the return paths, and the product is the inverse fourth power, the radar equation. LIMBO's received power from his (her) own source as seen in a mirror would be inverse square, but from a white object would be inverse fourth power. The polished ball bearing beloved of telescope makers as a test object will produce an inverse fourth power response for LIMBO's sensor in spite of the specular nature of the reflection, because it produces the scattering that is the underlying reason for the inverse square law. Not only the library's dusty tomes on radar show the inverse fourth power. The Second (1988) Edition of Antennas, by Professor John D. Kraus of Ohio State University, gives the radar equation and explains the fourth power of distance in the denominator. The equation is alive and well, as good today as the first time someone found that doubling the transmitter power didn't buy you much early warning time. It also includes other factors, such as the effective cross section of the target. The inverse fourth power behaviour was responsible for the effectiveness of a very successful anti-submarine measure during World War II. Submarines used to surface at night to run their diesel engines and charge their propulsion batteries. Maritime reconnaissance aircraft would search for them with radar, and the subs used receivers on the radar frequency to warn of their approach. This was very effective, as the signal arriving at the sub was detectable by its receiver long before the reflected echo from it was strong enough to appear on the radar receiver in the aircraft. In fact, the aircraft were detectable at such long ranges that the subs would only sub- INTRODUCING merge when the signals indicated the aircraft was getting close. This avoided the loss of valuable battery charging time when the aircraft could be a hundred miles away. To counter this countermeasure, the airborne radars were fitted with attenuators in the transmitter output, in the form of a vane that could be cranked into a slot in the waveguide. When a sub was first detected, with the radar transmitter at full output, the aircraft would turn for a run at the submarine. The radar operator would crank in the attenuator as they ran, reducing the power steadily to keep the received signal constant as the range decreased. At the submarine, the receiver operator would hear the radar signal decreasing from the time the aircraft went into kill mode, and assume that the aircraft was going away. With the noise of the sub's diesel to mask the sound of the aircraft's engines, it was usually possible to arrive over the sub before it submerged. The effectiveness of this system is apparent if you use the inverse square to calculate the signal at the sub, and the inverse fourth power to calculate the signal at the aircraft, assuming a transmit power adjusted at all times for a constant signal at the airborne radar receiver. So be careful! Failure to appreciate the inverse fourth power law in the radar equation has been known to be fatal! ~tude~ 25 MHz 8-bit ANALOG-TO-DIGITAL CONVERTER Based on the TRW THC1068-1 hybrid flash converter, its high signal-to-noise ratio yields excellent accuracy at the Nyquist limit. • 4 KB of cache SRAM or to host as converted at DMA speed • 110 or DMA data transfer • 10 MHz full-power bandwidth • 3.92 mV resolution • 16 jumper selectable base addresses • Input unipolar or bipolar • External clock and trigger inputs • Software source code included INTRODUCTORY PRICE $299 ALSO AVAILABLE AS A KIT FOR $99, INCLUDING: • Printed Circuit board • Software • Manual &assembly instructions (KITintroductoryprice includes PAL and 4KB of high-speed SRAM) Requires: PC compatible 1/2 length 8-bit expansion slot. DOS 2.11 or greater. EGA, VGA or Hercules display needed for graphic representation of data. John Innes 120 Macpherson Street Cremorne, NSW 2090 Australia Editor's note: All this leads me to a bit of specular reflection. Placing an alien infrared detector (for detecting alien infra reds , of course) and a fairly substantial laser on your robot might be the most effective way to sink other maze contestants. (I knew you'd get a charge out of that.) Silicon Alley ~ P.O. BOX 59593 DEPT. MC-1112 Renton, WA 98058 206.255.7410 C 1989 Silicon AUey Inc. 'tude Is a trademark of Silicon Alley Inc. Other brand or product namtJS are traoemarks or registertJdtrademarfcs oftMir respecUVtJ holders. Prices and sptJclicatbns subject to change. Reader Service Number 177 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 77 By Michael S. Hunt th 2313 N. 20 Boise, ID 83702 (208) 336-7413 A Short Look At Sparse Matrices Linking Your Way Into Tables Michael is short this time. It turns out he's still recovering from the Jolt SIGs at the Gunnison SOG. So he's covering sparse matrices in a sparse sort of way. f you've looked ahead at the code for this issue, you've probably noticed that I haven't included the promised B-tree balancer. Instead, the code this time supports a linked list implementation of sparse matrices. (Sparse matrices are like regular matrices only smaller, we hope.) Well, what can I say? It's summer, and there was SOG, the new Turbo Pascal 5.5 arrived, the new Stony Brook Modula-2 compilers arrived, and I went scuba diving. Still, I wrote the AVL routine (named after its developers), but right now it has a vaguely annoying tendency to drop pointers. So I'll cover the A VL routines in the next issue. I SOG SOG, as always, was great! My wife Pamm and I made the trek from Boise to Gunnison, Colorado, where I gave a talk about the differences between Pascal and Modula-2. After about an hour, the talk turned into a discussion about the column. Two camps emerged, one wanting more simple toolkits that explained common algorithms. The other wanted powerful applications-oriented toolboxes. I'll try to satisfy both camps by showcasing an algorithm from a robust toolbox. We can still put full source code on the issue disk and the Micro C BBS. Turbo Pascal 5.5 On the surface, 5.5 looks like 5.0. But scratch the surface and hmmm, what's 78 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 this, it looks like OOP (Object Oriented Programming). I also received the Turbo Assembler and Turbo Debugger. Soon I'll start digging into all of it. I have some code that could use assembly code speed so I'll discuss interfacing Pascal and Modula-2 to assembly code routines. I'll also compare writing with OOP and without OOP. Stony Brook Modula-2 My upgrade to version 2 of Stony Brook's Modula-2 compilers just arrived. With support for DOS, OS/2, Windows, QuickMod compiler for development, and optimizing compiler for production, it's a very impressive package. I'll talk in greater detail about the Turbo and Stony Brook products next time. Scuba Diving It was great! A whole day of diving in a high mountain lake. The water was cold, the air was clean, and the fish weren't biting. That Little Bug At the last minute I realized I could save some CPU time and simplify my A VL code. Foolishly I began a quick rewrite. The VAX editor at work saves all versions of a file, but the Turbo editor saves only one .BAK file. Ah, to experience Laine's Lament for a universal editor. Soon the original version had been wiped out and I had no back up. Sparse Matrices In numerical analysis, modeling, simulation, and many other fields of mathematics and data analysis, we often deal with large (1000 x 1000 or larger) matrices of data. The data are often real numbers at four or eight bytes apiece. This can consume more memory than many computers have. Many of the matrices used in these applications are called sparse matrices, meaning that most of their elements have the same value, usually zero. Some common forms of sparse matrices are upper and lower diagonal matrices and tridiagonal matrices found in systems of differential equations. The toolkit for sparse matrices (Figure 1) stores only the nondefault elements of the matrix. The elements are stored in an array of linked lists. The function Sparse returns the ith row and jth column element from the mth matrix. PutSparse stores an element in the linked list if it doesn't equal the default value for that element. The unit supports MAXSPARSEMATRIX (currently 3) matrices. Each matrix can be up to MAXROW (currently 1000) rows by 65,365 columns. SetDefault lets you change the default value for the m th matrix. The sample program (Figure 2) shows several common matrix operations using the SparseMatrix unit. Next Time Will there be A VL trees next time? Yes Virginia, there really is an AVL routine. After that, back to reality. ••• 3: DEFAULTVAL= 0.0: = nodePtr "'nodeType: node Type = record data : data1'ype; col :. WORD: nextCol : nodePtr USES SparseMatrix; CONS'1' MatA 1; MatS =2; Matc == 3: VAR i, j, k : WORD; = PROCEDURE AddMatrix: (* BEGIN FOR i := 1 TO 10 DO FOR j := 1 '1'010 DO BEGIN PutSparse(i, j, MatA, i*1.0): PutSparse(i, j, MatB, j*2.0); PutSparse(i,. j, MatC, Sparse(i, Sparse(i, END; WriteLn; WriteLn('MatA +MatB = MatC'): FOR i := 1 TO 10 DO BEGIN MICRO CORNUCOPIA, #50, Nov-Dec, 1989 79 Getting A Little Hyper Anthony Barcellos p.o. Box 2249 Davis, CA 95617-2249 Voice: (916) 756-4866 Data: (916) 758-1002 Tony is hyper about hypertext (he uses it to improve his manual dexterity). This time he also talks about his mini-BBS and about the Association of Shareware Professionals. These are three good connections for anyone considering a shareware future. n the beginning was text, and it d. idn't seem all that bad at the time. Then came formatting and everyone saw that it was good. When graphics were mixed in, the real excitement began. But there's yet another step in this progression from text editors to word processors to desktop publishers. It's called hypertext. It offers text, graphics, and freedom-with a bit of confusion tossed in. Unlike the documents most of us are used to, hypertext does not proceed in a straightforward linear fashion. Forget about beginnings, middles, and ends. Hypertext can go off in any direction. Say you're reading a hypertext document. (Clearly this is not a hard copy system.) A particular phrase or caption catches your attention. A special symbol flags it, indicating that more information is available. You click on the symbol and a window opens. It may be a technical citation or reference. Perhaps it's an illustration or graph. It might even be an extensive digression, containing further branches of its own. A hypertext document can be perused on several levels, tailored to each reader's individual needs and preferences. A novice, consulting a hypertext user's manual, could ask for additional help on difficult procedures. An expert could lightly skim or, alternatively, deeply dig into technical details that would frighten off a beginner. Using symbol keys and internal "links," a hypertext author can create a file that approaches all things to all people. I That New Black Magic NTERGAID has released a shareware hypertext authoring system called Black Magic. It includes a word processor to create your text, a 80 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 screen grabber for importing graphics from other programs, and a public domain reader to distribute with the hypertext. You can create four types of linkages within Black Magic. A simple Note link pops up a window that displays a short text string. Use Note links to clarify comments or add little digressions. Replacement links are quite different. Unlike Note links, which the user may examine (or not) on a case-by-case basis, Replacement links are typically organized in families scattered throughout a document. When a Replacement link of a particular kind activates, all other Replacement links of the same name also turn on. Replacement links substitute something for each occurrence of the link word. For example, "Boot your computer." could be uniformly replaced with "If your computer has a hard disk and is turned off, turn it on; if it's already turned on, press the keys Ctrl, Alt, and Del simultaneollsly. If your computer does not have a hard disk, place your DOS diskette in drive A and turn your computer on; if it is already turned on, place your DOS diskette in drive A and press the keys Ctrl, Alt, and Del simultaneously." How's that for customizing the level of your documentation? Reference links can take you from one hypertext document to another, thereby blurring the boundaries of individual hypertext files. So you don't get totally lost, the Reference link gives you a flowchart map of the document. Black Magic's DOS link lets you shell out to a new program while Black Magic shrinks into a tiny memory-resident kernel. When you exit the DOS program, Black Magic resumes control. Thus you can build a highly customized DOS shell and help system. In their press kit, NTERGAID says that DuPont is using hypertext as the documentation component of an active order system. The Environmental Protection Agency uses Black Magic to organize its voluminous regulations, and NASA uses it to distribute aerospace test data. Despite its power, Black Magic's system requirements are modest. Although it prefers a hard disk, Black Magic can manage with a dual-floppy Pc. The minimum RAM is 384K, although 640K is recommended. Black Magic requires a graphics card; it supports CGA, Hercules, EGA, and VGA. A Microsoft mouse (or compatible) is optional. It supports Epson dotmatrix and Hewlett-Packard LaserJet printers for printed output. (Of course, Black Magic loses most of its hypertext features when you print a document. You can, of course, choose which part of a hypertext file to print, so Notes and such can be included.) That old Black Magic doesn't have us under its speller, because it doesn't check your writing. They left that for release 2.0. Overall, however, the package is impressive. NTERGAID suggests several applications for Black Magic, including technical documentation, educational courseware, computer-based training, and presentations. The clever user can probably come up with several original applications for this combination word processor /DOS shell/clip art gallery / reference system. If you're eager to try it, you can download Black Magic from CompuServe or from NTERGAID's own HyperBoard at (203) 366-5698. There are also several payment levels, as noted below. Black Magic, version 1.4 NTERGAID 2490 Black Rock Turnpike, Ste. 337 Fairfield, CT 06430 (203) 368-0632 (Voice) (203) 366-5698 (BBS) Demo disk, $7.00 Trial disk set (unregistered) $18.95 Registered copy (with technical support), $49.95 Registered copy (with technical support, printed manual, keybrd template, quick reference card) $89.95 A Heavenly Host You're at the office. Your file is on your PC at home. You need it now. What to do? If you have Minihost running on your system at home, you just call it up via modem and download the file to your office computer. Minihost is by no means unique, since communications programs like ProComm offer a host mode for unattended operation. However, Minihost is more like a small bulletin board system with amazingly low maintenance requirements. Mankin's program comes practically ready to run as soon as you extract the components from the archive file and copy them to a Minihost directory on your hard disk. (Minihost supports floppies, too, but a hard disk is recommended.) You'll need to edit Minihost's parameters, but they've thrown in numerous example entries. Just enter your name in place of Don Mankin's (the author) as sysop, and edit the names in the user list to give your friends suitable access levels. Or you can lock everyone else out by declaring your Minihost a closed system. You also get to set disk and directory protection levels. You can change the COM port from 1 to 2 (or whatever). Or, you can prevent others from downloading files with specified extensions. The documentation explains each option in the order in which it occurs in the .CNF file, so I loaded the user's manual into one window of my word processor and MINIHOST.CNF into the other. As I scrolled through the manual, I moved through the parameters. I have been using Minihost for over two years so folks can send me articles for Sacra Blue, the newsletter I edit. In the olden days, contributors would call and we'd attempt to get my Qmodem talking to whatever they had. Then we'd patiently go through the file transfer procedure. Now I leave Minihost running and Sacra Blue's writers can upload files just about whenever they please. I don't have to do a thing. Minihost lets them leave messages to me (or to each other, since recent Minihost releases offer message conferences as well as messages to the sysop) and I can leave messages for them. My system is configured so that anyone can log in to leave messages or upload files. I have entered a few people in my user base so that they can download files and access additional directories. Minihost is very flexible. The simplest way to receive Minihost is to call Don Mankin's Minihost system at (209) 836-2402 and download the current version. If you do, you'll also discover that Don is in the process of creating a new system called Maxihost. He's converting to Turbo Pascal 5.5, thus shaking off the 64K limit. Since Minihost has always served me well in its "mini" form, I'm not sure I'll jump into Maxihost. In any case, I can attest after years of reliable use that Mankin's little BBS is a gem of a system. Minihost Don Mankin 3211 Crow Canyon Place, #A296 San Ramon, CA 94583 (209) 836-2402 (BBS) $25 hobbyist registration fee $50 commercial registration fee Shareware Sources The Association of Shareware Professionals has already done a great deal to professionalize the shareware business. Many shareware authors have turned to ASP for information on entering this alternative software marketplace. ASP also has other functions. ASP has an ombudsman to mediate disputes between users and ASP members. In addition to writing to the ombudsman at ASP's address, you can reach him via CompuServe. His ID number is 70007,3536. ASP has also published vendor who give guidelines. Vendors shareware authors due credit and adhere to the ASP guidelines may describe themselves as "ASP approved." As a shareware aficionado, I'm always curious where people obtain their shareware. Although users groups are a primary source for many people, the larger mail-order operations generally have more comprehensive inventories and many now carry the ASP seal of approval. What's your favorite shareware source? I've mentioned PC-SIG and Nelson Ford's Public (Software) Library in the past. Let me know your ,experiences with shareware vendors and I'll report on which ones seem to be the best bets for quick and friendly service. Just write to me or leave a message on my Minihost system. Keep those bytes coming. ASP Ombudsman Assoc. of Shareware Professionals P.O. Box 5786 Bellevue, WA 98006 CompuServe 70007,3536 ••• MICRO CORNUCOPIA, #50, Nov-Dec, 1989 81 mUD omm nrnm By Gary Entsminger P.o. Box 2091 Davis, CA 95617 Order And Chaos: Creating Fibonacci Attractors With Turbo Pascal Objects My last conversation with Gary began with: "How in the heck am I going to introduce this kind of chaos?" (Actually, I didn't say "heck," but you understand.) "You could tell them you assumed it was a Culture Corner until you got to the very end," he said. "The end wouldn't have straightened me out," I muttered. So here I am, still no introduction. (And, come to think of it, I still don't have a Culture Corner.) eonardo of Pisa created one of the first models of population growth in 1220, 7.69 centuries ago. Leonardo, better known to us as Fibonacci (renamed by mathematical historian, Guillaume Libri, in the 19th century), used a pair of rabbits as the basic unit for reproduction in his model. He reasoned the following(1) begin with one pair of rabbits; (2) let them mature for one year; (3) let them beget one pair like themselves; (4) for each successive season, let each new (mature!) pair beget a new (immature!) pair; (5) continue as far as integers (or rabbits) go. Figure 1 shows how this scheme develops. We call the pattern in the second, third, and L 82 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 fourth columns the Fibonacci sequence, and it has challenged and perplexed mathematical minds for almost eight centuries. The pattern's simple enough-each successive number is equal to the sum of the two preceding numbers. As a population model, the Fibonacci sequence has a basic flaw: it omits death. Consequently, rabbits grow by leaps and bounds (hops, actually), eventually filling the surface of the earth. Fibonacci wasn't all that interested in overrunning the planet with rabbits; he wanted to understand patterns of growth. His sequence, it turns out, fits a very interesting ratio contemplated in Greece some 15 centuries before Fibonacci. The Golden Ratio The golden ratio (11.z(1 + sqrt(5» or roughly 1.618034 ... is the ratio between two divisions of a line or plane, such that the smaller is to the larger as the larger is to the sum of the two. The golden ratio recurs throughout nature• it's roughly the ratio of your total height to your navel's height. (If you don't believe me, measure yourself; even better, measure a good friend.) • it accurately models the "bee-tree law," or pattern of reproduction in bee colonies (where a single female parent asexually reproduces males, and male and female parents together sexually reproduce females); • it describes the number of ways light can be refracted and reflected through different layers of glass; • it describes the arrangement of florets in sunflowers and other composites. A typical sunflower, for example, has a head containing spirals of tightly packed florets. Each spiral winds a fibonacci number of florets in one direction and the next smaller (or larger) fibonacci number of florets in the other. (See Figure 2.) Sunflowers have been found spiraling in all the Fibonacci numbers up to 144. The late summer hillside below (and for miles around) my writing table here in the Elk mountains glows golden with blooming composites. A hillside fractal of Fibonacci spirals. Growth Most models of population growth share a similar formX n +1 Figure 2-Chrysanthemum Morifolium (elusion). Photo by C. Anderson Figure 3 -Rl=1.61803398867 R2=O.6180339887 where Xn is the density in season ni Xn+l is the density in season n+ 1; and F is a mapping which shows how the density changes from season to season (or state to state). F has two parts: one part represents birth rate, and one part represents death rate. Most of these mappings (at least most of the published ones) have one significant trait in common: they define a single-humped (i.e., parabolic) curve. Qualitatively, they behave like the much-discussed logistic equation (w hich I briefly discussed in Micro C, #47, "Strange Attractors: Order In Chaos"). In particular, these mappings all exhibit both ordered and chaotic behavior depending on their initial conditions. I thought it might be fun to explore a population growth model based on the Fibonacci sequence. The equation I chose to model is simple enough, with a rate parameter for birth and a second rate parameter for deathXn+l Figure~Rl=1.83957 ·R2=O.6180339887 = F(Xn ) = R1 1< Xn 1< (1 - R2 1< (Xn-l 1< Xn -l» where Rl is the birth rate of this generation and R2 is the death rate of the last generation. The Fibonacci twist is twofold: (1) as a possible rate (for Rl or R2); (2) as a three generation component: future generations (or states) depend on both this generation (birth rate) and the generation before (death rate). Not surprisingly, the Fibonacci sequence (expressed as the golden ratio) produces dramatically different behavior (when used as a rate) than values very, very near the ratio. See the attractors in Figures 3 and 4 for immediate gratification. Later I'll talk results. Prolog & Pascal Usually I use Turbo Prolog for modMICRO CORNUCOPIA, #50, Nov-Dec, 1989 83 elling systems, primarily for three reasons(1) Models are state systems (Le., they're recursive). The value of the last state gets fed back into the system to produce the next state. Prolog is a recursor's dream; (2) The BGI (Borland Graphics Interface); (3) Speed. Lately, though, I've been programming about half-time in Turbo Pascal, first beta-testing TP 5.5 and lately betatesting Turbo Power's Object Pascal Toolbox. The new object extensions make TP a very intriguing compiler, so I couldn't resist an opportunity to test Turbo Pascal objects for chaos. After a bit of thought and a few halfblind alleys, I decided to create two objects: (1) a graphics object; to initialize and test the adapter; to set and modify scales; to setup basic variables such as screen coordinates. (2) and a Fibonacci model object which inherits all the graphic and scaling methods from the graphics object. The Fibonacci model object includes a recursive state-changing method and a menu. Pascal Objects I've described the objects and their methods in Figure 5. For convenience, I created and compiled the graphics object first as a unit. The Fibonacci object (created later) uses the graphics unit. Objects are handy here for several reasons: (1) It's easy to view an object as an entity with an internal state that it remembers (about itself!) even when you aren't using it; (2) The graphics object is generic, so I can create many more complex objects from it later (by inheriting its methods); (3) Since an object's methods know all about its data fields (Le., its state), I don't have to pass parameters between the object's methods; (4) Objects group data and methods (which might otherwise be confusing) in distinctive blocks. My code is simple enough, so I'll only comment here on a few interesting (I think) nuances. My first semi-blind alley generated one of Turbo Pascal's stack overflow errors. The problem-too much recursion. Even a 64K stack isn't enough for cranking out strange attractors. In Turbo Prolog, you can recurse 'til the cows go 84 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 Xmin unchanged') current··scale.Xmin := R: writeln('N;w Xmax: '): readln(Rs): Val(Rs,R,Return); IF Return <> 0 THEN writeln('Invalid input Xmax unchanged') begin Ratel:= Rate2 ,end: procedure begin WalLE I '1'rue·OO begin Nx :=Ratel* X* (1 Ny := X; ELSE calculate_scale; IF R > current scale. Xmin THEN current ecai'e.XmaK := R ELSE X := Nx; Y := Ny; - writeln('Xmax must be > Xmin: no change'): writeln('New Ymin: '); readln(Rs): Val (Rs, R, Return)·: IF Return <> 0 THEN writeln('Invalid input ELSE current scale.Ymin := R: writeln('N;w Ymax: '): readln(Rs): Val(Rs,R,Return); IF Return <> 0 THEN writeln('Invalidinput Ymax unchanged') ELSE end; end: procedure fibonacci.get_rate; current_scale.Ymin THEN current scale.Ymax := R ELSE - INGRAF 2.10 A multi-device graphics library for Scientific, Engineering, and Business usersl Supports video, printer, and plotter graphics for personal computers. Ov~r 100 routines to create bar. pie, and smith charts; linear. log (senu-log and log-log). and polar plots; axel and grid. with tick marks and labels. uuuken, line types. curves. arcs. circles, ellipses. and more. (EMU IOUte' cod,., 110 nqallill or rUII-tim, feu/) The window function allows you to use up to 32 windows. You can set individual characteristics (such as sizing. scaling. labeling, etc.) for each window or identical characteristics for all windows. INDUCTIVE REACTANCE TEMP. U: & RAINFALL OF HOUSTON AREA I~O 7S• 0 t,o,D v 65.0 ~ 60.0 ~ 55.0 . .c. C lui ~ SO.O ~O < a: '~O 35.0 JAM FEB MAR ~ CAPACITIVE REACTANCE tlAy Jl.II JI.l. AUC S[P OCT NOV 00 occ· 1984 INGRAF is available for C. FOR1RAN-77. and QuickBASIC (pascal available soon); support for numerous compilers. We also have GRAFLIB 4.10 for video and printer graphics; PLOTLIB 4.10 for pen plotter graphics, and FORTLIB 4.05. a FORTRAN enhancement library. Sutrasoft P.O. Box 1733 • Sugar Land, TX • 77487 Order Line : 1·800·888·8460 All other calls: 713 491·2088 Reader Service Number 173 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 85 home by inserting a cut (!) before the recursive call. Called tail recursion elimination, this is a beautiful technique. In Turbo Pascal, there's no obvious way to insert a cut. But there is a subtle way to recurse 'til your heart's content. My first (unsuccessful) attempt at a recursive method went something like this: (note: this procedure belongs to the object, fibonacci, hence it's one of fibonacci's methods) procedure fibonacci. fib; begin create_a_strange_attractor; WHILE KeyPressed <> True DO tween each call to fib. This sequence runs all night or until a KeyPressed. And there's no need for a large stack (a few K will do). Note in Figure 5 the use of New and Dispose to allocate and deallocate heap space for objects. And the use of the caret (") for referencing dynamically allocated objects. Note also that init and done do nothing besides internal notekeeping. Specifically, they set up and reference the VMT (virtual memory table), which guarantees that the right amount of memory will be allocated on and deallocated from the heap. fib; end; This code generates a stack overflow error long before it's created much of an attract or. My second (successful) attempt uses two proceduresprocedure fibonacci.recurse_fib; begin WHILE KeyPressed <> True DO fib; end; procedure fibonacci.fib; begin create_a_strange_attractor; end; There's no longer a stack overflow problem, since the stack is reclaimed be86 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 Results The results of my explorations were revealing. The attractors do vary depending on subtle changes in birth and death rates. If we use the golden ratio, the attractor is periodic and highly predictable (see Figure 3). If we vary rates ever so slightly away from the golden ratio, the attractors vary ever and ever more strangely, looping and looping between and around its loops. (See Figure 4). Incidentally, the data generated by the Fibonacci model equation plotted as a time series (i.e., each successive state versus time) shows a mass of chaotic dots. The two attractors in Figures 3 and 4 are phase portraits, generated by plotting one generation's data against the last generation's data, rather than against time. (See Micro C #47, "The Last Page" or Dynamics, The Geometry Of Behavior, by Abraham & Shaw for details.) The Fibonacci sequence clearly brings an intriguing (if not yet fully illuminating) order to chaos. And Turbo Pascal objects offer a potentially elegant solution to the programming of complex models. I'll get back to you. And that, friends, is Tidbits. References Abraham, Ralph & Christopher Shaw; Dynamics, Vols. 1-4; 1982, '83, '85, '88; Aerial Press. (An illustrative guide to attractors, basins, tangles, and the complex mathematics of dynamics. Highly recommended.) Entsminger, Gary; "Strange Attractors, Order In Chaos," Micro C #47; May-June 1989. (A short introduction, with Turbo Prolog code, to strange attractors.) . Graham, Ronald; Knuth; Patashnik; Concrete Mathematics; Addison-Wesley; 1989. (Contains an excellent discussion of the Fibonacci sequence.) Stevens, Peter S.; Patterns In Nature. (Excellent examples of how nature appears to an architect.) Stewart, Ian; Does God Play Dice? The Mathematics Of Chaos; Basil Blackwell; 1989. (A terrific introduction to the mathematical side of chaos. Includes many recent experimental discoveries & discussion of recent applications.) ••• 3D Surface Generation O,-l,incmode,fillcolor, (horangle>7.0*PI/4.0).? (incmode = 1): (incmode= 0): dosurf(xmin,xmax,ymin,ymax, nx~ny, z, 0, me-l,l, ny-l,D, -1, incznode, fillcolor, edqecolor): break; } if (box) invert? drawboxbottom(boxedgecol) drawboxtop(boxedgecol); drawboxfront(quadrant,boxedqecol); return (1): else if «horangle >== PI/2.0) && (horangle < PI» return (2)i else if «horangle >== PI) && (horangle < 3*PI/2. 0) ) return(3); else return(4)i 1* intget_quadrant() *1 1* finds· global transformation angles and their cosines and sines for later use in calls to axonometric () . *I void transform_angles(float horangle,float elangle, int quadrant) float phi,psi/sinel; } 1* avoid dividing by O. all this messing around with free (Xa) : ,'. free (Ya) ; return (0): / * int surface () *1 1* converts from decimal degrees to radians. */ void degrees_to_rads(float* horangle,float *elangle) { /* check that angles are in the range 0 to 360: *1 do if (*borangle <0.0)' *horangle.+::360.0; while, (*horangle < 0.0») do quadrants is because angles that generate cosines of 0.0 area function of the floating point library of the compiler and of round-off error. *1 if (cos(horangle)~ 0.0) 1* horiz angle 90 or 270*/ switch (quadrant) { case 1 case 3 phi = PI/2.0; psi;:: 0.0: break; case 2 case 4 phi =-PI/2.0; if(*horangle>360.0)*horangle-=.360.0; while .•·. (*horangle' >.360.0); *elangle =*elangle * PI /180.0; *hoiangle == *horangle·*·!?I 1180.0; l*voiddegrees_to_rads () *1 I*find.$ >st:andardmath quadrant of viewer *I ini: get quadrant (float horangle) { if «borangle>=O.O)'& (horangle< PI/2.0» - 286 or 386SX? CAN'T MAKE UP YOUR MIND? WHAT SUITS YOUR NEEDS NOW MAY NOT BE RIGHT FOR YOU IN THE FUTURE. TAKE ADVANTAGE OF THE SPEED AND POWER OF A PT286 SYSTEM AND RETAIN THE OPTION OF UPGRADING LATER TO A386SXWITH A PLUG IN CPU MODULE. ALL PRODUCTS ARE COMPATIBLE WITH DOS, UNIX, XENIX, OS/2. AND MAY CONTAIN UP TO 5 MEGABYTES OF ON-BOARD MEMORY. 2861386SX KITS ARE AVAILABLE .PT386SX Assembled board, 16MHZ, 1 MEG, $749.00 FDC, 2 serial, 1 parallel port ·PT286 Assembled board, 16M HZ, OK RAM, FDC, $475.00 2 serial, 1 parallel port .PT386SX Optional upgrade to PT286 $325.00 CPU Module ONLY CATALOG AVAILABLE UPON REQUEST PERIPHERAL TECHNOLOGY 1710 CUMBERLAND PT. DR. SUITE 8, MARIETTA, GEORGIA 30067 404/984-0742/FAX ORDER LINE: 404/984-8248 ALL TRADEMARKS ARE THE PROPERTY OF THEIR RESPECTIVE OWNERS. } sinel=sin(elangle); Sinphi= sinel* sin(phl); Cosphi= cos(pbi); Sinpsi= sinel* sin(psi); Cospsi == cos (psi) ;" Cosel = cos (elangle) ; AS AT OW $99.95 LAST! StH $3.00 Outside U.S. add $10.00 FLOW CHART AND ANALVZE YOUR ASSEMBLY LANGUAGE SOURCE CODE • Flow Charts • Tree Diagrams • Stack Sizing • Register Analysis • CPU Timing Analysis • Procedural X-Reference • 8088/87 to 80386/387 • Context-Sensitive Help • Menu/Batch/Command line Operation • MASM 5.1 Compatible QUANTASM GOIINRATIQRlt 19855 Stevens Creek BM:l, Suite 154 ~,CA95014 (408) 244-6826 break current line editor_warning save screen display-warning restore screen editor_warning insert blank line adjust)ne join_line editor_warning adjusUine delete_ediCline editor line out ediUine_oUt - E ~ Reader Service Number 139 Reader Service Number 119 VISA • Me 30 - Day Money Back Guarantee MICRO CORNUCOPIA, #50, Nov-Dec, 1989 87 88 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 ----- -------- -------------- Linef(pUn1] ,q[l] [1] ,pU] [0] ,q[l] [0]); Linef (pu] to] ,q[l] [0] , p [0] [0] , q[O] [0]); 1* void Clrawfillquadrangle 0 *1 for (i = 0; i < 5: i++) { transf(~[i),Zb[il,&Pb[i],&Qb[i]); 1* draws triangle described by the 3 points passed. itransf(&Pb[i],&Qb[i]); transf(Yt[i],Zt[il,&Pt[i]i&Qt[i]); itransf(&Pt[i],&Qt[i}); void filltriangle(int xO,int yO,intx1,int y1, int x2iint y2,int fi11color) int z,a,b,dx,dy,d,deltap,deltaq,jstart; intxl[2] [3],yl[2) [3); register int x,y,i,j,k; 1* sort thepoirits in ascending vertical order: if (y1 < yO) swapcoords(&xl,&yl,&xO,&yO); if (y2 < yO) swapcoords(&x2,&y2,&xO,&yO)i if (y2 < yl) swapcoords(&x2,&y2,&xl,&yl); I*stick em in arrays for triangle edge computation:*1 xl[O] [0] = xO; yl[O] [0] = yO; xl[O] [1] = xl; yl[O] [1] = y1; xl[O] [2] =x2; yl[O] [2] =y2; 1* to use loops instead of if statements, we pretend the long side of the triangle is made up of 2 lines. one has zero length: (x2,y2) to (x2,y2). xl[l) [0] =xO; yl[l] [0] = yO; xl[l] [1] = x2; yl[l] (1] = y2; xl[l] [2] = x2; yl[l] [2] = y2; 1* i loops· over. the 2 triangles: k·loops over the· two short aides. and· the one long side: *1 for (i = 0; i < 2; i++) { jstart 0; for (k = 1; k < 3; k++) = { Csetf(color); for (i = 0; i < 4; i++) Linef(Pb[i],Qb(i),Pb[i+l),Qb[i+l]); /* void drawboxbottom() *1 void drawboxback(int quadrant,int color) { Csetf(color): for (i=O; i<2; i++) { j = back [quadrant-1) [i); Linef(Pb [j] , Qb [j] , Pt [ j] , Qt [j 1) ; MICRO CORNUCOPIA, #50, Nov-Dec, 1989 89 Printer Error Handler Current Loop To RS-232C Converter This small circuit will convert a 20 rna signal to RS-232C. I originally built it to convert Reliance Automate 31 program files from our Datapoint to an Allen Bradley T-50 Industrial Terminal. By building and using this converter, I saved countless hours of hand converting files. The circuit consists of a single 4N28 IC. It decides which voltage (+12 VDC or -12 VDC) reaches the RS-232C port. I put a 2.7K resistor in series with the 4N28's input LED. The resistor limits the LED current to around 8 rna. I use a 10K resistor to pull up the 4N28' s output when it's not conducting. The schematic (see Figure 1) shows how I wired the 4N28. To transmit from the Datapoint, I fired up the 20 rna current loop and loaded the Automate 31 tape (this sets the baud rate). Then I connected the power supply and hooked up the signal to the computer's RS-232C port. After selecting the same baud rate in my terminal package, I just captured the files as they came in. (Imagine all the typos and all the eye strain of comparing and checking that I avoided.) Larry Kraemer Rt.2 Box 190 Jackson, MO 63755 Printer Error Handler With all the compilers I've used, there's been one sore point when using the standard printing routines. If there's a problem, you get the ugly "WRITE DEVICE FAULT ERROR," or something similar all over your beautiful screen. I wanted something that could handle the error in a professional way. I wrote Figure 2 for Borland's Turbo C 2.0. (The routines are not ANSI compatible.) The heart of the code is Turbo 90 MICRO CORNUCOPIA, #50, Nov-Dec, 1989 C's biosprintO routine. Let me briefly describe the algorithm. I print strings only; printing floating points and integers is just a matter of converting the number to a string and then printing the string. First, I send a string to the printing function. It prints out the string character by character, each time checking the status of the printer. If the function detects an error, it moves into the abort/retry function. The abort/retry function saves the contents of the current window. Then it creates its own window, prints the error message, and asks if the user would like to abort or retry. If the user selects retry, it keeps checking the printer to see if the error has been corrected. If it has, it returns to the printing function and continues printing the string. If the user chooses to abort, it exits the printing function. The abort/retry function restores the previous screen and window coordinates before finishing. You may notice a little double coding in the functions printer_okO and bio_print_stringO. The routines for checking in bio_print_stringO are so small I didn't want to make the extra call to printer_okO. However, you may want to call printer_okO to determine the printer status before you start printing. This is the reason for some duplicate code. Also, the abort/retry function uses printer_okO to keep determining printer status. You can use these routines universally with all your Turbo C programs. Just compile STDPRINT.H to an .OBJ file and use it in your project files, or put the code in your program as a header file. If you compile STDPRINT.H to an .OBJ file, make sure you include the files BIOS.H, CONSOLE.H and GRAPHICS.H in the program. I hope these routines will make your life a little easier when dealing with the printer. (Note: These routines do not work for serial printers.) Jeffrey Scott Donovan 1515 Santa Barbara St. #A Santa Barbara, CA 93101 Micro Ads A Micro Ad Is the inexpensive way to reach over 22,000 technical folks like yourself. To place a Micro Ad, Just print out your message (make it short and sweet) and mail it to Micro C. We'll typeset your ad (no charge) and run it In the next available Issue. You can also send camera ready copy. Rates: $99 for 1 time, $267 for three times, $474 for 6 times (a best buy at only $79 per Insertion). Full payment must accompany ad. Each ad space Is 2 V4 Inches by 1 3'4 Inches. Briefly, a hypertext help system, context sensitive, up to 80%compresslon, requires less than 10K, Includes editor for documents, and source for Pascal, C, and Basic. (203)368 - 0632 NTERGAID, 955 Connecticut Ave. Bridgeport, CT 06607 DUPLICATOR TOOLKIT PRO F LAS r--_-•. •Tb • :....J r -. H THE DUPLICATOR TOOLKIT PROfessional is a superfast diskette duplication utility for your Pc. It does what diskcopy can't do! Copies a 360K diskette in 20 seconds, fonnats and verifies "on the fly," and even produces diskette labels at the same time! Copies 5 1/4 360K DDDS, 1.2M high-density, 5 1/4 360K using a 1.2M high density drive, 3 1/2 720k, 3 1/2 1.44M and 3 1/2 720K using a l.44M drive. Stores master in RAM or on the hard drive. Fonnat-only option allows for high-speed fonnatting. Eliminates the "floppy shuffle!" $129.00 + 5.00 s/h Visa/MC/COD COpy TECHNOLOGIES 14252 Culver Dr. Ste. 323 Irvine, CA 92714 $5.00 Shp/hnd in USA & CANADA, $15.00 overseas. Reader Service Number 163 Reader Service Number 106 STOCKS OPTIONS FUTURES - - EASY to Install Cache up to 32 MEGS of EXTENDED and/or EXPANDED • Buffers up to 26 DEVICE driven drives • Comes with 2 FREE utilities!!!!! EDITOR CHOICE ORDER NOW $69.95 (800) 25-FLASH 100 page book covers satellite and radio data reception of financial news and quotes for your PC. $19 (includes demo diskette). Free informative catalog of: * Data receivers and kits * Quote processing and display software * Descrambling software utilities Digital Vision B&W Video Digitizer $249 or Color Video Digitizer $399 Willow PC Publisher VGNframe grabber $595 Everex Vision 8 frame grabber $795 Everex Vision 16 frame grabber $1295 303·223·2120 $5 Demo Diskette DATArx 111 E. Drake Rd. Suite 7041 Fort Collins, CO 80525 (SOD) K [Jg] 423-3400 KOMPUTERWERK, INC 851 Parkvlew Blvd Pittsburgh, PA 15215 Why you want BAlCOM! BATCOM is a batch file compiler that compiles your -.bat-files to -.exe-files to make them faster, more professional, and more capable. BAT· COM extends DOS with new commands so you can read keyboard input, perform arithmetic, use subroutines, and much more. In addition, BAT· COM protects your source code, and you can distrbU1e your compiled programs without royalties. For IBM PC. Only $59.95. Order todayl CCTV Video Cameras Special: Color VCC3700 Sanyo $395 Panasonic WV-141D B&W $219 Panasonic WV-BL200 CCD B&W $579 Free Shipping! TX residents add sales tax. / - ' \ , Wenham Software Company 5 Burley St. ' _ . / Wenham, Ma. 01984 (508) 774-7036 t • l joel Sampson Engineering P.O.Box550363 Dallas, TX75355·0363 Support for: ~ Enhanced Keyboards ~ EGA & VGA Graphics ~ 3.5 inch Floppies ~ More ... Reader Service Number 126 Technology for the Arts Music Quest PC Music MIDI Card with free software $119, Sequencer or Toolkit $39 each. BIOS *AWARD 286 * 386 Authorized AWARD Distributor SOFTWARE MASTERS 6352 North Guilford Ave. Indianapolis, In 46220/ (317) 253-8088 Turn Your PC Into A MARKET QUOTATION MONITOR LATEST PC/XT THE DISK ACCELERATOR Phone 214·328·2730 BBS214·328·6909 Reader Service Number 133 Reader Service Number 176 Reader Service Number 124 THOUSANDS OF NEW COMPUTER BOOKS 8031 J.l.Controller Module $39.95 The $25 Network Shipping: $3.00 US'$5.00 Canada 40% OFF LIST Get the newest computer titles at the lowest prices with a low minimum order. Send 3 stamp SASE. COMPUTER BOOKS • PO 70195. SAN DIEGO, CA 92107 Reader Service Number 167 WHITNEY EDITOR $39 Small and fast Uses all available memory Split-screen editing Conflgurable keyboard Regular expression search One key compile Features for writing documentation Condensed/Outline display Runs on IBM PC's, AT's, and PS/2's USA shipping & handling $3; Outside USA $15 CA residents add sales tax Whitney Software, Inc. P.O. Box 4999, Walnut Creek, CA 94596 (415) 933-9019 Reader Service Number 164 Try the 1st truly low cost LAN Ideal (or prototypt'!Ol. one cL a kind devic"" or .hlrl produttion NnL P...te.t buildil1ll block (or PC or MacintoRh data aquioitioo interface or otand alone control project&. A.".,mbled and """ted board include. 8031 microproce.or, CI')'1ItaI. 8K oI'EPROM. 128 byteo at RAM, 2 byte·wide 110 porta and proviRi
Source Exif Data:File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.3 Linearized : No XMP Toolkit : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37 Create Date : 2013:01:25 15:25:29-08:00 Modify Date : 2013:01:25 18:04:10-08:00 Metadata Date : 2013:01:25 18:04:10-08:00 Producer : Adobe Acrobat 9.52 Paper Capture Plug-in Format : application/pdf Document ID : uuid:0fbd1e96-86de-4034-921f-fa02463e8492 Instance ID : uuid:2c394d96-e2fc-4908-a64e-f62208065c16 Page Layout : SinglePage Page Mode : UseNone Page Count : 100EXIF Metadata provided by EXIF.tools